Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp7371404yba; Thu, 2 May 2019 08:45:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgwwSc5XDdisCLgmq46EB0jg4+Nh9IHVDsd2jLqO6aTYCOJy+5j/HhNJJITZPSG+t3xmi1 X-Received: by 2002:a62:5795:: with SMTP id i21mr5056612pfj.194.1556811911720; Thu, 02 May 2019 08:45:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556811911; cv=none; d=google.com; s=arc-20160816; b=x41gGlU3FC27ZS3edGBmnn0WAh0E1laCXr8BjDmHhOsUV+ncZUiMHeSrqq78jF/1C8 HszPF6p+uAGof8mjf3GkzZVRbyDosJcEOajg0VzlYtk9zuraqW8m+Uy2enEM65ucsf9i MJAizKRBmc5nV/lqt4BAjS/5Uzu7r+s7UqNMYYSCqfApJVeEQiuftNVEn2pmG7IBXmQ+ 98WArRcEtxOnCTulBVFDwuyAJieBpSB4FwEYczVXsjOLBbDLLnOwXpltQm47u6P/ij8h bZKeMnca2lU4aD6N+8VuEMzZiF/cQIjVM9pi1rIEtOgxcvJqtKgT8YstpyZzs8Ow7KC6 5y+w== 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=N5AZkzvKuO9ogNheRcHS/UcP6ufLF9Uie9X++DDzKpo=; b=VtoWqdc2Le56zNVMiUBHLAyDiVkPdBagI+z4rbNgaDNr5V6XJowj+DOiY6dKaeTxji rsrHkXzC/aKVmKRExTs7fphzJCZxBv+HCpWR4t0uVpaXmja5hDqoIV5UMg9qHPMnQKrA 8YPishspITREP63AyKNEYtuH5I0xnyE3GHGYIYjgYRZKOwuD/VL3mgpTodBezKLW/PuG hydDW0Mzyo43dMApP+vVwPTAVv54dcUXmeEjAwyw7753yi7iTD3mEoDbQnKGuR7u0qyl wqB4f74Afyp2ClVjg5MtxQbQXYNKl1LzD+mIH2q8FuFbOsOkk/2V+8xTDpSzz+YuKiIz 9Mcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=znShkYjH; 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 73si44274792pgb.414.2019.05.02.08.44.56; Thu, 02 May 2019 08:45:11 -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=znShkYjH; 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 S1727898AbfEBP1H (ORCPT + 99 others); Thu, 2 May 2019 11:27:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:43848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726497AbfEBP1G (ORCPT ); Thu, 2 May 2019 11:27:06 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 8F7422081C; Thu, 2 May 2019 15:27:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556810825; bh=5IKcHb/BiqpQ9jsv0SapryPbCO4oCW5m2Nfmbwo9D9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=znShkYjH2jAwJtjo0NQkCYYmiR2e82UTrfjN1tJ/xKVvrlq+/TMFvDLS5Rgwttxag JVSzHw3/LyMqsDlSsEntq6av76S+na7yIPVThpiiC1CE1pjKt0ax1AJ35iiaFN+B7E JcAeHzebr1scGCrP5aV9JJfS8lALuiO6iePSwQWo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Davide Caratti , "David S. Miller" , "Sasha Levin (Microsoft)" Subject: [PATCH 4.19 42/72] net/sched: dont dereference a->goto_chain to read the chain index Date: Thu, 2 May 2019 17:21:04 +0200 Message-Id: <20190502143336.829714760@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190502143333.437607839@linuxfoundation.org> References: <20190502143333.437607839@linuxfoundation.org> User-Agent: quilt/0.66 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 [ 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