All of lore.kernel.org
 help / color / mirror / Atom feed
* + kbuild-treat-char-as-always-unsigned.patch added to mm-nonmm-unstable branch
@ 2022-10-20  0:03 Andrew Morton
  2022-10-20  9:43 ` Alexey Dobriyan
                   ` (2 more replies)
  0 siblings, 3 replies; 35+ messages in thread
From: Andrew Morton @ 2022-10-20  0:03 UTC (permalink / raw)
  To: mm-commits, torvalds, masahiroy, keescook, gregkh,
	andriy.shevchenko, Jason, akpm


The patch titled
     Subject: kbuild: treat char as always unsigned
has been added to the -mm mm-nonmm-unstable branch.  Its filename is
     kbuild-treat-char-as-always-unsigned.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/kbuild-treat-char-as-always-unsigned.patch

This patch will later appear in the mm-nonmm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Subject: kbuild: treat char as always unsigned
Date: Wed, 19 Oct 2022 14:30:34 -0600

Recently, some compile-time checking I added to the clamp_t family of
functions triggered a build error when a poorly written driver was
compiled on ARM, because the driver assumed that the naked `char` type is
signed, but ARM treats it as unsigned, and the C standard says it's
architecture-dependent.

I doubt this particular driver is the only instance in which unsuspecting
authors make assumptions about `char` with no `signed` or `unsigned`
specifier.  We were lucky enough this time that that driver used
`clamp_t(char, negative_value, positive_value)`, so the new checking code
found it, and I've sent a patch to fix it, but there are likely other
places lurking that won't be so easily unearthed.

So let's just eliminate this particular variety of heisensign bugs
entirely.  Set `-funsigned-char` globally, so that gcc makes the type
unsigned on all architectures.

This will break things in some places and fix things in others, so this
will likely cause a bit of churn while reconciling the type misuse.

Link: https://lkml.kernel.org/r/20221019203034.3795710-1-Jason@zx2c4.com
Link: https://lore.kernel.org/lkml/202210190108.ESC3pc3D-lkp@intel.com/
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 Makefile |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/Makefile~kbuild-treat-char-as-always-unsigned
+++ a/Makefile
@@ -562,7 +562,7 @@ KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-P
 KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
 		   -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
 		   -Werror=implicit-function-declaration -Werror=implicit-int \
-		   -Werror=return-type -Wno-format-security \
+		   -Werror=return-type -Wno-format-security -funsigned-char \
 		   -std=gnu11
 KBUILD_CPPFLAGS := -D__KERNEL__
 KBUILD_RUSTFLAGS := $(rust_common_flags) \
_

Patches currently in -mm which might be from Jason@zx2c4.com are

wifi-rt2x00-use-explicitly-signed-type-for-clamping.patch
minmax-sanity-check-constant-bounds-when-clamping.patch
minmax-clamp-more-efficiently-by-avoiding-extra-comparison.patch
kbuild-treat-char-as-always-unsigned.patch


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

end of thread, other threads:[~2022-11-03 14:07 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-20  0:03 + kbuild-treat-char-as-always-unsigned.patch added to mm-nonmm-unstable branch Andrew Morton
2022-10-20  9:43 ` Alexey Dobriyan
2022-10-20  9:49 ` [PATCH -mm] -funsigned-char, x86: make struct p4_event_bind::cntr signed array Alexey Dobriyan
2022-10-20  9:56   ` [PATCH -mm] -funsigned-char, namei: delete cast in lookup_one_common() Alexey Dobriyan
2022-10-20 16:28   ` [PATCH -mm] -funsigned-char, x86: make struct p4_event_bind::cntr signed array Jason A. Donenfeld
2022-10-20 17:14     ` Linus Torvalds
2022-10-20 17:33       ` Jason A. Donenfeld
2022-10-20 17:42         ` Linus Torvalds
2022-10-20 18:57           ` Kees Cook
2022-10-20 19:39             ` Linus Torvalds
2022-10-20 20:17               ` Linus Torvalds
2022-10-20 21:34                 ` Andy Shevchenko
2022-10-20 22:46                   ` Jason A. Donenfeld
2022-10-21  6:48                 ` Greg KH
2022-10-21  7:24                   ` Jason A. Donenfeld
2022-10-21  7:36                     ` Greg KH
2022-10-26  1:50             ` Jason A. Donenfeld
2022-10-26 12:58               ` Jason A. Donenfeld
2022-10-26 12:58                 ` [cocci] " Jason A. Donenfeld
2022-10-26 13:17                 ` Andy Shevchenko
2022-10-26 13:17                   ` [cocci] " Andy Shevchenko
2022-11-02 17:17                 ` Julia Lawall
2022-11-03  0:08                   ` Jason A. Donenfeld
2022-11-03  6:31                     ` Julia Lawall
2022-11-03 12:45                     ` Julia Lawall
2022-11-03 12:47                       ` Jason A. Donenfeld
2022-11-03 12:57                         ` Julia Lawall
2022-11-03 14:07                           ` Jason A. Donenfeld
2022-10-24 15:44         ` Jason A. Donenfeld
2022-10-21  5:59       ` Alexey Dobriyan
2022-10-21 17:11         ` Linus Torvalds
2022-10-21 17:23           ` Linus Torvalds
2022-10-20 16:24 ` + kbuild-treat-char-as-always-unsigned.patch added to mm-nonmm-unstable branch Jason A. Donenfeld
2022-10-20 21:12   ` Andrew Morton
2022-10-20 21:13     ` Jason A. Donenfeld

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.