From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2390C282CE for ; Mon, 22 Apr 2019 20:09:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B59FB204EC for ; Mon, 22 Apr 2019 20:09:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555963744; bh=oGYkHQNu3BqXyCxRhZmTUV35WhDj7e17QJcfODQ0Egg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=RJZXLwDiE4YES9ziWc4N6xUBQAj/N5TK27IJPpmX+fqNb25vhFw/kEr9PaymSINmx X8auhOxmQbWacE5wiewh9SwMIdcWaUdfS3073zKhkycW7gw+WK447fOxNPxOQvZYKg BwZmEPMiU36tjDRNctXd7CtC0yAu8VhgNAZHFZjc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732487AbfDVUJD (ORCPT ); Mon, 22 Apr 2019 16:09:03 -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: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@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