linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Tomas Winkler <tomas.winkler@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alexander Usyskin <alexander.usyskin@intel.com>,
	linux-kernel@vger.kernel.org,
	"Gustavo A . R . Silva" <gustavoars@kernel.org>,
	Arnd Bergmann <arnd@arndb.de>
Subject: Re: [char-misc-next 2/6] mei: ioctl: use sizeof of variable instead of struct type
Date: Thu, 23 Jul 2020 11:55:25 -0500	[thread overview]
Message-ID: <992a5bd7-f8c6-c5ea-3531-65e2785f96a6@embeddedor.com> (raw)
In-Reply-To: <20200723145927.882743-3-tomas.winkler@intel.com>



On 7/23/20 09:59, Tomas Winkler wrote:
> Use sizeof(connect_data))) instead of
> sizeof(struct mei_connect_client_data) when copying data
> between user space and kernel.
> 
> There is a possibility of bug when variable type has changed but
> corresponding struct passed to the sizeof has not.
> 
> Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
--
Gustavo

> ---
>  drivers/misc/mei/main.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
> index f17297f2943d..05e6ad6d4d54 100644
> --- a/drivers/misc/mei/main.c
> +++ b/drivers/misc/mei/main.c
> @@ -1,6 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0
>  /*
> - * Copyright (c) 2003-2018, Intel Corporation. All rights reserved.
> + * Copyright (c) 2003-2020, Intel Corporation. All rights reserved.
>   * Intel Management Engine Interface (Intel MEI) Linux driver
>   */
>  
> @@ -476,7 +476,7 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
>  	case IOCTL_MEI_CONNECT_CLIENT:
>  		dev_dbg(dev->dev, ": IOCTL_MEI_CONNECT_CLIENT.\n");
>  		if (copy_from_user(&connect_data, (char __user *)data,
> -				sizeof(struct mei_connect_client_data))) {
> +				   sizeof(connect_data))) {
>  			dev_dbg(dev->dev, "failed to copy data from userland\n");
>  			rets = -EFAULT;
>  			goto out;
> @@ -488,7 +488,7 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
>  
>  		/* if all is ok, copying the data back to user. */
>  		if (copy_to_user((char __user *)data, &connect_data,
> -				sizeof(struct mei_connect_client_data))) {
> +				 sizeof(connect_data))) {
>  			dev_dbg(dev->dev, "failed to copy data to userland\n");
>  			rets = -EFAULT;
>  			goto out;
> 

  reply	other threads:[~2020-07-23 16:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-23 14:59 [char-misc-next 0/6] mei: remove one-element arrays Tomas Winkler
2020-07-23 14:59 ` [char-misc-next 1/6] mei: hbm: use sizeof of variable instead of struct type Tomas Winkler
2020-07-23 15:13   ` Greg Kroah-Hartman
2020-07-23 17:04     ` Gustavo A. R. Silva
2020-07-23 17:29       ` Greg Kroah-Hartman
2020-07-23 17:01   ` Gustavo A. R. Silva
2020-07-23 14:59 ` [char-misc-next 2/6] mei: ioctl: " Tomas Winkler
2020-07-23 16:55   ` Gustavo A. R. Silva [this message]
2020-07-23 14:59 ` [char-misc-next 3/6] mei: bus: " Tomas Winkler
2020-07-23 16:55   ` Gustavo A. R. Silva
2020-07-23 14:59 ` [char-misc-next 4/6] mei: client: " Tomas Winkler
2020-07-23 16:54   ` Gustavo A. R. Silva
2020-07-23 14:59 ` [char-misc-next 5/6] mei: hw: " Tomas Winkler
2020-07-23 16:53   ` Gustavo A. R. Silva
2020-07-23 14:59 ` [char-misc-next 6/6] mei: hw: don't use one element arrays Tomas Winkler
2020-07-23 16:49   ` Gustavo A. R. Silva

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=992a5bd7-f8c6-c5ea-3531-65e2785f96a6@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=alexander.usyskin@intel.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavoars@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tomas.winkler@intel.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;
as well as URLs for NNTP newsgroup(s).