Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3101617yba; Mon, 22 Apr 2019 20:01:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmnkucyJCDQpdx8JP9571yvjUOAQe9BWy4D0pHrQ3vCu9ogbQKDgOyLwLbf5CTz9KoZcgh X-Received: by 2002:a17:902:a513:: with SMTP id s19mr23361006plq.97.1555988505311; Mon, 22 Apr 2019 20:01:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555988505; cv=none; d=google.com; s=arc-20160816; b=pu4syTlMI15PF6aMsiJkrHALGAYHFN89OXPjlzFHmVNeuiPAA6meRftTAnfHL4QZID 5tlttoyRvb7ZQHPZS7NuHAAicHbkAn52pEWeq6OYEoWNHIJbHQIA/qhh3re5V75pF+qY AaZUwkX097PqCyBg1cllPRd88fKlB5i3txfiFrV53uuWHjGUfLaFcGlzklW1Pfs5JU2C Fj7P48+ZFBRERr8AwL4q213fFZtH5dkuAzZxmyRqHka18pv5qpJuJVxboWGfEbxRsaX1 WL8bf5Mxdn1dCZwIpl9vdefgmanmEMF1dwy3pcxJvLiCOdgZPT6MacNHqdo1mTiOrkIs tLbw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Cfj+qcdQ06XssGT0Rdbq/90FFaEx7szZjmv2gBYLSgw=; b=gH6MsLh0s7SlpYtoFXdYJzIqekW1CvNlnBLoNdwPYKvcuZ+7ouNi8bFrwBBOdiu78J 1DSXs9/UDexemCqrZ8rnA/KWUR9jQweXfHBhduxvczeexEs7HXxknDqW4R8r/Wqfvtwy zwbTizn6ObedfU7MFxrzUoYLaQpMz8GWfNXvWivUfTSU9AwS1ce01pB8ZuOlulXNQo5g 8kBWQqcBiB4dIVRpL4ljoGwJGSfjcKSolsijdbm5LWVsudmovsi6S8idTbZNUYK273Sf 5IOCHNIYriNa1D9JYZGCCOM8yxlB3z01d+DMthI8utQTLeDHoYccWrfV43UovTxr2zOM f7uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=H+3pinFc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j30si14074514pgl.338.2019.04.22.20.01.29; Mon, 22 Apr 2019 20:01:45 -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=H+3pinFc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732491AbfDVUJE (ORCPT + 99 others); Mon, 22 Apr 2019 16:09:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:44388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729244AbfDVTnq (ORCPT ); Mon, 22 Apr 2019 15:43:46 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1CEA8218DA; Mon, 22 Apr 2019 19:43:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555962225; bh=oGYkHQNu3BqXyCxRhZmTUV35WhDj7e17QJcfODQ0Egg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H+3pinFcxvSS8XJl1/HXAkVXAfci2lmG5RDZV1fkyBPyvUe5z/LZSWU1dBsQHQ3UN vXRc5TsUrZWx8ENbsNF01BwjdpsQ3T4M/hnboQiaHqaFJdcoI5nu30HGxen58+mLKM b4eF2ZLz8exCNoPiPjfeC9EUbIejgCoYknRRz5Ms= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Davide Caratti , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 47/98] net/sched: don't dereference a->goto_chain to read the chain index Date: Mon, 22 Apr 2019 15:41:14 -0400 Message-Id: <20190422194205.10404-47-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190422194205.10404-1-sashal@kernel.org> References: <20190422194205.10404-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Davide Caratti [ Upstream commit fe384e2fa36ca084a456fd30558cccc75b4b3fbd ] callers of tcf_gact_goto_chain_index() can potentially read an old value of the chain index, or even dereference a NULL 'goto_chain' pointer, because 'goto_chain' and 'tcfa_action' are read in the traffic path without caring of concurrent write in the control path. The most recent value of chain index can be read also from a->tcfa_action (it's encoded there together with TC_ACT_GOTO_CHAIN bits), so we don't really need to dereference 'goto_chain': just read the chain id from the control action. Fixes: e457d86ada27 ("net: sched: add couple of goto_chain helpers") Signed-off-by: Davide Caratti Signed-off-by: David S. Miller Signed-off-by: Sasha Levin (Microsoft) --- include/net/tc_act/tc_gact.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/tc_act/tc_gact.h b/include/net/tc_act/tc_gact.h index ef8dd0db70ce..56935bf027a7 100644 --- a/include/net/tc_act/tc_gact.h +++ b/include/net/tc_act/tc_gact.h @@ -56,7 +56,7 @@ static inline bool is_tcf_gact_goto_chain(const struct tc_action *a) static inline u32 tcf_gact_goto_chain_index(const struct tc_action *a) { - return a->goto_chain->index; + return READ_ONCE(a->tcfa_action) & TC_ACT_EXT_VAL_MASK; } #endif /* __NET_TC_GACT_H */ -- 2.19.1