From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org,
pabeni@redhat.com, edumazet@google.com, fw@strlen.de
Subject: [PATCH net-next 02/14] netfilter: bpf: Pass string literal as format argument of request_module()
Date: Fri, 15 Nov 2024 14:31:55 +0100 [thread overview]
Message-ID: <20241115133207.8907-3-pablo@netfilter.org> (raw)
In-Reply-To: <20241115133207.8907-1-pablo@netfilter.org>
From: Simon Horman <horms@kernel.org>
Both gcc-14 and clang-18 report that passing a non-string literal as the
format argument of request_module() is potentially insecure.
E.g. clang-18 says:
.../nf_bpf_link.c:46:24: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
46 | err = request_module(mod);
| ^~~
.../kmod.h:25:55: note: expanded from macro 'request_module'
25 | #define request_module(mod...) __request_module(true, mod)
| ^~~
.../nf_bpf_link.c:46:24: note: treat the string as an argument to avoid this
46 | err = request_module(mod);
| ^
| "%s",
.../kmod.h:25:55: note: expanded from macro 'request_module'
25 | #define request_module(mod...) __request_module(true, mod)
| ^
It is always the case where the contents of mod is safe to pass as the
format argument. That is, in my understanding, it never contains any
format escape sequences.
But, it seems better to be safe than sorry. And, as a bonus, compiler
output becomes less verbose by addressing this issue as suggested by
clang-18.
Compile tested only.
Signed-off-by: Simon Horman <horms@kernel.org>
Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_bpf_link.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netfilter/nf_bpf_link.c b/net/netfilter/nf_bpf_link.c
index 3d64a4511fcf..06b084844700 100644
--- a/net/netfilter/nf_bpf_link.c
+++ b/net/netfilter/nf_bpf_link.c
@@ -43,7 +43,7 @@ get_proto_defrag_hook(struct bpf_nf_link *link,
hook = rcu_dereference(*ptr_global_hook);
if (!hook) {
rcu_read_unlock();
- err = request_module(mod);
+ err = request_module("%s", mod);
if (err)
return ERR_PTR(err < 0 ? err : -EINVAL);
--
2.30.2
next prev parent reply other threads:[~2024-11-15 13:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-15 13:31 [PATCH net-next 00/14] Netfilter updates for net-next Pablo Neira Ayuso
2024-11-15 13:31 ` [PATCH net-next 01/14] netfilter: nfnetlink: Report extack policy errors for batched ops Pablo Neira Ayuso
2024-11-15 22:20 ` patchwork-bot+netdevbpf
2024-11-15 13:31 ` Pablo Neira Ayuso [this message]
2024-11-15 13:31 ` [PATCH net-next 03/14] netfilter: nf_tables: add nft_trans_commit_list_add_elem helper Pablo Neira Ayuso
2024-11-15 13:31 ` [PATCH net-next 04/14] netfilter: nf_tables: prepare for multiple elements in nft_trans_elem structure Pablo Neira Ayuso
2024-11-15 13:31 ` [PATCH net-next 05/14] netfilter: nf_tables: prepare nft audit for set element compaction Pablo Neira Ayuso
2024-11-15 13:31 ` [PATCH net-next 06/14] netfilter: nf_tables: switch trans_elem to real flex array Pablo Neira Ayuso
2024-11-15 13:32 ` [PATCH net-next 07/14] netfilter: nf_tables: allocate element update information dynamically Pablo Neira Ayuso
2024-11-15 13:32 ` [PATCH net-next 08/14] netfilter: ipv4: Convert ip_route_me_harder() to dscp_t Pablo Neira Ayuso
2024-11-15 13:32 ` [PATCH net-next 09/14] netfilter: flow_offload: Convert nft_flow_route() " Pablo Neira Ayuso
2024-11-15 13:32 ` [PATCH net-next 10/14] netfilter: rpfilter: Convert rpfilter_mt() " Pablo Neira Ayuso
2024-11-15 13:32 ` [PATCH net-next 11/14] netfilter: nft_fib: Convert nft_fib4_eval() " Pablo Neira Ayuso
2024-11-15 13:32 ` [PATCH net-next 12/14] netfilter: nf_dup4: Convert nf_dup_ipv4_route() " Pablo Neira Ayuso
2024-11-15 13:32 ` [PATCH net-next 13/14] netfilter: bitwise: rename some boolean operation functions Pablo Neira Ayuso
2024-11-15 13:32 ` [PATCH net-next 14/14] netfilter: bitwise: add support for doing AND, OR and XOR directly Pablo Neira Ayuso
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=20241115133207.8907-3-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).