All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Yiyuan Guo <yguoaz@gmail.com>
Cc: jic23@kernel.org, lars@metafoo.de, bleung@chromium.org,
	groeck@chromium.org, dianders@chromium.org,
	mazziesaccount@gmail.com, gwendal@chromium.org,
	linux-iio@vger.kernel.org, chrome-platform@lists.linux.dev
Subject: Re: [PATCH v2] iio: cros_ec: Fix the allocation size for cros_ec_command
Date: Fri, 30 Jun 2023 15:36:01 +0800	[thread overview]
Message-ID: <ZJ6F4THLoYy6S8HP@google.com> (raw)
In-Reply-To: <20230630063132.314700-1-yguoaz@gmail.com>

On Fri, Jun 30, 2023 at 02:31:32PM +0800, Yiyuan Guo wrote:
> The struct cros_ec_command contains several integer fields and a
> trailing array. An allocation size neglecting the integer fields can
> lead to buffer overrun.
> 
> Signed-off-by: Yiyuan Guo <yguoaz@gmail.com>

You could attach my R-b tag as v2 has no major changes from v1.

> ---

Always a good practice to put changelog here.  Search "changelog" in [1].

[1]: https://www.kernel.org/doc/html/latest/process/submitting-patches.html

> @@ -253,8 +253,8 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
>  	platform_set_drvdata(pdev, indio_dev);
>  
>  	state->ec = ec->ec_dev;
> -	state->msg = devm_kzalloc(&pdev->dev,
> -				max((u16)sizeof(struct ec_params_motion_sense),
> +	state->msg = devm_kzalloc(&pdev->dev, sizeof(*state->msg) +
> +			max((u16)sizeof(struct ec_params_motion_sense),
>  				state->ec->max_response), GFP_KERNEL);

While looking at the patch again, I found a nit.  Please align the code by
adding an extra tab before "max".

  reply	other threads:[~2023-06-30  7:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-29 13:24 [PATCH] iio: Fix the allocation size for cros_ec_command Yiyuan Guo
2023-06-30  5:13 ` Tzung-Bi Shih
2023-06-30  6:31 ` [PATCH v2] iio: cros_ec: " Yiyuan Guo
2023-06-30  7:36   ` Tzung-Bi Shih [this message]
2023-06-30  8:31     ` [PATCH v3] " Yiyuan Guo
2023-06-30 14:06       ` Guenter Roeck
2023-06-30 14:42         ` yguoaz

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=ZJ6F4THLoYy6S8HP@google.com \
    --to=tzungbi@kernel.org \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=dianders@chromium.org \
    --cc=groeck@chromium.org \
    --cc=gwendal@chromium.org \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=mazziesaccount@gmail.com \
    --cc=yguoaz@gmail.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.