Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp837593ybi; Fri, 12 Jul 2019 05:29:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwbizxafm7UaMkI3xrG7ifHHHqWMzACxTLHIUprL5k4KqsXkEtAKNgbyauYMG/XwWLKj88A X-Received: by 2002:a63:c84d:: with SMTP id l13mr5311293pgi.154.1562934551611; Fri, 12 Jul 2019 05:29:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562934551; cv=none; d=google.com; s=arc-20160816; b=YGLXC50sFPZkDr3DaiX6c7CSW74nykVjnQLZUP4jrstaiakHZzJHB6L1kZZXEVIIDj Id+qe3xNQeJ8e08YOMq0F4fD1CP2SdjjyBGANUS/pZLWV7HaWxzAhD/Hr5N8pwaIFzG6 h/F5hueSdyXZuaIVuwWiNV2TNZahC2uNtApZr7RVnuK0H7PBwybAxWX2pQHA864mL7gV AgCS8yPAom6jk/HkdIPCklDOSbIkczurscFjgLtfBiGcGOHSswcKHEODzuf99klOG3MT goMy4wzsCNCbnnNib+6NluSkqZdzwexUJWowHQdpZh6Ny+A7wiEz9LQr67UWzPma9pgY hmZA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HgMrIVbLOQnaG3GMtN0Q4gtth7523rpNFGVSKgjV09E=; b=j931th1oHiJ74ZgcJE9YhlPmqHN+QgxGCng9ISheVq+SkO1hKDa5Uig329UCrYW9Wr aqVsAl25yY1DjaEMcAXd63NfXGvnFGX4moswmQU45ZKijDF8XrsCCwcibYjuYnMZeC1C K5ooEqPl/jveiSPAt86XC1uhJkZd6HVv3uPvvrFdQ9qqyGmIE77qLaAARPuIvV4kIXPr 3jL9KOiNIuAaESWQyPlv7koM95HBw3OkTByRTMezUBHT+l4hAzHJ16J7j69Se16ZzzFV bq4C9iGaXQsReM3wPAtgQB3rAfCMjUSEcexr6TTW++uwz4M7hqeZ+KTqS58x1pbs6Wc3 RZ3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ytYPjkzi; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n6si8952493pgs.333.2019.07.12.05.28.56; Fri, 12 Jul 2019 05:29:11 -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; dkim=pass header.i=@kernel.org header.s=default header.b=ytYPjkzi; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728734AbfGLM17 (ORCPT + 99 others); Fri, 12 Jul 2019 08:27:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:41260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728280AbfGLM17 (ORCPT ); Fri, 12 Jul 2019 08:27:59 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BD38B2166E; Fri, 12 Jul 2019 12:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934478; bh=wFSwPxxFbPXkJsMVzLB+pPGVg6RH1cEWGYIaQ/K5+NM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ytYPjkziqZWHRmpXLARIhHb4v2kUG0yRxRSGJFWkCfTxV/b21L1UJUVIQn0WdZ0ZB 1RWXocWN/ucbxBbep898OJisdJxzRwJEkw1EP4ue0bJoBs1JNECrOH5XYMtIj/v6/6 MIW9Y/aa8On1TPxv0xoAM7ICm0cvT3tZp/HIrlQY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Ahern , Toshiaki Makita , Daniel Borkmann , Sasha Levin Subject: [PATCH 5.1 066/138] bpf, devmap: Add missing RCU read lock on flush Date: Fri, 12 Jul 2019 14:18:50 +0200 Message-Id: <20190712121631.204860654@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121628.731888964@linuxfoundation.org> References: <20190712121628.731888964@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 86723c8640633bee4b4588d3c7784ee7a0032f65 ] .ndo_xdp_xmit() assumes it is called under RCU. For example virtio_net uses RCU to detect it has setup the resources for tx. The assumption accidentally broke when introducing bulk queue in devmap. Fixes: 5d053f9da431 ("bpf: devmap prepare xdp frames for bulking") Reported-by: David Ahern Signed-off-by: Toshiaki Makita Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin --- kernel/bpf/devmap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c index a126d95d12de..1defea4b2755 100644 --- a/kernel/bpf/devmap.c +++ b/kernel/bpf/devmap.c @@ -282,6 +282,7 @@ void __dev_map_flush(struct bpf_map *map) unsigned long *bitmap = this_cpu_ptr(dtab->flush_needed); u32 bit; + rcu_read_lock(); for_each_set_bit(bit, bitmap, map->max_entries) { struct bpf_dtab_netdev *dev = READ_ONCE(dtab->netdev_map[bit]); struct xdp_bulk_queue *bq; @@ -297,6 +298,7 @@ void __dev_map_flush(struct bpf_map *map) __clear_bit(bit, bitmap); } + rcu_read_unlock(); } /* rcu_read_lock (from syscall and BPF contexts) ensures that if a delete and/or @@ -389,6 +391,7 @@ static void dev_map_flush_old(struct bpf_dtab_netdev *dev) int cpu; + rcu_read_lock(); for_each_online_cpu(cpu) { bitmap = per_cpu_ptr(dev->dtab->flush_needed, cpu); __clear_bit(dev->bit, bitmap); @@ -396,6 +399,7 @@ static void dev_map_flush_old(struct bpf_dtab_netdev *dev) bq = per_cpu_ptr(dev->bulkq, cpu); bq_xmit_all(dev, bq, XDP_XMIT_FLUSH, false); } + rcu_read_unlock(); } } -- 2.20.1