linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/uaccess: Move variable into switch case statement
@ 2021-12-09  4:34 Kees Cook
  2021-12-09 19:56 ` [tip: x86/cleanups] " tip-bot2 for Kees Cook
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kees Cook @ 2021-12-09  4:34 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Kees Cook, stable, Nick Desaulniers, Ingo Molnar,
	Borislav Petkov, Dave Hansen, H. Peter Anvin, Will Deacon,
	Lukas Bulwahn, linux-kernel, x86, linux-hardening

When building with automatic stack variable initialization, GCC 12
complains about variables defined outside of switch case statements.
Move the variable into the case that uses it, which silences the warning:

./arch/x86/include/asm/uaccess.h:317:23: warning: statement will never be executed [-Wswitch-unreachable]
  317 |         unsigned char x_u8__; \
      |                       ^~~~~~

Fixes: 865c50e1d279 ("x86/uaccess: utilize CONFIG_CC_HAS_ASM_GOTO_OUTPUT")
Cc: stable@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 arch/x86/include/asm/uaccess.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index 33a68407def3..8ab9e79abb2b 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -314,11 +314,12 @@ do {									\
 do {									\
 	__chk_user_ptr(ptr);						\
 	switch (size) {							\
-	unsigned char x_u8__;						\
-	case 1:								\
+	case 1:	{							\
+		unsigned char x_u8__;					\
 		__get_user_asm(x_u8__, ptr, "b", "=q", label);		\
 		(x) = x_u8__;						\
 		break;							\
+	}								\
 	case 2:								\
 		__get_user_asm(x, ptr, "w", "=r", label);		\
 		break;							\
-- 
2.30.2


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

* [tip: x86/cleanups] x86/uaccess: Move variable into switch case statement
  2021-12-09  4:34 [PATCH] x86/uaccess: Move variable into switch case statement Kees Cook
@ 2021-12-09 19:56 ` tip-bot2 for Kees Cook
  2021-12-10 18:05 ` tip-bot2 for Kees Cook
  2021-12-10 18:18 ` tip-bot2 for Kees Cook
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Kees Cook @ 2021-12-09 19:56 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: stable, Kees Cook, Dave Hansen, x86, linux-kernel

The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID:     f529cc537b8e907c25f29eb00f50979e8e532cbc
Gitweb:        https://git.kernel.org/tip/f529cc537b8e907c25f29eb00f50979e8e532cbc
Author:        Kees Cook <keescook@chromium.org>
AuthorDate:    Wed, 08 Dec 2021 20:34:56 -08:00
Committer:     Dave Hansen <dave.hansen@linux.intel.com>
CommitterDate: Thu, 09 Dec 2021 11:48:18 -08:00

x86/uaccess: Move variable into switch case statement

When building with automatic stack variable initialization, GCC 12
complains about variables defined outside of switch case statements.
Move the variable into the case that uses it, which silences the warning:

./arch/x86/include/asm/uaccess.h:317:23: warning: statement will never be executed [-Wswitch-unreachable]
  317 |         unsigned char x_u8__; \
      |                       ^~~~~~

