* [masahiroy-kbuild:kbuild 5/7] kernel/kallsyms.c:181:56: warning: array subscript is outside array bounds
@ 2024-04-23 3:49 kernel test robot
2024-04-23 6:57 ` Ard Biesheuvel
0 siblings, 1 reply; 4+ messages in thread
From: kernel test robot @ 2024-04-23 3:49 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: oe-kbuild-all, linux-kbuild, Masahiro Yamada
tree: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kbuild
head: 8246a1e9b922c0e797ec28d8a602de1384ff8140
commit: 0bdad28369fc5e93de39b5046228ed78e982fc71 [5/7] kallsyms: Avoid weak references for kallsyms symbols
config: i386-randconfig-001-20240423 (https://download.01.org/0day-ci/archive/20240423/202404231102.r0G0StUJ-lkp@intel.com/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240423/202404231102.r0G0StUJ-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/202404231102.r0G0StUJ-lkp@intel.com/
Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
All warnings (new ones prefixed by >>):
kernel/kallsyms.c: In function 'get_symbol_pos':
>> kernel/kallsyms.c:181:56: warning: array subscript is outside array bounds [-Warray-bounds]
return kallsyms_relative_base + (u32)kallsyms_offsets[idx];
~~~~~~~~~~~~~~~~^~~~~
vim +181 kernel/kallsyms.c
^1da177e4c3f41 Linus Torvalds 2005-04-16 173
30f3bb09778de6 Zhen Lei 2022-11-15 174 unsigned long kallsyms_sym_address(int idx)
2213e9a66bb87d Ard Biesheuvel 2016-03-15 175 {
2213e9a66bb87d Ard Biesheuvel 2016-03-15 176 if (!IS_ENABLED(CONFIG_KALLSYMS_BASE_RELATIVE))
2213e9a66bb87d Ard Biesheuvel 2016-03-15 177 return kallsyms_addresses[idx];
2213e9a66bb87d Ard Biesheuvel 2016-03-15 178
2213e9a66bb87d Ard Biesheuvel 2016-03-15 179 /* values are unsigned offsets if --absolute-percpu is not in effect */
2213e9a66bb87d Ard Biesheuvel 2016-03-15 180 if (!IS_ENABLED(CONFIG_KALLSYMS_ABSOLUTE_PERCPU))
2213e9a66bb87d Ard Biesheuvel 2016-03-15 @181 return kallsyms_relative_base + (u32)kallsyms_offsets[idx];
2213e9a66bb87d Ard Biesheuvel 2016-03-15 182
2213e9a66bb87d Ard Biesheuvel 2016-03-15 183 /* ...otherwise, positive offsets are absolute values */
2213e9a66bb87d Ard Biesheuvel 2016-03-15 184 if (kallsyms_offsets[idx] >= 0)
2213e9a66bb87d Ard Biesheuvel 2016-03-15 185 return kallsyms_offsets[idx];
2213e9a66bb87d Ard Biesheuvel 2016-03-15 186
2213e9a66bb87d Ard Biesheuvel 2016-03-15 187 /* ...and negative offsets are relative to kallsyms_relative_base - 1 */
2213e9a66bb87d Ard Biesheuvel 2016-03-15 188 return kallsyms_relative_base - 1 - kallsyms_offsets[idx];
2213e9a66bb87d Ard Biesheuvel 2016-03-15 189 }
2213e9a66bb87d Ard Biesheuvel 2016-03-15 190
:::::: The code at line 181 was first introduced by commit
:::::: 2213e9a66bb87d8344a1256b4ef568220d9587fb kallsyms: add support for relative offsets in kallsyms address table
:::::: TO: Ard Biesheuvel <ard.biesheuvel@linaro.org>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [masahiroy-kbuild:kbuild 5/7] kernel/kallsyms.c:181:56: warning: array subscript is outside array bounds
2024-04-23 3:49 [masahiroy-kbuild:kbuild 5/7] kernel/kallsyms.c:181:56: warning: array subscript is outside array bounds kernel test robot
@ 2024-04-23 6:57 ` Ard Biesheuvel
2024-04-23 10:14 ` Masahiro Yamada
2024-04-23 12:22 ` Alexander Stein
0 siblings, 2 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2024-04-23 6:57 UTC (permalink / raw)
To: kernel test robot, Masahiro Yamada; +Cc: oe-kbuild-all, linux-kbuild
On Tue, 23 Apr 2024 at 05:50, kernel test robot <lkp@intel.com> wrote:
>
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kbuild
> head: 8246a1e9b922c0e797ec28d8a602de1384ff8140
> commit: 0bdad28369fc5e93de39b5046228ed78e982fc71 [5/7] kallsyms: Avoid weak references for kallsyms symbols
> config: i386-randconfig-001-20240423 (https://download.01.org/0day-ci/archive/20240423/202404231102.r0G0StUJ-lkp@intel.com/config)
> compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240423/202404231102.r0G0StUJ-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/202404231102.r0G0StUJ-lkp@intel.com/
>
> Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
>
> All warnings (new ones prefixed by >>):
>
> kernel/kallsyms.c: In function 'get_symbol_pos':
> >> kernel/kallsyms.c:181:56: warning: array subscript is outside array bounds [-Warray-bounds]
> return kallsyms_relative_base + (u32)kallsyms_offsets[idx];
>
OK, so weak definitions result in compiler warnings. I don't know
whether C requires weak definitions of array types are always the same
size.
We could work around this by
a) emitting the weak definitions into a separate object file, although
this may still violate C, and does not hide the issue from LTO
b) go back to using PROVIDE() in the linker scripts
@Masahiro: any preference?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [masahiroy-kbuild:kbuild 5/7] kernel/kallsyms.c:181:56: warning: array subscript is outside array bounds
2024-04-23 6:57 ` Ard Biesheuvel
@ 2024-04-23 10:14 ` Masahiro Yamada
2024-04-23 12:22 ` Alexander Stein
1 sibling, 0 replies; 4+ messages in thread
From: Masahiro Yamada @ 2024-04-23 10:14 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: kernel test robot, oe-kbuild-all, linux-kbuild
On Tue, Apr 23, 2024 at 3:57 PM Ard Biesheuvel <ardb@kernel.org> wrote:
>
> On Tue, 23 Apr 2024 at 05:50, kernel test robot <lkp@intel.com> wrote:
> >
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kbuild
> > head: 8246a1e9b922c0e797ec28d8a602de1384ff8140
> > commit: 0bdad28369fc5e93de39b5046228ed78e982fc71 [5/7] kallsyms: Avoid weak references for kallsyms symbols
> > config: i386-randconfig-001-20240423 (https://download.01.org/0day-ci/archive/20240423/202404231102.r0G0StUJ-lkp@intel.com/config)
> > compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240423/202404231102.r0G0StUJ-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/202404231102.r0G0StUJ-lkp@intel.com/
> >
> > Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
> >
> > All warnings (new ones prefixed by >>):
> >
> > kernel/kallsyms.c: In function 'get_symbol_pos':
> > >> kernel/kallsyms.c:181:56: warning: array subscript is outside array bounds [-Warray-bounds]
> > return kallsyms_relative_base + (u32)kallsyms_offsets[idx];
> >
>
> OK, so weak definitions result in compiler warnings. I don't know
> whether C requires weak definitions of array types are always the same
> size.
>
> We could work around this by
> a) emitting the weak definitions into a separate object file, although
> this may still violate C, and does not hide the issue from LTO
> b) go back to using PROVIDE() in the linker scripts
>
> @Masahiro: any preference?
Then, I am fine with b (i.e. v4) for now.
Maybe, I may want to kill PROVIDE() when I have time.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [masahiroy-kbuild:kbuild 5/7] kernel/kallsyms.c:181:56: warning: array subscript is outside array bounds
2024-04-23 6:57 ` Ard Biesheuvel
2024-04-23 10:14 ` Masahiro Yamada
@ 2024-04-23 12:22 ` Alexander Stein
1 sibling, 0 replies; 4+ messages in thread
From: Alexander Stein @ 2024-04-23 12:22 UTC (permalink / raw)
To: kernel test robot, Masahiro Yamada, Ard Biesheuvel
Cc: oe-kbuild-all, linux-kbuild
Hi,
Am Dienstag, 23. April 2024, 08:57:16 CEST schrieb Ard Biesheuvel:
> On Tue, 23 Apr 2024 at 05:50, kernel test robot <lkp@intel.com> wrote:
> >
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kbuild
> > head: 8246a1e9b922c0e797ec28d8a602de1384ff8140
> > commit: 0bdad28369fc5e93de39b5046228ed78e982fc71 [5/7] kallsyms: Avoid weak references for kallsyms symbols
> > config: i386-randconfig-001-20240423 (https://download.01.org/0day-ci/archive/20240423/202404231102.r0G0StUJ-lkp@intel.com/config)
> > compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240423/202404231102.r0G0StUJ-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/202404231102.r0G0StUJ-lkp@intel.com/
> >
> > Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
> >
> > All warnings (new ones prefixed by >>):
> >
> > kernel/kallsyms.c: In function 'get_symbol_pos':
> > >> kernel/kallsyms.c:181:56: warning: array subscript is outside array bounds [-Warray-bounds]
> > return kallsyms_relative_base + (u32)kallsyms_offsets[idx];
> >
>
> OK, so weak definitions result in compiler warnings. I don't know
> whether C requires weak definitions of array types are always the same
> size.
It's not just compiler warnings. UBSAN is also triggered by this commit.
> UBSAN: array-index-out-of-bounds in ../kernel/kallsyms.c:181:56
> index 64143 is out of range for type 'int [1]'
> CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.9.0-rc5-next-20240423+ #2422 cee92685fac34b7fb981de78571f7250231badab
[1] might also be affected by this as CONFIG_UBSAN_BOUNDS=y is set.
Best regards,
Alexander
[1] https://lore.kernel.org/linux-kbuild/691143b5-4636-4911-9c93-437b95f46157@amd.com/T/#m3e5e9112bac8a56b8a7dfa6a19cbc03dcb43a480
> We could work around this by
> a) emitting the weak definitions into a separate object file, although
> this may still violate C, and does not hide the issue from LTO
> b) go back to using PROVIDE() in the linker scripts
>
> @Masahiro: any preference?
>
>
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-23 12:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-23 3:49 [masahiroy-kbuild:kbuild 5/7] kernel/kallsyms.c:181:56: warning: array subscript is outside array bounds kernel test robot
2024-04-23 6:57 ` Ard Biesheuvel
2024-04-23 10:14 ` Masahiro Yamada
2024-04-23 12:22 ` Alexander Stein
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).