Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp3982179ybe; Mon, 9 Sep 2019 02:12:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+RpMwJlBkDUn745cu0ccTyHwFXaDUgPGDCYodnk0FUZcUx4PMEDRUTPaKtSD1v9BvCycE X-Received: by 2002:a50:da8e:: with SMTP id q14mr10348288edj.171.1568020372374; Mon, 09 Sep 2019 02:12:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568020372; cv=none; d=google.com; s=arc-20160816; b=V6yjee8l5dGRwkNoj5F0UqSbrzRo5B7QSnoRyYnvHWf4VHexF6gMyHBF1ptekaDsDF 1GyQjuS+zsTLZi6UOgLmiKlHssmyjF1rdAZpfl6qDM+poo70hWgtEttCn8GwhPZjstS7 v0RNw9rKzh+33AaPvrj7PmtN5C2SevaqRPRJgUBnkx/rs1y74CWCODHR7FJmMG1dMoY6 zMta5pRJeLEpY7lEmKaVKEzAGPCQk8baF7vobyOHiobYu33mJUD+p81WMMrKccF7lmx5 qmvxDgRVmiUw0heqU4SqV1ecIxCe7u1FwKyVpKW67CnWJXLhv5XwVJYEjcQKTWd7rOHH Xo3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=qBja7lUfIoEqpNFsue1OnifKI45maVx8a6grsM9imwo=; b=iWpl6o7/KIE+JyHxagEWcwq/dwkRSrTHZ2s1xLqkzfEpYD4UddbhHvwJoqmEM8MXhb gtQtyNuESs1GNLiG5VZ/DImTxxRUmOyiLc/mdhUgVS7CS2e0DobaJfD+CRV6YlaV2N/z wXja07G/d5w/neIHrWsY3R6Mj3G9Fr3aJ7Mw2Yu4F1CtRiw813CUeT6g0VYRxgxNGifS UWWhTS+NtZ95Qhrvdh1IyuecJcESy0AXRRtQ5rXgrmxUkVV2M12HLGzwFaXJX8CFpDK1 UmLB+4DWQWJ4B0nzvnZUzPagsB47pRY14ltgpyZ/4xX6voJjezmOGa98l67pyIdPQ1za y9Bw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l26si9351926edb.258.2019.09.09.02.12.28; Mon, 09 Sep 2019 02:12:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728880AbfIHL2f convert rfc822-to-8bit (ORCPT + 99 others); Sun, 8 Sep 2019 07:28:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48666 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726186AbfIHL2f (ORCPT ); Sun, 8 Sep 2019 07:28:35 -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 B8A8018C891B; Sun, 8 Sep 2019 11:28:34 +0000 (UTC) Received: from carbon (ovpn-200-20.brq.redhat.com [10.40.200.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7786D5C1D4; Sun, 8 Sep 2019 11:28:23 +0000 (UTC) Date: Sun, 8 Sep 2019 13:28:22 +0200 From: Jesper Dangaard Brouer To: Toke =?UTF-8?B?SMO4aWxhbmQtSsO4cmdlbnNlbg==?= Cc: brouer@redhat.com, ast@kernel.org, bpf@vger.kernel.org, daniel@iogearbox.net, davem@davemloft.net, hawk@kernel.org, jakub.kicinski@netronome.com, john.fastabend@gmail.com, kafai@fb.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, songliubraving@fb.com, syzkaller-bugs@googlegroups.com, yhs@fb.com, syzbot+4e7a85b1432052e8d6f8@syzkaller.appspotmail.com Subject: Re: [PATCH bpf-next] xdp: Fix race in dev_map_hash_update_elem() when replacing element Message-ID: <20190908132822.5ac2fbe1@carbon> In-Reply-To: <20190908082016.17214-1-toke@redhat.com> References: <0000000000005091a70591d3e1d9@google.com> <20190908082016.17214-1-toke@redhat.com> 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.6.2 (mx1.redhat.com [10.5.110.70]); Sun, 08 Sep 2019 11:28:35 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 8 Sep 2019 09:20:16 +0100 Toke Høiland-Jørgensen wrote: > syzbot found a crash in dev_map_hash_update_elem(), when replacing an > element with a new one. Jesper correctly identified the cause of the crash > as a race condition between the initial lookup in the map (which is done > before taking the lock), and the removal of the old element. > > Rather than just add a second lookup into the hashmap after taking the > lock, fix this by reworking the function logic to take the lock before the > initial lookup. > > Fixes: 6f9d451ab1a3 ("xdp: Add devmap_hash map type for looking up devices by hashed index") > Reported-and-tested-by: syzbot+4e7a85b1432052e8d6f8@syzkaller.appspotmail.com > Signed-off-by: Toke Høiland-Jørgensen Acked-by: Jesper Dangaard Brouer -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer