Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4150535pxb; Mon, 27 Sep 2021 10:24:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmTYP9PJQvMA+XOC4UAywkdFckzvav5eIeN234QbJxGxulXtseaPf2T2pP5Z1UIV6Oi4hQ X-Received: by 2002:a63:c101:: with SMTP id w1mr694668pgf.53.1632763497409; Mon, 27 Sep 2021 10:24:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632763497; cv=none; d=google.com; s=arc-20160816; b=ByJN4V2g2TgakuMrQwh6EKkqVbzXTDEqXeWpBW7JNvhm2J98ur8QSYJJ8puszfydeH 6Lv9lagzxswsbu7veePatBFUrLXaRi4zYtUDq/NYgXf97s9dAftBveQgDZAt5RHqLr2y P5AangWYqiLnBAfvdhA5R8bsB/oWJrUI2ZdvHuSo7yglMlNnWCEk4M33J+a9BU1Dcotk mTFh7gpWAFXVRGNgfvcTSZzbyNSeQXnBqrJWWig/ELRrTxE9Q9maj+cvubg8UjsC9b7l wlVasQAyzbdHaREUxX61EINcxQ6mDgzLh7jpL12sp+VNaG9SPC6J0C7num4d2DQ4XeSu eWoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NLXFQUYvcs6gcaGUxgTWm8KgKCpSg8huNFR1lyQ7DQs=; b=zizAwHNr4u+Dzj1nb4O5O/IVJ7Ukefscr517a13Mv9HL/bFUMYx2KuG/FfbN7Wep0O 2ChGVTiKHtbt4QuXxCR0cexQ6aNFH0F6omGqMx7MDT7L7AuEp2LEPNm/cjThoqJcFJtz KlerIt1whKrhdW/G9vmM5k76yG/5K3MQRLDLX/jgDd3oIzMBd/AWJDKw6Foio2m1a6s1 3dpKKCHaTKyOb4wUpsX3VZ//GFfEe10VIg8VB/wVeoI/vgaFgTyD2JsG9tc18SuVSrJR TYw7zAlsmrAt85rAWy69G7hMM2k2CTsUYP8gaRM0AS1TB/xcg6KVD7kdcTHKl1vzQz3B yD2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ok3lBXxN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g11si21024657plp.180.2021.09.27.10.24.44; Mon, 27 Sep 2021 10:24:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ok3lBXxN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237135AbhI0RZZ (ORCPT + 99 others); Mon, 27 Sep 2021 13:25:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:35166 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235898AbhI0RWO (ORCPT ); Mon, 27 Sep 2021 13:22:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BFDA1613A8; Mon, 27 Sep 2021 17:14:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632762847; bh=A4ahRCMAKn0v+DioCp9jJOd8r99Q792ns3PteJVLp0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ok3lBXxNjY0LYgupTxOdN19yiUYiPeRsvBXnHdiAUcFPs5jX6VLXLU0lP6yJdQcLD 0xJmjKWTsp1kVCNpKkFuNNAnaMumwuQk7E/HjKAAiC7sHQaFDTwKrH5gvXqByW+xfs 0ZqgRGHLCg8UtpUBLq/ylAcJvnNdg2ZSCEdfurnE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Claudiu Manoil , "David S. Miller" , Sasha Levin Subject: [PATCH 5.14 056/162] enetc: Fix illegal access when reading affinity_hint Date: Mon, 27 Sep 2021 19:01:42 +0200 Message-Id: <20210927170235.427711689@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210927170233.453060397@linuxfoundation.org> References: <20210927170233.453060397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Claudiu Manoil [ Upstream commit 7237a494decfa17d0b9d0076e6cee3235719de90 ] irq_set_affinity_hit() stores a reference to the cpumask_t parameter in the irq descriptor, and that reference can be accessed later from irq_affinity_hint_proc_show(). Since the cpu_mask parameter passed to irq_set_affinity_hit() has only temporary storage (it's on the stack memory), later accesses to it are illegal. Thus reads from the corresponding procfs affinity_hint file can result in paging request oops. The issue is fixed by the get_cpu_mask() helper, which provides a permanent storage for the cpumask_t parameter. Fixes: d4fd0404c1c9 ("enetc: Introduce basic PF and VF ENETC ethernet drivers") Signed-off-by: Claudiu Manoil Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/freescale/enetc/enetc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 3ca93adb9662..7f90c27c0e79 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1879,7 +1879,6 @@ static void enetc_clear_bdrs(struct enetc_ndev_priv *priv) static int enetc_setup_irqs(struct enetc_ndev_priv *priv) { struct pci_dev *pdev = priv->si->pdev; - cpumask_t cpu_mask; int i, j, err; for (i = 0; i < priv->bdr_int_num; i++) { @@ -1908,9 +1907,7 @@ static int enetc_setup_irqs(struct enetc_ndev_priv *priv) enetc_wr(hw, ENETC_SIMSITRV(idx), entry); } - cpumask_clear(&cpu_mask); - cpumask_set_cpu(i % num_online_cpus(), &cpu_mask); - irq_set_affinity_hint(irq, &cpu_mask); + irq_set_affinity_hint(irq, get_cpu_mask(i % num_online_cpus())); } return 0; -- 2.33.0