netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: kuba@kernel.org, pablo@netfilter.org, davem@davemloft.net,
	netdev@vger.kernel.org
Subject: Re: [PATCH net 3/3] wireguard: netlink: avoid variable-sized memcpy on sockaddr
Date: Fri, 16 Sep 2022 08:04:01 -0700	[thread overview]
Message-ID: <202209160802.60021AF07@keescook> (raw)
In-Reply-To: <20220916143740.831881-4-Jason@zx2c4.com>

On Fri, Sep 16, 2022 at 03:37:40PM +0100, Jason A. Donenfeld wrote:
> Doing a variable-sized memcpy is slower, and the compiler isn't smart
> enough to turn this into a constant-size assignment.
> 
> Further, Kees' latest fortified memcpy will actually bark, because the
> destination pointer is type sockaddr, not explicitly sockaddr_in or
> sockaddr_in6, so it thinks there's an overflow:
> 
>     memcpy: detected field-spanning write (size 28) of single field
>     "&endpoint.addr" at drivers/net/wireguard/netlink.c:446 (size 16)
> 
> Fix this by just assigning by using explicit casts for each checked
> case.
> 
> Cc: Kees Cook <keescook@chromium.org>
> Fixes: e7096c131e51 ("net: WireGuard secure network tunnel")
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>

Oh, also, please include reporter details:

Reported-by: syzbot+a448cda4dba2dac50de5@syzkaller.appspotmail.com


-- 
Kees Cook

  parent reply	other threads:[~2022-09-16 15:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-16 14:37 [PATCH net 0/3] wireguard patches for 6.0-rc6 Jason A. Donenfeld
2022-09-16 14:37 ` [PATCH net 1/3] wireguard: ratelimiter: disable timings test by default Jason A. Donenfeld
2022-09-16 14:37 ` [PATCH net 2/3] wireguard: selftests: do not install headers on UML Jason A. Donenfeld
2022-09-16 14:37 ` [PATCH net 3/3] wireguard: netlink: avoid variable-sized memcpy on sockaddr Jason A. Donenfeld
2022-09-16 15:02   ` Kees Cook
2022-09-16 15:04   ` Kees Cook [this message]
2022-09-20  1:20 ` [PATCH net 0/3] wireguard patches for 6.0-rc6 Jakub Kicinski
2022-09-20  6:47   ` Jason A. Donenfeld

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=202209160802.60021AF07@keescook \
    --to=keescook@chromium.org \
    --cc=Jason@zx2c4.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pablo@netfilter.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).