* [PATCH] Makefile: Globally enable fall-through warning
@ 2022-05-17 17:35 ALOK JHA
2022-05-17 18:42 ` Andrew Morton
2022-05-17 18:46 ` Andrew Morton
0 siblings, 2 replies; 19+ messages in thread
From: ALOK JHA @ 2022-05-17 17:35 UTC (permalink / raw)
To: alok08jha
Cc: Gustavo A. R. Silva, Masahiro Yamada, Andrew Morton, Michal Marek,
Kees Cook, linux-kbuild
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Now that all the fall-through warnings have been addressed in the
kernel, enable the fall-through warning globally.
Also, update the deprecated.rst file to include implicit fall-through
as 'deprecated' so people can be pointed to a single location for
justification.
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: Kees Cook <keescook@chromium.org>
Cc: linux-kbuild@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
Documentation/process/deprecated.rst | 14 ++++++++++++++
Makefile | 3 +++
2 files changed, 17 insertions(+)
diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst
index 49e0f64a3427..053b24a6dd38 100644
--- a/Documentation/process/deprecated.rst
+++ b/Documentation/process/deprecated.rst
@@ -119,3 +119,17 @@ array may exceed the remaining memory in the stack segment. This could
lead to a crash, possible overwriting sensitive contents at the end of the
stack (when built without `CONFIG_THREAD_INFO_IN_TASK=y`), or overwriting
memory adjacent to the stack (when built without `CONFIG_VMAP_STACK=y`)
+
+Implicit switch case fall-through
+---------------------------------
+The C language allows switch cases to "fall through" when
+a "break" statement is missing at the end of a case. This,
+however, introduces ambiguity in the code, as it's not always
+clear if the missing break is intentional or a bug. As there
+have been a long list of flaws `due to missing "break" statements
+<https://cwe.mitre.org/data/definitions/484.html>`_, we no longer allow
+"implicit fall-through". In order to identify an intentional fall-through
+case, we have adopted the marking used by static analyzers: a comment
+saying `/* Fall through */`. Once the C++17 `__attribute__((fallthrough))`
+is more widely handled by C compilers, static analyzers, and IDEs, we can
+switch to using that instead.
diff --git a/Makefile b/Makefile
index 9be5834073f8..bdf8eac51b07 100644
--- a/Makefile
+++ b/Makefile
@@ -843,6 +843,9 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
# warn about C99 declaration after statement
KBUILD_CFLAGS += -Wdeclaration-after-statement
+# Warn about unmarked fall-throughs in switch statement.
+KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough=3,)
+
# Variable Length Arrays (VLAs) should not be used anywhere in the kernel
KBUILD_CFLAGS += -Wvla
--
2.34.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH] Makefile: Globally enable fall-through warning
2022-05-17 17:35 ALOK JHA
@ 2022-05-17 18:42 ` Andrew Morton
2022-05-17 18:46 ` Andrew Morton
1 sibling, 0 replies; 19+ messages in thread
From: Andrew Morton @ 2022-05-17 18:42 UTC (permalink / raw)
To: ALOK JHA
Cc: Gustavo A. R. Silva, Masahiro Yamada, Michal Marek, Kees Cook,
linux-kbuild
On Tue, 17 May 2022 23:05:34 +0530 ALOK JHA <alok08jha@gmail.com> wrote:
> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
>
> Now that all the fall-through warnings have been addressed in the
> kernel, enable the fall-through warning globally.
>
> Also, update the deprecated.rst file to include implicit fall-through
> as 'deprecated' so people can be pointed to a single location for
> justification.
>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Michal Marek <michal.lkml@markovi.net>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: linux-kbuild@vger.kernel.org
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Since you sent the patch, it should have your signoff as well as
Gustavo's. Please resend?
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] Makefile: Globally enable fall-through warning
2022-05-17 17:35 ALOK JHA
2022-05-17 18:42 ` Andrew Morton
@ 2022-05-17 18:46 ` Andrew Morton
2022-05-17 19:40 ` Jeff Johnson
2022-05-17 19:59 ` Gustavo A. R. Silva
1 sibling, 2 replies; 19+ messages in thread
From: Andrew Morton @ 2022-05-17 18:46 UTC (permalink / raw)
To: ALOK JHA
Cc: Gustavo A. R. Silva, Masahiro Yamada, Michal Marek, Kees Cook,
linux-kbuild
On Tue, 17 May 2022 23:05:34 +0530 ALOK JHA <alok08jha@gmail.com> wrote:
> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
>
> Now that all the fall-through warnings have been addressed in the
> kernel, enable the fall-through warning globally.
>
> Also, update the deprecated.rst file to include implicit fall-through
> as 'deprecated' so people can be pointed to a single location for
> justification.
>
> ...
>
> --- a/Documentation/process/deprecated.rst
> +++ b/Documentation/process/deprecated.rst
> @@ -119,3 +119,17 @@ array may exceed the remaining memory in the stack segment. This could
> lead to a crash, possible overwriting sensitive contents at the end of the
> stack (when built without `CONFIG_THREAD_INFO_IN_TASK=y`), or overwriting
> memory adjacent to the stack (when built without `CONFIG_VMAP_STACK=y`)
> +
> +Implicit switch case fall-through
> +---------------------------------
>
> ...
>
Documentation/process/deprecated.rst already has a section "Implicit
switch case fall-through". Maybe you're working against an old kernel.
Please update when resending.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] Makefile: Globally enable fall-through warning
2022-05-17 18:46 ` Andrew Morton
@ 2022-05-17 19:40 ` Jeff Johnson
2022-05-17 19:59 ` Gustavo A. R. Silva
1 sibling, 0 replies; 19+ messages in thread
From: Jeff Johnson @ 2022-05-17 19:40 UTC (permalink / raw)
To: Andrew Morton, ALOK JHA
Cc: Gustavo A. R. Silva, Masahiro Yamada, Michal Marek, Kees Cook,
linux-kbuild
On 5/17/2022 11:46 AM, Andrew Morton wrote:
> On Tue, 17 May 2022 23:05:34 +0530 ALOK JHA <alok08jha@gmail.com> wrote:
>
>> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
>>
>> Now that all the fall-through warnings have been addressed in the
>> kernel, enable the fall-through warning globally.
>>
>> Also, update the deprecated.rst file to include implicit fall-through
>> as 'deprecated' so people can be pointed to a single location for
>> justification.
>>
>> ...
>>
>> --- a/Documentation/process/deprecated.rst
>> +++ b/Documentation/process/deprecated.rst
>> @@ -119,3 +119,17 @@ array may exceed the remaining memory in the stack segment. This could
>> lead to a crash, possible overwriting sensitive contents at the end of the
>> stack (when built without `CONFIG_THREAD_INFO_IN_TASK=y`), or overwriting
>> memory adjacent to the stack (when built without `CONFIG_VMAP_STACK=y`)
>> +
>> +Implicit switch case fall-through
>> +---------------------------------
>>
>> ...
>>
>
> Documentation/process/deprecated.rst already has a section "Implicit
> switch case fall-through". Maybe you're working against an old kernel.
> Please update when resending.
>
shouldn't we now just be referencing the fallthrough() macro?
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] Makefile: Globally enable fall-through warning
2022-05-17 18:46 ` Andrew Morton
2022-05-17 19:40 ` Jeff Johnson
@ 2022-05-17 19:59 ` Gustavo A. R. Silva
1 sibling, 0 replies; 19+ messages in thread
From: Gustavo A. R. Silva @ 2022-05-17 19:59 UTC (permalink / raw)
To: Andrew Morton
Cc: ALOK JHA, Gustavo A. R. Silva, Masahiro Yamada, Michal Marek,
Kees Cook, linux-kbuild
On Tue, May 17, 2022 at 11:46:01AM -0700, Andrew Morton wrote:
> On Tue, 17 May 2022 23:05:34 +0530 ALOK JHA <alok08jha@gmail.com> wrote:
>
> > From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> >
> > Now that all the fall-through warnings have been addressed in the
> > kernel, enable the fall-through warning globally.
> >
> > Also, update the deprecated.rst file to include implicit fall-through
> > as 'deprecated' so people can be pointed to a single location for
> > justification.
> >
> > ...
> >
> > --- a/Documentation/process/deprecated.rst
> > +++ b/Documentation/process/deprecated.rst
> > @@ -119,3 +119,17 @@ array may exceed the remaining memory in the stack segment. This could
> > lead to a crash, possible overwriting sensitive contents at the end of the
> > stack (when built without `CONFIG_THREAD_INFO_IN_TASK=y`), or overwriting
> > memory adjacent to the stack (when built without `CONFIG_VMAP_STACK=y`)
> > +
> > +Implicit switch case fall-through
> > +---------------------------------
> >
> > ...
> >
>
> Documentation/process/deprecated.rst already has a section "Implicit
> switch case fall-through". Maybe you're working against an old kernel.
> Please update when resending.
This looks like spam to me.
Let's just ignore this.
--
Gustavo
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH] Makefile: Globally enable fall-through warning
@ 2025-05-05 17:14 Omar el Azouny
2025-05-05 17:53 ` Miguel Ojeda
0 siblings, 1 reply; 19+ messages in thread
From: Omar el Azouny @ 2025-05-05 17:14 UTC (permalink / raw)
To: omarlazouny
Cc: Gustavo A. R. Silva, Masahiro Yamada, Andrew Morton, Michal Marek,
Kees Cook, linux-kbuild
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Now that all the fall-through warnings have been addressed in the
kernel, enable the fall-through warning globally.
Also, update the deprecated.rst file to include implicit fall-through
as 'deprecated' so people can be pointed to a single location for
justification.
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: Kees Cook <keescook@chromium.org>
Cc: linux-kbuild@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
Documentation/process/deprecated.rst | 14 ++++++++++++++
Makefile | 3 +++
2 files changed, 17 insertions(+)
diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst
index 49e0f64a3427..053b24a6dd38 100644
--- a/Documentation/process/deprecated.rst
+++ b/Documentation/process/deprecated.rst
@@ -119,3 +119,17 @@ array may exceed the remaining memory in the stack segment. This could
lead to a crash, possible overwriting sensitive contents at the end of the
stack (when built without `CONFIG_THREAD_INFO_IN_TASK=y`), or overwriting
memory adjacent to the stack (when built without `CONFIG_VMAP_STACK=y`)
+
+Implicit switch case fall-through
+---------------------------------
+The C language allows switch cases to "fall through" when
+a "break" statement is missing at the end of a case. This,
+however, introduces ambiguity in the code, as it's not always
+clear if the missing break is intentional or a bug. As there
+have been a long list of flaws `due to missing "break" statements
+<https://cwe.mitre.org/data/definitions/484.html>`_, we no longer allow
+"implicit fall-through". In order to identify an intentional fall-through
+case, we have adopted the marking used by static analyzers: a comment
+saying `/* Fall through */`. Once the C++17 `__attribute__((fallthrough))`
+is more widely handled by C compilers, static analyzers, and IDEs, we can
+switch to using that instead.
diff --git a/Makefile b/Makefile
index 9be5834073f8..bdf8eac51b07 100644
--- a/Makefile
+++ b/Makefile
@@ -843,6 +843,9 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
# warn about C99 declaration after statement
KBUILD_CFLAGS += -Wdeclaration-after-statement
+# Warn about unmarked fall-throughs in switch statement.
+KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough=3,)
+
# Variable Length Arrays (VLAs) should not be used anywhere in the kernel
KBUILD_CFLAGS += -Wvla
--
2.43.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH] Makefile: Globally enable fall-through warning
2025-05-05 17:14 Omar el Azouny
@ 2025-05-05 17:53 ` Miguel Ojeda
0 siblings, 0 replies; 19+ messages in thread
From: Miguel Ojeda @ 2025-05-05 17:53 UTC (permalink / raw)
To: Omar el Azouny
Cc: Gustavo A. R. Silva, Masahiro Yamada, Andrew Morton, Michal Marek,
Kees Cook, linux-kbuild
On Mon, May 5, 2025 at 7:17 PM Omar el Azouny <omarlazouny@gmail.com> wrote:
>
> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
>
> Now that all the fall-through warnings have been addressed in the
> kernel, enable the fall-through warning globally.
>
> Also, update the deprecated.rst file to include implicit fall-through
> as 'deprecated' so people can be pointed to a single location for
> justification.
>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Michal Marek <michal.lkml@markovi.net>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: linux-kbuild@vger.kernel.org
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
I am confused -- hasn't this patch been in mainline since 2019?
a035d552a93b ("Makefile: Globally enable fall-through warning")
Even if that were not the case, you would need to provide your SoB
etc. Please see:
https://docs.kernel.org/process/submitting-patches.html
Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH] Makefile: Globally enable fall-through warning
@ 2026-01-10 1:34 MIshraMohit21-LE
2026-01-10 3:12 ` Gustavo A. R. Silva
0 siblings, 1 reply; 19+ messages in thread
From: MIshraMohit21-LE @ 2026-01-10 1:34 UTC (permalink / raw)
To: mohit.mishra
Cc: Gustavo A. R. Silva, Masahiro Yamada, Andrew Morton, Michal Marek,
Kees Cook, linux-kbuild
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Now that all the fall-through warnings have been addressed in the
kernel, enable the fall-through warning globally.
Also, update the deprecated.rst file to include implicit fall-through
as 'deprecated' so people can be pointed to a single location for
justification.
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: Kees Cook <keescook@chromium.org>
Cc: linux-kbuild@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
Documentation/process/deprecated.rst | 14 ++++++++++++++
Makefile | 3 +++
2 files changed, 17 insertions(+)
diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst
index 49e0f64a3427..053b24a6dd38 100644
--- a/Documentation/process/deprecated.rst
+++ b/Documentation/process/deprecated.rst
@@ -119,3 +119,17 @@ array may exceed the remaining memory in the stack segment. This could
lead to a crash, possible overwriting sensitive contents at the end of the
stack (when built without `CONFIG_THREAD_INFO_IN_TASK=y`), or overwriting
memory adjacent to the stack (when built without `CONFIG_VMAP_STACK=y`)
+
+Implicit switch case fall-through
+---------------------------------
+The C language allows switch cases to "fall through" when
+a "break" statement is missing at the end of a case. This,
+however, introduces ambiguity in the code, as it's not always
+clear if the missing break is intentional or a bug. As there
+have been a long list of flaws `due to missing "break" statements
+<https://cwe.mitre.org/data/definitions/484.html>`_, we no longer allow
+"implicit fall-through". In order to identify an intentional fall-through
+case, we have adopted the marking used by static analyzers: a comment
+saying `/* Fall through */`. Once the C++17 `__attribute__((fallthrough))`
+is more widely handled by C compilers, static analyzers, and IDEs, we can
+switch to using that instead.
diff --git a/Makefile b/Makefile
index 9be5834073f8..bdf8eac51b07 100644
--- a/Makefile
+++ b/Makefile
@@ -843,6 +843,9 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
# warn about C99 declaration after statement
KBUILD_CFLAGS += -Wdeclaration-after-statement
+# Warn about unmarked fall-throughs in switch statement.
+KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough=3,)
+
# Variable Length Arrays (VLAs) should not be used anywhere in the kernel
KBUILD_CFLAGS += -Wvla
--
2.43.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH] Makefile: Globally enable fall-through warning
2026-01-10 1:34 MIshraMohit21-LE
@ 2026-01-10 3:12 ` Gustavo A. R. Silva
[not found] ` <CAP5HdgoFya1NfeJH0wT7KtzqaFmupn5C-kSwXNEtEdbq5bQSEw@mail.gmail.com>
0 siblings, 1 reply; 19+ messages in thread
From: Gustavo A. R. Silva @ 2026-01-10 3:12 UTC (permalink / raw)
To: MIshraMohit21-LE, mohit.mishra
Cc: Masahiro Yamada, Andrew Morton, Michal Marek, Kees Cook,
linux-kbuild
Are you intentionally spamming us?
-Gustavo
On 1/10/26 10:34, MIshraMohit21-LE wrote:
> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
>
> Now that all the fall-through warnings have been addressed in the
> kernel, enable the fall-through warning globally.
>
> Also, update the deprecated.rst file to include implicit fall-through
> as 'deprecated' so people can be pointed to a single location for
> justification.
>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Michal Marek <michal.lkml@markovi.net>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: linux-kbuild@vger.kernel.org
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> Documentation/process/deprecated.rst | 14 ++++++++++++++
> Makefile | 3 +++
> 2 files changed, 17 insertions(+)
>
> diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst
> index 49e0f64a3427..053b24a6dd38 100644
> --- a/Documentation/process/deprecated.rst
> +++ b/Documentation/process/deprecated.rst
> @@ -119,3 +119,17 @@ array may exceed the remaining memory in the stack segment. This could
> lead to a crash, possible overwriting sensitive contents at the end of the
> stack (when built without `CONFIG_THREAD_INFO_IN_TASK=y`), or overwriting
> memory adjacent to the stack (when built without `CONFIG_VMAP_STACK=y`)
> +
> +Implicit switch case fall-through
> +---------------------------------
> +The C language allows switch cases to "fall through" when
> +a "break" statement is missing at the end of a case. This,
> +however, introduces ambiguity in the code, as it's not always
> +clear if the missing break is intentional or a bug. As there
> +have been a long list of flaws `due to missing "break" statements
> +<https://cwe.mitre.org/data/definitions/484.html>`_, we no longer allow
> +"implicit fall-through". In order to identify an intentional fall-through
> +case, we have adopted the marking used by static analyzers: a comment
> +saying `/* Fall through */`. Once the C++17 `__attribute__((fallthrough))`
> +is more widely handled by C compilers, static analyzers, and IDEs, we can
> +switch to using that instead.
> diff --git a/Makefile b/Makefile
> index 9be5834073f8..bdf8eac51b07 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -843,6 +843,9 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
> # warn about C99 declaration after statement
> KBUILD_CFLAGS += -Wdeclaration-after-statement
>
> +# Warn about unmarked fall-throughs in switch statement.
> +KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough=3,)
> +
> # Variable Length Arrays (VLAs) should not be used anywhere in the kernel
> KBUILD_CFLAGS += -Wvla
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] Makefile: Globally enable fall-through warning
[not found] ` <CAP5HdgoFya1NfeJH0wT7KtzqaFmupn5C-kSwXNEtEdbq5bQSEw@mail.gmail.com>
@ 2026-01-10 4:04 ` Gustavo A. R. Silva
0 siblings, 0 replies; 19+ messages in thread
From: Gustavo A. R. Silva @ 2026-01-10 4:04 UTC (permalink / raw)
To: Mohit Mishra
Cc: mohit.mishra, Masahiro Yamada, Andrew Morton, Michal Marek,
Kees Cook, linux-kbuild
On 1/10/26 12:55, Mohit Mishra wrote:
> Please accept my apologies for the unintended email. It was sent
> accidentally due to a configuration error while setting up git-send-email
> for a Linux fundamentals course.
Okay, best of luck with the course!
-Gustavo
>
> I am sorry for any inconvenience this caused.
>
> On Sat, Jan 10, 2026 at 8:43 AM Gustavo A. R. Silva <gustavo@embeddedor.com>
> wrote:
>
>> Are you intentionally spamming us?
>>
>> -Gustavo
>>
>> On 1/10/26 10:34, MIshraMohit21-LE wrote:
>>> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
>>>
>>> Now that all the fall-through warnings have been addressed in the
>>> kernel, enable the fall-through warning globally.
>>>
>>> Also, update the deprecated.rst file to include implicit fall-through
>>> as 'deprecated' so people can be pointed to a single location for
>>> justification.
>>>
>>> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>> Cc: Michal Marek <michal.lkml@markovi.net>
>>> Cc: Kees Cook <keescook@chromium.org>
>>> Cc: linux-kbuild@vger.kernel.org
>>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>>> ---
>>> Documentation/process/deprecated.rst | 14 ++++++++++++++
>>> Makefile | 3 +++
>>> 2 files changed, 17 insertions(+)
>>>
>>> diff --git a/Documentation/process/deprecated.rst
>> b/Documentation/process/deprecated.rst
>>> index 49e0f64a3427..053b24a6dd38 100644
>>> --- a/Documentation/process/deprecated.rst
>>> +++ b/Documentation/process/deprecated.rst
>>> @@ -119,3 +119,17 @@ array may exceed the remaining memory in the stack
>> segment. This could
>>> lead to a crash, possible overwriting sensitive contents at the end of
>> the
>>> stack (when built without `CONFIG_THREAD_INFO_IN_TASK=y`), or
>> overwriting
>>> memory adjacent to the stack (when built without `CONFIG_VMAP_STACK=y`)
>>> +
>>> +Implicit switch case fall-through
>>> +---------------------------------
>>> +The C language allows switch cases to "fall through" when
>>> +a "break" statement is missing at the end of a case. This,
>>> +however, introduces ambiguity in the code, as it's not always
>>> +clear if the missing break is intentional or a bug. As there
>>> +have been a long list of flaws `due to missing "break" statements
>>> +<https://cwe.mitre.org/data/definitions/484.html>`_, we no longer allow
>>> +"implicit fall-through". In order to identify an intentional
>> fall-through
>>> +case, we have adopted the marking used by static analyzers: a comment
>>> +saying `/* Fall through */`. Once the C++17
>> `__attribute__((fallthrough))`
>>> +is more widely handled by C compilers, static analyzers, and IDEs, we
>> can
>>> +switch to using that instead.
>>> diff --git a/Makefile b/Makefile
>>> index 9be5834073f8..bdf8eac51b07 100644
>>> --- a/Makefile
>>> +++ b/Makefile
>>> @@ -843,6 +843,9 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC)
>> -print-file-name=include)
>>> # warn about C99 declaration after statement
>>> KBUILD_CFLAGS += -Wdeclaration-after-statement
>>>
>>> +# Warn about unmarked fall-throughs in switch statement.
>>> +KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough=3,)
>>> +
>>> # Variable Length Arrays (VLAs) should not be used anywhere in the
>> kernel
>>> KBUILD_CFLAGS += -Wvla
>>>
>>
>>
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH] Makefile: Globally enable fall-through warning
@ 2026-01-22 15:53 Simone Rea
2026-01-22 18:19 ` Randy Dunlap
0 siblings, 1 reply; 19+ messages in thread
From: Simone Rea @ 2026-01-22 15:53 UTC (permalink / raw)
To: hheh47660
Cc: Gustavo A. R. Silva, Masahiro Yamada, Andrew Morton, Michal Marek,
Kees Cook, linux-kbuild
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Now that all the fall-through warnings have been addressed in the
kernel, enable the fall-through warning globally.
Also, update the deprecated.rst file to include implicit fall-through
as 'deprecated' so people can be pointed to a single location for
justification.
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: Kees Cook <keescook@chromium.org>
Cc: linux-kbuild@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
Documentation/process/deprecated.rst | 14 ++++++++++++++
Makefile | 3 +++
2 files changed, 17 insertions(+)
diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst
index 49e0f64a3427..053b24a6dd38 100644
--- a/Documentation/process/deprecated.rst
+++ b/Documentation/process/deprecated.rst
@@ -119,3 +119,17 @@ array may exceed the remaining memory in the stack segment. This could
lead to a crash, possible overwriting sensitive contents at the end of the
stack (when built without `CONFIG_THREAD_INFO_IN_TASK=y`), or overwriting
memory adjacent to the stack (when built without `CONFIG_VMAP_STACK=y`)
+
+Implicit switch case fall-through
+---------------------------------
+The C language allows switch cases to "fall through" when
+a "break" statement is missing at the end of a case. This,
+however, introduces ambiguity in the code, as it's not always
+clear if the missing break is intentional or a bug. As there
+have been a long list of flaws `due to missing "break" statements
+<https://cwe.mitre.org/data/definitions/484.html>`_, we no longer allow
+"implicit fall-through". In order to identify an intentional fall-through
+case, we have adopted the marking used by static analyzers: a comment
+saying `/* Fall through */`. Once the C++17 `__attribute__((fallthrough))`
+is more widely handled by C compilers, static analyzers, and IDEs, we can
+switch to using that instead.
diff --git a/Makefile b/Makefile
index 9be5834073f8..bdf8eac51b07 100644
--- a/Makefile
+++ b/Makefile
@@ -843,6 +843,9 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
# warn about C99 declaration after statement
KBUILD_CFLAGS += -Wdeclaration-after-statement
+# Warn about unmarked fall-throughs in switch statement.
+KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough=3,)
+
# Variable Length Arrays (VLAs) should not be used anywhere in the kernel
KBUILD_CFLAGS += -Wvla
--
2.52.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH] Makefile: Globally enable fall-through warning
2026-01-22 15:53 Simone Rea
@ 2026-01-22 18:19 ` Randy Dunlap
2026-01-22 18:44 ` Andrew Morton
0 siblings, 1 reply; 19+ messages in thread
From: Randy Dunlap @ 2026-01-22 18:19 UTC (permalink / raw)
To: Simone Rea
Cc: Gustavo A. R. Silva, Masahiro Yamada, Andrew Morton, Michal Marek,
Kees Cook, linux-kbuild
Hi,
On 1/22/26 7:53 AM, Simone Rea wrote:
> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
>
> Now that all the fall-through warnings have been addressed in the
> kernel, enable the fall-through warning globally.
>
> Also, update the deprecated.rst file to include implicit fall-through
> as 'deprecated' so people can be pointed to a single location for
> justification.
>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Michal Marek <michal.lkml@markovi.net>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: linux-kbuild@vger.kernel.org
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
This is missing your Signed-off-by: line. See
Documentation/process/submitting-patches.rst for info.
Also you should copy the current KBUILD maintainers.
See the MAINTAINERS file.
> ---
> Documentation/process/deprecated.rst | 14 ++++++++++++++
> Makefile | 3 +++
> 2 files changed, 17 insertions(+)
>
> diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst
> index 49e0f64a3427..053b24a6dd38 100644
> --- a/Documentation/process/deprecated.rst
> +++ b/Documentation/process/deprecated.rst
> @@ -119,3 +119,17 @@ array may exceed the remaining memory in the stack segment. This could
> lead to a crash, possible overwriting sensitive contents at the end of the
> stack (when built without `CONFIG_THREAD_INFO_IN_TASK=y`), or overwriting
> memory adjacent to the stack (when built without `CONFIG_VMAP_STACK=y`)
> +
> +Implicit switch case fall-through
> +---------------------------------
> +The C language allows switch cases to "fall through" when
> +a "break" statement is missing at the end of a case. This,
> +however, introduces ambiguity in the code, as it's not always
> +clear if the missing break is intentional or a bug. As there
> +have been a long list of flaws `due to missing "break" statements
> +<https://cwe.mitre.org/data/definitions/484.html>`_, we no longer allow
> +"implicit fall-through". In order to identify an intentional fall-through
> +case, we have adopted the marking used by static analyzers: a comment
> +saying `/* Fall through */`. Once the C++17 `__attribute__((fallthrough))`
> +is more widely handled by C compilers, static analyzers, and IDEs, we can
> +switch to using that instead.
Given that we have 80 cases of
/* Fall through */
or /* fall through */
in the kernel tree and we have over 5000 cases of
fallthrough;
ITSM that you could go ahead and call for using the latter.
> diff --git a/Makefile b/Makefile
> index 9be5834073f8..bdf8eac51b07 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -843,6 +843,9 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
> # warn about C99 declaration after statement
> KBUILD_CFLAGS += -Wdeclaration-after-statement
>
> +# Warn about unmarked fall-throughs in switch statement.
> +KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough=3,)
> +
> # Variable Length Arrays (VLAs) should not be used anywhere in the kernel
> KBUILD_CFLAGS += -Wvla
>
--
~Randy
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] Makefile: Globally enable fall-through warning
2026-01-22 18:19 ` Randy Dunlap
@ 2026-01-22 18:44 ` Andrew Morton
2026-01-22 18:46 ` Randy Dunlap
0 siblings, 1 reply; 19+ messages in thread
From: Andrew Morton @ 2026-01-22 18:44 UTC (permalink / raw)
To: Randy Dunlap
Cc: Simone Rea, Gustavo A. R. Silva, Masahiro Yamada, Michal Marek,
Kees Cook, linux-kbuild
On Thu, 22 Jan 2026 10:19:56 -0800 Randy Dunlap <rdunlap@infradead.org> wrote:
> On 1/22/26 7:53 AM, Simone Rea wrote:
> > From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> >
> > Now that all the fall-through warnings have been addressed in the
> > kernel, enable the fall-through warning globally.
> >
> > Also, update the deprecated.rst file to include implicit fall-through
> > as 'deprecated' so people can be pointed to a single location for
> > justification.
> >
> > Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Cc: Michal Marek <michal.lkml@markovi.net>
> > Cc: Kees Cook <keescook@chromium.org>
> > Cc: linux-kbuild@vger.kernel.org
> > Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>
> This is missing your Signed-off-by: line. See
> Documentation/process/submitting-patches.rst for info.
>
> Also you should copy the current KBUILD maintainers.
> See the MAINTAINERS file.
This went into mainline in 2019 :) I suspect Gustavo had a slight IT
problem.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] Makefile: Globally enable fall-through warning
2026-01-22 18:44 ` Andrew Morton
@ 2026-01-22 18:46 ` Randy Dunlap
2026-01-22 22:35 ` Miguel Ojeda
[not found] ` <CAEfWggNK7DgsRHXTE8BhWCTuDKyt6pMR_9UEHEs1NKPfPPyopw@mail.gmail.com>
0 siblings, 2 replies; 19+ messages in thread
From: Randy Dunlap @ 2026-01-22 18:46 UTC (permalink / raw)
To: Andrew Morton
Cc: Simone Rea, Gustavo A. R. Silva, Masahiro Yamada, Michal Marek,
Kees Cook, linux-kbuild
On 1/22/26 10:44 AM, Andrew Morton wrote:
> On Thu, 22 Jan 2026 10:19:56 -0800 Randy Dunlap <rdunlap@infradead.org> wrote:
>
>> On 1/22/26 7:53 AM, Simone Rea wrote:
>>> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
>>>
>>> Now that all the fall-through warnings have been addressed in the
>>> kernel, enable the fall-through warning globally.
>>>
>>> Also, update the deprecated.rst file to include implicit fall-through
>>> as 'deprecated' so people can be pointed to a single location for
>>> justification.
>>>
>>> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>> Cc: Michal Marek <michal.lkml@markovi.net>
>>> Cc: Kees Cook <keescook@chromium.org>
>>> Cc: linux-kbuild@vger.kernel.org
>>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>>
>> This is missing your Signed-off-by: line. See
>> Documentation/process/submitting-patches.rst for info.
>>
>> Also you should copy the current KBUILD maintainers.
>> See the MAINTAINERS file.
>
> This went into mainline in 2019 :) I suspect Gustavo had a slight IT
> problem.
I think Simone did.
--
~Randy
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] Makefile: Globally enable fall-through warning
2026-01-22 18:46 ` Randy Dunlap
@ 2026-01-22 22:35 ` Miguel Ojeda
[not found] ` <CAEfWggNK7DgsRHXTE8BhWCTuDKyt6pMR_9UEHEs1NKPfPPyopw@mail.gmail.com>
1 sibling, 0 replies; 19+ messages in thread
From: Miguel Ojeda @ 2026-01-22 22:35 UTC (permalink / raw)
To: Randy Dunlap
Cc: Andrew Morton, Simone Rea, Gustavo A. R. Silva, Masahiro Yamada,
Michal Marek, Kees Cook, linux-kbuild
On Thu, Jan 22, 2026 at 7:46 PM Randy Dunlap <rdunlap@infradead.org> wrote:
>
> I think Simone did.
Yeah, I don't know what is going on with that particular patch, but
someone sent the same one earlier this month:
https://lore.kernel.org/all/20260110013412.14426-2-mohit.mishra@lunaredgeit.com/
Maybe an assignment?
Cheers,
Miguel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] Makefile: Globally enable fall-through warning
[not found] ` <CAEfWggNK7DgsRHXTE8BhWCTuDKyt6pMR_9UEHEs1NKPfPPyopw@mail.gmail.com>
@ 2026-01-23 1:51 ` Gustavo A. R. Silva
0 siblings, 0 replies; 19+ messages in thread
From: Gustavo A. R. Silva @ 2026-01-23 1:51 UTC (permalink / raw)
To: Simone Rea, Randy Dunlap
Cc: Andrew Morton, Masahiro Yamada, Michal Marek, Kees Cook,
linux-kbuild
On 1/23/26 03:48, Simone Rea wrote:
> Guys I’m so sorry 🙏🙏🙏 I don’t know what I did, i’m justinf following a
> tutorial…
This is the second time someone submit this same patch by mistake.
I'm curious about that tutorial. Can you please share with us a link to it?
Who's the author?
Are you paying for it?
Thanks
-Gustavo
>
> Il giorno gio 22 gen 2026 alle 19:46 Randy Dunlap <rdunlap@infradead.org>
> ha scritto:
>
>>
>>
>> On 1/22/26 10:44 AM, Andrew Morton wrote:
>>> On Thu, 22 Jan 2026 10:19:56 -0800 Randy Dunlap <rdunlap@infradead.org>
>> wrote:
>>>
>>>> On 1/22/26 7:53 AM, Simone Rea wrote:
>>>>> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
>>>>>
>>>>> Now that all the fall-through warnings have been addressed in the
>>>>> kernel, enable the fall-through warning globally.
>>>>>
>>>>> Also, update the deprecated.rst file to include implicit fall-through
>>>>> as 'deprecated' so people can be pointed to a single location for
>>>>> justification.
>>>>>
>>>>> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
>>>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>>>> Cc: Michal Marek <michal.lkml@markovi.net>
>>>>> Cc: Kees Cook <keescook@chromium.org>
>>>>> Cc: linux-kbuild@vger.kernel.org
>>>>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>>>>
>>>> This is missing your Signed-off-by: line. See
>>>> Documentation/process/submitting-patches.rst for info.
>>>>
>>>> Also you should copy the current KBUILD maintainers.
>>>> See the MAINTAINERS file.
>>>
>>> This went into mainline in 2019 :) I suspect Gustavo had a slight IT
>>> problem.
>>
>> I think Simone did.
>>
>> --
>> ~Randy
>>
>>
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] Makefile: Globally enable fall-through warning
2026-01-31 5:40 ` [PATCH] Makefile: Globally enable fall-through warning david
@ 2026-01-31 5:33 ` Gustavo A. R. Silva
0 siblings, 0 replies; 19+ messages in thread
From: Gustavo A. R. Silva @ 2026-01-31 5:33 UTC (permalink / raw)
To: david, Shuah Khan
Cc: Masahiro Yamada, Andrew Morton, Michal Marek, Kees Cook,
linux-kbuild
Shuah,
People taking this[1] LF training have been wrongly submitting this
patch since 2022 [2].
Why?
-Gustavo
[1] https://training.linuxfoundation.org/training/a-beginners-guide-to-linux-kernel-development-lfd103/
[2] https://lore.kernel.org/all/20220517195912.GA10952@embeddedor/
On 1/31/26 14:40, david@stennet.com wrote:
> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
>
> Now that all the fall-through warnings have been addressed in the
> kernel, enable the fall-through warning globally.
>
> Also, update the deprecated.rst file to include implicit fall-through
> as 'deprecated' so people can be pointed to a single location for
> justification.
>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Michal Marek <michal.lkml@markovi.net>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: linux-kbuild@vger.kernel.org
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> Documentation/process/deprecated.rst | 14 ++++++++++++++
> Makefile | 3 +++
> 2 files changed, 17 insertions(+)
>
> diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst
> index 49e0f64a3427..053b24a6dd38 100644
> --- a/Documentation/process/deprecated.rst
> +++ b/Documentation/process/deprecated.rst
> @@ -119,3 +119,17 @@ array may exceed the remaining memory in the stack segment. This could
> lead to a crash, possible overwriting sensitive contents at the end of the
> stack (when built without `CONFIG_THREAD_INFO_IN_TASK=y`), or overwriting
> memory adjacent to the stack (when built without `CONFIG_VMAP_STACK=y`)
> +
> +Implicit switch case fall-through
> +---------------------------------
> +The C language allows switch cases to "fall through" when
> +a "break" statement is missing at the end of a case. This,
> +however, introduces ambiguity in the code, as it's not always
> +clear if the missing break is intentional or a bug. As there
> +have been a long list of flaws `due to missing "break" statements
> +<https://cwe.mitre.org/data/definitions/484.html>`_, we no longer allow
> +"implicit fall-through". In order to identify an intentional fall-through
> +case, we have adopted the marking used by static analyzers: a comment
> +saying `/* Fall through */`. Once the C++17 `__attribute__((fallthrough))`
> +is more widely handled by C compilers, static analyzers, and IDEs, we can
> +switch to using that instead.
> diff --git a/Makefile b/Makefile
> index 9be5834073f8..bdf8eac51b07 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -843,6 +843,9 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
> # warn about C99 declaration after statement
> KBUILD_CFLAGS += -Wdeclaration-after-statement
>
> +# Warn about unmarked fall-throughs in switch statement.
> +KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough=3,)
> +
> # Variable Length Arrays (VLAs) should not be used anywhere in the kernel
> KBUILD_CFLAGS += -Wvla
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH] Makefile: Globally enable fall-through warning
[not found] <20260131054051.6938-1-david@stennet.com>
@ 2026-01-31 5:40 ` david
2026-01-31 5:33 ` Gustavo A. R. Silva
0 siblings, 1 reply; 19+ messages in thread
From: david @ 2026-01-31 5:40 UTC (permalink / raw)
To: Shuah Khan
Cc: Gustavo A. R. Silva, Masahiro Yamada, Andrew Morton, Michal Marek,
Kees Cook, linux-kbuild
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Now that all the fall-through warnings have been addressed in the
kernel, enable the fall-through warning globally.
Also, update the deprecated.rst file to include implicit fall-through
as 'deprecated' so people can be pointed to a single location for
justification.
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: Kees Cook <keescook@chromium.org>
Cc: linux-kbuild@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
Documentation/process/deprecated.rst | 14 ++++++++++++++
Makefile | 3 +++
2 files changed, 17 insertions(+)
diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst
index 49e0f64a3427..053b24a6dd38 100644
--- a/Documentation/process/deprecated.rst
+++ b/Documentation/process/deprecated.rst
@@ -119,3 +119,17 @@ array may exceed the remaining memory in the stack segment. This could
lead to a crash, possible overwriting sensitive contents at the end of the
stack (when built without `CONFIG_THREAD_INFO_IN_TASK=y`), or overwriting
memory adjacent to the stack (when built without `CONFIG_VMAP_STACK=y`)
+
+Implicit switch case fall-through
+---------------------------------
+The C language allows switch cases to "fall through" when
+a "break" statement is missing at the end of a case. This,
+however, introduces ambiguity in the code, as it's not always
+clear if the missing break is intentional or a bug. As there
+have been a long list of flaws `due to missing "break" statements
+<https://cwe.mitre.org/data/definitions/484.html>`_, we no longer allow
+"implicit fall-through". In order to identify an intentional fall-through
+case, we have adopted the marking used by static analyzers: a comment
+saying `/* Fall through */`. Once the C++17 `__attribute__((fallthrough))`
+is more widely handled by C compilers, static analyzers, and IDEs, we can
+switch to using that instead.
diff --git a/Makefile b/Makefile
index 9be5834073f8..bdf8eac51b07 100644
--- a/Makefile
+++ b/Makefile
@@ -843,6 +843,9 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
# warn about C99 declaration after statement
KBUILD_CFLAGS += -Wdeclaration-after-statement
+# Warn about unmarked fall-throughs in switch statement.
+KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough=3,)
+
# Variable Length Arrays (VLAs) should not be used anywhere in the kernel
KBUILD_CFLAGS += -Wvla
--
2.34.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH] Makefile: Globally enable fall-through warning
@ 2026-02-14 9:19 Rishabh
0 siblings, 0 replies; 19+ messages in thread
From: Rishabh @ 2026-02-14 9:19 UTC (permalink / raw)
To: rishabhssap
Cc: Gustavo A. R. Silva, Masahiro Yamada, Andrew Morton, Michal Marek,
Kees Cook, linux-kbuild
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Now that all the fall-through warnings have been addressed in the
kernel, enable the fall-through warning globally.
Also, update the deprecated.rst file to include implicit fall-through
as 'deprecated' so people can be pointed to a single location for
justification.
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: Kees Cook <keescook@chromium.org>
Cc: linux-kbuild@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
Documentation/process/deprecated.rst | 14 ++++++++++++++
Makefile | 3 +++
2 files changed, 17 insertions(+)
diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst
index 49e0f64a3427..053b24a6dd38 100644
--- a/Documentation/process/deprecated.rst
+++ b/Documentation/process/deprecated.rst
@@ -119,3 +119,17 @@ array may exceed the remaining memory in the stack segment. This could
lead to a crash, possible overwriting sensitive contents at the end of the
stack (when built without `CONFIG_THREAD_INFO_IN_TASK=y`), or overwriting
memory adjacent to the stack (when built without `CONFIG_VMAP_STACK=y`)
+
+Implicit switch case fall-through
+---------------------------------
+The C language allows switch cases to "fall through" when
+a "break" statement is missing at the end of a case. This,
+however, introduces ambiguity in the code, as it's not always
+clear if the missing break is intentional or a bug. As there
+have been a long list of flaws `due to missing "break" statements
+<https://cwe.mitre.org/data/definitions/484.html>`_, we no longer allow
+"implicit fall-through". In order to identify an intentional fall-through
+case, we have adopted the marking used by static analyzers: a comment
+saying `/* Fall through */`. Once the C++17 `__attribute__((fallthrough))`
+is more widely handled by C compilers, static analyzers, and IDEs, we can
+switch to using that instead.
diff --git a/Makefile b/Makefile
index 9be5834073f8..bdf8eac51b07 100644
--- a/Makefile
+++ b/Makefile
@@ -843,6 +843,9 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
# warn about C99 declaration after statement
KBUILD_CFLAGS += -Wdeclaration-after-statement
+# Warn about unmarked fall-throughs in switch statement.
+KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough=3,)
+
# Variable Length Arrays (VLAs) should not be used anywhere in the kernel
KBUILD_CFLAGS += -Wvla
--
2.51.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
end of thread, other threads:[~2026-02-14 9:19 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260131054051.6938-1-david@stennet.com>
2026-01-31 5:40 ` [PATCH] Makefile: Globally enable fall-through warning david
2026-01-31 5:33 ` Gustavo A. R. Silva
2026-02-14 9:19 Rishabh
-- strict thread matches above, loose matches on Subject: below --
2026-01-22 15:53 Simone Rea
2026-01-22 18:19 ` Randy Dunlap
2026-01-22 18:44 ` Andrew Morton
2026-01-22 18:46 ` Randy Dunlap
2026-01-22 22:35 ` Miguel Ojeda
[not found] ` <CAEfWggNK7DgsRHXTE8BhWCTuDKyt6pMR_9UEHEs1NKPfPPyopw@mail.gmail.com>
2026-01-23 1:51 ` Gustavo A. R. Silva
2026-01-10 1:34 MIshraMohit21-LE
2026-01-10 3:12 ` Gustavo A. R. Silva
[not found] ` <CAP5HdgoFya1NfeJH0wT7KtzqaFmupn5C-kSwXNEtEdbq5bQSEw@mail.gmail.com>
2026-01-10 4:04 ` Gustavo A. R. Silva
2025-05-05 17:14 Omar el Azouny
2025-05-05 17:53 ` Miguel Ojeda
2022-05-17 17:35 ALOK JHA
2022-05-17 18:42 ` Andrew Morton
2022-05-17 18:46 ` Andrew Morton
2022-05-17 19:40 ` Jeff Johnson
2022-05-17 19:59 ` Gustavo A. R. Silva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox