mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* arch/arm/kernel/hibernate.c:29:40: warning: array subscript -1 is outside array bounds of 'const void[2147483647]'
@ 2023-10-18 12:16 kernel test robot
  2023-11-06 13:19 ` Linus Walleij
  0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2023-10-18 12:16 UTC (permalink / raw)
  To: Linus Walleij; +Cc: oe-kbuild-all, linux-kernel

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   06dc10eae55b5ceabfef287a7e5f16ceea204aa0
commit: a9ff6961601d9aa0c42b6eb7d850371f31b1f5e6 ARM: mm: Make virt_to_pfn() a static inline
date:   5 months ago
config: arm-allyesconfig (https://download.01.org/0day-ci/archive/20231018/202310182007.8ziiRe0j-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231018/202310182007.8ziiRe0j-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310182007.8ziiRe0j-lkp@intel.com/

All warnings (new ones prefixed by >>):

   arch/arm/kernel/hibernate.c: In function 'pfn_is_nosave':
>> arch/arm/kernel/hibernate.c:29:40: warning: array subscript -1 is outside array bounds of 'const void[2147483647]' [-Warray-bounds=]
      29 |         unsigned long nosave_end_pfn = virt_to_pfn(&__nosave_end - 1);
         |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from arch/arm/include/asm/sections.h:5,
                    from include/linux/interrupt.h:21,
                    from include/linux/kernel_stat.h:9,
                    from include/linux/cgroup.h:26,
                    from include/linux/memcontrol.h:13,
                    from include/linux/swap.h:9,
                    from include/linux/suspend.h:5,
                    from arch/arm/kernel/hibernate.c:18:
   include/asm-generic/sections.h:59:45: note: at offset -1 into object '__nosave_end' of size [0, 2147483647]
      59 | extern __visible const void __nosave_begin, __nosave_end;
         |                                             ^~~~~~~~~~~~


vim +29 arch/arm/kernel/hibernate.c

603fb42a66499a Sebastian Capella 2014-03-25  25  
603fb42a66499a Sebastian Capella 2014-03-25  26  int pfn_is_nosave(unsigned long pfn)
603fb42a66499a Sebastian Capella 2014-03-25  27  {
603fb42a66499a Sebastian Capella 2014-03-25  28  	unsigned long nosave_begin_pfn = virt_to_pfn(&__nosave_begin);
603fb42a66499a Sebastian Capella 2014-03-25 @29  	unsigned long nosave_end_pfn = virt_to_pfn(&__nosave_end - 1);
603fb42a66499a Sebastian Capella 2014-03-25  30  
603fb42a66499a Sebastian Capella 2014-03-25  31  	return (pfn >= nosave_begin_pfn) && (pfn <= nosave_end_pfn);
603fb42a66499a Sebastian Capella 2014-03-25  32  }
603fb42a66499a Sebastian Capella 2014-03-25  33  

:::::: The code at line 29 was first introduced by commit
:::::: 603fb42a66499ab353466c7afa3d38beea20a8a9 ARM: 8011/1: ARM hibernation / suspend-to-disk

:::::: TO: Sebastian Capella <sebastian.capella@linaro.org>
:::::: CC: Russell King <rmk+kernel@arm.linux.org.uk>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: arch/arm/kernel/hibernate.c:29:40: warning: array subscript -1 is outside array bounds of 'const void[2147483647]'
  2023-10-18 12:16 arch/arm/kernel/hibernate.c:29:40: warning: array subscript -1 is outside array bounds of 'const void[2147483647]' kernel test robot
@ 2023-11-06 13:19 ` Linus Walleij
  2023-11-20  7:14   ` Yujie Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2023-11-06 13:19 UTC (permalink / raw)
  To: kernel test robot; +Cc: oe-kbuild-all, linux-kernel

Hi Robot,

On Wed, Oct 18, 2023 at 2:17 PM kernel test robot <lkp@intel.com> wrote:

>    arch/arm/kernel/hibernate.c: In function 'pfn_is_nosave':
> >> arch/arm/kernel/hibernate.c:29:40: warning: array subscript -1 is outside array bounds of 'const void[2147483647]' [-Warray-bounds=]
>       29 |         unsigned long nosave_end_pfn = virt_to_pfn(&__nosave_end - 1);
>          |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

So the concern is that &__nosave_end  could be 0 and the -1 would make
it wrap around?

It still has nothing to do with arrays, I don't get it.

Yours,
Linus Walleij

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

* Re: arch/arm/kernel/hibernate.c:29:40: warning: array subscript -1 is outside array bounds of 'const void[2147483647]'
  2023-11-06 13:19 ` Linus Walleij
@ 2023-11-20  7:14   ` Yujie Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Yujie Liu @ 2023-11-20  7:14 UTC (permalink / raw)
  To: Linus Walleij, Kees Cook; +Cc: kernel test robot, oe-kbuild-all, linux-kernel

On Mon, Nov 06, 2023 at 02:19:33PM +0100, Linus Walleij wrote:
> Hi Robot,
> 
> On Wed, Oct 18, 2023 at 2:17 PM kernel test robot <lkp@intel.com> wrote:
> 
> >    arch/arm/kernel/hibernate.c: In function 'pfn_is_nosave':
> > >> arch/arm/kernel/hibernate.c:29:40: warning: array subscript -1 is outside array bounds of 'const void[2147483647]' [-Warray-bounds=]
> >       29 |         unsigned long nosave_end_pfn = virt_to_pfn(&__nosave_end - 1);
> >          |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> So the concern is that &__nosave_end  could be 0 and the -1 would make
> it wrap around?
> 
> It still has nothing to do with arrays, I don't get it.

Hi Linus Walleij, sorry that we couldn't explain this warning very
clearly. Let's consult Kees for more input.

Hi Kees, our robot has sent out several reports of "-Warray-bounds"
warnings. Thanks a lot for helping to analyze them. [1][2]

[1] https://lore.kernel.org/all/202309200904.CEED70DA33@keescook/
[2] https://lore.kernel.org/all/202311071521.099CAEA58@keescook/

As for some other reports, developers have some doubt about them that we
are not sure how to explain, such as the one in this report and
[3][4][5][6]. If it's not too much trouble, could you please help take a
look to see if these are valid warnings or false positives? Thanks a lot.

[3] https://lore.kernel.org/oe-kbuild-all/CACRpkdZ-1OcZ-cz0V218-VxAc07DMPvKWee3MHngs6Hrwv4zPA@mail.gmail.com/
[4] https://lore.kernel.org/oe-kbuild-all/20231019092258.c2cbwmmgffa33bro@vireshk-i7/
[5] https://lore.kernel.org/oe-kbuild-all/CANn89iKdMVNrV_0QienhpCJ98D7hj2sqOOYFhhSHBVHzvtkgWQ@mail.gmail.com/
[6] https://lore.kernel.org/oe-kbuild-all/CAOQ4uxjTv+5cB4z8TZQ02c5F3rags1HARoEQG9834A0+_+_twA@mail.gmail.com/

Best Regards,
Yujie

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

end of thread, other threads:[~2023-11-20  7:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-18 12:16 arch/arm/kernel/hibernate.c:29:40: warning: array subscript -1 is outside array bounds of 'const void[2147483647]' kernel test robot
2023-11-06 13:19 ` Linus Walleij
2023-11-20  7:14   ` Yujie Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®