From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (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 366513E9C0B for ; Mon, 8 Jun 2026 20:02:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780948942; cv=none; b=XqN1l62mwDCoYaiB6oF3uDhhWAV/UkqQGuJv8Fon3IiD+jpdNQmALwdFmsnCOcdW5zJWFcWKDRE1JibSXCQ7QOcpAazNt75XxrU3IecrWOGj9pPxUcUOn3lUy5ekJZKOJYzorxnhP3O2HelZLJwOrZpg0jykde/QKuh145ejbXU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780948942; c=relaxed/simple; bh=wrqE2O76YCV8wdY1YPpUUnMYdTSt/lGtjLT9N9f7KaA=; h=Mime-Version:Content-Type:Date:Message-Id:From:To:Cc:Subject: References:In-Reply-To; b=XWFaDkFokTO5UeZscS050r2xlgLLQ/GNvCtGh9pHeRAkb7qJ6w79UQS6Jn2rpz8fYbFF5bCGHbmEVR7ejxaD/jT+6IInZ8kpmXKdISQfCUWvDOq7yf5KomBf3CmcuS9tifjRgl3D/+TBn/xAHt/BRkrIRmvHDEcKt3jfuYRpDI4= 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=JaGM42CN; arc=none smtp.client-ip=209.85.210.54 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="JaGM42CN" Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-7e6e41cf7aeso2799624a34.0 for ; Mon, 08 Jun 2026 13:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780948940; x=1781553740; darn=vger.kernel.org; h=in-reply-to:references:subject:cc:to:from:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=pwrxcif3XUtEKF7lrhb7eyL0FpVd3GzB9U/X8qwd09o=; b=JaGM42CND++GVCO/APZTAt8fet5/AfRQBUcUWxHYxHHqZInMxKQbF6OT3FmXDjtx6i ozM356muRW6wHE7nxLSzn0SpJLwzCmam74OffTWA0QxKNXp2uBjvUKkWZHa5Qn2qSMvL LUMkkAtJm/hr/K3MutMWwkwk9vP0EL8d053cguGLhQO+eWhd9DcMNR1Mp9om4+fpp3Ne R6SlRzNODEgUPxSoeYrLPmWT5FDBkX33xxLwNapI3/HMCNc2SEWNQmWHBOZPmRQYpqpp +PAbwSpx/A6u4EDuoiFZcwRcVVsnSb9x8xXTMxRMeUutezTmyBN38WGw74RGHhb8To9j 5amQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780948940; x=1781553740; h=in-reply-to:references:subject:cc:to:from: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=pwrxcif3XUtEKF7lrhb7eyL0FpVd3GzB9U/X8qwd09o=; b=iMtDIi3AxfEG3AGuDkutEkyFeVs5PTt1XN24nS3RI8Ujixv0wrMCAFRR/+ye6ZA9hf hN4wS9aLogs4mARLlPCEhKpd4xou/OkrZvy3GvcshFxm3TQsMSyzW2qkDPCVowAOOm6y 1CBL0XYQXnq/C5azJ+JzWtCm9BwbXVU0nPW6dw+gcYkvdmCLyMjis/kflpIkHTvL0Zbj +D+mv6E0hSDxVKKqeulM7jcEZB27gzNAN2L8u8XfR0lIF+/gkO0Tf0IKJcOzhidt4xZJ 2yDzBcU3P45gFpiAYqBYBoK31/9IImNpEGMRzqypzaW5BSYLdRbsPH9qeUkRu+jqrq24 3J1g== X-Forwarded-Encrypted: i=1; AFNElJ9DhBDhoeumYP4B+mho7bFazckH7PcxNZ0xz9gv567WSH25PoL9LpVz15hCz7qFOrIbjIDiCJ2mbgamcCc=@vger.kernel.org X-Gm-Message-State: AOJu0YwUOhNSrVTOh3LW70Ivo8tqq9Zm+vKcc4uviUCfMKn6tMCvoRd+ IYQlVobO5VySpZQaZh2wprkXcWZLTYxJoU5wtDopt7HPds81hputnzkU X-Gm-Gg: Acq92OGUxkCj3U+hBAYzZU1kBdlfmOFqATN67yHggaAqPJ9KwoQefSls2rg7/aNcqTJ kT7vjSA0EbNbnpcHdoi1Ww6wIS8LkuiU6KdoTQHZ+dX584SibMAIJVVE0nmPO1jRRjKV4ZKeQQP vJZq+0E7xtC5hro/Ynj+ezJtkLdMz67CsRdQjB6ytSKnRsl/QQKxNeLarkLfkzD1FTJjzfZW712 lw7chwsz/+OazoU8rxcICBP5W83npq+iEZbrCxHie+ThsqAzmxs1BsAg8Vbx3iTFSzID6LEMQmU XUIoZfQsTvJZgzJAk9g9e2e3DICbNLQWjZ/H6bVtM4clZeiRT3Ci+Oldk/zNz9Wm5XUeixfyJ1y LZlY8q6r0Zg+Iwn2k6ykR4khIugk6ZL8NVhoDMVuG8UgzuIhAyuU+ZZ5Jg1PsdDH4HTy914tV1p /835/ZbKCHPVi+Sh3Zuxt3Og0K1lrvHYIafcAlWFaWtgiJcM266JtAO+cRjknAs2FMZ9G/7gE0L 3NZhOD/WzvQIb1IvzHZ+ElREd58qSvywmdzxKg= X-Received: by 2002:a05:6830:902:b0:7dc:dd19:7f53 with SMTP id 46e09a7af769-7e70c7906d4mr9896252a34.14.1780948940066; Mon, 08 Jun 2026 13:02:20 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:5c::]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7e6e7923af1sm13046364a34.20.2026.06.08.13.02.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Jun 2026 13:02:19 -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: Mon, 08 Jun 2026 13:02:17 -0700 Message-Id: From: "Alexei Starovoitov" To: "Kuniyuki Iwashima" , "Jiayuan Chen" , "Alexei Starovoitov" Cc: , "David S. Miller" , "Eric Dumazet" , "Jakub Kicinski" , "Paolo Abeni" , "Simon Horman" , "Willem de Bruijn" , "Daniel Borkmann" , "Andrii Nakryiko" , "Martin KaFai Lau" , "Eduard Zingerman" , "Kumar Kartikeya Dwivedi" , "Song Liu" , "Yonghong Song" , "Jiri Olsa" , "Shuah Khan" , "Joe Stringer" , , , Subject: Re: [PATCH bpf v8 1/2] net: Validate protocol in skb_steal_sock() for BPF-assigned sockets X-Mailer: aerc References: <20260608125846.157004-1-jiayuan.chen@linux.dev> <20260608125846.157004-2-jiayuan.chen@linux.dev> In-Reply-To: On Mon Jun 8, 2026 at 10:21 AM PDT, Kuniyuki Iwashima wrote: > On Mon, Jun 8, 2026 at 5:59=E2=80=AFAM Jiayuan Chen wrote: >> >> bpf_sk_assign_tcp_reqsk() can assign a TCP reqsk to a non-TCP skb, >> causing a panic when the skb enters the wrong L4 receive path [1]. >> An initial attempt tried to fix this in the BPF helper by checking >> iph->protocol, but Sashiko [2] revealed that BPF programs can bypass >> this check via a TOCTOU attack by modifying iph->protocol around the >> call: >> >> iph->protocol =3D IPPROTO_TCP; >> bpf_sk_assign_tcp_reqsk(udp_skb, tcp_sk); >> iph->protocol =3D IPPROTO_UDP; >> >> Furthermore, bpf_sk_assign() has had the same class of vulnerability >> since its introduction =E2=80=94 it can assign any socket type to any sk= b >> without protocol validation. Since the BPF helper check alone cannot >> prevent a malicious BPF program from crashing the kernel, add protocol > > I'm curious about the BPF maintainers' stance on this kind of "bug" > where admin tries to shoot oneself in the foot. > > I saw Alexei said this recently, and I guess it applies here as well ? > https://lore.kernel.org/bpf/CAADnVQLh7VEKAtckzz=3DXOVPT8ovpDQshvPPCWHDQu2= OWQx27_w@mail.gmail.com/ > > ---8<--- > Not every "bug" needs a fix. > If a malicious bpf user wants to crash the kernel they will > find a way to do so. Especially with agents. > We cannot realistically close all of the holes. > Right now the priority is to fix the issues that normal > users can hit and not bots. > ---8<--- In addition to that I have to add that skb_steal_sock() is performance critical path of networking stack. Adding runtime overheard there because bots can find a way to abuse the interfaces is not a good trade off= . If there is no simple way to fix it completely on the bpf side then we have to flag this issue as "won't fix" and move on.