Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2844024yba; Mon, 22 Apr 2019 14:07:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqzot9x6H/ViN1+qMKOAVJwib3CF+8au5zoUWULi4efG2+HkXQENKD6YqJN9URibTm6fDT8l X-Received: by 2002:a63:5953:: with SMTP id j19mr20809953pgm.260.1555967249708; Mon, 22 Apr 2019 14:07:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555967249; cv=none; d=google.com; s=arc-20160816; b=dSEiRSdys/LUZlsw3m/LUcGJAwdPDU13Knx0SUzV8Ho5rdPnQiVzkWOVV1eODH3Ifg iD8VweIEU0R1CE6DnUCT1KMypzbOXMWZT2hFoFnnmXSATqIKzwpdrWVQr3bEonkvOwdr +2r4qBxaV0f2piL9XuUiuMwKYOTEQP91wWnW07xIAVWYofimX7Py9PF6qta7OBgDjH51 /GOzhZmSF40/6FWotw60qHErDxanmLqODmhmqRxZHKnxMGcMLTwpRtjIaWCe3u5tjGlf NO5z8ZQ50oIr4p9E0EM2isT2BGxwfoF3WvVdi+rAJl65EgRVc59pBlHrN5E5xHQMCkzY /yqQ== 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=IOL+2Vs4HQ/bm2bUknwVqfqhREsa4GN4MUXN04RXsA9Erkx7BCw5/HaAsxVxUuStU/ 5/isSNwsInmodlivOXZmHYdzXgRm5EdQ8h2QnLbWSbjwh0aOPwgn8SvwTLVVHUNFpEtS BKlRPU1O5VgHadD2q5wXvjspqCzIJmjNQtiKtjSxaDTNCWj1H5zPTUP9//Mey0JQg59G 8cXazkEk+PJ9lVkGsBVIe+y/w8c8x9SsPhIcqrcmzrFdtO0YqKG3UGVUYRJZQay/OWiW EPihOrQ9rJ6feCICsO/9ZE1uzRvKxBPsoQvKfOTVKE4OkMeTLzOBkB2u+NYSF6tM0iUV VvdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Il6T5jAe; 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 d2si5631020plo.389.2019.04.22.14.07.14; Mon, 22 Apr 2019 14:07:29 -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=Il6T5jAe; 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 S1730049AbfDVTqn (ORCPT + 99 others); Mon, 22 Apr 2019 15:46:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:48958 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730002AbfDVTqj (ORCPT ); Mon, 22 Apr 2019 15:46:39 -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 D1F30218FF; Mon, 22 Apr 2019 19:46:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555962398; bh=oGYkHQNu3BqXyCxRhZmTUV35WhDj7e17QJcfODQ0Egg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Il6T5jAe7RgBz750r9ieR8/S9+n5BJjMtYJrg0j4BfoQebm3+Z+FMIvvumwF/F+R6 Liw7fCk9J5I8kPZPZjxu2cv+ca5RClyb/O+Ur4Y/4DpEfqQpMNMC1tk3kXm8ZsejYB icqKpxU1oVtaSe/eiUCqYnOA3PAVVO/qau4ZQaSU= 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 4.19 36/68] net/sched: don't dereference a->goto_chain to read the chain index Date: Mon, 22 Apr 2019 15:44:44 -0400 Message-Id: <20190422194516.11634-36-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190422194516.11634-1-sashal@kernel.org> References: <20190422194516.11634-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