2024-06-11 20:59:53

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] modpost: Enable section warning from *driver to .exit.text

There used to be several offenders, but now that for all of them patches
were sent and most of them were applied, enable the warning also for
builds without W=1.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
Hello,

as of v6.10-rc2 there are two known offenders:

- drivers/virt/coco/sev-guest/sev-guest.c
patch submitted in March, available at
https://lore.kernel.org/all/4a81b0e87728a58904283e2d1f18f73abc69c2a1.1711748999.git.u.kleine-koenig@pengutronix.de

- drivers/parport/parport_amiga.c
fixed in next (commit 73fedc31fed3 ("parport: amiga: Mark driver
struct with __refdata to prevent section mismatch"))

I tested this patch using allmodconfig builds for arm64, riscv, s390 and
x86_64 which didn't expose further drivers with this problem.

In my eyes this is good enough to enable the warning for all builds (and
not only with W=1).

Best regards
Uwe

scripts/mod/modpost.c | 11 -----------
1 file changed, 11 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 937294ff164f..30881d94f00e 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -965,17 +965,6 @@ static int secref_whitelist(const char *fromsec, const char *fromsym,
match(fromsym, PATTERNS("*_ops", "*_probe", "*_console")))
return 0;

- /*
- * symbols in data sections must not refer to .exit.*, but there are
- * quite a few offenders, so hide these unless for W=1 builds until
- * these are fixed.
- */
- if (!extra_warn &&
- match(fromsec, PATTERNS(DATA_SECTIONS)) &&
- match(tosec, PATTERNS(ALL_EXIT_SECTIONS)) &&
- match(fromsym, PATTERNS("*driver")))
- return 0;
-
/* Check for pattern 3 */
if (strstarts(fromsec, ".head.text") &&
match(tosec, PATTERNS(ALL_INIT_SECTIONS)))

base-commit: c3f38fa61af77b49866b006939479069cd451173
prerequisite-patch-id: 7300dede00db637042647e12d558fe1dd57c20cc
prerequisite-patch-id: 82cfe8597f709f05b9fbbd3e4eca8be35e077e2b
--
2.43.0



2024-06-13 00:03:38

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH] modpost: Enable section warning from *driver to .exit.text

On Tue, Jun 11, 2024 at 10:59:00PM +0200, Uwe Kleine-K?nig wrote:
> There used to be several offenders, but now that for all of them patches
> were sent and most of them were applied, enable the warning also for
> builds without W=1.
>
> Signed-off-by: Uwe Kleine-K?nig <[email protected]>

Seems reasonable to me, this is just a modpost warning, so it should not
matter too much if there are a few instances lagging behind for a bit
(but it would be good for that to get back on people's radar).

Reviewed-by: Nathan Chancellor <[email protected]>

> ---
> Hello,
>
> as of v6.10-rc2 there are two known offenders:
>
> - drivers/virt/coco/sev-guest/sev-guest.c
> patch submitted in March, available at
> https://lore.kernel.org/all/4a81b0e87728a58904283e2d1f18f73abc69c2a1.1711748999.git.u.kleine-koenig@pengutronix.de
>
> - drivers/parport/parport_amiga.c
> fixed in next (commit 73fedc31fed3 ("parport: amiga: Mark driver
> struct with __refdata to prevent section mismatch"))
>
> I tested this patch using allmodconfig builds for arm64, riscv, s390 and
> x86_64 which didn't expose further drivers with this problem.
>
> In my eyes this is good enough to enable the warning for all builds (and
> not only with W=1).
>
> Best regards
> Uwe
>
> scripts/mod/modpost.c | 11 -----------
> 1 file changed, 11 deletions(-)
>
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index 937294ff164f..30881d94f00e 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -965,17 +965,6 @@ static int secref_whitelist(const char *fromsec, const char *fromsym,
> match(fromsym, PATTERNS("*_ops", "*_probe", "*_console")))
> return 0;
>
> - /*
> - * symbols in data sections must not refer to .exit.*, but there are
> - * quite a few offenders, so hide these unless for W=1 builds until
> - * these are fixed.
> - */
> - if (!extra_warn &&
> - match(fromsec, PATTERNS(DATA_SECTIONS)) &&
> - match(tosec, PATTERNS(ALL_EXIT_SECTIONS)) &&
> - match(fromsym, PATTERNS("*driver")))
> - return 0;
> -
> /* Check for pattern 3 */
> if (strstarts(fromsec, ".head.text") &&
> match(tosec, PATTERNS(ALL_INIT_SECTIONS)))
>
> base-commit: c3f38fa61af77b49866b006939479069cd451173
> prerequisite-patch-id: 7300dede00db637042647e12d558fe1dd57c20cc
> prerequisite-patch-id: 82cfe8597f709f05b9fbbd3e4eca8be35e077e2b
> --
> 2.43.0
>

2024-06-15 06:49:10

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH] modpost: Enable section warning from *driver to .exit.text

On Wed, Jun 12, 2024 at 5:59 AM Uwe Kleine-König
<[email protected]> wrote:
>
> There used to be several offenders, but now that for all of them patches
> were sent and most of them were applied, enable the warning also for
> builds without W=1.
>
> Signed-off-by: Uwe Kleine-König <[email protected]>


Applied to linux-kbuild.
Thanks!


--
Best Regards
Masahiro Yamada