[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aTA9y3iH1JjMPwQ1@strlen.de>
Date: Wed, 3 Dec 2025 14:40:27 +0100
From: Florian Westphal <fw@...len.de>
To: Melbin K Mathew <mlbnkm1@...il.com>
Cc: pablo@...filter.org, kadlec@...filter.org, phil@....cc,
netfilter-devel@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH] netfilter: nft_set_hash: fix potential NULL deref in
nft_rhash_deactivate
Melbin K Mathew <mlbnkm1@...il.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.
Powered by blists - more mailing lists