From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: Masahiro Yamada <masahiroy@kernel.org>,
Andreas Schwab <schwab@linux-m68k.org>,
Jean Delvare <khali@linux-fr.org>,
Jochen Friedrich <jochen@scram.de>, Michal Marek <mmarek@suse.cz>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nicolas@fjasle.eu>,
Sam Ravnborg <sam@ravnborg.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH 01/15] modpost: remove incorrect code in do_eisa_entry()
Date: Wed, 20 Nov 2024 08:56:39 +0900 [thread overview]
Message-ID: <20241119235705.1576946-1-masahiroy@kernel.org> (raw)
This function contains multiple bugs after the following commits:
- ac551828993e ("modpost: i2c aliases need no trailing wildcard")
- 6543becf26ff ("mod/file2alias: make modalias generation safe for cross compiling")
Commit ac551828993e inserted the following code to do_eisa_entry():
else
strcat(alias, "*");
This is incorrect because 'alias' is uninitialized. If it is not
NULL-terminated, strcat() could cause a buffer overrun.
Even if 'alias' happens to be zero-filled, it would output:
MODULE_ALIAS("*");
This would match anything. As a result, the module could be loaded by
any unrelated uevent from an unrelated subsystem.
Commit ac551828993e introduced another bug.
Prior to that commit, the conditional check was:
if (eisa->sig[0])
This checked if the first character of eisa_device_id::sig was not '\0'.
However, commit ac551828993e changed it as follows:
if (sig[0])
sig[0] is NOT the first character of the eisa_device_id::sig. The
type of 'sig' is 'char (*)[8]', meaning that the type of 'sig[0]' is
'char [8]' instead of 'char'. 'sig[0]' and 'symval' refer to the same
address, which never becomes NULL.
The correct conversion would have been:
if ((*sig)[0])
However, this if-conditional was meaningless because the earlier change
in commit ac551828993e was incorrect.
This commit removes the entire incorrect code, which should never have
been executed.
Fixes: ac551828993e ("modpost: i2c aliases need no trailing wildcard")
Fixes: 6543becf26ff ("mod/file2alias: make modalias generation safe for cross compiling")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/mod/file2alias.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index c4cc11aa558f..634e40748287 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -809,10 +809,7 @@ static int do_eisa_entry(const char *filename, void *symval,
char *alias)
{
DEF_FIELD_ADDR(symval, eisa_device_id, sig);
- if (sig[0])
- sprintf(alias, EISA_DEVICE_MODALIAS_FMT "*", *sig);
- else
- strcat(alias, "*");
+ sprintf(alias, EISA_DEVICE_MODALIAS_FMT "*", *sig);
return 1;
}
--
2.43.0
next reply other threads:[~2024-11-19 23:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-19 23:56 Masahiro Yamada [this message]
2024-11-19 23:56 ` [PATCH 02/15] modpost: remove unnecessary check in do_acpi_entry() Masahiro Yamada
2024-11-19 23:56 ` [PATCH 03/15] modpost: introduce module_alias_printf() helper Masahiro Yamada
2024-11-20 2:37 ` Masahiro Yamada
2024-11-19 23:56 ` [PATCH 04/15] modpost: deduplicate MODULE_ALIAS() for all drivers Masahiro Yamada
2024-11-19 23:56 ` [PATCH 05/15] modpost: remove DEF_FIELD_ADDR_VAR() macro Masahiro Yamada
2024-11-19 23:56 ` [PATCH 06/15] modpost: pass (struct module *) to do_*_entry() functions Masahiro Yamada
2024-11-19 23:56 ` [PATCH 07/15] modpost: call module_alias_printf() from all " Masahiro Yamada
2024-11-19 23:56 ` [PATCH 08/15] modpost: convert do_pnp_card_entries() to a generic handler Masahiro Yamada
2024-11-19 23:56 ` [PATCH 09/15] modpost: convert do_pnp_device_entry() " Masahiro Yamada
2024-11-19 23:56 ` [PATCH 10/15] modpost: convert do_of_table() " Masahiro Yamada
2024-11-19 23:56 ` [PATCH 11/15] modpost: convert do_usb_table() " Masahiro Yamada
2024-11-19 23:56 ` [PATCH 12/15] modpost: move strstarts() to modpost.h Masahiro Yamada
2024-11-19 23:56 ` [PATCH 13/15] modpost: rename variables in handle_moddevtable() Masahiro Yamada
2024-11-19 23:56 ` [PATCH 14/15] modpost: rename alias symbol for MODULE_DEVICE_TABLE() Masahiro Yamada
2024-11-19 23:56 ` [PATCH 15/15] modpost: improve error messages in device_id_check() Masahiro Yamada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241119235705.1576946-1-masahiroy@kernel.org \
--to=masahiroy@kernel.org \
--cc=jochen@scram.de \
--cc=khali@linux-fr.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mmarek@suse.cz \
--cc=nathan@kernel.org \
--cc=nicolas@fjasle.eu \
--cc=sam@ravnborg.org \
--cc=schwab@linux-m68k.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox