linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [mcgrof:modules-next 1/1] include/linux/kern_levels.h:5:18: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'Elf32_Off' {aka 'unsigned int'}
@ 2021-10-13 16:42 kernel test robot
  2021-10-13 17:09 ` Shuah Khan
  0 siblings, 1 reply; 5+ messages in thread
From: kernel test robot @ 2021-10-13 16:42 UTC (permalink / raw)
  To: Shuah Khan; +Cc: kbuild-all, linux-kernel, Luis Chamberlain

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git modules-next
head:   8b1185a4427b772b9f02376a08272c3019777581
commit: 8b1185a4427b772b9f02376a08272c3019777581 [1/1] module: change to print useful messages from elf_validity_check()
config: um-i386_defconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/commit/?id=8b1185a4427b772b9f02376a08272c3019777581
        git remote add mcgrof https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git
        git fetch --no-tags mcgrof modules-next
        git checkout 8b1185a4427b772b9f02376a08272c3019777581
        # save the attached .config to linux build tree
        make W=1 ARCH=um SUBARCH=i386

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

All warnings (new ones prefixed by >>):

   In file included from include/linux/kernel.h:19,
                    from include/linux/list.h:9,
                    from include/linux/module.h:12,
                    from include/linux/moduleloader.h:6,
                    from kernel/module.c:11:
   kernel/module.c: In function 'validate_section_offset':
>> include/linux/kern_levels.h:5:18: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'Elf32_Off' {aka 'unsigned int'} [-Wformat=]
       5 | #define KERN_SOH "\001"  /* ASCII Start Of Header */
         |                  ^~~~~~
   include/linux/printk.h:418:11: note: in definition of macro 'printk_index_wrap'
     418 |   _p_func(_fmt, ##__VA_ARGS__);    \
         |           ^~~~
   include/linux/printk.h:489:2: note: in expansion of macro 'printk'
     489 |  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |  ^~~~~~
   include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
      11 | #define KERN_ERR KERN_SOH "3" /* error conditions */
         |                  ^~~~~~~~
   include/linux/printk.h:489:9: note: in expansion of macro 'KERN_ERR'
     489 |  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~~~
   kernel/module.c:2953:3: note: in expansion of macro 'pr_err'
    2953 |   pr_err("Invalid ELF section offset/size: secend(%lu) < shdr->sh_offset(%llu) or secend(%lu) > e_shnum(%lu)\n",
         |   ^~~~~~
   kernel/module.c:2953:77: note: format string is defined here
    2953 |   pr_err("Invalid ELF section offset/size: secend(%lu) < shdr->sh_offset(%llu) or secend(%lu) > e_shnum(%lu)\n",
         |                                                                          ~~~^
         |                                                                             |
         |                                                                             long long unsigned int
         |                                                                          %u
   In file included from include/linux/kernel.h:19,
                    from include/linux/list.h:9,
                    from include/linux/module.h:12,
                    from include/linux/moduleloader.h:6,
                    from kernel/module.c:11:
   kernel/module.c: In function 'elf_validity_check':
   include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'unsigned int' [-Wformat=]
       5 | #define KERN_SOH "\001"  /* ASCII Start Of Header */
         |                  ^~~~~~
   include/linux/printk.h:418:11: note: in definition of macro 'printk_index_wrap'
     418 |   _p_func(_fmt, ##__VA_ARGS__);    \
         |           ^~~~
   include/linux/printk.h:489:2: note: in expansion of macro 'printk'
     489 |  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |  ^~~~~~
   include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
      11 | #define KERN_ERR KERN_SOH "3" /* error conditions */
         |                  ^~~~~~~~
   include/linux/printk.h:489:9: note: in expansion of macro 'KERN_ERR'
     489 |  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~~~
   kernel/module.c:2974:3: note: in expansion of macro 'pr_err'
    2974 |   pr_err("Invalid ELF header len %lu < %lu\n", info->len,
         |   ^~~~~~
   kernel/module.c:2974:42: note: format string is defined here
    2974 |   pr_err("Invalid ELF header len %lu < %lu\n", info->len,
         |                                        ~~^
         |                                          |
         |                                          long unsigned int
         |                                        %u
   In file included from include/linux/kernel.h:19,
                    from include/linux/list.h:9,
                    from include/linux/module.h:12,
                    from include/linux/moduleloader.h:6,
                    from kernel/module.c:11:
   include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'unsigned int' [-Wformat=]
       5 | #define KERN_SOH "\001"  /* ASCII Start Of Header */
         |                  ^~~~~~
   include/linux/printk.h:418:11: note: in definition of macro 'printk_index_wrap'
     418 |   _p_func(_fmt, ##__VA_ARGS__);    \
         |           ^~~~
   include/linux/printk.h:489:2: note: in expansion of macro 'printk'
     489 |  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |  ^~~~~~
   include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
      11 | #define KERN_ERR KERN_SOH "3" /* error conditions */
         |                  ^~~~~~~~
   include/linux/printk.h:489:9: note: in expansion of macro 'KERN_ERR'
     489 |  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~~~
   kernel/module.c:2994:3: note: in expansion of macro 'pr_err'
    2994 |   pr_err("Invalid ELF section header size %d != %lu\n",
         |   ^~~~~~
   kernel/module.c:2994:51: note: format string is defined here
    2994 |   pr_err("Invalid ELF section header size %d != %lu\n",
         |                                                 ~~^
         |                                                   |
         |                                                   long unsigned int
         |                                                 %u
   In file included from include/linux/kernel.h:19,
                    from include/linux/list.h:9,
                    from include/linux/module.h:12,
                    from include/linux/moduleloader.h:6,
                    from kernel/module.c:11:
>> include/linux/kern_levels.h:5:18: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'unsigned int' [-Wformat=]
       5 | #define KERN_SOH "\001"  /* ASCII Start Of Header */
         |                  ^~~~~~
   include/linux/printk.h:418:11: note: in definition of macro 'printk_index_wrap'
     418 |   _p_func(_fmt, ##__VA_ARGS__);    \
         |           ^~~~
   include/linux/printk.h:489:2: note: in expansion of macro 'printk'
     489 |  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |  ^~~~~~
   include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
      11 | #define KERN_ERR KERN_SOH "3" /* error conditions */
         |                  ^~~~~~~~
   include/linux/printk.h:489:9: note: in expansion of macro 'KERN_ERR'
     489 |  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~~~
   kernel/module.c:3007:3: note: in expansion of macro 'pr_err'
    3007 |   pr_err("Invalid ELF section header overflow: %ld > %llu\n",
         |   ^~~~~~
   kernel/module.c:3007:50: note: format string is defined here
    3007 |   pr_err("Invalid ELF section header overflow: %ld > %llu\n",
         |                                                ~~^
         |                                                  |
         |                                                  long int
         |                                                %d
   In file included from include/linux/kernel.h:19,
                    from include/linux/list.h:9,
                    from include/linux/module.h:12,
                    from include/linux/moduleloader.h:6,
                    from kernel/module.c:11:
>> include/linux/kern_levels.h:5:18: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'long unsigned int' [-Wformat=]
       5 | #define KERN_SOH "\001"  /* ASCII Start Of Header */
         |                  ^~~~~~
   include/linux/printk.h:418:11: note: in definition of macro 'printk_index_wrap'
     418 |   _p_func(_fmt, ##__VA_ARGS__);    \
         |           ^~~~
   include/linux/printk.h:489:2: note: in expansion of macro 'printk'
     489 |  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |  ^~~~~~
   include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
      11 | #define KERN_ERR KERN_SOH "3" /* error conditions */
         |                  ^~~~~~~~
   include/linux/printk.h:489:9: note: in expansion of macro 'KERN_ERR'
     489 |  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~~~
   kernel/module.c:3007:3: note: in expansion of macro 'pr_err'
    3007 |   pr_err("Invalid ELF section header overflow: %ld > %llu\n",
         |   ^~~~~~
   kernel/module.c:3007:57: note: format string is defined here
    3007 |   pr_err("Invalid ELF section header overflow: %ld > %llu\n",
         |                                                      ~~~^
         |                                                         |
         |                                                         long long unsigned int
         |                                                      %lu
   In file included from include/linux/kernel.h:19,
                    from include/linux/list.h:9,
                    from include/linux/module.h:12,
                    from include/linux/moduleloader.h:6,
                    from kernel/module.c:11:
>> include/linux/kern_levels.h:5:18: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'Elf32_Word' {aka 'unsigned int'} [-Wformat=]
       5 | #define KERN_SOH "\001"  /* ASCII Start Of Header */
         |                  ^~~~~~
   include/linux/printk.h:418:11: note: in definition of macro 'printk_index_wrap'
     418 |   _p_func(_fmt, ##__VA_ARGS__);    \
         |           ^~~~
   include/linux/printk.h:489:2: note: in expansion of macro 'printk'
     489 |  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |  ^~~~~~
   include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
      11 | #define KERN_ERR KERN_SOH "3" /* error conditions */
         |                  ^~~~~~~~
   include/linux/printk.h:489:9: note: in expansion of macro 'KERN_ERR'
     489 |  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~~~
   kernel/module.c:3049:3: note: in expansion of macro 'pr_err'
    3049 |   pr_err("ELF Spec violation: section 0 type!=SH_NULL(%d) or non-zero len(%llu) or addr(%llu)\n",
         |   ^~~~~~
   kernel/module.c:3049:78: note: format string is defined here
    3049 |   pr_err("ELF Spec violation: section 0 type!=SH_NULL(%d) or non-zero len(%llu) or addr(%llu)\n",
         |                                                                           ~~~^
         |                                                                              |
         |                                                                              long long unsigned int
         |                                                                           %u
   In file included from include/linux/kernel.h:19,
                    from include/linux/list.h:9,
                    from include/linux/module.h:12,
                    from include/linux/moduleloader.h:6,
                    from kernel/module.c:11:
>> include/linux/kern_levels.h:5:18: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 4 has type 'Elf32_Addr' {aka 'unsigned int'} [-Wformat=]
       5 | #define KERN_SOH "\001"  /* ASCII Start Of Header */
         |                  ^~~~~~
   include/linux/printk.h:418:11: note: in definition of macro 'printk_index_wrap'
     418 |   _p_func(_fmt, ##__VA_ARGS__);    \
         |           ^~~~
   include/linux/printk.h:489:2: note: in expansion of macro 'printk'
     489 |  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |  ^~~~~~
   include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
      11 | #define KERN_ERR KERN_SOH "3" /* error conditions */
         |                  ^~~~~~~~
   include/linux/printk.h:489:9: note: in expansion of macro 'KERN_ERR'
     489 |  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~~~
   kernel/module.c:3049:3: note: in expansion of macro 'pr_err'
    3049 |   pr_err("ELF Spec violation: section 0 type!=SH_NULL(%d) or non-zero len(%llu) or addr(%llu)\n",
         |   ^~~~~~
   kernel/module.c:3049:92: note: format string is defined here
    3049 |   pr_err("ELF Spec violation: section 0 type!=SH_NULL(%d) or non-zero len(%llu) or addr(%llu)\n",
         |                                                                                         ~~~^
         |                                                                                            |
         |                                                                                            long long unsigned int
         |                                                                                         %u


vim +5 include/linux/kern_levels.h

314ba3520e513a Joe Perches 2012-07-30  4  
04d2c8c83d0e3a Joe Perches 2012-07-30 @5  #define KERN_SOH	"\001"		/* ASCII Start Of Header */
04d2c8c83d0e3a Joe Perches 2012-07-30  6  #define KERN_SOH_ASCII	'\001'
04d2c8c83d0e3a Joe Perches 2012-07-30  7  

:::::: The code at line 5 was first introduced by commit
:::::: 04d2c8c83d0e3ac5f78aeede51babb3236200112 printk: convert the format for KERN_<LEVEL> to a 2 byte pattern

:::::: TO: Joe Perches <joe@perches.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

---
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: 9867 bytes --]

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

* Re: [mcgrof:modules-next 1/1] include/linux/kern_levels.h:5:18: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'Elf32_Off' {aka 'unsigned int'}
  2021-10-13 16:42 [mcgrof:modules-next 1/1] include/linux/kern_levels.h:5:18: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'Elf32_Off' {aka 'unsigned int'} kernel test robot
@ 2021-10-13 17:09 ` Shuah Khan
  2021-10-13 21:18   ` Luis Chamberlain
  0 siblings, 1 reply; 5+ messages in thread
From: Shuah Khan @ 2021-10-13 17:09 UTC (permalink / raw)
  To: kernel test robot, Luis Chamberlain; +Cc: kbuild-all, linux-kernel, Shuah Khan

Hi Luis,

On 10/13/21 10:42 AM, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git modules-next
> head:   8b1185a4427b772b9f02376a08272c3019777581
> commit: 8b1185a4427b772b9f02376a08272c3019777581 [1/1] module: change to print useful messages from elf_validity_check()
> config: um-i386_defconfig (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
> reproduce (this is a W=1 build):
>          # https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/commit/?id=8b1185a4427b772b9f02376a08272c3019777581
>          git remote add mcgrof https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git
>          git fetch --no-tags mcgrof modules-next
>          git checkout 8b1185a4427b772b9f02376a08272c3019777581
>          # save the attached .config to linux build tree
>          make W=1 ARCH=um SUBARCH=i386
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All warnings (new ones prefixed by >>):
> 

All of these warnings can be fixed easily by leaving out the fields that
are the problem. I can send a patch for that.

This one is real issue though;

static int validate_section_offset(struct load_info *info, Elf_Shdr *shdr)
{
         unsigned long secend; /* too short when sh_offset is Elf64_Off */

         /*
          * Check for both overflow and offset/size being
          * too large.
          */
         secend = shdr->sh_offset + shdr->sh_size;


secend is unsigned long which is too short when sh_offset is Elf64_Off

It appears to me that some sections of this elf validation code probably
needs to be arch specific. validate_section_offset() is one with this
potential for secend overflow.

We can introduce arch specific header print routine. Easy option is not
printing any info., which we know isn't very useful.

Let me know your thoughts.

thanks,
-- Shuah

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

* Re: [mcgrof:modules-next 1/1] include/linux/kern_levels.h:5:18: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'Elf32_Off' {aka 'unsigned int'}
  2021-10-13 17:09 ` Shuah Khan
