From patchwork Tue May 9 14:42:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 98924 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp1857472qge; Tue, 9 May 2017 07:43:21 -0700 (PDT) X-Received: by 10.99.177.8 with SMTP id r8mr505040pgf.109.1494341001208; Tue, 09 May 2017 07:43:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494341001; cv=none; d=google.com; s=arc-20160816; b=nJBwOHXo9qAUaTcCk7v8YpKVVkdZouaurmpQ48uE/ow0+sDFkFoEq792QNUVDQw1jC ekLI17GshZS3mIn3E+SwZ9Kk1+xplYhjxYV5YYNE369JO2RA+9kA9QbjqqpN0poKeX9m JER0OC+yzgDj5+zzPsX3Aviz2QyEmT5TO3oPffvClXd/YX/v2Qz8oMoE/oMDYuzNUssd eYE9H832S8bXrOCtbaSiq55qjURe1ULzRpY28gDhaxuf2pZAZH0hJ2+4BtM5UnToUPeX tHg+Kvs6WHfzAZf1frUXVujy+osXHQCLRYJZVmur44W2MF60k8CJ3LEFBVOxGoQKTngk gMTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Q2ht5CSMUFZ116iMeui79EKUX9FPPcMK2L2gX04aQGs=; b=ZbbnH1jG++HwUpTm34lGTBJWFr6IW677ef5qMk4kG8AqCwfGY+lUiHjYupNRENKsl4 GzmKS1t+3BsqiLydOX7qrrx15WDB9KPPh+uQePcwFy5ktOvlQL0cH5YvFl1qZ18L3VGb Alo9Ry4Jz7GuzxCPQkAv3j60Sd2dtCkMZPc9j9FIxpluHL4qJ2FvFr212qFgvCyJLHfQ wUJS5LS1eHHW61872vj4SxFi48V2ifVD+e1wNZbQdFTp7320J4RhuJ/8L6PsNxshrHfc 44N4PUE+cWYJs/ilINfP+c1awFYZ9uB1cZh7sE04LGvwL0+qBoRxBHIvsB2M94QUxMfR rowg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w34si113540pla.121.2017.05.09.07.43.20; Tue, 09 May 2017 07:43:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754192AbdEIOnU (ORCPT + 6 others); Tue, 9 May 2017 10:43:20 -0400 Received: from mail-pg0-f51.google.com ([74.125.83.51]:36830 "EHLO mail-pg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753957AbdEIOnT (ORCPT ); Tue, 9 May 2017 10:43:19 -0400 Received: by mail-pg0-f51.google.com with SMTP id 64so729093pgb.3 for ; Tue, 09 May 2017 07:43:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Q2ht5CSMUFZ116iMeui79EKUX9FPPcMK2L2gX04aQGs=; b=HiQ/ehLQa76W+AHE/PGs1gD31wx4n4BiEoy5Z9kD0AJngeGBAnd1Nw4v6m+PiDQz3e U22iSQIKUqEzH7Avt6X0px8J0CPaPeOmDXtXqn4TOuB/ZYASjZNuto6XLnX6fT8CQQ9y Vt+dC0ASnSUTshH+tf8auvCO12OH6/pWliEI0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Q2ht5CSMUFZ116iMeui79EKUX9FPPcMK2L2gX04aQGs=; b=YQ5jxHCccOIQNNkSKQKjCl+HRCcEoT9YIxk6/+6yuMpCZiJ01Io2wyzbquh5RLR9uY rhG12bDSdtT9oD6bnOsGkciOxWyF85X/HAPLjmxAKOQPt7WGzHgYASY7t6559/GRQiED lBoDOyf0eddK8MtQBUj76CQ4LWxk3bd22niJ6reDAK7xYxOCvs7HyNE41oIe+ljkdtXL W484/alb7Mm8kLsn8o5c4RbzNn6fCy1lpmSPS85pSnOyh6ca+dSHd0Is2vrnyACeYcks UZWmH8iNGWb3NDmql6LSe7RODjNqZ9mSaKKNzeg0WSYFCprqqqVGFR2cro9EDKM9oD1k M7jQ== X-Gm-Message-State: AODbwcBm42YYD/T9oY/xRvYwwdlDiZ4A3fOokHo6/Xtv52THcm7oKYGj Eeq83JmEpLvlguuy X-Received: by 10.99.139.195 with SMTP id j186mr550947pge.134.1494340999189; Tue, 09 May 2017 07:43:19 -0700 (PDT) Received: from localhost.localdomain ([106.51.135.126]) by smtp.gmail.com with ESMTPSA id 11sm341811pfj.59.2017.05.09.07.43.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 May 2017 07:43:18 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: stable@vger.kernel.org, Eric Dumazet , "David S . Miller" Subject: [PATCH for-3.18 11/24] ipv6: sctp: add rcu protection around np->opt Date: Tue, 9 May 2017 20:12:35 +0530 Message-Id: <1494340968-17152-12-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494340968-17152-1-git-send-email-amit.pundir@linaro.org> References: <1494340968-17152-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Eric Dumazet commit c836a8ba93869d6a0290a6ae0047fbef09066871 upstream. This patch completes the work I did in commit 45f6fad84cc3 ("ipv6: add complete rcu protection around np->opt"), as I missed sctp part. This simply makes sure np->opt is used with proper RCU locking and accessors. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Amit Pundir --- net/sctp/ipv6.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index 18361cbfc882..15bc2886a529 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c @@ -209,6 +209,7 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport) struct sock *sk = skb->sk; struct ipv6_pinfo *np = inet6_sk(sk); struct flowi6 *fl6 = &transport->fl.u.ip6; + int res; pr_debug("%s: skb:%p, len:%d, src:%pI6 dst:%pI6\n", __func__, skb, skb->len, &fl6->saddr, &fl6->daddr); @@ -220,7 +221,10 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport) SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS); - return ip6_xmit(sk, skb, fl6, np->opt, np->tclass); + rcu_read_lock(); + res = ip6_xmit(sk, skb, fl6, rcu_dereference(np->opt), np->tclass); + rcu_read_unlock(); + return res; } /* Returns the dst cache entry for the given source and destination ip @@ -262,7 +266,10 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr, pr_debug("src=%pI6 - ", &fl6->saddr); } - final_p = fl6_update_dst(fl6, np->opt, &final); + rcu_read_lock(); + final_p = fl6_update_dst(fl6, rcu_dereference(np->opt), &final); + rcu_read_unlock(); + dst = ip6_dst_lookup_flow(sk, fl6, final_p); if (!asoc || saddr) goto out; @@ -321,7 +328,7 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr, if (baddr) { fl6->saddr = baddr->v6.sin6_addr; fl6->fl6_sport = baddr->v6.sin6_port; - final_p = fl6_update_dst(fl6, np->opt, &final); + final_p = fl6_update_dst(fl6, rcu_dereference(np->opt), &final); dst = ip6_dst_lookup_flow(sk, fl6, final_p); }