Message ID | 20191114175209.205382-1-ppenkov.kernel@gmail.com |
---|---|
State | Accepted |
Delegated to: | David Miller |
Headers | show |
Series | [net-next] tun: fix data-race in gro_normal_list() | expand |
On Thu, Nov 14, 2019 at 9:52 AM Petar Penkov <ppenkov.kernel@gmail.com> wrote: > > From: Petar Penkov <ppenkov@google.com> > > There is a race in the TUN driver between napi_busy_loop and > napi_gro_frags. This commit resolves the race by adding the NAPI struct > via netif_tx_napi_add, instead of netif_napi_add, which disables polling > for the NAPI struct. > > KCSAN reported: > BUG: KCSAN: data-race in gro_normal_list.part.0 / napi_busy_loop > Fixes: 943170998b20 ("tun: enable NAPI for TUN/TAP driver") > Signed-off-by: Petar Penkov <ppenkov@google.com> > Reported-by: syzbot <syzkaller@googlegroups.com> > --- Reviewed-by: Eric Dumazet <edumazet@google.com>
From: Petar Penkov <ppenkov.kernel@gmail.com> Date: Thu, 14 Nov 2019 09:52:09 -0800 > From: Petar Penkov <ppenkov@google.com> > > There is a race in the TUN driver between napi_busy_loop and > napi_gro_frags. This commit resolves the race by adding the NAPI struct > via netif_tx_napi_add, instead of netif_napi_add, which disables polling > for the NAPI struct. > > KCSAN reported: > BUG: KCSAN: data-race in gro_normal_list.part.0 / napi_busy_loop ... > Fixes: 943170998b20 ("tun: enable NAPI for TUN/TAP driver") > Signed-off-by: Petar Penkov <ppenkov@google.com> > Reported-by: syzbot <syzkaller@googlegroups.com> Applied.
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index dcb63f1f9110..683d371e6e82 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -313,8 +313,8 @@ static void tun_napi_init(struct tun_struct *tun, struct tun_file *tfile, tfile->napi_enabled = napi_en; tfile->napi_frags_enabled = napi_en && napi_frags; if (napi_en) { - netif_napi_add(tun->dev, &tfile->napi, tun_napi_poll, - NAPI_POLL_WEIGHT); + netif_tx_napi_add(tun->dev, &tfile->napi, tun_napi_poll, + NAPI_POLL_WEIGHT); napi_enable(&tfile->napi); } }