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 15FF21D0945; Wed, 2 Oct 2024 13:43:50 +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=1727876630; cv=none; b=JcnLreoJh7T3GExlMQWMY7n7Od7kwj/4sp+Jlfl4uFWrWFgE5ytwfoiM4y5tv9yXd3qaU4+ID4rKi40osv4OmP/koQBh3kku5og9YGjA6VkaWTcEj0Kur6Xlych9U/CFkBlt8ZF0GsjwhFWzE6binhlBCjTElqaElsyp4CPvyf0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727876630; c=relaxed/simple; bh=JrsOBIGFV4kAJOdGW9BzF33WkytgOZ0eP4v29ZVeBZo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NX9huFLbrOKqPVjnphBn35tdGZ2JqfMsUJIfB1KP9NdJB9HTNk6YTM6T8JuV44WlWVBfryt3NqZIG8EhGNUognfSKOd2fRwR6Wn/EukKSj/kZIDPevaQdu/VRbgXWFfWxpw+07MYySZOmzjczTmrVzmkh7TK7iOYdHl4W2GsnZw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=vdqi+rWF; 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="vdqi+rWF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 939BEC4CEC5; Wed, 2 Oct 2024 13:43:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1727876630; bh=JrsOBIGFV4kAJOdGW9BzF33WkytgOZ0eP4v29ZVeBZo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vdqi+rWFtIxpp5pxE0wj5lxBYYbjXaZOC4F9cFO3SBROSi5tl7Hm0BcHihj2T7cRO mpo1dKUYlaiaatNCJlvxWGwXSwEekW4YtKUd0Q4Qu+hXIckMqJLA6hB74OKbcLaGNj 51vU7ZRQrtTrPY0Q+mzaopw1C7RZQQggeISmBgLg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Felix Moessbauer , Jens Axboe Subject: [PATCH 6.11 509/695] io_uring/sqpoll: do not put cpumask on stack Date: Wed, 2 Oct 2024 14:58:27 +0200 Message-ID: <20241002125842.799135376@linuxfoundation.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241002125822.467776898@linuxfoundation.org> References: <20241002125822.467776898@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.11-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;