All of lore.kernel.org
 help / color / mirror / Atom feed
* drivers/video/fbdev/core/fbcon.c:3509:8-16: WARNING: use scnprintf or sprintf
@ 2020-08-10  9:20 ` kernel test robot
  0 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2020-08-10  9:20 UTC (permalink / raw)
  To: Denis Efremov; +Cc: kbuild-all, linux-kernel, Julia Lawall

[-- Attachment #1: Type: text/plain, Size: 971 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   fc80c51fd4b23ec007e88d4c688f2cac1b8648e7
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script
date:   6 days ago
config: parisc-randconfig-c003-20200810 (attached as .config)
compiler: hppa-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


coccinelle warnings: (new ones prefixed by >>)

>> drivers/video/fbdev/core/fbcon.c:3509:8-16: WARNING: use scnprintf or sprintf
   drivers/video/fbdev/core/fbcon.c:3484:8-16: WARNING: use scnprintf or sprintf
--
>> drivers/tty/vt/vt.c:3820:8-16: WARNING: use scnprintf or sprintf
   drivers/tty/vt/vt.c:3828:8-16: WARNING: use scnprintf or sprintf

Please review and possibly fold the followup patch.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 23830 bytes --]

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

* drivers/video/fbdev/core/fbcon.c:3509:8-16: WARNING: use scnprintf or sprintf
@ 2020-08-10  9:20 ` kernel test robot
  0 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2020-08-10  9:20 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 997 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   fc80c51fd4b23ec007e88d4c688f2cac1b8648e7
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script
date:   6 days ago
config: parisc-randconfig-c003-20200810 (attached as .config)
compiler: hppa-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


coccinelle warnings: (new ones prefixed by >>)

>> drivers/video/fbdev/core/fbcon.c:3509:8-16: WARNING: use scnprintf or sprintf
   drivers/video/fbdev/core/fbcon.c:3484:8-16: WARNING: use scnprintf or sprintf
--
>> drivers/tty/vt/vt.c:3820:8-16: WARNING: use scnprintf or sprintf
   drivers/tty/vt/vt.c:3828:8-16: WARNING: use scnprintf or sprintf

Please review and possibly fold the followup patch.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 23830 bytes --]

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

* [PATCH] coccinelle: api: fix device_attr_show.cocci warnings
  2020-08-10  9:20 ` kernel test robot
  (?)
@ 2020-08-10  9:21   ` kernel test robot
  -1 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2020-08-10  9:21 UTC (permalink / raw)
  To: Denis Efremov
  Cc: kbuild-all, linux-kernel, Julia Lawall,
	Bartlomiej Zolnierkiewicz, Daniel Vetter, Nathan Chancellor,
	Sam Ravnborg, Alex Deucher, Qiujun Huang, Peter Rosin, dri-devel

From: kernel test robot <lkp@intel.com>

drivers/video/fbdev/core/fbcon.c:3509:8-16: WARNING: use scnprintf or sprintf
drivers/video/fbdev/core/fbcon.c:3484:8-16: WARNING: use scnprintf or sprintf


 From Documentation/filesystems/sysfs.txt:
  show() must not use snprintf() when formatting the value to be
  returned to user space. If you can guarantee that an overflow
  will never happen you can use sprintf() otherwise you must use
  scnprintf().

Generated by: scripts/coccinelle/api/device_attr_show.cocci

Fixes: abfc19ff202d ("coccinelle: api: add device_attr_show script")
CC: Denis Efremov <efremov@linux.com>
Signed-off-by: kernel test robot <lkp@intel.com>
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   fc80c51fd4b23ec007e88d4c688f2cac1b8648e7
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script

