* [PATCH v2] ACPI: NFIT: limit string attribute write
@ 2023-07-11 9:37 Ben Dooks
2023-07-11 15:28 ` Dave Jiang
0 siblings, 1 reply; 3+ messages in thread
From: Ben Dooks @ 2023-07-11 9:37 UTC (permalink / raw)
To: nvdimm; +Cc: linux-acpi, linux-kernel, lenb, Ben Dooks
If we're writing what could be an arbitrary sized string into an attribute
we should probably use sysfs_emit() just to be safe. Most of the other
attriubtes are some sort of integer so unlikely to be an issue so not
altered at this time.
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
v2:
- use sysfs_emit() instead of snprintf.
---
drivers/acpi/nfit/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 9213b426b125..d7e9d9cd16d2 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -1579,7 +1579,7 @@ static ssize_t id_show(struct device *dev,
{
struct nfit_mem *nfit_mem = to_nfit_mem(dev);
- return sprintf(buf, "%s\n", nfit_mem->id);
+ return snprintf(buf, PAGE_SIZE, "%s\n", nfit_mem->id);
}
static DEVICE_ATTR_RO(id);
--
2.40.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ACPI: NFIT: limit string attribute write
2023-07-11 9:37 [PATCH v2] ACPI: NFIT: limit string attribute write Ben Dooks
@ 2023-07-11 15:28 ` Dave Jiang
2023-07-12 9:57 ` Ben Dooks
0 siblings, 1 reply; 3+ messages in thread
From: Dave Jiang @ 2023-07-11 15:28 UTC (permalink / raw)
To: Ben Dooks, nvdimm; +Cc: linux-acpi, linux-kernel, lenb
On 7/11/23 02:37, Ben Dooks wrote:
> If we're writing what could be an arbitrary sized string into an attribute
> we should probably use sysfs_emit() just to be safe. Most of the other
> attriubtes are some sort of integer so unlikely to be an issue so not
> altered at this time.
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
> v2:
> - use sysfs_emit() instead of snprintf.
> ---
> drivers/acpi/nfit/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
> index 9213b426b125..d7e9d9cd16d2 100644
> --- a/drivers/acpi/nfit/core.c
> +++ b/drivers/acpi/nfit/core.c
> @@ -1579,7 +1579,7 @@ static ssize_t id_show(struct device *dev,
> {
> struct nfit_mem *nfit_mem = to_nfit_mem(dev);
>
> - return sprintf(buf, "%s\n", nfit_mem->id);
> + return snprintf(buf, PAGE_SIZE, "%s\n", nfit_mem->id);
Doesn't look like you updated your patch with your new changes....
> }
> static DEVICE_ATTR_RO(id);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ACPI: NFIT: limit string attribute write
2023-07-11 15:28 ` Dave Jiang
@ 2023-07-12 9:57 ` Ben Dooks
0 siblings, 0 replies; 3+ messages in thread
From: Ben Dooks @ 2023-07-12 9:57 UTC (permalink / raw)
To: Dave Jiang, nvdimm; +Cc: linux-acpi, linux-kernel, lenb
On 11/07/2023 16:28, Dave Jiang wrote:
>
>
> On 7/11/23 02:37, Ben Dooks wrote:
>> If we're writing what could be an arbitrary sized string into an
>> attribute
>> we should probably use sysfs_emit() just to be safe. Most of the other
>> attriubtes are some sort of integer so unlikely to be an issue so not
>> altered at this time.
>>
>> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
>> ---
>> v2:
>> - use sysfs_emit() instead of snprintf.
>> ---
>> drivers/acpi/nfit/core.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
>> index 9213b426b125..d7e9d9cd16d2 100644
>> --- a/drivers/acpi/nfit/core.c
>> +++ b/drivers/acpi/nfit/core.c
>> @@ -1579,7 +1579,7 @@ static ssize_t id_show(struct device *dev,
>> {
>> struct nfit_mem *nfit_mem = to_nfit_mem(dev);
>> - return sprintf(buf, "%s\n", nfit_mem->id);
>> + return snprintf(buf, PAGE_SIZE, "%s\n", nfit_mem->id);
>
> Doesn't look like you updated your patch with your new changes....
Ooops, sorry about that. Will sort that for v2++
--
Ben Dooks http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
https://www.codethink.co.uk/privacy.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-12 9:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-11 9:37 [PATCH v2] ACPI: NFIT: limit string attribute write Ben Dooks
2023-07-11 15:28 ` Dave Jiang
2023-07-12 9:57 ` Ben Dooks
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.