From: Florian Westphal <fw@strlen.de>
To: Melbin K Mathew <mlbnkm1@gmail.com>
Cc: pablo@netfilter.org, kadlec@netfilter.org, phil@nwl.cc,
netfilter-devel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] netfilter: nft_set_hash: fix potential NULL deref in nft_rhash_deactivate
Date: Wed, 3 Dec 2025 14:40:27 +0100 [thread overview]
Message-ID: <aTA9y3iH1JjMPwQ1@strlen.de> (raw)
In-Reply-To: <20251203132044.57242-1-mlbnkm1@gmail.com>
Melbin K Mathew <mlbnkm1@gmail.com> wrote:
> In nft_rhash_deactivate(), rhashtable_lookup() may return NULL when the
> set element is not found, but the function unconditionally returns
> &he->priv.
Which is equal to 'return NULL' in that case.
> Dereferencing a member of a NULL pointer is undefined behavior in C.
&he->priv doesn't dereference he, it returns the address of the member.
> Although the current struct layout places 'priv' at offset 0 (making
> this behave like returning NULL), this is fragile and relies on
> implementation details.
Its not fragile, this file has:
BUILD_BUG_ON(offsetof(struct nft_rhash_elem, priv) != 0);
to ensure 'priv is first member' requirement.
prev parent reply other threads:[~2025-12-03 13:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-03 13:20 [PATCH] netfilter: nft_set_hash: fix potential NULL deref in nft_rhash_deactivate Melbin K Mathew
2025-12-03 13:40 ` Florian Westphal [this message]
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=aTA9y3iH1JjMPwQ1@strlen.de \
--to=fw@strlen.de \
--cc=kadlec@netfilter.org \
--cc=mlbnkm1@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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;
as well as URLs for NNTP newsgroup(s).