Please take the patch only if it's a positive warning. Thanks!

 fbcon.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -3481,7 +3481,7 @@ static ssize_t show_rotate(struct device
 	rotate = fbcon_get_rotate(info);
 err:
 	console_unlock();
-	return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", rotate);
 }
 
 static ssize_t show_cursor_blink(struct device *device,
@@ -3506,7 +3506,7 @@ static ssize_t show_cursor_blink(struct
 	blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0;
 err:
 	console_unlock();
-	return snprintf(buf, PAGE_SIZE, "%d\n", blink);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", blink);
 }
 
 static ssize_t store_cursor_blink(struct device *device,

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

* [PATCH] coccinelle: api: fix device_attr_show.cocci warnings
@ 2020-08-10  9:21   ` kernel test robot
  0 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2020-08-10  9:21 UTC (permalink / raw)
  To: Denis Efremov
  Cc: kbuild-all, Bartlomiej Zolnierkiewicz, Daniel Vetter,
	linux-kernel, dri-devel, Julia Lawall, Alex Deucher,
	Nathan Chancellor, Sam Ravnborg, Peter Rosin, Qiujun Huang

From: kernel test robot <lkp@intel.com>

drivers/video/fbdev/core/fbcon.c:3509:8-16: WARNING: use scnprintf or sprintf
drivers/video/fbdev/core/fbcon.c:3484:8-16: WARNING: use scnprintf or sprintf


 From Documentation/filesystems/sysfs.txt:
  show() must not use snprintf() when formatting the value to be
  returned to user space. If you can guarantee that an overflow
  will never happen you can use sprintf() otherwise you must use
  scnprintf().

Generated by: scripts/coccinelle/api/device_attr_show.cocci

Fixes: abfc19ff202d ("coccinelle: api: add device_attr_show script")
CC: Denis Efremov <efremov@linux.com>
Signed-off-by: kernel test robot <lkp@intel.com>
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   fc80c51fd4b23ec007e88d4c688f2cac1b8648e7
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script

Please take the patch only if it's a positive warning. Thanks!

 fbcon.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -3481,7 +3481,7 @@ static ssize_t show_rotate(struct device
 	rotate = fbcon_get_rotate(info);
 err:
 	console_unlock();
-	return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", rotate);
 }
 
 static ssize_t show_cursor_blink(struct device *device,
@@ -3506,7 +3506,7 @@ static ssize_t show_cursor_blink(struct
 	blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0;
 err:
 	console_unlock();
-	return snprintf(buf, PAGE_SIZE, "%d\n", blink);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", blink);
 }
 
 static ssize_t store_cursor_blink(struct device *device,
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH] coccinelle: api: fix device_attr_show.cocci warnings
@ 2020-08-10  9:21   ` kernel test robot
  0 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2020-08-10  9:21 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1759 bytes --]

From: kernel test robot <lkp@intel.com>

drivers/video/fbdev/core/fbcon.c:3509:8-16: WARNING: use scnprintf or sprintf
drivers/video/fbdev/core/fbcon.c:3484:8-16: WARNING: use scnprintf or sprintf


 From Documentation/filesystems/sysfs.txt:
  show() must not use snprintf() when formatting the value to be
  returned to user space. If you can guarantee that an overflow
  will never happen you can use sprintf() otherwise you must use
  scnprintf().

Generated by: scripts/coccinelle/api/device_attr_show.cocci

Fixes: abfc19ff202d ("coccinelle: api: add device_attr_show script")
CC: Denis Efremov <efremov@linux.com>
Signed-off-by: kernel test robot <lkp@intel.com>
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   fc80c51fd4b23ec007e88d4c688f2cac1b8648e7
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script

Please take the patch only if it's a positive warning. Thanks!

 fbcon.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -3481,7 +3481,7 @@ static ssize_t show_rotate(struct device
 	rotate = fbcon_get_rotate(info);
 err:
 	console_unlock();
-	return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", rotate);
 }
 
 static ssize_t show_cursor_blink(struct device *device,
@@ -3506,7 +3506,7 @@ static ssize_t show_cursor_blink(struct
 	blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0;
 err:
 	console_unlock();
-	return snprintf(buf, PAGE_SIZE, "%d\n", blink);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", blink);
 }
 
 static ssize_t store_cursor_blink(struct device *device,

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

* Re: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings
  2020-08-10  9:21   ` kernel test robot
  (?)
@ 2020-09-08 11:37     ` Bartlomiej Zolnierkiewicz
  -1 siblings, 0 replies; 11+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2020-09-08 11:37 UTC (permalink / raw)
  To: kernel test robot
  Cc: Denis Efremov, kbuild-all, linux-kernel, Julia Lawall,
	Daniel Vetter, Nathan Chancellor, Sam Ravnborg, Alex Deucher,
	Qiujun Huang, Peter Rosin, dri-devel


Hi,

On 8/10/20 11:21 AM, kernel test robot wrote:
> From: kernel test robot <lkp@intel.com>
> 
> drivers/video/fbdev/core/fbcon.c:3509:8-16: WARNING: use scnprintf or sprintf
> drivers/video/fbdev/core/fbcon.c:3484:8-16: WARNING: use scnprintf or sprintf
> 
> 
>  From Documentation/filesystems/sysfs.txt:
>   show() must not use snprintf() when formatting the value to be
>   returned to user space. If you can guarantee that an overflow
>   will never happen you can use sprintf() otherwise you must use
>   scnprintf().
> 
> Generated by: scripts/coccinelle/api/device_attr_show.cocci
> 
> Fixes: abfc19ff202d ("coccinelle: api: add device_attr_show script")
> CC: Denis Efremov <efremov@linux.com>
> Signed-off-by: kernel test robot <lkp@intel.com>
> ---
> 
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   fc80c51fd4b23ec007e88d4c688f2cac1b8648e7
> commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script
> 
> Please take the patch only if it's a positive warning. Thanks!
> 
>  fbcon.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> --- a/drivers/video/fbdev/core/fbcon.c
> +++ b/drivers/video/fbdev/core/fbcon.c
> @@ -3481,7 +3481,7 @@ static ssize_t show_rotate(struct device
>  	rotate = fbcon_get_rotate(info);
>  err:
>  	console_unlock();
> -	return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
> +	return scnprintf(buf, PAGE_SIZE, "%d\n", rotate);

buf length is at least PAGE_SIZE and rotate val is an int so
shouldn't this be converted to use sprintf() instead?

>  }
>  
>  static ssize_t show_cursor_blink(struct device *device,
> @@ -3506,7 +3506,7 @@ static ssize_t show_cursor_blink(struct
>  	blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0;
>  err:
>  	console_unlock();
> -	return snprintf(buf, PAGE_SIZE, "%d\n", blink);
> +	return scnprintf(buf, PAGE_SIZE, "%d\n", blink);

ditto for blink val

>  }
>  
>  static ssize_t store_cursor_blink(struct device *device,
> 
 
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

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

* Re: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings
@ 2020-09-08 11:37     ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 11+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2020-09-08 11:37 UTC (permalink / raw)
  To: kernel test robot
  Cc: kbuild-all, Daniel Vetter, linux-kernel, Denis Efremov,
	Julia Lawall, dri-devel, Alex Deucher, Nathan Chancellor,
	Sam Ravnborg, Peter Rosin, Qiujun Huang


Hi,

On 8/10/20 11:21 AM, kernel test robot wrote:
> From: kernel test robot <lkp@intel.com>
> 
> drivers/video/fbdev/core/fbcon.c:3509:8-16: WARNING: use scnprintf or sprintf
> drivers/video/fbdev/core/fbcon.c:3484:8-16: WARNING: use scnprintf or sprintf
> 
> 
>  From Documentation/filesystems/sysfs.txt:
>   show() must not use snprintf() when formatting the value to be
>   returned to user space. If you can guarantee that an overflow
>   will never happen you can use sprintf() otherwise you must use
>   scnprintf().
> 
> Generated by: scripts/coccinelle/api/device_attr_show.cocci
> 
> Fixes: abfc19ff202d ("coccinelle: api: add device_attr_show script")
> CC: Denis Efremov <efremov@linux.com>
> Signed-off-by: kernel test robot <lkp@intel.com>
> ---
> 
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   fc80c51fd4b23ec007e88d4c688f2cac1b8648e7
> commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script
> 
> Please take the patch only if it's a positive warning. Thanks!
> 
>  fbcon.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> --- a/drivers/video/fbdev/core/fbcon.c
> +++ b/drivers/video/fbdev/core/fbcon.c
> @@ -3481,7 +3481,7 @@ static ssize_t show_rotate(struct device
>  	rotate = fbcon_get_rotate(info);
>  err:
>  	console_unlock();
> -	return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
> +	return scnprintf(buf, PAGE_SIZE, "%d\n", rotate);

buf length is at least PAGE_SIZE and rotate val is an int so
shouldn't this be converted to use sprintf() instead?

>  }
>  
>  static ssize_t show_cursor_blink(struct device *device,
> @@ -3506,7 +3506,7 @@ static ssize_t show_cursor_blink(struct
>  	blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0;
>  err:
>  	console_unlock();
> -	return snprintf(buf, PAGE_SIZE, "%d\n", blink);
> +	return scnprintf(buf, PAGE_SIZE, "%d\n", blink);

ditto for blink val

>  }
>  
>  static ssize_t store_cursor_blink(struct device *device,
> 
 
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings
@ 2020-09-08 11:37     ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 11+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2020-09-08 11:37 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2161 bytes --]


Hi,

On 8/10/20 11:21 AM, kernel test robot wrote:
> From: kernel test robot <lkp@intel.com>
> 
> drivers/video/fbdev/core/fbcon.c:3509:8-16: WARNING: use scnprintf or sprintf
> drivers/video/fbdev/core/fbcon.c:3484:8-16: WARNING: use scnprintf or sprintf
> 
> 
>  From Documentation/filesystems/sysfs.txt:
>   show() must not use snprintf() when formatting the value to be
>   returned to user space. If you can guarantee that an overflow
>   will never happen you can use sprintf() otherwise you must use
>   scnprintf().
> 
> Generated by: scripts/coccinelle/api/device_attr_show.cocci
> 
> Fixes: abfc19ff202d ("coccinelle: api: add device_attr_show script")
> CC: Denis Efremov <efremov@linux.com>
> Signed-off-by: kernel test robot <lkp@intel.com>
> ---
> 
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   fc80c51fd4b23ec007e88d4c688f2cac1b8648e7
> commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script
> 
> Please take the patch only if it's a positive warning. Thanks!
> 
>  fbcon.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> --- a/drivers/video/fbdev/core/fbcon.c
> +++ b/drivers/video/fbdev/core/fbcon.c
> @@ -3481,7 +3481,7 @@ static ssize_t show_rotate(struct device
>  	rotate = fbcon_get_rotate(info);
>  err:
>  	console_unlock();
> -	return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
> +	return scnprintf(buf, PAGE_SIZE, "%d\n", rotate);

buf length is at least PAGE_SIZE and rotate val is an int so
shouldn't this be converted to use sprintf() instead?

>  }
>  
>  static ssize_t show_cursor_blink(struct device *device,
> @@ -3506,7 +3506,7 @@ static ssize_t show_cursor_blink(struct
>  	blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0;
>  err:
>  	console_unlock();
> -	return snprintf(buf, PAGE_SIZE, "%d\n", blink);
> +	return scnprintf(buf, PAGE_SIZE, "%d\n", blink);

ditto for blink val

>  }
>  
>  static ssize_t store_cursor_blink(struct device *device,
> 
 
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

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

* Re: [kbuild-all] Re: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings
  2020-09-08 11:37     ` Bartlomiej Zolnierkiewicz
  (?)
@ 2020-09-08 12:08       ` Julia Lawall
  -1 siblings, 0 replies; 11+ messages in thread
From: Julia Lawall @ 2020-09-08 12:08 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: kernel test robot, Denis Efremov, kbuild-all, linux-kernel,
	Daniel Vetter, Nathan Chancellor, Sam Ravnborg, Alex Deucher,
	Qiujun Huang, Peter Rosin, dri-devel



On Tue, 8 Sep 2020, Bartlomiej Zolnierkiewicz wrote:

>
> Hi,
>
> On 8/10/20 11:21 AM, kernel test robot wrote:
> > From: kernel test robot <lkp@intel.com>
> >
> > drivers/video/fbdev/core/fbcon.c:3509:8-16: WARNING: use scnprintf or sprintf
> > drivers/video/fbdev/core/fbcon.c:3484:8-16: WARNING: use scnprintf or sprintf
> >
> >
> >  From Documentation/filesystems/sysfs.txt:
> >   show() must not use snprintf() when formatting the value to be
> >   returned to user space. If you can guarantee that an overflow
> >   will never happen you can use sprintf() otherwise you must use
> >   scnprintf().
> >
> > Generated by: scripts/coccinelle/api/device_attr_show.cocci
> >
> > Fixes: abfc19ff202d ("coccinelle: api: add device_attr_show script")
> > CC: Denis Efremov <efremov@linux.com>
> > Signed-off-by: kernel test robot <lkp@intel.com>
> > ---
> >
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head:   fc80c51fd4b23ec007e88d4c688f2cac1b8648e7
> > commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script
> >
> > Please take the patch only if it's a positive warning. Thanks!
> >
> >  fbcon.c |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > --- a/drivers/video/fbdev/core/fbcon.c
> > +++ b/drivers/video/fbdev/core/fbcon.c
> > @@ -3481,7 +3481,7 @@ static ssize_t show_rotate(struct device
> >  	rotate = fbcon_get_rotate(info);
> >  err:
> >  	console_unlock();
> > -	return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
> > +	return scnprintf(buf, PAGE_SIZE, "%d\n", rotate);
>
> buf length is at least PAGE_SIZE and rotate val is an int so
> shouldn't this be converted to use sprintf() instead?

The rule is evolving in this direction.  Thanks for the feedback.

julia

>
> >  }
> >
> >  static ssize_t show_cursor_blink(struct device *device,
> > @@ -3506,7 +3506,7 @@ static ssize_t show_cursor_blink(struct
> >  	blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0;
> >  err:
> >  	console_unlock();
> > -	return snprintf(buf, PAGE_SIZE, "%d\n", blink);
> > +	return scnprintf(buf, PAGE_SIZE, "%d\n", blink);
>
> ditto for blink val
>
> >  }
> >
> >  static ssize_t store_cursor_blink(struct device *device,
> >
>
> Best regards,
> --
> Bartlomiej Zolnierkiewicz
> Samsung R&D Institute Poland
> Samsung Electronics
> _______________________________________________
> kbuild-all mailing list -- kbuild-all@lists.01.org
> To unsubscribe send an email to kbuild-all-leave@lists.01.org
>

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

* Re: [kbuild-all] Re: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings
@ 2020-09-08 12:08       ` Julia Lawall
  0 siblings, 0 replies; 11+ messages in thread
From: Julia Lawall @ 2020-09-08 12:08 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: kbuild-all, kernel test robot, Daniel Vetter, linux-kernel,
	Denis Efremov, dri-devel, Alex Deucher, Nathan Chancellor,
	Sam Ravnborg, Peter Rosin, Qiujun Huang



On Tue, 8 Sep 2020, Bartlomiej Zolnierkiewicz wrote:

>
> Hi,
>
> On 8/10/20 11:21 AM, kernel test robot wrote:
> > From: kernel test robot <lkp@intel.com>
> >
> > drivers/video/fbdev/core/fbcon.c:3509:8-16: WARNING: use scnprintf or sprintf
> > drivers/video/fbdev/core/fbcon.c:3484:8-16: WARNING: use scnprintf or sprintf
> >
> >
> >  From Documentation/filesystems/sysfs.txt:
> >   show() must not use snprintf() when formatting the value to be
> >   returned to user space. If you can guarantee that an overflow
> >   will never happen you can use sprintf() otherwise you must use
> >   scnprintf().
> >
> > Generated by: scripts/coccinelle/api/device_attr_show.cocci
> >
> > Fixes: abfc19ff202d ("coccinelle: api: add device_attr_show script")
> > CC: Denis Efremov <efremov@linux.com>
> > Signed-off-by: kernel test robot <lkp@intel.com>
> > ---
> >
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head:   fc80c51fd4b23ec007e88d4c688f2cac1b8648e7
> > commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script
> >
> > Please take the patch only if it's a positive warning. Thanks!
> >
> >  fbcon.c |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > --- a/drivers/video/fbdev/core/fbcon.c
> > +++ b/drivers/video/fbdev/core/fbcon.c
> > @@ -3481,7 +3481,7 @@ static ssize_t show_rotate(struct device
> >  	rotate = fbcon_get_rotate(info);
> >  err:
> >  	console_unlock();
> > -	return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
> > +	return scnprintf(buf, PAGE_SIZE, "%d\n", rotate);
>
> buf length is at least PAGE_SIZE and rotate val is an int so
> shouldn't this be converted to use sprintf() instead?

The rule is evolving in this direction.  Thanks for the feedback.

julia

>
> >  }
> >
> >  static ssize_t show_cursor_blink(struct device *device,
> > @@ -3506,7 +3506,7 @@ static ssize_t show_cursor_blink(struct
> >  	blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0;
> >  err:
> >  	console_unlock();
> > -	return snprintf(buf, PAGE_SIZE, "%d\n", blink);
> > +	return scnprintf(buf, PAGE_SIZE, "%d\n", blink);
>
> ditto for blink val
>
> >  }
> >
> >  static ssize_t store_cursor_blink(struct device *device,
> >
>
> Best regards,
> --
> Bartlomiej Zolnierkiewicz
> Samsung R&D Institute Poland
> Samsung Electronics
> _______________________________________________
> kbuild-all mailing list -- kbuild-all@lists.01.org
> To unsubscribe send an email to kbuild-all-leave@lists.01.org
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings
@ 2020-09-08 12:08       ` Julia Lawall
  0 siblings, 0 replies; 11+ messages in thread
From: Julia Lawall @ 2020-09-08 12:08 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2588 bytes --]



On Tue, 8 Sep 2020, Bartlomiej Zolnierkiewicz wrote:

>
> Hi,
>
> On 8/10/20 11:21 AM, kernel test robot wrote:
> > From: kernel test robot <lkp@intel.com>
> >
> > drivers/video/fbdev/core/fbcon.c:3509:8-16: WARNING: use scnprintf or sprintf
> > drivers/video/fbdev/core/fbcon.c:3484:8-16: WARNING: use scnprintf or sprintf
> >
> >
> >  From Documentation/filesystems/sysfs.txt:
> >   show() must not use snprintf() when formatting the value to be
> >   returned to user space. If you can guarantee that an overflow
> >   will never happen you can use sprintf() otherwise you must use
> >   scnprintf().
> >
> > Generated by: scripts/coccinelle/api/device_attr_show.cocci
> >
> > Fixes: abfc19ff202d ("coccinelle: api: add device_attr_show script")
> > CC: Denis Efremov <efremov@linux.com>
> > Signed-off-by: kernel test robot <lkp@intel.com>
> > ---
> >
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head:   fc80c51fd4b23ec007e88d4c688f2cac1b8648e7
> > commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script
> >
> > Please take the patch only if it's a positive warning. Thanks!
> >
> >  fbcon.c |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > --- a/drivers/video/fbdev/core/fbcon.c
> > +++ b/drivers/video/fbdev/core/fbcon.c
> > @@ -3481,7 +3481,7 @@ static ssize_t show_rotate(struct device
> >  	rotate = fbcon_get_rotate(info);
> >  err:
> >  	console_unlock();
> > -	return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
> > +	return scnprintf(buf, PAGE_SIZE, "%d\n", rotate);
>
> buf length is at least PAGE_SIZE and rotate val is an int so
> shouldn't this be converted to use sprintf() instead?

The rule is evolving in this direction.  Thanks for the feedback.

julia

>
> >  }
> >
> >  static ssize_t show_cursor_blink(struct device *device,
> > @@ -3506,7 +3506,7 @@ static ssize_t show_cursor_blink(struct
> >  	blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0;
> >  err:
> >  	console_unlock();
> > -	return snprintf(buf, PAGE_SIZE, "%d\n", blink);
> > +	return scnprintf(buf, PAGE_SIZE, "%d\n", blink);
>
> ditto for blink val
>
> >  }
> >
> >  static ssize_t store_cursor_blink(struct device *device,
> >
>
> Best regards,
> --
> Bartlomiej Zolnierkiewicz
> Samsung R&D Institute Poland
> Samsung Electronics
> _______________________________________________
> kbuild-all mailing list -- kbuild-all(a)lists.01.org
> To unsubscribe send an email to kbuild-all-leave(a)lists.01.org
>

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

end of thread, other threads:[~2020-09-09  7:05 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-10  9:20 drivers/video/fbdev/core/fbcon.c:3509:8-16: WARNING: use scnprintf or sprintf kernel test robot
2020-08-10  9:20 ` kernel test robot
2020-08-10  9:21 ` [PATCH] coccinelle: api: fix device_attr_show.cocci warnings kernel test robot
2020-08-10  9:21   ` kernel test robot
2020-08-10  9:21   ` kernel test robot
2020-09-08 11:37   ` Bartlomiej Zolnierkiewicz
2020-09-08 11:37     ` Bartlomiej Zolnierkiewicz
2020-09-08 11:37     ` Bartlomiej Zolnierkiewicz
2020-09-08 12:08     ` [kbuild-all] " Julia Lawall
2020-09-08 12:08       ` Julia Lawall
2020-09-08 12:08       ` [kbuild-all] " Julia Lawall

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.