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: <878r1bb2zj.fsf@mail.lhotse>
Date: Thu, 18 Apr 2024 16:26:40 +1000
From: Michael Ellerman <mpe@...erman.id.au>
To: Arnd Bergmann <arnd@...nel.org>
Cc: Arnd Bergmann <arnd@...db.de>, Naresh Kamboju
 <naresh.kamboju@...aro.org>, linux-kernel@...r.kernel.org, linuxppc-dev
 <linuxppc-dev@...ts.ozlabs.org>, "Aneesh Kumar K . V"
 <aneesh.kumar@...nel.org>, Anders Roxell <anders.roxell@...aro.org>, Kees
 Cook <keescook@...omium.org>, Niklas Schnelle <schnelle@...ux.ibm.com>,
 clang-built-linux <llvm@...ts.linux.dev>, Nick Desaulniers
 <ndesaulniers@...gle.com>, Nathan Chancellor <nathan@...nel.org>, Jeff Xu
 <jeffxu@...omium.org>, "Naveen N . Rao" <naveen.n.rao@...ux.ibm.com>, Dan
 Carpenter <dan.carpenter@...aro.org>, Nicholas Piggin <npiggin@...il.com>,
 Christophe Leroy <christophe.leroy@...roup.eu>, Bill Wendling
 <morbo@...gle.com>, Justin Stitt <justinstitt@...gle.com>, Baoquan He
 <bhe@...hat.com>, "Mike Rapoport (IBM)" <rppt@...nel.org>
Subject: Re: [PATCH] powerpc: drop port I/O helpers for CONFIG_HAS_IOPORT=n

Arnd Bergmann <arnd@...nel.org> writes:
> From: Arnd Bergmann <arnd@...db.de>
>
> Calling inb()/outb() on powerpc when CONFIG_PCI is disabled causes
> a NULL pointer dereference, which is bad for a number of reasons.
>
> After my patch to turn on -Werror in linux-next, this caused a
> compiler-time warning with clang:
>
> In file included from arch/powerpc/include/asm/io.h:672:
> arch/powerpc/include/asm/io-defs.h:43:1: error: performing pointer
> arithmetic on a null pointer has undefined behavior
> [-Werror,-Wnull-pointer-arithmetic]
>    43 | DEF_PCI_AC_NORET(insb, (unsigned long p, void *b, unsigned long c),
>       | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    44 |                  (p, b, c), pio, p)
>       |                  ~~~~~~~~~~~~~~~~~~
>
> In this configuration, CONFIG_HAS_IOPORT is already disabled, and all
> drivers that use inb()/outb() should now depend on that (some patches are
> still in the process of getting marged).
>
> Hide all references to inb()/outb() in the powerpc code and the definitions
> when HAS_IOPORT is disabled to remove the possible NULL pointer access.
> The same should happin in asm-generic in the near future, but for now
> the empty inb() macros are still defined to ensure the generic version
> does not get pulled in.
>
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
> Reported-by: Naresh Kamboju <naresh.kamboju@...aro.org>
> --

This needs a small fixup:

diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index 86c212fcbc0c..60c80d0baf40 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -692,6 +692,7 @@ static inline void name at                                  \
 #define writesw writesw
 #define writesl writesl

+#ifdef CONFIG_HAS_IOPORT
 #define inb inb
 #define inw inw
 #define inl inl
@@ -704,6 +705,8 @@ static inline void name at                                  \
 #define outsb outsb
 #define outsw outsw
 #define outsl outsl
+#endif // CONFIG_HAS_IOPORT
+
 #ifdef __powerpc64__
 #define readq  readq
 #define writeq writeq


I'm running it through some randconfig builds now.

cheers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