All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org,
	kernel-team@android.com
Cc: cang@codeaurora.org, alim.akhtar@samsung.com,
	avri.altman@wdc.com, bvanassche@acm.org,
	martin.petersen@oracle.com, stanley.chu@mediatek.com,
	Jaegeuk Kim <jaegeuk@google.com>
Subject: [PATCH] scsi: ufs: fix memory boundary check for UFS 3.0
Date: Fri, 11 Dec 2020 11:38:14 -0800	[thread overview]
Message-ID: <20201211193814.1709484-1-jaegeuk@kernel.org> (raw)

From: Jaegeuk Kim <jaegeuk@google.com>

If param_offset is greater than what UFS supports, it'll give kernel panic.

Signed-off-by: Jaegeuk Kim <jaegeuk@google.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


             reply	other threads:[~2020-12-11 21:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11 19:38 Jaegeuk Kim [this message]
2020-12-11 20:43 ` [PATCH] scsi: ufs: fix memory boundary check for UFS 3.0 Eric Biggers
2020-12-11 20:46   ` Jaegeuk Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201211193814.1709484-1-jaegeuk@kernel.org \
    --to=jaegeuk@kernel.org \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=bvanassche@acm.org \
    --cc=cang@codeaurora.org \
    --cc=jaegeuk@google.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=stanley.chu@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.