Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2510251imm; Mon, 24 Sep 2018 05:41:22 -0700 (PDT) X-Google-Smtp-Source: ACcGV63/TthUs+JOr9bbxDUAoJCj3KfmFaH254L8MCQ3uz+jJgt0qfUZ0AZhIapVB9R18TtrkhBU X-Received: by 2002:a63:f043:: with SMTP id s3-v6mr9133607pgj.94.1537792881995; Mon, 24 Sep 2018 05:41:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537792881; cv=none; d=google.com; s=arc-20160816; b=BAkVAweYuaCo07Pwja3NAttxjiWquHPhvu2w1WnC2RYJKtddC2T/XERFgt1JDbAXyg jDOy2xecD/MXVfbuOkfV606/45nQkU5gvSyjMXzE2T9jNvVJvnHV10M3wLBBGinihV7U jLAFiAvKpYwCLJ+t7l1RKosPo0a7VdaUWHGnFra3uW4hHp1QSfOY9idYQZSRXUqe4VhK WTgZpdyALjABplOTEvoG9/tzeuRIqcd1QoXvrKVjbWNvY8MNaDKjudKlSiaMcX6ApvJ6 Y0pfjvJNQ3ZVUftW0wo8ld1A8olU9uVxewgrBq6Opn9r7GADvSkoyXkaRxXbtTEnDxTU ISyg== 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; bh=oIVRSj0+dGrPC4YKbzu8wPm7g1sqi7+yUkTbaUj5Kuc=; b=pfQSx/oLU1YTKo0vsRJXe7VcP/mM4deg7hyi9GSYdsQCJS3dG8QPISqOU2FAf0RLmn V6oHOXbgdgs/LlqZRqsBflG6F3lyizHiCNulREIEp/yk1v944lZhf6Jxp6B+lb/v45zM WAUhef3Cw4fKoNtYcGjsdHmFA9wz70wKlULrbLS7Ty4T+ItYhlrn0MqmSdihl06HjSA5 qLKVOSeX14Hf6kqlIyQorfcTX8YbV4sPjggMzMxo8CPPVx/Pdnh0cV1O4SuvRgPElexk 9849YLXz8pse2HZyWaCyOcDummCqFV+PzXHxaRH2xqYjjp921JcmGBWOFsr/BuM4FSS0 fpnw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11-v6si37484542pfk.165.2018.09.24.05.41.06; Mon, 24 Sep 2018 05:41:21 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388009AbeIXSmE (ORCPT + 99 others); Mon, 24 Sep 2018 14:42:04 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58912 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729165AbeIXSmD (ORCPT ); Mon, 24 Sep 2018 14:42:03 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B1266109A; Mon, 24 Sep 2018 12:40:05 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roman Gushchin , Alexei Starovoitov , Daniel Borkmann , Sasha Levin Subject: [PATCH 4.18 152/235] bpf: fix rcu annotations in compute_effective_progs() Date: Mon, 24 Sep 2018 13:52:18 +0200 Message-Id: <20180924113120.557117770@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Roman Gushchin [ Upstream commit 3960f4fd6585608e8cc285d9665821985494e147 ] The progs local variable in compute_effective_progs() is marked as __rcu, which is not correct. This is a local pointer, which is initialized by bpf_prog_array_alloc(), which also now returns a generic non-rcu pointer. The real rcu-protected pointer is *array (array is a pointer to an RCU-protected pointer), so the assignment should be performed using rcu_assign_pointer(). Fixes: 324bda9e6c5a ("bpf: multi program support for cgroup+bpf") Signed-off-by: Roman Gushchin Cc: Alexei Starovoitov Cc: Daniel Borkmann Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/cgroup.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/kernel/bpf/cgroup.c +++ b/kernel/bpf/cgroup.c @@ -95,7 +95,7 @@ static int compute_effective_progs(struc enum bpf_attach_type type, struct bpf_prog_array __rcu **array) { - struct bpf_prog_array __rcu *progs; + struct bpf_prog_array *progs; struct bpf_prog_list *pl; struct cgroup *p = cgrp; int cnt = 0; @@ -120,13 +120,12 @@ static int compute_effective_progs(struc &p->bpf.progs[type], node) { if (!pl->prog) continue; - rcu_dereference_protected(progs, 1)-> - progs[cnt++] = pl->prog; + progs->progs[cnt++] = pl->prog; } p = cgroup_parent(p); } while (p); - *array = progs; + rcu_assign_pointer(*array, progs); return 0; }