Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2455509imd; Fri, 2 Nov 2018 11:42:07 -0700 (PDT) X-Google-Smtp-Source: AJdET5foZr8GmTGRWELl/Lr19G3wzY1qzV4fJs2g3USTdr4Foc4C5iWi7Y9lXo/GvKfDiVIP/mqe X-Received: by 2002:a62:34c5:: with SMTP id b188-v6mr13257513pfa.65.1541184127767; Fri, 02 Nov 2018 11:42:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541184127; cv=none; d=google.com; s=arc-20160816; b=ZcroBeqr6V6SD7Gu876tJAB3b1lAdHm6nIlwbJM1PmGHaCiq5ZobX47dBezR7kmSzC xVEt0woiQ9HsKdFRtxYiC05ElKhJ4fKRBRNkHW8mLkzw68FBS1U0ODAHggUjD0egigpa o1vyIP5mlnB2OfB/TZVNtSPbZj30DQTwxb3JwWNgcH+Ah6TLYkytsfJBEyUbK2EhHyLf g1kvXb7DAU+wIJSfOjzlrKhk5h/W5UafiCkPWvY+sARtJ50AjSc9NH6iC3V3evUjdecd u6Tqx5TrXQ1EBfLhcSXFSdEHRg2hplyL+sbTWYdCfAom9oNdSpjVqH2e7S71wwEkY9Rf u0uw== 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:dkim-signature; bh=HQrilRxCO6iY1qrFDYco2cq7F+3AnwQziKf48HJ2YYk=; b=PLhnUptUyywFsOFs+K3+CqmUGzZpqW2KEhkt4Qu0WLprbs9CaBjtG+ySFnCS3Pku5b zAoO0RHwTBM30jf3ti0pP/7fEM+8rrcRaOrSueYfenvdU26O7iSC9vshjoeMjro6SXO7 NDjLa/lcxpbhAWMQg5aptFfhTpWxVMlzEfJ6fgdC1S6QprVgtVEZaEVawjiOEbyBH8a/ wpeXHX/Tk5IUp4suhD+GKG2cL3MmSGobr8TzhO30qJfOOhkIf0lYeDQJ8C0pL8GWJzss lTmuGwIIn5WOvQhhf8oX+1aMQZ7bB1V6lLap+glfAml/TLIOoa06Iv9keJEy3B9f4zvL j8zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B8sww7uC; 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 z126-v6si12978867pfb.280.2018.11.02.11.41.53; Fri, 02 Nov 2018 11:42:07 -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; dkim=pass header.i=@kernel.org header.s=default header.b=B8sww7uC; 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 S1729209AbeKCDrx (ORCPT + 99 others); Fri, 2 Nov 2018 23:47:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:42076 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729198AbeKCDrx (ORCPT ); Fri, 2 Nov 2018 23:47:53 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 038732082E; Fri, 2 Nov 2018 18:39:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541183981; bh=+FiNWyYf+rWcL2H52QxCfIoU/t7oH4HWlvEJrDjvMCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B8sww7uCVP3YYIDpuk32LNjl9Epirlk2j9TqyU+YbJgnGTbdYTmqtTZmRbG3nR0cW ZxpelAsz0png0fNtFuXtit8hWRRMgV+ZbrDTWM77AyRjkYtCcI/apaGloswHptwVV4 mP2O+pGAjJ2ZRk3hVTo3IxgC+gWxFcwDb0FCx+UE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Ahern , Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.18 041/150] netfilter: avoid erronous array bounds warning Date: Fri, 2 Nov 2018 19:33:23 +0100 Message-Id: <20181102182906.232620214@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102182902.250560510@linuxfoundation.org> References: <20181102182902.250560510@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. ------------------ [ Upstream commit 421c119f558761556afca6a62ad183bc2d8659e0 ] Unfortunately some versions of gcc emit following warning: $ make net/xfrm/xfrm_output.o linux/compiler.h:252:20: warning: array subscript is above array bounds [-Warray-bounds] hook_head = rcu_dereference(net->nf.hooks_arp[hook]); ^~~~~~~~~~~~~~~~~~~~~ xfrm_output_resume passes skb_dst(skb)->ops->family as its 'pf' arg so compiler can't know that we'll never access hooks_arp[]. (NFPROTO_IPV4 or NFPROTO_IPV6 are only possible cases). Avoid this by adding an explicit WARN_ON_ONCE() check. This patch has no effect if the family is a compile-time constant as gcc will remove the switch() construct entirely. Reported-by: David Ahern Signed-off-by: Florian Westphal Reviewed-by: David Ahern Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- include/linux/netfilter.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h index dd2052f0efb7..11b7b8ab0696 100644 --- a/include/linux/netfilter.h +++ b/include/linux/netfilter.h @@ -215,6 +215,8 @@ static inline int nf_hook(u_int8_t pf, unsigned int hook, struct net *net, break; case NFPROTO_ARP: #ifdef CONFIG_NETFILTER_FAMILY_ARP + if (WARN_ON_ONCE(hook >= ARRAY_SIZE(net->nf.hooks_arp))) + break; hook_head = rcu_dereference(net->nf.hooks_arp[hook]); #endif break; -- 2.17.1