@ 2021-10-13 21:18   ` Luis Chamberlain
  2021-10-13 22:16     ` Shuah Khan
  0 siblings, 1 reply; 5+ messages in thread
From: Luis Chamberlain @ 2021-10-13 21:18 UTC (permalink / raw)
  To: Shuah Khan; +Cc: kernel test robot, kbuild-all, linux-kernel

On Wed, Oct 13, 2021 at 11:09:15AM -0600, Shuah Khan wrote:
> Hi Luis,
> We can introduce arch specific header print routine. Easy option is not
> printing any info., which we know isn't very useful.
> 
> Let me know your thoughts.

You found an issue without the debug prints, and so you'd know better if
the effort is worth the trouble, so I'll let you decide.

  Luis

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

* Re: [mcgrof:modules-next 1/1] include/linux/kern_levels.h:5:18: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'Elf32_Off' {aka 'unsigned int'}
  2021-10-13 21:18   ` Luis Chamberlain
@ 2021-10-13 22:16     ` Shuah Khan
  2021-10-13 22:40       ` Luis Chamberlain
  0 siblings, 1 reply; 5+ messages in thread
From: Shuah Khan @ 2021-10-13 22:16 UTC (permalink / raw)
  To: Luis Chamberlain; +Cc: kernel test robot, kbuild-all, linux-kernel, Shuah Khan

On 10/13/21 3:18 PM, Luis Chamberlain wrote:
> On Wed, Oct 13, 2021 at 11:09:15AM -0600, Shuah Khan wrote:
>> Hi Luis,
>> We can introduce arch specific header print routine. Easy option is not
>> printing any info., which we know isn't very useful.
>>
>> Let me know your thoughts.
> 
> You found an issue without the debug prints, and so you'd know better if
> the effort is worth the trouble, so I'll let you decide.
> 

Right the issue with validate_section_offset() is separate from the debug.
I will fix the pr_err warns first by tweaking the messages to not print
the variables that cause problems.

I will send a separate patch for validate_section_offset() which needs to
be arch specific similar to elf_check_arch().

Let me know if this plan sounds good.

thanks,
-- Shuah

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

* Re: [mcgrof:modules-next 1/1] include/linux/kern_levels.h:5:18: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'Elf32_Off' {aka 'unsigned int'}
  2021-10-13 22:16     ` Shuah Khan
