From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 91BCB34A794 for ; Sat, 6 Jun 2026 12:57:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780750670; cv=none; b=Qu6vdKqraynADgMbaqfVZB80xXX4c4YqLWqJYBCJoLDjcC3mUjnr93JDOZ9Jwuoy8LpsIb7/BPi1t7/xBuLhutQF3mDLFP1N+wYFL0qZRMiC2kpZePOgxA5G1tWxPHbLhVM13AOy4yR0mGlW+AcYLLN1JPbCl9rN4iValXro4GI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780750670; c=relaxed/simple; bh=yLdlxn6wnXWvE70fdE6r10MFvEYbWAWQsm/plhLqsUw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=qCG7QyackYtvy5zWyGBOS/lVmiu/YJke7nNsUaX/3nJ4aOHlbgI3G1pTvJDlqWGe/FCAuZjH34P1+cKxPII4EoD05XYr8ZXVYNbrMLzlxxwShlHNaicNge7Vy8aYQXyh4qUIK2xnO6nIG8gVnPj5T8N/iK0d0smzDXj1/L7siDM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=V0JK8tXF; arc=none smtp.client-ip=91.218.175.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="V0JK8tXF" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1780750664; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RlEFEF1O4G2UXEfB1iSkIV3C6hrJc1jLqx1ZQFCYkCU=; b=V0JK8tXFL9oJI8kIYQqKY8br1OUd8l+KnJNNpsTOnQMOCetjMJxHQbNiGpvOK+RamSXMwW zZaWfDF2TNrxG1H53as/CD+HiZhsIj0GiTjbIVKvGSPXOO7G1RB5kVuZZxCimOAlG461U/ hMw8aExQ77jF0P7MMSzVaHEm4WMSsII= Date: Sat, 6 Jun 2026 20:57:34 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH bpf v3] bpf: fix NULL pointer dereference in bpf_task_from_vpid() To: Sechang Lim , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi Cc: Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Juntong Deng , bpf@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260606091941.1803115-1-rhkrqnwk98@gmail.com> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Leon Hwang In-Reply-To: <20260606091941.1803115-1-rhkrqnwk98@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 2026/6/6 17:19, Sechang Lim wrote: [...] > diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c > index b5314c9fed3c..226c31ccb5d6 100644 > --- a/kernel/bpf/helpers.c > +++ b/kernel/bpf/helpers.c > @@ -2912,7 +2912,14 @@ __bpf_kfunc struct task_struct *bpf_task_from_vpid(s32 vpid) > { > struct task_struct *p; > > + if (in_interrupt()) > + return NULL; > + > rcu_read_lock(); Better to use guard(rcu)() here, and drop the rcu_read_unlock(). Thanks, Leon > + if (!task_active_pid_ns(current)) { > + rcu_read_unlock(); > + return NULL; > + } > p = find_task_by_vpid(vpid); > if (p) > p = bpf_task_acquire(p);