From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-f68.google.com ([209.85.208.68]:34974 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727217AbfFNMKm (ORCPT ); Fri, 14 Jun 2019 08:10:42 -0400 Received: by mail-ed1-f68.google.com with SMTP id p26so3214349edr.2 for ; Fri, 14 Jun 2019 05:10:41 -0700 (PDT) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= Subject: Re: [PATCH bpf 1/3] devmap: Fix premature entry free on destroying map In-Reply-To: <877e9octre.fsf@toke.dk> References: <20190614082015.23336-1-toshiaki.makita1@gmail.com> <20190614082015.23336-2-toshiaki.makita1@gmail.com> <877e9octre.fsf@toke.dk> Date: Fri, 14 Jun 2019 14:10:38 +0200 Message-ID: <87sgscbc5d.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: xdp-newbies-owner@vger.kernel.org List-ID: To: Toshiaki Makita , Alexei Starovoitov , Daniel Borkmann , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend Cc: netdev@vger.kernel.org, xdp-newbies@vger.kernel.org, bpf@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , David Ahern Toke Høiland-Jørgensen writes: > Toshiaki Makita writes: > >> dev_map_free() waits for flush_needed bitmap to be empty in order to >> ensure all flush operations have completed before freeing its entries. >> However the corresponding clear_bit() was called before using the >> entries, so the entries could be used after free. >> >> All access to the entries needs to be done before clearing the bit. >> It seems commit a5e2da6e9787 ("bpf: netdev is never null in >> __dev_map_flush") accidentally changed the clear_bit() and memory access >> order. >> >> Note that the problem happens only in __dev_map_flush(), not in >> dev_map_flush_old(). dev_map_flush_old() is called only after nulling >> out the corresponding netdev_map entry, so dev_map_free() never frees >> the entry thus no such race happens there. >> >> Fixes: a5e2da6e9787 ("bpf: netdev is never null in __dev_map_flush") >> Signed-off-by: Toshiaki Makita > > I recently posted a patch[0] that gets rid of the bitmap entirely, so I > think you can drop this one... Alternatively, since this entire series should probably go to stable, I can respin mine on top of it? -Toke