From: Stefano Brivio <sbrivio@redhat.com>
To: Florian Westphal <fw@strlen.de>
Cc: <netfilter-devel@vger.kernel.org>, lonial con <kongln9170@gmail.com>
Subject: Re: [PATCH nf] netfilter: nft_set_pipapo: fix improper element removal
Date: Thu, 20 Jul 2023 12:24:14 +0200 [thread overview]
Message-ID: <20230720122414.7f633c03@elisabeth> (raw)
In-Reply-To: <20230719190824.21196-1-fw@strlen.de>
On Wed, 19 Jul 2023 21:08:21 +0200
Florian Westphal <fw@strlen.de> wrote:
> end key should be equal to start unless NFT_SET_EXT_KEY_END is present.
>
> Its possible to add elements that only have a start key
> ("{ 1.0.0.0 . 2.0.0.0 }") without an internval end.
>
> Insertion treats this via:
>
> if (nft_set_ext_exists(ext, NFT_SET_EXT_KEY_END))
> end = (const u8 *)nft_set_ext_key_end(ext)->data;
> else
> end = start;
>
> but removal side always uses nft_set_ext_key_end().
Oops, right, nft_pipapo_remove() should do exactly the same.
> This is wrong and leads to garbage remaining in the set after removal
> next lookup/insert attempt will give:
>
> BUG: KASAN: slab-use-after-free in pipapo_get+0x8eb/0xb90
> Read of size 1 at addr ffff888100d50586 by task nft-pipapo_uaf_/1399
> Call Trace:
> kasan_report+0x105/0x140
> pipapo_get+0x8eb/0xb90
> nft_pipapo_insert+0x1dc/0x1710
> nf_tables_newsetelem+0x31f5/0x4e00
> ..
>
> Fixes: 3c4287f62044 ("nf_tables: Add set type for arbitrary concatenation of ranges")
> Cc: Stefano Brivio <sbrivio@redhat.com>
> Reported-by: lonial con <kongln9170@gmail.com>
> Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Thanks for fixing this!
--
Stefano
prev parent reply other threads:[~2023-07-20 10:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-19 19:08 [PATCH nf] netfilter: nft_set_pipapo: fix improper element removal Florian Westphal
2023-07-20 10:24 ` Stefano Brivio [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=20230720122414.7f633c03@elisabeth \
--to=sbrivio@redhat.com \
--cc=fw@strlen.de \
--cc=kongln9170@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
/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).