From: Eric Dumazet <eric.dumazet@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>, Eric Dumazet <edumazet@google.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, netdev <netdev@vger.kernel.org>,
syzbot <syzkaller@googlegroups.com>,
Mat Martineau <mathew.j.martineau@linux.intel.com>,
Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
Jason Wang <jasowang@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
virtualization@lists.linux-foundation.org
Subject: Re: [PATCH net-next] virtio-net: fix use-after-free in page_to_skb()
Date: Tue, 20 Apr 2021 20:11:49 +0200 [thread overview]
Message-ID: <7f2caba4-cdc1-c45b-6b41-18c9de703349@gmail.com> (raw)
In-Reply-To: <335cc59c-47c4-2781-7146-6c671c2ee62c@roeck-us.net>
On 4/20/21 7:51 PM, Guenter Roeck wrote:
>
> sh does indeed fail, with the same symptoms as before, but so far I was not
> able to track it down to a specific commit. The alpha failure is different,
> though. It is a NULL pointer access.
>
> Anyway, testing ...
>
> The patch below does indeed fix the problem I am seeing on sh.
>
> ... and it does fix the alpha problem as well. Neat, though I don't really understand
> what a NULL pointer access and an unaligned access have to do with each other.
>
> Great catch, thanks!
>
> Guenter
>
Note that build_skb(), without an additional skb_reserve(skb, NET_IP_ALIGN)
can not possibly work on arches that care about alignments.
That is because we can not both align skb->data and skb_shinfo(skb)
So unless we change build_skb() to make sure to align skb_shinfo(),
a fix could be simply :
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 8cd76037c72481200ea3e8429e9fdfec005dad85..9cbe9c1737649450e451e3c65f59f794d1bf34b0 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -415,7 +415,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
shinfo_size = SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
- if (len > GOOD_COPY_LEN && tailroom >= shinfo_size) {
+ if (!_NET_IP_ALIGN && len > GOOD_COPY_LEN && tailroom >= shinfo_size) {
skb = build_skb(p, truesize);
if (unlikely(!skb))
return NULL;
next prev parent reply other threads:[~2021-04-20 18:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-20 9:43 [PATCH net-next] virtio-net: fix use-after-free in page_to_skb() Eric Dumazet
2021-04-20 10:07 ` Michael S. Tsirkin
2021-04-20 13:48 ` Guenter Roeck
2021-04-20 14:00 ` Eric Dumazet
2021-04-20 15:42 ` Guenter Roeck
2021-04-20 16:31 ` Eric Dumazet
2021-04-20 17:51 ` Guenter Roeck
2021-04-20 17:52 ` Eric Dumazet
2021-04-20 18:11 ` Eric Dumazet [this message]
2021-04-21 2:15 ` Jason Wang
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=7f2caba4-cdc1-c45b-6b41-18c9de703349@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jasowang@redhat.com \
--cc=kuba@kernel.org \
--cc=linux@roeck-us.net \
--cc=mathew.j.martineau@linux.intel.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=syzkaller@googlegroups.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=xuanzhuo@linux.alibaba.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;
as well as URLs for NNTP newsgroup(s).