* [PATCH] remoteproc: sysfs: Use scnprintf instead of sprintf
@ 2021-03-03 20:01 Siddharth Gupta
2021-03-03 20:56 ` Bjorn Andersson
0 siblings, 1 reply; 3+ messages in thread
From: Siddharth Gupta @ 2021-03-03 20:01 UTC (permalink / raw)
To: ohad, bjorn.andersson, linux-remoteproc, linux-kernel
Cc: Raghavendra Rao Ananta, Siddharth Gupta
From: Raghavendra Rao Ananta <rananta@codeaurora.org>
For security reasons scnprintf() is preferred over sprintf().
Hence, convert the remoteproc's sysfs show functions accordingly.
Signed-off-by: Raghavendra Rao Ananta <rananta@codeaurora.org>
Signed-off-by: Siddharth Gupta <sidgup@codeaurora.org>
---
drivers/remoteproc/remoteproc_sysfs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c
index 1dbef89..853f569 100644
--- a/drivers/remoteproc/remoteproc_sysfs.c
+++ b/drivers/remoteproc/remoteproc_sysfs.c
@@ -15,7 +15,8 @@ static ssize_t recovery_show(struct device *dev,
{
struct rproc *rproc = to_rproc(dev);
- return sprintf(buf, "%s", rproc->recovery_disabled ? "disabled\n" : "enabled\n");
+ return scnprintf(buf, PAGE_SIZE, "%s",
+ rproc->recovery_disabled ? "disabled\n" : "enabled\n");
}
/*
@@ -82,7 +83,7 @@ static ssize_t coredump_show(struct device *dev,
{
struct rproc *rproc = to_rproc(dev);
- return sprintf(buf, "%s\n", rproc_coredump_str[rproc->dump_conf]);
+ return scnprintf(buf, PAGE_SIZE, "%s\n", rproc_coredump_str[rproc->dump_conf]);
}
/*
--
Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] remoteproc: sysfs: Use scnprintf instead of sprintf
2021-03-03 20:01 [PATCH] remoteproc: sysfs: Use scnprintf instead of sprintf Siddharth Gupta
@ 2021-03-03 20:56 ` Bjorn Andersson
2021-03-03 21:38 ` Siddharth Gupta
0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Andersson @ 2021-03-03 20:56 UTC (permalink / raw)
To: Siddharth Gupta
Cc: ohad, linux-remoteproc, linux-kernel, Raghavendra Rao Ananta
On Wed 03 Mar 14:01 CST 2021, Siddharth Gupta wrote:
> From: Raghavendra Rao Ananta <rananta@codeaurora.org>
>
> For security reasons scnprintf() is preferred over sprintf().
> Hence, convert the remoteproc's sysfs show functions accordingly.
>
Thanks for the patch Siddharth.
There's no possibility for these calls to generate more than PAGE_SIZE
amount of data, so this isn't really necessary. But if you insist,
please let's use sysfs_emit() instead.
Regards,
Bjorn
> Signed-off-by: Raghavendra Rao Ananta <rananta@codeaurora.org>
> Signed-off-by: Siddharth Gupta <sidgup@codeaurora.org>
> ---
> drivers/remoteproc/remoteproc_sysfs.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c
> index 1dbef89..853f569 100644
> --- a/drivers/remoteproc/remoteproc_sysfs.c
> +++ b/drivers/remoteproc/remoteproc_sysfs.c
> @@ -15,7 +15,8 @@ static ssize_t recovery_show(struct device *dev,
> {
> struct rproc *rproc = to_rproc(dev);
>
> - return sprintf(buf, "%s", rproc->recovery_disabled ? "disabled\n" : "enabled\n");
> + return scnprintf(buf, PAGE_SIZE, "%s",
> + rproc->recovery_disabled ? "disabled\n" : "enabled\n");
> }
>
> /*
> @@ -82,7 +83,7 @@ static ssize_t coredump_show(struct device *dev,
> {
> struct rproc *rproc = to_rproc(dev);
>
> - return sprintf(buf, "%s\n", rproc_coredump_str[rproc->dump_conf]);
> + return scnprintf(buf, PAGE_SIZE, "%s\n", rproc_coredump_str[rproc->dump_conf]);
> }
>
> /*
> --
> Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] remoteproc: sysfs: Use scnprintf instead of sprintf
2021-03-03 20:56 ` Bjorn Andersson
@ 2021-03-03 21:38 ` Siddharth Gupta
0 siblings, 0 replies; 3+ messages in thread
From: Siddharth Gupta @ 2021-03-03 21:38 UTC (permalink / raw)
To: Bjorn Andersson
Cc: ohad, linux-remoteproc, linux-kernel, Raghavendra Rao Ananta
On 3/3/2021 12:56 PM, Bjorn Andersson wrote:
> On Wed 03 Mar 14:01 CST 2021, Siddharth Gupta wrote:
>
>> From: Raghavendra Rao Ananta <rananta@codeaurora.org>
>>
>> For security reasons scnprintf() is preferred over sprintf().
>> Hence, convert the remoteproc's sysfs show functions accordingly.
>>
> Thanks for the patch Siddharth.
>
> There's no possibility for these calls to generate more than PAGE_SIZE
> amount of data, so this isn't really necessary. But if you insist,
> please let's use sysfs_emit() instead.
>
> Regards,
> Bjorn
Sure Bjorn, I'll push the new patch immediately.
Thanks,
Siddharth
>
>> Signed-off-by: Raghavendra Rao Ananta <rananta@codeaurora.org>
>> Signed-off-by: Siddharth Gupta <sidgup@codeaurora.org>
>> ---
>> drivers/remoteproc/remoteproc_sysfs.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c
>> index 1dbef89..853f569 100644
>> --- a/drivers/remoteproc/remoteproc_sysfs.c
>> +++ b/drivers/remoteproc/remoteproc_sysfs.c
>> @@ -15,7 +15,8 @@ static ssize_t recovery_show(struct device *dev,
>> {
>> struct rproc *rproc = to_rproc(dev);
>>
>> - return sprintf(buf, "%s", rproc->recovery_disabled ? "disabled\n" : "enabled\n");
>> + return scnprintf(buf, PAGE_SIZE, "%s",
>> + rproc->recovery_disabled ? "disabled\n" : "enabled\n");
>> }
>>
>> /*
>> @@ -82,7 +83,7 @@ static ssize_t coredump_show(struct device *dev,
>> {
>> struct rproc *rproc = to_rproc(dev);
>>
>> - return sprintf(buf, "%s\n", rproc_coredump_str[rproc->dump_conf]);
>> + return scnprintf(buf, PAGE_SIZE, "%s\n", rproc_coredump_str[rproc->dump_conf]);
>> }
>>
>> /*
>> --
>> Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
>> a Linux Foundation Collaborative Project
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-04 0:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-03 20:01 [PATCH] remoteproc: sysfs: Use scnprintf instead of sprintf Siddharth Gupta
2021-03-03 20:56 ` Bjorn Andersson
2021-03-03 21:38 ` Siddharth Gupta
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).