From: "Lin Ma" <linma@zju.edu.cn>
To: "Alexey Dobriyan" <adobriyan@gmail.com>
Cc: steffen.klassert@secunet.com, herbert@gondor.apana.org.au,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, simon.horman@corigine.com
Subject: Re: [PATCH v2] net: xfrm: Fix xfrm_address_filter OOB read
Date: Mon, 26 Jun 2023 09:20:57 +0800 (GMT+08:00) [thread overview]
Message-ID: <55aca58a.a2c0e.188f54a2741.Coremail.linma@zju.edu.cn> (raw)
In-Reply-To: <8a80ec0b-154a-4e6c-8fb8-916f506cd26d@p183>
Hello Alexey,
(sorry last mail just reply to one ..)
>
> > + if (filter->splen >= (sizeof(xfrm_address_t) << 3) ||
> > + filter->dplen >= (sizeof(xfrm_address_t) << 3)) {
>
> Please multiply by 8 if you want to multiply by 8.
>
Thanks for reminding.
As I told in the commit message, this checking code is just copy from the function pfkey_dump (net/key/af_key.c), which like
if ((xfilter->sadb_x_filter_splen >=
(sizeof(xfrm_address_t) << 3)) ||
(xfilter->sadb_x_filter_dplen >=
(sizeof(xfrm_address_t) << 3))) {
mutex_unlock(&pfk->dump_lock);
return -EINVAL;
}
I think the left shift 3 is okay as the actual calculation on those lengths is right shift + left shift (see in addr_match() function).
> Should it be "splen > 8 * sizeof()" ?
Good question. It seems that the filter length is legal to reach the maximum length. So should I send another patch that allows the checking code in pfkey_dump (net/key/af_key.c) to change to > instead of >= ?
Regards
Lin
next prev parent reply other threads:[~2023-06-26 1:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-25 14:07 [PATCH v2] net: xfrm: Fix xfrm_address_filter OOB read Alexey Dobriyan
2023-06-26 1:20 ` Lin Ma [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-06-25 13:48 Lin Ma
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=55aca58a.a2c0e.188f54a2741.Coremail.linma@zju.edu.cn \
--to=linma@zju.edu.cn \
--cc=adobriyan@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=simon.horman@corigine.com \
--cc=steffen.klassert@secunet.com \
/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