From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBE2414293; Tue, 2 Jul 2024 17:21:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719940873; cv=none; b=lJ1yjdmoZ73f67qag6DUwHvTYcJyrEP1kqhlQ6t+0LOJPT3hEOCOLD4KXIgJCtR4GZDEufqp1TqFJ8BTa7PcRlVQcqMEOXBULtcgax7kaQakbjKVm14Tbl/cwV0ci3JLkljAix/7f+fZwMV/m3bjm7+OV9Guc0BPIkU8rNTtDe0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719940873; c=relaxed/simple; bh=09Xo4me+gnMvjsW/0wKUoKMtSl5rNImjSkIn8Uln6Cg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Uk2KY+GN5a85bRUksWBp3qJyategiU8G2MTtLuoAjpYDrJ0cMbtmKIjOxMR3dZcD8yGXl251goSfW7xCY9Bu+KK2Uupe8OaSdAx8JYbMssl2MMaX6x/wefhtlVEDPQ1ALa9zulNqDB066xGF0oSOU0HG9fl4SbQO9QzsH7a3Ff0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=PNqS8Wn5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="PNqS8Wn5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6089AC116B1; Tue, 2 Jul 2024 17:21:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1719940873; bh=09Xo4me+gnMvjsW/0wKUoKMtSl5rNImjSkIn8Uln6Cg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PNqS8Wn59a9fKE6cxPxmngzhTpZNz4JH6XeWRh+BYHBS9KZAYbNgzXTrJOx4J256G xUipsRvBIqlHWepqf7bSfQa7cpQpbJiWgZdxv490ZoMm2Uw3uqK9GbQpyjji7AJ5H9 zL1xnkfNe9YW80dE0Om5CsyNSzmCq6Qdx/CQds0Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dawei Li , Alexandra Winter , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 061/163] net/iucv: Avoid explicit cpumask var allocation on stack Date: Tue, 2 Jul 2024 19:02:55 +0200 Message-ID: <20240702170235.374598707@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240702170233.048122282@linuxfoundation.org> References: <20240702170233.048122282@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dawei Li [ Upstream commit be4e1304419c99a164b4c0e101c7c2a756b635b9 ] For CONFIG_CPUMASK_OFFSTACK=y kernel, explicit allocation of cpumask variable on stack is not recommended since it can cause potential stack overflow. Instead, kernel code should always use *cpumask_var API(s) to allocate cpumask var in config-neutral way, leaving allocation strategy to CONFIG_CPUMASK_OFFSTACK. Use *cpumask_var API(s) to address it. Signed-off-by: Dawei Li Reviewed-by: Alexandra Winter Link: https://lore.kernel.org/r/20240331053441.1276826-2-dawei.li@shingroup.cn Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/iucv/iucv.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c index f66b5f74cd83a..db41eb2d977f2 100644 --- a/net/iucv/iucv.c +++ b/net/iucv/iucv.c @@ -519,7 +519,7 @@ static void iucv_setmask_mp(void) */ static void iucv_setmask_up(void) { - cpumask_t cpumask; + static cpumask_t cpumask; int cpu; /* Disable all cpu but the first in cpu_irq_cpumask. */ @@ -627,23 +627,33 @@ static int iucv_cpu_online(unsigned int cpu) static int iucv_cpu_down_prep(unsigned int cpu) { - cpumask_t cpumask; + cpumask_var_t cpumask; + int ret = 0; if (!iucv_path_table) return 0; - cpumask_copy(&cpumask, &iucv_buffer_cpumask); - cpumask_clear_cpu(cpu, &cpumask); - if (cpumask_empty(&cpumask)) + if (!alloc_cpumask_var(&cpumask, GFP_KERNEL)) + return -ENOMEM; + + cpumask_copy(cpumask, &iucv_buffer_cpumask); + cpumask_clear_cpu(cpu, cpumask); + if (cpumask_empty(cpumask)) { /* Can't offline last IUCV enabled cpu. */ - return -EINVAL; + ret = -EINVAL; + goto __free_cpumask; + } iucv_retrieve_cpu(NULL); if (!cpumask_empty(&iucv_irq_cpumask)) - return 0; + goto __free_cpumask; + smp_call_function_single(cpumask_first(&iucv_buffer_cpumask), iucv_allow_cpu, NULL, 1); - return 0; + +__free_cpumask: + free_cpumask_var(cpumask); + return ret; } /** -- 2.43.0