Cc: stable@vger.kernel.org
Fixes: 865c50e1d279 ("x86/uaccess: utilize CONFIG_CC_HAS_ASM_GOTO_OUTPUT")
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://lkml.kernel.org/r/20211209043456.1377875-1-keescook@chromium.org
---
 arch/x86/include/asm/uaccess.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index 33a6840..8ab9e79 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -314,11 +314,12 @@ do {									\
 do {									\
 	__chk_user_ptr(ptr);						\
 	switch (size) {							\
-	unsigned char x_u8__;						\
-	case 1:								\
+	case 1:	{							\
+		unsigned char x_u8__;					\
 		__get_user_asm(x_u8__, ptr, "b", "=q", label);		\
 		(x) = x_u8__;						\
 		break;							\
+	}								\
 	case 2:								\
 		__get_user_asm(x, ptr, "w", "=r", label);		\
 		break;							\

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

* [tip: x86/cleanups] x86/uaccess: Move variable into switch case statement
  2021-12-09  4:34 [PATCH] x86/uaccess: Move variable into switch case statement Kees Cook
  2021-12-09 19:56 ` [tip: x86/cleanups] " tip-bot2 for Kees Cook
@ 2021-12-10 18:05 ` tip-bot2 for Kees Cook
  2021-12-10 18:18 ` tip-bot2 for Kees Cook
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Kees Cook @ 2021-12-10 18:05 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Kees Cook, Dave Hansen, x86, linux-kernel

The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID:     7fde7c0d4b5d125b6e6cbb1b22fabed883c7331e
Gitweb:        https://git.kernel.org/tip/7fde7c0d4b5d125b6e6cbb1b22fabed883c7331e
Author:        Kees Cook <keescook@chromium.org>
AuthorDate:    Wed, 08 Dec 2021 20:34:56 -08:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Fri, 10 Dec 2021 18:04:12 +01:00

x86/uaccess: Move variable into switch case statement

When building with automatic stack variable initialization, GCC 12
complains about variables defined outside of switch case statements.
Move the variable into the case that uses it, which silences the warning:

./arch/x86/include/asm/uaccess.h:317:23: warning: statement will never be executed [-Wswitch-unreachable]
  317 |         unsigned char x_u8__; \
      |                       ^~~~~~

Fixes: 865c50e1d279 ("x86/uaccess: utilize CONFIG_CC_HAS_ASM_GOTO_OUTPUT")
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://lkml.kernel.org/r/20211209043456.1377875-1-keescook@chromium.org
---
 arch/x86/include/asm/uaccess.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index 33a6840..8ab9e79 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -314,11 +314,12 @@ do {									\
 do {									\
 	__chk_user_ptr(ptr);						\
 	switch (size) {							\
-	unsigned char x_u8__;						\
-	case 1:								\
+	case 1:	{							\
+		unsigned char x_u8__;					\
 		__get_user_asm(x_u8__, ptr, "b", "=q", label);		\
 		(x) = x_u8__;						\
 		break;							\
+	}								\
 	case 2:								\
 		__get_user_asm(x, ptr, "w", "=r", label);		\
 		break;							\

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

* [tip: x86/cleanups] x86/uaccess: Move variable into switch case statement
  2021-12-09  4:34 [PATCH] x86/uaccess: Move variable into switch case statement Kees Cook
  2021-12-09 19:56 ` [tip: x86/cleanups] " tip-bot2 for Kees Cook
  2021-12-10 18:05 ` tip-bot2 for Kees Cook
@ 2021-12-10 18:18 ` tip-bot2 for Kees Cook
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Kees Cook @ 2021-12-10 18:18 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Kees Cook, Dave Hansen, Borislav Petkov, x86, linux-kernel

The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID:     61646ca83d3889696f2772edaff122dd96a2935e
Gitweb:        https://git.kernel.org/tip/61646ca83d3889696f2772edaff122dd96a2935e
Author:        Kees Cook <keescook@chromium.org>
AuthorDate:    Wed, 08 Dec 2021 20:34:56 -08:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Fri, 10 Dec 2021 19:13:00 +01:00

x86/uaccess: Move variable into switch case statement

When building with automatic stack variable initialization, GCC 12
complains about variables defined outside of switch case statements.
Move the variable into the case that uses it, which silences the warning:

./arch/x86/include/asm/uaccess.h:317:23: warning: statement will never be executed [-Wswitch-unreachable]
  317 |         unsigned char x_u8__; \
      |                       ^~~~~~

Fixes: 865c50e1d279 ("x86/uaccess: utilize CONFIG_CC_HAS_ASM_GOTO_OUTPUT")
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20211209043456.1377875-1-keescook@chromium.org
---
 arch/x86/include/asm/uaccess.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index 33a6840..8ab9e79 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -314,11 +314,12 @@ do {									\
 do {									\
 	__chk_user_ptr(ptr);						\
 	switch (size) {							\
-	unsigned char x_u8__;						\
-	case 1:								\
+	case 1:	{							\
+		unsigned char x_u8__;					\
 		__get_user_asm(x_u8__, ptr, "b", "=q", label);		\
 		(x) = x_u8__;						\
 		break;							\
+	}								\
 	case 2:								\
 		__get_user_asm(x, ptr, "w", "=r", label);		\
 		break;							\

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

end of thread, other threads:[~2021-12-10 18:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-09  4:34 [PATCH] x86/uaccess: Move variable into switch case statement Kees Cook
2021-12-09 19:56 ` [tip: x86/cleanups] " tip-bot2 for Kees Cook
2021-12-10 18:05 ` tip-bot2 for Kees Cook
2021-12-10 18:18 ` tip-bot2 for Kees Cook

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).