All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libfs: fix simple_attr_write on 32bit machine
@ 2011-07-09  5:00 Akinobu Mita
  2011-07-12 22:24 ` Andrew Morton
  2011-08-23  0:38 ` Greg KH
  0 siblings, 2 replies; 4+ messages in thread
From: Akinobu Mita @ 2011-07-09  5:00 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: Akinobu Mita, Greg Kroah-Hartman

Assume that /sys/kernel/debug/dummy64 is debugfs file created by
debugfs_create_x64().

	# cd /sys/kernel/debug
	# echo 0x1234567812345678 > dummy64
	# cat dummy64
	0x0000000012345678

	# echo 0x80000000 > dummy64
	# cat dummy64
	0xffffffff80000000

The value more than INT_MAX cannot be written to the debugfs file
created by debugfs_create_u64 or debugfs_create_x64 on 32bit machine.
Because simple_attr_write() uses simple_strtol() for the conversion.

To fix this, use simple_strtoll() instead.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
---
 fs/libfs.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/libfs.c b/fs/libfs.c
index c88eab5..275ca474 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -822,7 +822,7 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
 		goto out;
 
 	attr->set_buf[size] = '\0';
-	val = simple_strtol(attr->set_buf, NULL, 0);
+	val = simple_strtoll(attr->set_buf, NULL, 0);
 	ret = attr->set(attr->data, val);
 	if (ret == 0)
 		ret = len; /* on success, claim we got the whole input */
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] libfs: fix simple_attr_write on 32bit machine
  2011-07-09  5:00 [PATCH] libfs: fix simple_attr_write on 32bit machine Akinobu Mita
@ 2011-07-12 22:24 ` Andrew Morton
  2011-08-23  0:38 ` Greg KH
  1 sibling, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2011-07-12 22:24 UTC (permalink / raw)
  To: Akinobu Mita; +Cc: linux-kernel, Greg Kroah-Hartman

On Sat,  9 Jul 2011 14:00:26 +0900
Akinobu Mita <akinobu.mita@gmail.com> wrote:

> Assume that /sys/kernel/debug/dummy64 is debugfs file created by
> debugfs_create_x64().
> 
> 	# cd /sys/kernel/debug
> 	# echo 0x1234567812345678 > dummy64
> 	# cat dummy64
> 	0x0000000012345678
> 
> 	# echo 0x80000000 > dummy64
> 	# cat dummy64
> 	0xffffffff80000000
> 
> The value more than INT_MAX cannot be written to the debugfs file
> created by debugfs_create_u64 or debugfs_create_x64 on 32bit machine.
> Because simple_attr_write() uses simple_strtol() for the conversion.
> 
> To fix this, use simple_strtoll() instead.
> 
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: Greg Kroah-Hartman <gregkh@suse.de>
> ---
>  fs/libfs.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/libfs.c b/fs/libfs.c
> index c88eab5..275ca474 100644
> --- a/fs/libfs.c
> +++ b/fs/libfs.c
> @@ -822,7 +822,7 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
>  		goto out;
>  
>  	attr->set_buf[size] = '\0';
> -	val = simple_strtol(attr->set_buf, NULL, 0);
> +	val = simple_strtoll(attr->set_buf, NULL, 0);
>  	ret = attr->set(attr->data, val);
>  	if (ret == 0)
>  		ret = len; /* on success, claim we got the whole input */

It should strictly be simple_strtoull(), but I guess that doesn't
change anything.

And it should always have been strict_*(), now known as kstrto*().  But
that interface fix is non-back-compatible so it's too late to fix it.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libfs: fix simple_attr_write on 32bit machine
  2011-07-09  5:00 [PATCH] libfs: fix simple_attr_write on 32bit machine Akinobu Mita
  2011-07-12 22:24 ` Andrew Morton
@ 2011-08-23  0:38 ` Greg KH
  2011-08-23 15:05   ` Akinobu Mita
  1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2011-08-23  0:38 UTC (permalink / raw)
  To: Akinobu Mita; +Cc: linux-kernel, akpm, Greg Kroah-Hartman

On Sat, Jul 09, 2011 at 02:00:26PM +0900, Akinobu Mita wrote:
> Assume that /sys/kernel/debug/dummy64 is debugfs file created by
> debugfs_create_x64().
> 
> 	# cd /sys/kernel/debug
> 	# echo 0x1234567812345678 > dummy64
> 	# cat dummy64
> 	0x0000000012345678
> 
> 	# echo 0x80000000 > dummy64
> 	# cat dummy64
> 	0xffffffff80000000
> 
> The value more than INT_MAX cannot be written to the debugfs file
> created by debugfs_create_u64 or debugfs_create_x64 on 32bit machine.
> Because simple_attr_write() uses simple_strtol() for the conversion.
> 
> To fix this, use simple_strtoll() instead.
> 
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: Greg Kroah-Hartman <gregkh@suse.de>

Do we have any debugfs files that need this change in the tree now for
3.1 or newer?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libfs: fix simple_attr_write on 32bit machine
  2011-08-23  0:38 ` Greg KH
@ 2011-08-23 15:05   ` Akinobu Mita
  0 siblings, 0 replies; 4+ messages in thread
From: Akinobu Mita @ 2011-08-23 15:05 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, akpm, Greg Kroah-Hartman, Andi Kleen, Huang Ying

2011/8/23 Greg KH <greg@kroah.com>:
> On Sat, Jul 09, 2011 at 02:00:26PM +0900, Akinobu Mita wrote:
>> Assume that /sys/kernel/debug/dummy64 is debugfs file created by
>> debugfs_create_x64().
>>
>>       # cd /sys/kernel/debug
>>       # echo 0x1234567812345678 > dummy64
>>       # cat dummy64
>>       0x0000000012345678
>>
>>       # echo 0x80000000 > dummy64
>>       # cat dummy64
>>       0xffffffff80000000
>>
>> The value more than INT_MAX cannot be written to the debugfs file
>> created by debugfs_create_u64 or debugfs_create_x64 on 32bit machine.
>> Because simple_attr_write() uses simple_strtol() for the conversion.
>>
>> To fix this, use simple_strtoll() instead.
>>
>> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
>> Cc: Greg Kroah-Hartman <gregkh@suse.de>
>
> Do we have any debugfs files that need this change in the tree now for
> 3.1 or newer?

This patch has already been merged into 3.0.  Some files are created
debugfs_create_[ux]64 with write permission and affected by this bug.

hwpoison/corrupt-filter-flags-mask
hwpoison/corrupt-filter-flags-value
hwpoison/corrupt-filter-memcg
apei/einj/param1
apei/einj/param2

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-08-23 15:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-09  5:00 [PATCH] libfs: fix simple_attr_write on 32bit machine Akinobu Mita
2011-07-12 22:24 ` Andrew Morton
2011-08-23  0:38 ` Greg KH
2011-08-23 15:05   ` Akinobu Mita

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.