From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Fernando Fernandez Mancera <fmancera@suse.de>
Cc: netfilter-devel@vger.kernel.org, netdev@vger.kernel.org,
coreteam@netfilter.org, fw@strlen.de, phil@nwl.cc,
"Kito Xu (veritas501)" <hxzene@gmail.com>
Subject: Re: [PATCH 2/2 nf] netfilter: nfnetlink_osf: fix potential NULL dereference in ttl check
Date: Sat, 18 Apr 2026 09:53:22 +0200 [thread overview]
Message-ID: <aeM4ctFJOxAttIrk@chamomile> (raw)
In-Reply-To: <20260417162057.3732-2-fmancera@suse.de>
On Fri, Apr 17, 2026 at 06:20:57PM +0200, Fernando Fernandez Mancera wrote:
> The nf_osf_ttl() function accessed skb->dev to perform a local interface
> address lookup without verifying that the device pointer was valid.
>
> Additionally, the implementation utilized an in_dev_for_each_ifa_rcu
> loop to match the packet source address against local interface
> addresses. It assumed that packets from the same subnet should not see a
> decrement on the initial TTL. A packet might appear it is from the same
> subnet but it actually isn't especially in modern environments with
> containers and virtual switching.
>
> Remove the device dereference and interface loop. Replace the logic with
> a switch statement that evaluates the TTL according to the ttl_check.
>
> Fixes: 11eeef41d5f6 ("netfilter: passive OS fingerprint xtables match")
> Reported-by: Kito Xu (veritas501) <hxzene@gmail.com>
> Closes: https://lore.kernel.org/netfilter-devel/20260414074556.2512750-1-hxzene@gmail.com/
> Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
> Note: if some help is needed during the backport I can assist.
> ---
> net/netfilter/nfnetlink_osf.c | 22 +++++++---------------
> 1 file changed, 7 insertions(+), 15 deletions(-)
>
> diff --git a/net/netfilter/nfnetlink_osf.c b/net/netfilter/nfnetlink_osf.c
> index f58267986453..f0d1e596e146 100644
> --- a/net/netfilter/nfnetlink_osf.c
> +++ b/net/netfilter/nfnetlink_osf.c
> @@ -31,26 +31,18 @@ EXPORT_SYMBOL_GPL(nf_osf_fingers);
> static inline int nf_osf_ttl(const struct sk_buff *skb,
> int ttl_check, unsigned char f_ttl)
> {
> - struct in_device *in_dev = __in_dev_get_rcu(skb->dev);
> const struct iphdr *ip = ip_hdr(skb);
> - const struct in_ifaddr *ifa;
> - int ret = 0;
>
> - if (ttl_check == NF_OSF_TTL_TRUE)
> + switch (ttl_check) {
> + case NF_OSF_TTL_TRUE:
> return ip->ttl == f_ttl;
> - if (ttl_check == NF_OSF_TTL_NOCHECK)
> - return 1;
> - else if (ip->ttl <= f_ttl)
> + break;
> + case NF_OSF_TTL_NOCHECK:
> return 1;
> -
> - in_dev_for_each_ifa_rcu(ifa, in_dev) {
> - if (inet_ifa_match(ip->saddr, ifa)) {
> - ret = (ip->ttl == f_ttl);
> - break;
> - }
> + case NF_OSF_TTL_LESS:
> + default:
> + return ip->ttl <= f_ttl;
> }
> -
> - return ret;
> }
>
> struct nf_osf_hdr_ctx {
> --
> 2.53.0
>
next prev parent reply other threads:[~2026-04-18 7:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-17 16:20 [PATCH 1/2 nf] netfilter: nfnetlink_osf: fix out-of-bounds read on option matching Fernando Fernandez Mancera
2026-04-17 16:20 ` [PATCH 2/2 nf] netfilter: nfnetlink_osf: fix potential NULL dereference in ttl check Fernando Fernandez Mancera
2026-04-18 7:53 ` Pablo Neira Ayuso [this message]
2026-04-18 7:57 ` [PATCH 1/2 nf] netfilter: nfnetlink_osf: fix out-of-bounds read on option matching 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=aeM4ctFJOxAttIrk@chamomile \
--to=pablo@netfilter.org \
--cc=coreteam@netfilter.org \
--cc=fmancera@suse.de \
--cc=fw@strlen.de \
--cc=hxzene@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=phil@nwl.cc \
/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