Received: by 10.223.176.5 with SMTP id f5csp724439wra; Fri, 9 Feb 2018 06:15:50 -0800 (PST) X-Google-Smtp-Source: AH8x226/7VZo22WaLUZ0W1hVU35MG5Tz2zE/uYLfsZCZnDIA7/zA8HoHINettz4KOWZsokzqzaiK X-Received: by 2002:a17:902:507:: with SMTP id 7-v6mr2717593plf.0.1518185750591; Fri, 09 Feb 2018 06:15:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518185750; cv=none; d=google.com; s=arc-20160816; b=0Au7bHlByXB65Oxyw8Va5iC6PhdvglqTe2Z3taT8h4GP6/rWJOQw358JPrAFIiMmp2 nH14loQebAOYKz6v5NTYbGXoSAUtwLIrGByAAumag7c/GrgoEDc3BlLjWPIg0YAd+8DS svFO6kCEeJ/VjiZRGHueOFvGR7CTlbSJqaAShW15G5jlkKNzr8dQIoaN/7cCQxYaK3yA HbV+22FvAteh6pYus4fyrACcL8wGO0jQq2ddwbxde1KUkiK0NaMf0+v3cQcWMwzvOO4K xkJzWr6cRsfH13AcpeHxuA0+vG264WReaFWyo8DS0z9khbldUqMPzFErrZq42G9h8HZ7 pixA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=PNhWg+vjSSythD4h3xXKO1HSoPGLeFCa2YOrVFFxaIg=; b=lZEC4EbCjBn2pDL3IP+RdGX3I0OCB9n9DOlD4SAq+DFqDdOTq9HArN4MYFTCEtwAk6 PsGMAieB8wvzGzu3auebrEHabxOAx39xdYQd4rqza0ss3aWZpiGna/7ZqiL/EOCXmqg8 nM92R5OlV3rt5nphuR+jbfXxAZNSxJ++KsXojNqHthtP5Ll4Yq6BOTB5p7fYCTImbu2T ahXFzDYRkautG794mRIAeSGjCg4rt23TygYRKj16blwFLoTUhHYPmjiGRmw5rnjosLx9 4DTonCI6x+7OEPrYFlcxx97DXJpBaNcS39sxT2W/vwY68eoWQj+lqRp4ciJOAd72QBU6 R2pg== 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 t25si1375907pge.368.2018.02.09.06.15.36; Fri, 09 Feb 2018 06:15:50 -0800 (PST) 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 S1752745AbeBIOOV (ORCPT + 99 others); Fri, 9 Feb 2018 09:14:21 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:48716 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752497AbeBINlZ (ORCPT ); Fri, 9 Feb 2018 08:41:25 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A19B2BFF; Fri, 9 Feb 2018 13:41:24 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Abeni , Cong Wang , "David S. Miller" Subject: [PATCH 4.9 27/92] cls_u32: add missing RCU annotation. Date: Fri, 9 Feb 2018 14:38:56 +0100 Message-Id: <20180209133933.184130086@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180209133931.211869118@linuxfoundation.org> References: <20180209133931.211869118@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paolo Abeni [ Upstream commit 058a6c033488494a6b1477b05fe8e1a16e344462 ] In a couple of points of the control path, n->ht_down is currently accessed without the required RCU annotation. The accesses are safe, but sparse complaints. Since we already held the rtnl lock, let use rtnl_dereference(). Fixes: a1b7c5fd7fe9 ("net: sched: add cls_u32 offload hooks for netdevs") Fixes: de5df63228fc ("net: sched: cls_u32 changes to knode must appear atomic to readers") Signed-off-by: Paolo Abeni Acked-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sched/cls_u32.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -496,6 +496,7 @@ static void u32_clear_hw_hnode(struct tc static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n, u32 flags) { + struct tc_u_hnode *ht = rtnl_dereference(n->ht_down); struct net_device *dev = tp->q->dev_queue->dev; struct tc_cls_u32_offload u32_offload = {0}; struct tc_to_netdev offload; @@ -520,7 +521,7 @@ static int u32_replace_hw_knode(struct t offload.cls_u32->knode.sel = &n->sel; offload.cls_u32->knode.exts = &n->exts; if (n->ht_down) - offload.cls_u32->knode.link_handle = n->ht_down->handle; + offload.cls_u32->knode.link_handle = ht->handle; err = dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, tp->protocol, &offload); @@ -788,8 +789,9 @@ static void u32_replace_knode(struct tcf static struct tc_u_knode *u32_init_knode(struct tcf_proto *tp, struct tc_u_knode *n) { - struct tc_u_knode *new; + struct tc_u_hnode *ht = rtnl_dereference(n->ht_down); struct tc_u32_sel *s = &n->sel; + struct tc_u_knode *new; new = kzalloc(sizeof(*n) + s->nkeys*sizeof(struct tc_u32_key), GFP_KERNEL); @@ -807,11 +809,11 @@ static struct tc_u_knode *u32_init_knode new->fshift = n->fshift; new->res = n->res; new->flags = n->flags; - RCU_INIT_POINTER(new->ht_down, n->ht_down); + RCU_INIT_POINTER(new->ht_down, ht); /* bump reference count as long as we hold pointer to structure */ - if (new->ht_down) - new->ht_down->refcnt++; + if (ht) + ht->refcnt++; #ifdef CONFIG_CLS_U32_PERF /* Statistics may be incremented by readers during update