Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4140264pxb; Mon, 27 Sep 2021 10:11:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbwteMfhAbrb91/YnqoOpG4Hrnb8EX08jZCzMRujOXQGi6D4QFL0IR8/fq517S4k9olXou X-Received: by 2002:a17:90b:383:: with SMTP id ga3mr212180pjb.72.1632762714456; Mon, 27 Sep 2021 10:11:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632762714; cv=none; d=google.com; s=arc-20160816; b=rn17Vqpm4EE38aAn/Sjqgd/x9u3+lDxhFpPj47WSlNjQpVp4mbSQPKz41CZ8FRL8wk srC3RJiY6brIJYowBD1vGzHusB2PNd3uAuhgl3qblc0yP5Jql0Q0y4GHRrLd2LSmG4v2 eSg9o3nsAwvDeD7lfwFbJAXgwd+S3NT4cKOXo48IwtqMCvOmUnxq9D6CAWcFXmJbfOyT jGx9aysMke8S0/qfm55VsRJihzXnfARkNVr+x87eviEnmBepqNO05X93q56HUJmcqXHk IGGq40q9z/yap8HLmDzalZ6YxXAFAL/o735/j7ccR5cvUmuA8Ykx/I5PQS/Gm9jP4xE5 5elA== 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=G85zGK/B0x7/lwYAhP9LMuJFiB9Ahy9ncTKhQ0ewurw=; b=RRsjuR9oGp/fnuMsjLA6n+IoA3YnNHFe12g2WuHMYHXaL6wbgpEr1PZKQGKZmvLlnm xQnBFWB6FYgcEGvojuTxN2dF4RFywxfM63WbS8THQNbAExIzlg3pZFLHQmr7CW5GbTIm RazWDnhZEb4TLQjCQePAgLBwhzVgGRWrNI7VkWPWOZBfzTKrw/wzDgO36YI1JgJsU8No SHxAgoj/yfTsaSm5uWsOCb2S8cOkEfL5JlIABm9wYsGJpEvij7gEuphaM4yu8jbpvN1L M/vI1RTDwXtVDgqWxfJ8cMOusO508veNOH15BRNHTBpWL9EQoUNcjIBaQNfIosLBYNw/ 7nGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sPLUkI+6; 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 ke3si110579pjb.99.2021.09.27.10.11.41; Mon, 27 Sep 2021 10:11:54 -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=sPLUkI+6; 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 S236102AbhI0RMh (ORCPT + 99 others); Mon, 27 Sep 2021 13:12:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:48116 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236610AbhI0RKP (ORCPT ); Mon, 27 Sep 2021 13:10:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CEAC861178; Mon, 27 Sep 2021 17:07:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632762472; bh=Qph3P2vCb/2ExWigLookIyt32+Kp6aSqwYW2z8dJTbE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sPLUkI+6fr9OKKIAo2HWg4FrFIniEEct+locW2JzIlcOXdK6PDzvnxljytjgyQ6vv /G+z5wkBHjJR14bulrUX6W+9CQilJZkolsVKIfm6lK2nJAEDhH5oZkLxs74oYI4I7r SD/26nuocrz2Z6Jq4zUtaIuNp1zTeZrAkNlJ/pQg= 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.10 036/103] enetc: Fix illegal access when reading affinity_hint Date: Mon, 27 Sep 2021 19:02:08 +0200 Message-Id: <20210927170226.996416573@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210927170225.702078779@linuxfoundation.org> References: <20210927170225.702078779@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 df4a858c8001..6877f8e2047b 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1320,7 +1320,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++) { @@ -1349,9 +1348,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