From: Kees Cook <kees@kernel.org>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Jakub Kicinski <kuba@kernel.org>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH RFC 3/5] rtnetlink: do_setlink: Use sockaddr_storage
Date: Mon, 16 Dec 2024 17:52:31 -0800 [thread overview]
Message-ID: <202412161749.84F7671F3@keescook> (raw)
In-Reply-To: <7a2e5da2-5122-4c73-9a94-20e7f21a26f5@gmail.com>
On Tue, Nov 05, 2024 at 11:59:49AM +0100, Eric Dumazet wrote:
>
> On 11/4/24 11:25 PM, Kees Cook wrote:
> > Instead of a heap allocation use a stack allocated sockaddr_storage to
> > support arbitrary length addr_len value (but bounds check it against the
> > maximum address length).
> >
> > Signed-off-by: Kees Cook <kees@kernel.org>
> > ---
> > net/core/rtnetlink.c | 12 ++++--------
> > 1 file changed, 4 insertions(+), 8 deletions(-)
> >
> > diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> > index f0a520987085..eddd10b74f06 100644
> > --- a/net/core/rtnetlink.c
> > +++ b/net/core/rtnetlink.c
> > @@ -2839,21 +2839,17 @@ static int do_setlink(const struct sk_buff *skb,
> > }
> > if (tb[IFLA_ADDRESS]) {
> > - struct sockaddr *sa;
> > - int len;
> > + struct sockaddr_storage addr;
> > + struct sockaddr *sa = (struct sockaddr *)&addr;
>
> We already use too much stack space.
I'm finally coming back to this. I was over-thinking: this only calls
dev_set_mac_address_user() so it really is a true struct sockaddr.
> Please move addr into struct rtnl_newlink_tbs ?
I couldn't figure out how that was meant to work -- I didn't see a
struct rtnl_newlink_tbs instance near this routine.
Regardless, I can just tweak the length and leave it heap allocated.
-Kees
--
Kees Cook
next prev parent reply other threads:[~2024-12-17 1:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-04 22:25 [PATCH RFC 0/5] sockaddr usage removal Kees Cook
2024-11-04 22:25 ` [PATCH RFC 1/5] Revert "net: dev: Convert sa_data to flexible array in struct sockaddr" Kees Cook
2024-11-04 22:25 ` [PATCH RFC 2/5] net: core: dev.c confirmed to use classic sockaddr Kees Cook
2024-11-04 22:25 ` [PATCH RFC 3/5] rtnetlink: do_setlink: Use sockaddr_storage Kees Cook
2024-11-05 10:59 ` Eric Dumazet
2024-12-17 1:52 ` Kees Cook [this message]
2024-11-04 22:25 ` [PATCH RFC 4/5] net: core: Convert inet_addr_is_any() to sockaddr_storage Kees Cook
2024-11-04 22:25 ` [PATCH RFC 5/5] net: Convert proto_ops::getname " Kees Cook
2024-11-06 1:16 ` [PATCH RFC 0/5] sockaddr usage removal Jakub Kicinski
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=202412161749.84F7671F3@keescook \
--to=kees@kernel.org \
--cc=eric.dumazet@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@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).