[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <fcb1fe6f-56c2-46f1-a8bb-1a97916af892@amd.com>
Date: Tue, 1 Jul 2025 14:46:24 +0530
From: "Gupta, Akshay" <Akshay.Gupta@....com>
To: Greg KH <gregkh@...uxfoundation.org>
Cc: linux-kernel@...r.kernel.org, arnd@...db.de, shyam-sundar.s-k@....com,
gautham.shenoy@....com, mario.limonciello@....com,
naveenkrishna.chatradhi@....com, anand.umarji@....com,
Dan Carpenter <dan.carpenter@...aro.org>
Subject: Re: [PATCH v3 2/2] misc: amd-sbi: Address copy_to/from_user() warning
reported in smatch
On 7/1/2025 11:19 AM, Greg KH wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> 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@...aro.org>
>> Closes: https://lore.kernel.org/all/aDVyO8ByVsceybk9@stanley.mountain/
>> Reviewed-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@....com>
>> Signed-off-by: Akshay Gupta <akshay.gupta@....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?
I will update the commit message to address this, thank you
>
> thanks,
>
> greg k-h
Powered by blists - more mailing lists