Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 55FE254706C; Thu, 17 Sep 2026 19:02:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789671730; cv=none; b=YfhwC5wMLopas1JWfxffcpYMY0P920bkS4/J+2+dLWZud6KvlLUlqcsB4euFFiOfy2k/N/04u+lLD68cWp/ftN3Im333m5gKk7n6DfR8L93ctfDa7UsvZiJ28+sx2JrnDMxRCK/UT5Nizn8Sn2NR91ba37oZNxE5BcbissnPF8I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789671730; c=relaxed/simple; bh=VJqtP1XEDBrOu+0zKLD6BgPVMyJL1Br9gvgUGm55GGE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=soj2zay5T4mZUcW1Z1JeuuLXOiOzuqtN54dWOYo4eReJoHO1E9a2bd8jYrA0K6cdGZSE9Px51eRh3jDrfDnDkjou/4IIIET/iHe02KFhVVJiPvWa3SF7QRAsXeyk9A3WtJAz9mXu8/HZJE+ZLQ1bZ1FL5gm8xSVrxcZIikewUYM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=r9l3+n7p; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="r9l3+n7p" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F4171F000FF; Thu, 17 Sep 2026 19:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789671729; bh=YgwsuB+ovVir0vW3HrOZ6c92MKPSkbOA01eDNtda/8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=r9l3+n7pVWm+3XHOzec9RZimA66B7GljwlMc8i8LawUCqhFUpbWb10OqAReNHZpV3 0Rea6X8zkDZQPvrdaNP9d+6TVFEFsEwB3XBdEBLMEFd5G5hHYi1oXre0u+ybpkQbTB 5VCxK7QCB9y9ABqdnz9rmRhQ6A77ZbTWoXVWjEHk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tao Chen , Jiri Olsa , Andrii Nakryiko , Sasha Levin Subject: [PATCH 6.12 1071/1102] bpf: Disable preemption in bpf_get_stackid Date: Thu, 17 Sep 2026 16:16:54 +0100 Message-ID: <20260917151607.715617411@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260917151539.408551884@linuxfoundation.org> References: <20260917151539.408551884@linuxfoundation.org> User-Agent: quilt/0.69 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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jiri Olsa [ Upstream commit 15f1bd8574662f1b7b26aaa2e23ebf4066f0117d ] The get_perf_callchain call needs disabled preemption plus we need it disabled as long as we access its returned trace entries buffer. Note the bpf_get_stackid_pe function is executed already with preemption disabled. Fixes: d5a3b1f69186 ("bpf: introduce BPF_MAP_TYPE_STACK_TRACE") Reported-by: Tao Chen Signed-off-by: Jiri Olsa Signed-off-by: Andrii Nakryiko Cc: stable@vger.kernel.org Link: https://lore.kernel.org/bpf/20260803210149.296496-6-jolsa@kernel.org Closes: https://lore.kernel.org/bpf/20260206090653.1336687-2-chen.dylane@linux.dev/ [ adapted get_perf_callchain() to the older six-argument form ] Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/stackmap.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) --- a/kernel/bpf/stackmap.c +++ b/kernel/bpf/stackmap.c @@ -374,20 +374,22 @@ BPF_CALL_3(bpf_get_stackid, struct pt_re return -EINVAL; max_depth = stack_map_calculate_max_depth(map->value_size, elem_size, flags); - trace = get_perf_callchain(regs, kernel, user, max_depth, - false, false); - if (unlikely(!trace)) - /* couldn't fetch the stack trace */ - return -EFAULT; + scoped_guard(preempt) { + trace = get_perf_callchain(regs, kernel, user, max_depth, + false, false); + if (unlikely(!trace)) + /* couldn't fetch the stack trace */ + return -EFAULT; - err = stackid_fastpath(&stackid, map, trace, flags); - if (err != -ENOENT) - return err; + err = stackid_fastpath(&stackid, map, trace, flags); + if (err != -ENOENT) + return err; - new_bucket = stackid_new_bucket(&stackid, map); - if (!new_bucket) - return -ENOMEM; + new_bucket = stackid_new_bucket(&stackid, map); + if (!new_bucket) + return -ENOMEM; + } return stackid_install(&stackid, map, new_bucket, flags); }