Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6271054imu; Mon, 21 Jan 2019 06:09:55 -0800 (PST) X-Google-Smtp-Source: ALg8bN7qUsBY4GS3EVFfIhxHL23AartTPd9k3w3oKAM3yCJbFJRPh1AZ0Z9DPBR5mV86if925yD2 X-Received: by 2002:a65:4646:: with SMTP id k6mr23281120pgr.153.1548079795154; Mon, 21 Jan 2019 06:09:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548079795; cv=none; d=google.com; s=arc-20160816; b=POfdGZAXq4Ad0ZUZpaYxvcZ3//UEnFvLyX2riiIE2vJlK7PT6CgqGKPNmRBW8syiky cyVFvnICZU6QmO0BGvQJ9bbMnMh5w6bIz9kR+84piwsA4s5JjsuDWMvs17JIVkFIC2a8 Xz/no5EPdXGK4cQ/kgyfOpVi2/I6aEild3gf4jzpQLPas4DB4G2nTjNGHdd/+dV8Fr5Y qv/4kv9Lxv+kiB6vfnV98jUY0xs+2Gj/zJuvniwFpQFUITJby+DJK+wuK0ABfYKK2cyv T8w7pWIXJWgODHz0b5rRFtEyPiU445YpPg+vB7Bagi0H5IOciMKIGO1YesQE2JAh/WYi tvlg== 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=akIMvU5tZKsUX2ZpQNUF02Vqk3VXzyU8fvY63z7k00g=; b=BO9Ad6wURtKXcd+6t9GGeAHK1Tiw3nIPWxAFXrRfLUqIW271zcJXYDPKW3oBX8qmVK RZTpqZCq0MKXemq3HnkqTYRQ/Qw4CzSDTR0nIqtmuHpD4hdjvHRYlUf26n1vEVegipmP MMBZGo29HfI9PE9rP663OKJWkD+BgNAJ7rm3PRPb6JX5DwdmAF4eDFqe0WuJCyj1ZDHf E1DGzAFOQUadraESsWGV9L9/hv68F+gkOE6vx7sB0BXZw3f0ZdJsKJHGUrJWQPVwSxow IL7JO1TF+wzbkWH9/UiQEA5jH1ZfG3lz6yhWqJDFvIWYDE1LrSM4mrUpsVI4tk1g9Oz3 z9AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VigK2BCS; 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 e8si715546pgn.325.2019.01.21.06.09.39; Mon, 21 Jan 2019 06:09:55 -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; dkim=pass header.i=@kernel.org header.s=default header.b=VigK2BCS; 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 S1732116AbfAUN7B (ORCPT + 99 others); Mon, 21 Jan 2019 08:59:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:44788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732101AbfAUN66 (ORCPT ); Mon, 21 Jan 2019 08:58:58 -0500 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 184F02084C; Mon, 21 Jan 2019 13:58:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548079137; bh=hD8guslAjE26GdE0K9YvJPRDwpw6LMCAA6eG+APF6MQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VigK2BCSBmfPXPvTHf7S+fjEB+4rrn3JGNk249VOIcRI9ZPVJ7pM5lB84UlpopFGN bGYSU8yk5Xk2cVmwbWju2QaaqtReqSMwst5wdRLBEESTJVSESDwNeKNQArnXQA7UEB EwWeTE0wknDlHLajy9ZEqzaj0Mnibe/qwfDUe7z4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, JianJhen Chen , JinLin Chen , "David S. Miller" Subject: [PATCH 4.19 21/99] net: bridge: fix a bug on using a neighbour cache entry without checking its state Date: Mon, 21 Jan 2019 14:48:13 +0100 Message-Id: <20190121134914.714915835@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121134913.924726465@linuxfoundation.org> References: <20190121134913.924726465@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: JianJhen Chen [ Upstream commit 4c84edc11b76590859b1e45dd676074c59602dc4 ] When handling DNAT'ed packets on a bridge device, the neighbour cache entry from lookup was used without checking its state. It means that a cache entry in the NUD_STALE state will be used directly instead of entering the NUD_DELAY state to confirm the reachability of the neighbor. This problem becomes worse after commit 2724680bceee ("neigh: Keep neighbour cache entries if number of them is small enough."), since all neighbour cache entries in the NUD_STALE state will be kept in the neighbour table as long as the number of cache entries does not exceed the value specified in gc_thresh1. This commit validates the state of a neighbour cache entry before using the entry. Signed-off-by: JianJhen Chen Reviewed-by: JinLin Chen Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/bridge/br_netfilter_hooks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/bridge/br_netfilter_hooks.c +++ b/net/bridge/br_netfilter_hooks.c @@ -278,7 +278,7 @@ int br_nf_pre_routing_finish_bridge(stru struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb); int ret; - if (neigh->hh.hh_len) { + if ((neigh->nud_state & NUD_CONNECTED) && neigh->hh.hh_len) { neigh_hh_bridge(&neigh->hh, skb); skb->dev = nf_bridge->physindev; ret = br_handle_frame_finish(net, sk, skb);