lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFULd4ahxmEiJ37hLXUg3RwZMW9GnkN=38ZuirSq_cu3VHMU0g@mail.gmail.com>
Date: Tue, 2 Apr 2024 22:40:06 +0200
From: Uros Bizjak <ubizjak@...il.com>
To: Charlemagne Lasse <charlemagnelasse@...il.com>
Cc: x86@...nel.org, LKML <linux-kernel@...r.kernel.org>, 
	Luc Van Oostenryck <lucvoo@...nel.org>, Andy Lutomirski <luto@...nel.org>, Ingo Molnar <mingo@...nel.org>, 
	Brian Gerst <brgerst@...il.com>, Denys Vlasenko <dvlasenk@...hat.com>, 
	"H . Peter Anvin" <hpa@...or.com>, Linus Torvalds <torvalds@...ux-foundation.org>, 
	Peter Zijlstra <peterz@...radead.org>, Thomas Gleixner <tglx@...utronix.de>, 
	Borislav Petkov <bp@...en8.de>, Josh Poimboeuf <jpoimboe@...hat.com>
Subject: Re: warning: cast removes address space '__percpu' of expression

On Tue, Apr 2, 2024 at 10:10 PM Charlemagne Lasse
<charlemagnelasse@...il.com> wrote:
>
> Am Di., 2. Apr. 2024 um 11:53 Uhr schrieb Charlemagne Lasse
> <charlemagnelasse@...il.com>:
> >
> > Am Di., 2. Apr. 2024 um 11:43 Uhr schrieb Uros Bizjak <ubizjak@...il.com>:
> > [snip]
> > > Please try the attached patch that informs sparse about this action.
> >
> > I've tested it using
> >
> > ```
> > git reset --hard v6.9-rc2
> > patch -p1 -i ~/p.diff.txt
> > git clean -dfx
> > make allnoconfig -j$(nproc)
> > make kvm_guest.config
> > make prepare -j$(nproc)
> > touch include/linux/netdevice.h
> > make C=1 net/core/dev.o CHECK="sparse -Wcast-from-as"
> > ```
> >
> > And it seems to work. Thanks
>
> But I found another problem which seem to have been introduced by
> commit ed2f752e0e0a ("x86/percpu: Introduce const-qualified
> const_pcpu_hot to micro-optimize code generation")
>
>
> ```
> git reset --hard ed2f752e0e0a21d941ca0ee539ef3d4cd576bc5e
> git cherry-pick 3a1d3829e193c091475ceab481c5f8deab385023
> patch -p1 -i ~/p.diff.txt
> git clean -dfx
> make allnoconfig -j$(nproc)
> make kvm_guest.config
> echo CONFIG_MODULES=y >> .config
> echo CONFIG_NET_9P_VIRTIO=m >> .config
> make olddefconfig
> make prepare -j$(nproc)
> touch net/9p/trans_virtio.o
> make C=1 M=net/9p/ trans_virtio.o CHECK="sparse -Wconstexpr-not-const"
> ```
>
> This now shows the warning:
>
> ```
> net/9p/trans_virtio.c:831:1: warning: non-constant initializer for static object
> net/9p/trans_virtio.c:832:1: warning: non-constant initializer for static object
> ```
>
> Which is from
>
> ```
> module_init(p9_virtio_init);
> module_exit(p9_virtio_cleanup);
> ```
>
> The same happens when directly switching to the mentioned commit:
>
> ```
> git reset --hard ed2f752e0e0a21d941ca0ee539ef3d4cd576bc5e
> git cherry-pick 3a1d3829e193c091475ceab481c5f8deab385023
> patch -p1 -i ~/p.diff.txt
> git clean -dfx
> make allnoconfig -j$(nproc)
> make kvm_guest.config
> echo CONFIG_MODULES=y >> .config
> echo CONFIG_NET_9P_VIRTIO=m >> .config
> make olddefconfig
> make prepare -j$(nproc)
> touch net/9p/trans_virtio.o
> make C=1 M=net/9p/ trans_virtio.o CHECK="sparse -Wconstexpr-not-const"
> ```
>
>
> So something for module_init and module_exit changed with this commit.
> I can't see this when switching to a version before this commit:
>
> ```
> git reset --hard ed2f752e0e0a21d941ca0ee539ef3d4cd576bc5e~1
> git cherry-pick 3a1d3829e193c091475ceab481c5f8deab385023
> git clean -dfx
> make allnoconfig -j$(nproc)
> make kvm_guest.config
> echo CONFIG_MODULES=y >> .config
> echo CONFIG_NET_9P_VIRTIO=m >> .config
> make olddefconfig
> make prepare -j$(nproc)
> touch net/9p/trans_virtio.o
> make C=1 M=net/9p/ trans_virtio.o CHECK="sparse -Wconstexpr-not-const"
> ```

It's this part:

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index d7779a18b24fc3..bf9815eaf4aabf 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -212,7 +212,7 @@ void ftrace_likely_update(struct
ftrace_likely_data *f, int val,
*/
#define ___ADDRESSABLE(sym, __attrs) \
static void * __used __attrs \
- __UNIQUE_ID(__PASTE(__addressable_,sym)) = (void *)&sym;
+ __UNIQUE_ID(__PASTE(__addressable_,sym)) = (void *)(uintptr_t)&sym;
#define __ADDRESSABLE(sym) \
___ADDRESSABLE(sym, __section(".discard.addressable"))

But ... how is this not const?

Uros.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