[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201211193814.1709484-1-jaegeuk@kernel.org>
Date: Fri, 11 Dec 2020 11:38:14 -0800
From: Jaegeuk Kim <jaegeuk@...nel.org>
To: linux-kernel@...r.kernel.org, linux-scsi@...r.kernel.org,
kernel-team@...roid.com
Cc: cang@...eaurora.org, alim.akhtar@...sung.com, avri.altman@....com,
bvanassche@....org, martin.petersen@...cle.com,
stanley.chu@...iatek.com, Jaegeuk Kim <jaegeuk@...gle.com>
Subject: [PATCH] scsi: ufs: fix memory boundary check for UFS 3.0
From: Jaegeuk Kim <jaegeuk@...gle.com>
If param_offset is greater than what UFS supports, it'll give kernel panic.
Signed-off-by: Jaegeuk Kim <jaegeuk@...gle.com>
Change-Id: I48ea6f3f3074bd42abf4ecf8be87806732f3e6a3
---
drivers/scsi/ufs/ufshcd.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index d6a3a0ba6960..04687661d0df 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -3194,6 +3194,9 @@ int ufshcd_read_desc_param(struct ufs_hba *hba,
return -EINVAL;
}
+ if (param_offset > buff_len)
+ return -EINVAL;
+
/* Check whether we need temp memory */
if (param_offset != 0 || param_size < buff_len) {
desc_buf = kmalloc(buff_len, GFP_KERNEL);
--
2.29.2.576.ga3fc446d84-goog
Powered by blists - more mailing lists