@ 2021-10-13 22:40       ` Luis Chamberlain
  0 siblings, 0 replies; 5+ messages in thread
From: Luis Chamberlain @ 2021-10-13 22:40 UTC (permalink / raw)
  To: Shuah Khan, Jessica Yu; +Cc: kernel test robot, kbuild-all, linux-kernel

On Wed, Oct 13, 2021 at 04:16:36PM -0600, Shuah Khan wrote:
> On 10/13/21 3:18 PM, Luis Chamberlain wrote:
> > On Wed, Oct 13, 2021 at 11:09:15AM -0600, Shuah Khan wrote:
> > > Hi Luis,
> > > We can introduce arch specific header print routine. Easy option is not
> > > printing any info., which we know isn't very useful.
> > > 
> > > Let me know your thoughts.
> > 
> > You found an issue without the debug prints, and so you'd know better if
> > the effort is worth the trouble, so I'll let you decide.
> > 
> 
> Right the issue with validate_section_offset() is separate from the debug.
> I will fix the pr_err warns first by tweaking the messages to not print
> the variables that cause problems.
> 
> I will send a separate patch for validate_section_offset() which needs to
> be arch specific similar to elf_check_arch().
> 
> Let me know if this plan sounds good.

Sounds good! Thanks for doing this work!

  Luis

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

end of thread, other threads:[~2021-10-13 22:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13 16:42 [mcgrof:modules-next 1/1] include/linux/kern_levels.h:5:18: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'Elf32_Off' {aka 'unsigned int'} kernel test robot
2021-10-13 17:09 ` Shuah Khan
2021-10-13 21:18   ` Luis Chamberlain
2021-10-13 22:16     ` Shuah Khan
2021-10-13 22:40       ` Luis Chamberlain

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).