From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D873CC31E4B for ; Fri, 14 Jun 2019 12:20:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BB6D120850 for ; Fri, 14 Jun 2019 12:20:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727808AbfFNMUa convert rfc822-to-8bit (ORCPT ); Fri, 14 Jun 2019 08:20:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57746 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727362AbfFNMUa (ORCPT ); Fri, 14 Jun 2019 08:20:30 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5B7C52F8BFD; Fri, 14 Jun 2019 12:20:25 +0000 (UTC) Received: from carbon (ovpn-200-32.brq.redhat.com [10.40.200.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5BF467261; Fri, 14 Jun 2019 12:20:11 +0000 (UTC) Date: Fri, 14 Jun 2019 14:20:09 +0200 From: Jesper Dangaard Brouer To: Toke =?UTF-8?B?SMO4aWxhbmQtSsO4cmdlbnNlbg==?= Cc: Toshiaki Makita , Alexei Starovoitov , Daniel Borkmann , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , netdev@vger.kernel.org, xdp-newbies@vger.kernel.org, bpf@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , David Ahern , brouer@redhat.com Subject: Re: [PATCH bpf 1/3] devmap: Fix premature entry free on destroying map Message-ID: <20190614142009.3922795a@carbon> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 14 Jun 2019 12:20:30 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, 14 Jun 2019 13:04:53 +0200 Toke Høiland-Jørgensen wrote: > 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... One could argue that this is a stable tree fix... which unfortunately will cause some pain for your patch. Or maybe for the maintainers, as this is for 'bpf' git-tree and your patch is for 'bpf-next' git-tree. > [0] https://lore.kernel.org/netdev/156042464148.25684.11881534392137955942.stgit@alrua-x1/ -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer