Re: [PATCH v3] vsprintf: Prevent crash when dereferencing invalid pointers

kbuild test robot
2018-03-15T20:28:14Z

Hi Petr,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v4.16-rc5 next-20180314]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Petr-Mladek/vsprintf-Prevent-crash-when-dereferencing-invalid-pointers/20180315-214100
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__

sparse warnings: (new ones prefixed by >>)

>> lib/vsprintf.c:533:16: sparse: Using plain integer as NULL pointer
lib/vsprintf.c:762:18: sparse: Variable length array is used.
lib/vsprintf.c:765:38: sparse: cannot size expression
lib/vsprintf.c:1532:23: sparse: incorrect type in assignment (different base types) @@ expected unsigned long [unsigned] [assigned] flags @@ got long [unsigned] [assigned] flags @@
lib/vsprintf.c:1532:23: expected unsigned long [unsigned] [assigned] flags
lib/vsprintf.c:1532:23: got restricted gfp_t [usertype] <noident>

vim +533 lib/vsprintf.c

522
523 static const char *check_pointer_access(const void *ptr)
524 {
525 unsigned char byte;
526
527 if (!ptr)
528 return "(null)";
529
530 if (probe_kernel_read(&byte, ptr, 1))
531 return "(efault)";
532
> 533 return 0;
534 }
535

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation