public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Akshay Gupta <akshay.gupta@amd.com>
Cc: linux-kernel@vger.kernel.org, arnd@arndb.de,
	shyam-sundar.s-k@amd.com, gautham.shenoy@amd.com,
	mario.limonciello@amd.com, naveenkrishna.chatradhi@amd.com,
	anand.umarji@amd.com, Dan Carpenter <dan.carpenter@linaro.org>
Subject: Re: [PATCH v3 2/2] misc: amd-sbi: Address copy_to/from_user() warning reported in smatch
Date: Tue, 1 Jul 2025 07:49:31 +0200	[thread overview]
Message-ID: <2025070119-kitchen-drowsily-1f2d@gregkh> (raw)
In-Reply-To: <20250701054041.373358-2-akshay.gupta@amd.com>

On Tue, Jul 01, 2025 at 05:40:41AM +0000, Akshay Gupta wrote:
> Smatch warnings are reported for below commit,
> 
> Commit bb13a84ed6b7 ("misc: amd-sbi: Add support for CPUID protocol")
> from Apr 28, 2025 (linux-next), leads to the following Smatch static
> checker warning:
> 
> drivers/misc/amd-sbi/rmi-core.c:376 apml_rmi_reg_xfer() warn: maybe return -EFAULT instead of the bytes remaining?
> drivers/misc/amd-sbi/rmi-core.c:394 apml_mailbox_xfer() warn: maybe return -EFAULT instead of the bytes remaining?
> drivers/misc/amd-sbi/rmi-core.c:411 apml_cpuid_xfer() warn: maybe return -EFAULT instead of the bytes remaining?
> drivers/misc/amd-sbi/rmi-core.c:428 apml_mcamsr_xfer() warn: maybe return -EFAULT instead of the bytes remaining?
> 
> copy_to/from_user() returns number of bytes, not copied.
> In case data not copied, return "-EFAULT".
> Additionally, fixes the "-EPROTOTYPE" error return as intended.
> 
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/all/aDVyO8ByVsceybk9@stanley.mountain/
> Reviewed-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>
> Signed-off-by: Akshay Gupta <akshay.gupta@amd.com>
> ---
> Changes from v2:
>  - Update commit message to add, "fix the -EPROTOTYPE error return".
> 
> Changes from v1:
>  - Split patch as per Greg's suggestion
> 
>  drivers/misc/amd-sbi/rmi-core.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/misc/amd-sbi/rmi-core.c b/drivers/misc/amd-sbi/rmi-core.c
> index 3570f3b269a9..9048517c088c 100644
> --- a/drivers/misc/amd-sbi/rmi-core.c
> +++ b/drivers/misc/amd-sbi/rmi-core.c
> @@ -372,7 +372,8 @@ static int apml_rmi_reg_xfer(struct sbrmi_data *data,
>  	mutex_unlock(&data->lock);
>  
>  	if (msg.rflag && !ret)
> -		return copy_to_user(arg, &msg, sizeof(struct apml_reg_xfer_msg));
> +		if (copy_to_user(arg, &msg, sizeof(struct apml_reg_xfer_msg)))
> +			return -EFAULT;
>  	return ret;

What commit id does this change fix?

thanks,

greg k-h

  reply	other threads:[~2025-07-01  5:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-01  5:40 [PATCH v3 1/2] misc: amd-sbi: Address potential integer overflow issue reported in smatch Akshay Gupta
2025-07-01  5:40 ` [PATCH v3 2/2] misc: amd-sbi: Address copy_to/from_user() warning " Akshay Gupta
2025-07-01  5:49   ` Greg KH [this message]
2025-07-01  9:16     ` Gupta, Akshay
2025-07-01  5:49 ` [PATCH v3 1/2] misc: amd-sbi: Address potential integer overflow issue " Greg KH
2025-07-01  9:15   ` Gupta, Akshay

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=2025070119-kitchen-drowsily-1f2d@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=akshay.gupta@amd.com \
    --cc=anand.umarji@amd.com \
    --cc=arnd@arndb.de \
    --cc=dan.carpenter@linaro.org \
    --cc=gautham.shenoy@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=naveenkrishna.chatradhi@amd.com \
    --cc=shyam-sundar.s-k@amd.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