mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: Yu Zhe <yuzhe@nfschina.com>, <alison.schofield@intel.com>,
	<vishal.l.verma@intel.com>, <ira.weiny@intel.com>,
	<bwidawsk@kernel.org>, <dan.j.williams@intel.com>
Cc: <linux-cxl@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<liqiong@nfschina.com>, <kernel-janitors@vger.kernel.org>,
	Yu Zhe <yuzhe@nfschina.com>
Subject: RE: [PATCH] cxl/pmem: Use size_add() against integer overflow
Date: Fri, 21 Oct 2022 16:07:00 -0700	[thread overview]
Message-ID: <635326141b6d9_4da3294cd@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <20220927070247.23148-1-yuzhe@nfschina.com>

Yu Zhe wrote:
> "struct_size() + n" may cause a integer overflow,
> use size_add() to handle it.
> 
> Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
> ---
>  drivers/cxl/pmem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cxl/pmem.c b/drivers/cxl/pmem.c
> index 7dc0a2fa1a6b..8c08aa009a56 100644
> --- a/drivers/cxl/pmem.c
> +++ b/drivers/cxl/pmem.c
> @@ -148,7 +148,7 @@ static int cxl_pmem_set_config_data(struct cxl_dev_state *cxlds,
>  		return -EINVAL;
>  
>  	/* 4-byte status follows the input data in the payload */
> -	if (struct_size(cmd, in_buf, cmd->in_length) + 4 > buf_len)
> +	if (size_add(struct_size(cmd, in_buf, cmd->in_length), 4) > buf_len)
>  		return -EINVAL;

Looks good, applied for v6.1-rc fixes.

      parent reply	other threads:[~2022-10-21 23:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-27  7:02 Yu Zhe
2022-09-27 16:23 ` Ira Weiny
2022-09-29  7:02   ` Yu Zhe
2022-10-21 23:07 ` Dan Williams [this message]

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=635326141b6d9_4da3294cd@dwillia2-xfh.jf.intel.com.notmuch \
    --to=dan.j.williams@intel.com \
    --cc=alison.schofield@intel.com \
    --cc=bwidawsk@kernel.org \
    --cc=ira.weiny@intel.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liqiong@nfschina.com \
    --cc=vishal.l.verma@intel.com \
    --cc=yuzhe@nfschina.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®