From: "Toke Høiland-Jørgensen" <toke@redhat•com>
To: Simon Horman <horms@kernel•org>,
Pablo Neira Ayuso <pablo@netfilter•org>,
Jozsef Kadlecsik <kadlec@netfilter•org>
Cc: "David S. Miller" <davem@davemloft•net>,
Eric Dumazet <edumazet@google•com>,
Jakub Kicinski <kuba@kernel•org>, Paolo Abeni <pabeni@redhat•com>,
Nathan Chancellor <nathan@kernel•org>,
Nick Desaulniers <ndesaulniers@google•com>,
Bill Wendling <morbo@google•com>,
Justin Stitt <justinstitt@google•com>,
netfilter-devel@vger•kernel.org, coreteam@netfilter•org,
netdev@vger•kernel.org, bpf@vger•kernel.org,
llvm@lists•linux.dev
Subject: Re: [PATCH nf-next] netfilter: bpf: Pass string literal as format argument of request_module()
Date: Fri, 18 Oct 2024 12:35:50 +0200 [thread overview]
Message-ID: <87ttd9y9yx.fsf@toke.dk> (raw)
In-Reply-To: <20241018-nf-mod-fmt-v1-1-b5a275d6861c@kernel.org>
Simon Horman <horms@kernel•org> writes:
> 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.
>
> No functional change intended.
> Compile tested only.
>
> Signed-off-by: Simon Horman <horms@kernel•org>
Reviewed-by: Toke Høiland-Jørgensen <toke@redhat•com>
next prev parent reply other threads:[~2024-10-18 10:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 9:42 [PATCH nf-next] netfilter: bpf: Pass string literal as format argument of request_module() Simon Horman
2024-10-18 9:44 ` Florian Westphal
2024-10-18 10:35 ` Toke Høiland-Jørgensen [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-11-11 14:47 Simon Horman
2024-11-12 11:36 ` 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=87ttd9y9yx.fsf@toke.dk \
--to=toke@redhat$(echo .)com \
--cc=bpf@vger$(echo .)kernel.org \
--cc=coreteam@netfilter$(echo .)org \
--cc=davem@davemloft$(echo .)net \
--cc=edumazet@google$(echo .)com \
--cc=horms@kernel$(echo .)org \
--cc=justinstitt@google$(echo .)com \
--cc=kadlec@netfilter$(echo .)org \
--cc=kuba@kernel$(echo .)org \
--cc=llvm@lists$(echo .)linux.dev \
--cc=morbo@google$(echo .)com \
--cc=nathan@kernel$(echo .)org \
--cc=ndesaulniers@google$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=netfilter-devel@vger$(echo .)kernel.org \
--cc=pabeni@redhat$(echo .)com \
--cc=pablo@netfilter$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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