Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1087504ybl; Wed, 21 Aug 2019 09:57:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqwt80X75vWLd1kjYyZhkUxYcD0SFb5N/v50tYMMgwO9p+c08X3ICrxJiiMjCaOj4DCfCaY3 X-Received: by 2002:a17:902:bb0d:: with SMTP id l13mr3994138pls.176.1566406639444; Wed, 21 Aug 2019 09:57:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566406639; cv=none; d=google.com; s=arc-20160816; b=vD4ZsE2WqiuGxa5bOHbXmbHn/Xb9o4IqZ2+EBaFRPmXJM+xDrVeMpBrsTKsWQEaAKh GPxxhIXI1QBrjI4/4q6v8JOVjWJ7BqazUZU3iuYPKvug3PLsuY1XDMrASsQHVvxrCEB3 RMk5FcTe8l4EzMsFlnbvNzQW2Dsx6x7XN6qc7Ih0JH7/azXxl48bn3yKXrYFYNXCOhel tHrbStNxcqzWWGmaQz1AkEfx1YRorc7ThNmOAWFlPt4+jNJcoYMoc2xYhM9Lr0c+Xhds emKgjUbfmN8ENxoHOd37dKS/7MukSrQyDSBl+s1Tc+Nd1t7mW+6Q7MvXc/KUfiacSTbq 5/QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:date:subject:cc:to:from; bh=pPQ3s9GsP0R72khXr/ztVBH0K74AU3YKrv0rrfx8ci4=; b=zv/KNFhiZaG8Z14CTtJFE5lYzXfad8x/KSChDcyC2EAF1trGIJWhdAKQ5/bacwuUvu jNtvt/DRRYiaUmOnbT1HdSCXSYlE1C7mzrDwzAOq/s84nbGxzWMGhc3yB51iJmwFafL6 k9wpfztQDmsH5ZAnATNvRHrOjKh/1onBy5zQF8urfYO+T5+Va6NKCznFrgxJ4Y1JRx+8 zWHBml8gl4kokBsozvMVKxwN9MDRhG1WVK2qZLbQENWR+cU51ck1GnA11fYt9kzF8ADQ qA73WOoUkkiK6jYWGQKAuCgbhl8wlU2pL67fRDz/09q/pmRBnKt8oPCvpivvri/31fq5 xT9w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f128si14611386pgc.55.2019.08.21.09.57.04; Wed, 21 Aug 2019 09:57:19 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729130AbfHUOQR (ORCPT + 99 others); Wed, 21 Aug 2019 10:16:17 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:20738 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728923AbfHUOQQ (ORCPT ); Wed, 21 Aug 2019 10:16:16 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x7LECqZs124985 for ; Wed, 21 Aug 2019 10:16:15 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0a-001b2d01.pphosted.com with ESMTP id 2uh5pnwmt1-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 21 Aug 2019 10:16:15 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 21 Aug 2019 15:16:14 +0100 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 21 Aug 2019 15:16:11 +0100 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x7LEGAlr39977240 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:16:10 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BFEC4AC064; Wed, 21 Aug 2019 14:16:10 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 724A6AC05F; Wed, 21 Aug 2019 14:16:07 +0000 (GMT) Received: from LeoBras.ibmuc.com (unknown [9.85.171.79]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 21 Aug 2019 14:16:07 +0000 (GMT) From: Leonardo Bras To: netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Leonardo Bras , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI Subject: [PATCH v2 1/1] netfilter: nf_tables: fib: Drop IPV6 packages if IPv6 is disabled on boot Date: Wed, 21 Aug 2019 11:15:06 -0300 X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19082114-0072-0000-0000-000004541531 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011629; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01250020; UDB=6.00659932; IPR=6.01031574; MB=3.00028261; MTD=3.00000008; XFM=3.00000015; UTC=2019-08-21 14:16:14 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19082114-0073-0000-0000-00004CC5379D Message-Id: <20190821141505.2394-1-leonardo@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-21_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210156 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If IPv6 is disabled on boot (ipv6.disable=1), but nft_fib_inet ends up dealing with a IPv6 package, it causes a kernel panic in fib6_node_lookup_1(), crashing in bad_page_fault. The panic is caused by trying to deference a very low address (0x38 in ppc64le), due to ipv6.fib6_main_tbl = NULL. BUG: Kernel NULL pointer dereference at 0x00000038 Fix this behavior by dropping IPv6 packages if !ipv6_mod_enabled(). Signed-off-by: Leonardo Bras --- Changes from v1: - Move drop logic from nft_fib_inet_eval() to nft_fib6_eval{,_type} so it can affect other usages of these functions. net/ipv6/netfilter/nft_fib_ipv6.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/net/ipv6/netfilter/nft_fib_ipv6.c b/net/ipv6/netfilter/nft_fib_ipv6.c index 7ece86afd079..75acc417e2ff 100644 --- a/net/ipv6/netfilter/nft_fib_ipv6.c +++ b/net/ipv6/netfilter/nft_fib_ipv6.c @@ -125,6 +125,11 @@ void nft_fib6_eval_type(const struct nft_expr *expr, struct nft_regs *regs, u32 *dest = ®s->data[priv->dreg]; struct ipv6hdr *iph, _iph; + if (!ipv6_mod_enabled()) { + regs->verdict.code = NF_DROP; + return; + } + iph = skb_header_pointer(pkt->skb, noff, sizeof(_iph), &_iph); if (!iph) { regs->verdict.code = NFT_BREAK; @@ -150,6 +155,11 @@ void nft_fib6_eval(const struct nft_expr *expr, struct nft_regs *regs, struct rt6_info *rt; int lookup_flags; + if (!ipv6_mod_enabled()) { + regs->verdict.code = NF_DROP; + return; + } + if (priv->flags & NFTA_FIB_F_IIF) oif = nft_in(pkt); else if (priv->flags & NFTA_FIB_F_OIF) -- 2.20.1