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 DAD661D0F67; Wed, 2 Oct 2024 14:16:14 +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=1727878574; cv=none; b=ucuu4LDQe9DVWFbA7f61AASLx6tNNPPLCM+tOr+1+3//82ynflPvL0D5jOkDrtq5imnSM+W5vW260G1epQwv4vC2VciJkbc+5Hl7EmLLiF5kUwOAbgmIxX5d/vcEDWjdzodlGZq1hbCFhxhl2oD632Cj8lk7jn/MzZjgWZQCXAo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727878574; c=relaxed/simple; bh=UMP3vflGRgMllkBCrCGw8iZSrhpWHpqPc13LFU8dX2A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tKmc3k/WCPLlr2Jhu8XlfY27AfuHJam4jzpaefLnh0JvbzNFsxR9qoUTlMpoyzKGZxszzIlL+sXnZm/RdjWI4qVVZODYY6XeACiWMHjPdc1hOkl8AVln0ldmLgF5CrNvYOkOqcRrwGhg47GniQOHm/O0SBhimnlgwvUeTe1AJY4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=SiaqtO68; 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="SiaqtO68" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61CCEC4CEC2; Wed, 2 Oct 2024 14:16:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1727878574; bh=UMP3vflGRgMllkBCrCGw8iZSrhpWHpqPc13LFU8dX2A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SiaqtO689KG4b0Mq+i4WkGYlTrPXmeTJGG4WPSXBLGRadAm3Dq8e0OcJDVL0L89M/ 9OC+yxeKM2s2wybUSzCymI0GbyTH2OnroRr3WjB6q9mtU3kajCisG2xXG2v85nUgBn YYGX5Rix2EiVKx11gUhATVcMzyfi1LSRRPQbZ6UE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Felix Moessbauer , Jens Axboe Subject: [PATCH 6.10 460/634] io_uring/sqpoll: do not put cpumask on stack Date: Wed, 2 Oct 2024 14:59:20 +0200 Message-ID: <20241002125829.259547114@linuxfoundation.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241002125811.070689334@linuxfoundation.org> References: <20241002125811.070689334@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Felix Moessbauer commit 7f44beadcc11adb98220556d2ddbe9c97aa6d42d upstream. Putting the cpumask on the stack is deprecated for a long time (since 2d3854a37e8), as these can be big. Given that, change the on-stack allocation of allowed_mask to be dynamically allocated. Fixes: f011c9cf04c0 ("io_uring/sqpoll: do not allow pinning outside of cpuset") Signed-off-by: Felix Moessbauer Link: https://lore.kernel.org/r/20240916111150.1266191-1-felix.moessbauer@siemens.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- io_uring/sqpoll.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) --- a/io_uring/sqpoll.c +++ b/io_uring/sqpoll.c @@ -461,15 +461,22 @@ __cold int io_sq_offload_create(struct i return 0; if (p->flags & IORING_SETUP_SQ_AFF) { - struct cpumask allowed_mask; + cpumask_var_t allowed_mask; int cpu = p->sq_thread_cpu; ret = -EINVAL; if (cpu >= nr_cpu_ids || !cpu_online(cpu)) goto err_sqpoll; - cpuset_cpus_allowed(current, &allowed_mask); - if (!cpumask_test_cpu(cpu, &allowed_mask)) + ret = -ENOMEM; + if (!alloc_cpumask_var(&allowed_mask, GFP_KERNEL)) goto err_sqpoll; + ret = -EINVAL; + cpuset_cpus_allowed(current, allowed_mask); + if (!cpumask_test_cpu(cpu, allowed_mask)) { + free_cpumask_var(allowed_mask); + goto err_sqpoll; + } + free_cpumask_var(allowed_mask); sqd->sq_cpu = cpu; } else { sqd->sq_cpu = -1;