From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3681E38945A for ; Sun, 7 Jun 2026 11:06:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.67 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780830399; cv=none; b=T5biAgrv8Dx+VJojRk+jBablmHItRETxUnLSOi5/5c37I6L/pdhFmyczg77N+647uvjBOhn0bSJVTq987xxlydCQgfPyfZ4PX0wXMS0tByl7NHk3HH/0ha0jKLf9MixWilwmNop0n4xqZTEGz+ifATtxjd6KgRH8rXtMdzLA8bQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780830399; c=relaxed/simple; bh=aVd7z22a+mRisIph7HsQw1b/xfCIYxnP8FjGBSiqnAA=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=pvjsML0rznvy9jhpp5qjYH8/2EBoXUM30xGS6YyGe1g9SejAfpPhEh78Zy8ouu68fk5MzOMVaDcZc1Jb+kBaSxapbbgu1QES7UNlMRy5Quk/jBPDmjUgjZubXon6PhoLGjm74tQ8q+R8DyuHR+UEf4L9xq9kEvtPL+k1yK27wQ4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UgmfDDhP; arc=none smtp.client-ip=209.85.128.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UgmfDDhP" Received: by mail-wm1-f67.google.com with SMTP id 5b1f17b1804b1-490b1bbcf3aso26998565e9.1 for ; Sun, 07 Jun 2026 04:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780830396; x=1781435196; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=zbrPFfMUPEshyjWmvJtWAlA2RlCdQJQIVgTBRQv0Avw=; b=UgmfDDhPmrIxuD9p0ffAmgaAQFCmN5KedmMnV7VX3Kbq7KjSvoL/RDyJIg2vp81ylv qL6x34DHELv61hRQhd5X1+sAbwCQZlPwZztEqzxA0C0KM1VvABuJqsjkKDPuqvEmZMcP pNRouNekbwQKR5ZQDr7DcoUASivDfvm2BKiF5RDlt03RCmEWIsWEPczjSSra9iRnBYRs 6BqT4vchZSa1zwGWbG8KsS3He59MdJJNYVm74iQJZilLlq9tFknLATsIMyC552etn1XI 4aBjGK9rBKuAkYxpDswGqx7RwtluNW4AVwjtrPX7NVIarIldLmdO8B+bcX3F6njl3SFd iA+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780830396; x=1781435196; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=zbrPFfMUPEshyjWmvJtWAlA2RlCdQJQIVgTBRQv0Avw=; b=LOM/vjb5d62vUFL3dE8PHT2HtyqsY9271RxqA/a7qfZAKPhSsMwx0naVmBDcZrLp3M Pv2jhs99Ss46IkOuUXSeGb28B7Abkudzw1+QTCruZp4GD/AtRgeXhBGP5oQDwVYDomNf Br2O16yIuNB8D6rnuCWF/54ihkjhzE29LiGeIrfqjVszQOq5SHQo3Wh2EZ/gW0ojf0qk dnK3NkM1I3lHmro/JaPeEQyY8jmk9uuPftrK77ui7xofQyxY/0vz7sA1pnHilgRgaKCi A+X0A/BmLJaLejbq0s3bAkGEzDHDC1B5L/TxLfouycVwtjNYcwsPLKnHIcPjNbv837CP X2NA== X-Forwarded-Encrypted: i=1; AFNElJ9b0FyisaDVfc8rtgvLp0GqPnAxLlo/NNb0pwmiLpHQ8IE0aHyfF+rmZMbbcXVxTX1hoO39X5kWvbP02zo=@vger.kernel.org X-Gm-Message-State: AOJu0Yz4rlISDYkp8aSoL+EleXgJK3AMTHvaMUub5/yub7xmdnjCR+cW 7MZRI8vYX+XMsvsS8sDUe7fugkH9DGQGYO+sXYAU9ar7sFJhwAtBtbrv X-Gm-Gg: Acq92OGi5R0bimOEGnumTS4AZOI1y+ViOMgrjOuUKNq0TyIClCBmAOWea9i5fx9VAj6 2UGHWh4yx2O6fLAbkUgxEab8dFWxxKg9KgKQkOp5qD841pnYrIppgcNYsAZcK1IcPj7WSxkIC6X thJ6ax7dOUB/xQOJw456PlrbDiX168t10QQdxBoh+8TfozeQBQZLIs7yIURT4VAHu2rOyU8CT7C /5Rn9RBbXnCtCw6PnfM5MinvC4k6ZSHe2WhzouF5OGAiQ6WMLwGXIk/zWLS4WXuSEqo6sUGksQd dWgYc2DXv2nzVk0mDCbhBo7Leu+cMn3cXQLlwFxCiayTN1C0TXyJx5drNRMzFYcUaZKi/tzBbHw dSkrzPyfu0kVRnAk9L+Ao/qw32kuVjqZRkaJ2NL8hsCEnw7FsyZosnvoTzEA04HxHG4luvn3S7i ZHF/Z+8ha5/jzZN8LOmA29ZQ81HA8ys7PWNCAkDi5PsB71cy6pGMCT/bM9C3cH7aomtYAi+ZHzP zPcyss/HxAlHzJL2o/MHWvlgCUllUROPzewF5PMJldtitS/+vPMykccBd7TxknFAmh26rVm3i/5 X-Received: by 2002:a05:600c:4e47:b0:490:9bc2:bf8b with SMTP id 5b1f17b1804b1-490c25acd68mr187067275e9.5.1780830395478; Sun, 07 Jun 2026 04:06:35 -0700 (PDT) Received: from localhost (nat-icclus-192-26-29-3.epfl.ch. [192.26.29.3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490c2d37edbsm210341945e9.2.2026.06.07.04.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jun 2026 04:06:34 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Sun, 07 Jun 2026 13:06:34 +0200 Message-Id: Cc: "Alexei Starovoitov" , "Daniel Borkmann" , "Andrii Nakryiko" , "Eduard Zingerman" , "Martin KaFai Lau" , "Song Liu" , "Yonghong Song" , "Jiri Olsa" , "Juntong Deng" , , Subject: Re: [PATCH bpf v3] bpf: fix NULL pointer dereference in bpf_task_from_vpid() From: "Kumar Kartikeya Dwivedi" To: "Sechang Lim" , "Kumar Kartikeya Dwivedi" X-Mailer: aerc 0.21.0 References: <20260606091941.1803115-1-rhkrqnwk98@gmail.com> <64l5t5yu77d5xg4jqjjwyqr2k75f2pi2vl7yus4oczgosjrpyx@2ink2pha4wt5> In-Reply-To: <64l5t5yu77d5xg4jqjjwyqr2k75f2pi2vl7yus4oczgosjrpyx@2ink2pha4wt5> On Sun Jun 7, 2026 at 12:05 PM CEST, Sechang Lim wrote: > On Sun, Jun 07, 2026 at 10:44:41AM +0200, Kumar Kartikeya Dwivedi wrote: >>> kernel/bpf/helpers.c | 7 +++++++ >>> 1 file changed, 7 insertions(+) >>> >>> 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_vp= id(s32 vpid) >>> { >>> struct task_struct *p; >>> >>> + if (in_interrupt()) >>> + return NULL; >>> + >> >>This seems too broad, I would just drop this hunk. It seems unrelated to = the fix. >>IIUC we only need the bit below to prevent the original NULL deref. >> >>pw-bot: cr >> >>> rcu_read_lock(); >>> + if (!task_active_pid_ns(current)) { >>> + rcu_read_unlock(); >>> + return NULL; >>> + } >>> p =3D find_task_by_vpid(vpid); >>> if (p) >>> p =3D bpf_task_acquire(p); >> > > Right, the NULL check alone fixes the crash. The async-context guard was > added on Yonghong's v1 request: in softirq current is unrelated to the > packet, so the looked-up task is meaning less even without the crash. > > Drop it entirely, or keep that intent with a narrower predicate? > in_interrupt() is also true under spin_lock_bh(), so !in_task() would be > more precise. Drop it. I think there are contexts where tracing programs use it, may run = with interrupts disabled, but current still remains meaningful.