Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3115704pxa; Sat, 8 Aug 2020 10:08:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyntyKj3ANHmBNc5t5rKu/t8jyg0G0Biad2tRbmjJp2WCe1L/zY8wtmDi3QhK/VwDoLD65 X-Received: by 2002:a17:906:64d7:: with SMTP id p23mr14401016ejn.185.1596906491836; Sat, 08 Aug 2020 10:08:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596906491; cv=none; d=google.com; s=arc-20160816; b=fPiZHVLJz2vOPuWT+g4qIPVe71q7v4D5rkhIpUfJkBNrKKh4/p7mVx858Rset0rubC BYSEvJGCfWSJ93zVcQ9rCf020Bno2Mvqh2pU/XZw5a2U7GLseRingNvhC1d8PGOH4uZ3 woaeT4m2qjKjN3x+61zeyLWwBOhfEAllASrveTtO6zED2PfAmBMlS/tori7oPGx5s4HH EAfbP8sxentAzsZZ9WlG6zP5s9ykTxGnEGDFnF8Sp7CIJukvgXnvu5mT100DO5YctmeD 212GcWJGiaLy3Pf7ZOr8gpraxF9mOMR1beS8q7QhPWnnUKY6HRUrWw9ALJ69zA93WP0X VFvg== 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:to:from:dkim-signature; bh=sxTuf0IwgAfwzDYXePIrkVVlcrBM8hU9HVtBsgATuy8=; b=I2jBziGgyNd+NapoLvp5rV955fbt3V8njkVHkbBmfvGk3t4BSAmfNP58AVlT8TT8tI rCL2PVfIaVb19k5G/WXn3RvQw/Ru6uW5uUi9ciTmv/Nd7CDS0Br9UV6rghVoVnY5DolJ NbGkLFAJu9flpf80X/nnXKQiVKt9FwGsakSraeMlMWWFnpc4Qh4bG4LPbpatsRNEgsOA MgZpz+Mj2gL1RV2Xwq2dmPXZwJV46Noj5cG+lRmXmQSXkdXWHf/l2S2cdMqBc98y03RR PkHMtd8bvpKqRgsXNjYJLnXVp9yHirtco2wfi0EDckvvwx/mz3CIMg5FvhwlRCAKzSlX wXjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dhTy8dLQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n22si7559722eds.472.2020.08.08.10.07.45; Sat, 08 Aug 2020 10:08:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dhTy8dLQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726382AbgHHRHC (ORCPT + 99 others); Sat, 8 Aug 2020 13:07:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbgHHRHB (ORCPT ); Sat, 8 Aug 2020 13:07:01 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EECEFC061756; Sat, 8 Aug 2020 10:07:00 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id e5so3709842qth.5; Sat, 08 Aug 2020 10:07:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=sxTuf0IwgAfwzDYXePIrkVVlcrBM8hU9HVtBsgATuy8=; b=dhTy8dLQSMXrCeaq0dZX4wB66oJi9+P+V5oHbuB3Tg1+SD5/ewJt5zV5lQ7VvOTJqM MUt3C+GP+rTpb96vlDVxJrCXtwRHUYi6zTbx3ej0ZullUbRgtY+rTfmBUo/YKq4SZmAG y1990eSK4iBV3WB5m7d9SJV+En7CehL4hv47nSvz3rAUfBZeVTcIxQFTk/EZ50xvivGX h4M+9Wm14nQQ7ZtOgZwMoIuOx7XCjs4DVq5TdOyCsdvVElPR0U703fu2mUsmRQCfS4Hn EjM2hOOTjeFDvnM46Nj3VsfrjnYIjql6EHdnAyWbyR87r09Vxs3UWGlozt21wssQamZr lt7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=sxTuf0IwgAfwzDYXePIrkVVlcrBM8hU9HVtBsgATuy8=; b=P7QZ+zhCo6iH2AYxYWL75pOjCiXo0SdQHnnBmPl0c3fDe9e06MxEW6n10C3E1hNOkz oLcx6NwMd6tpLUPg8SwqbZI0g1BeSmGhGz2vXS9f4gFQYL88xH1nxexztvwbONYfnxBX iitfO1j7tEoeO5YhM4oLqLUWZrRxRvqjIMnYqtZReSK3VTxMI0IR7aKdC+a+HQN5qZHP qGY8/LTUOzx3nzFMw+JRQV8qCpDIzhfGBZfQWnnb0mv//Cyt2pT6pqei6SJySwMtGqrR +FkBE9gNM5xLECWodVlT7+yB7pkcvGoqeQmFmBTBJZBFziJ+AM162rB4ZaS5cZeY2kD7 NgQg== X-Gm-Message-State: AOAM532xbaCjMlE1BhC94cab/sSAvEKLJ41IzFg3ucLGkaNEa3SuaBlF JiMiiU7prkHSDv91Pvhu64y/nywEXyOJJQ== X-Received: by 2002:ac8:7455:: with SMTP id h21mr19833129qtr.201.1596906420079; Sat, 08 Aug 2020 10:07:00 -0700 (PDT) Received: from linux.home ([2604:2000:1344:41d:d81:1efe:2043:bb12]) by smtp.googlemail.com with ESMTPSA id m15sm11432122qta.6.2020.08.08.10.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Aug 2020 10:06:59 -0700 (PDT) From: Gaurav Singh To: gaurav1086@gmail.com, "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Jakub Kicinski , Shaohua Li , netdev@vger.kernel.org (open list:NETWORKING [IPv4/IPv6]), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] [net/ipv6] ip6_output: Add ipv6_pinfo null check Date: Sat, 8 Aug 2020 13:06:52 -0400 Message-Id: <20200808170653.8515-1-gaurav1086@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200728021348.4116-1-gaurav1086@gmail.com> References: <20200728021348.4116-1-gaurav1086@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This PR fixes a possible segmentation violation. In function: ip6_xmit(), we have const struct ipv6_pinfo *np = inet6_sk(sk); which returns NULL unconditionally (regardless sk being NULL or not). In include/linux/ipv6.h: static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk) { return NULL; } Further down the function, there's a check: if (np) hlimit = hp->htop_limit Thereafter, we have a call ip6_flow_hdr(hdr, tclass, ip6_make_flowlabel(net, skb, fl6->flowlabel, ip6_autoflowlabel(net, np), fl6)); Hence np = NULL gets passed in the function ip6_autoflowlabel() that accesses np without check which may cause a segment violation. Fixes: 513674b5a2c9c ("net: reevalulate autoflowlabel setting after sysctl setting") Signed-off-by: Gaurav Singh --- net/ipv6/ip6_output.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 8a8c2d0cfcc8..94a07c9bd925 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -181,10 +181,10 @@ int ip6_output(struct net *net, struct sock *sk, struct sk_buff *skb) bool ip6_autoflowlabel(struct net *net, const struct ipv6_pinfo *np) { - if (!np->autoflowlabel_set) - return ip6_default_np_autolabel(net); - else + if (np && np->autoflowlabel_set) return np->autoflowlabel; + else + return ip6_default_np_autolabel(net); } /* -- 2.17.1