From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pz2-f37.google.com (mail-pz2-f37.google.com [74.125.228.37]) (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 B13814A441D for ; Wed, 30 Sep 2026 14:04:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.228.37 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790777071; cv=none; b=Qu+Xb2MqfMUOWhi26BZdLTDRBsiHp1TZNzFhp8D5N3I+B0BeRlj4rZsjTKRoYKlNayCiv+0tcnBzj0zfWwpxdhAVra7tL3YMA/1hm1rS/fTz9WJ37zA5WF/TUZNR82s586nBR+fSIbk1UtwkASZvd48YYf9EDaJZkRuBxIIfWmI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790777071; c=relaxed/simple; bh=dDRtbqYPrbcSZk8XTIR1mhxTewKaoQ7Hl8OVK4zyccw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=jkaix8lJsylVygcOUP61NjnObqfEGaNYALarn9FRHIv+o/dznEw4vr8nQNeB+gVH9OKGKttQS+aRve/+AS0EbwZEsfPCl0rLGyX/1waU6nv8iRJ8EKrAjUf1Y1VccjkZ3WOkitWAOdoJUvsCEr5hUrCzD7BP6Pwe9DLjjU6j1oI= 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=W5xr+1lP; arc=none smtp.client-ip=74.125.228.37 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="W5xr+1lP" Received: by mail-pz2-f37.google.com with SMTP id 41be03b00d2f7-cc7c4c92477so1253650a12.0 for ; Wed, 30 Sep 2026 07:04:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790777053; x=1791381853; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=0/hVX4C+yQqwsDE4LgI16fX3ANft9SjFARlaoadqqlc=; b=W5xr+1lPy4kXFvznJdBdMZA81GHwJDOEyvkLvK1qXGzVdR54+Y1w/jnsnEsyR6XdYT 73zya3usx/nxhX0b4L2cime9dP1bqlLPQ3STEAxH+8S2npascYUrAgmZi/6/u5HF95Co ke3PoUrv3CyQNK0D6VHRIw+WBIjiY6TWTFnwmdKqXwgfBEki7b4ovfMebRI2n0VdI3gy XDrEkkZguSzZ+18kiqVU/g9HsiQwo97wvz/JQTZBk2PZrz7pXPHEVcsUiNLx4ZTijRH8 lpKBYou6V3WBUnRxDNbqbHiWO6Ll+JOMCKQY4B40EHHo+5GWEWC2PZFOQdHFda7/4iEs uJvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790777053; x=1791381853; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=0/hVX4C+yQqwsDE4LgI16fX3ANft9SjFARlaoadqqlc=; b=w9R4/Sp6mUVZOBrzhHp+eme1ohEJ55U4Zv7WvnxVbUPoXdIfKEQYDeU67nylGETLi/ Lj7TQuN+5ub4HVC0wFFHjMcxSP+H7zM+WDLSLaGg/rnvtBSNKhUbDPM9A0dC8nBPEkjh aTW8ZegowbKaX4Fh3Q+/KVFTaYNoI5HbQClqVRTjJkXUBifR/Irn504O8yLJVBdXWo0+ Yi/kPaDvPZGuhZO+FIGwTq4dTeB/TuAHKCpGTPCe3ykMP0dhE28OioQeeOReDxfbOyzI MLE7N0nJ3BIqzJGLBfV8wZ4sYXz0OP9kAMCUS9EPrFwC+UHc+f7ic7UdbmhREbgIZPDT SmPw== X-Forwarded-Encrypted: i=1; AKwUvBxKE9KOJdvchUIK/Rw/bh7WZ8oGuc+XYYnaM9FibWwkQMN3IifDhcQqSqWFEib2toMMYgsdZviUka9WEjE=@vger.kernel.org X-Gm-Message-State: AFq9FYJgbA6PqPnETYUCaWskNJcz02GrBJ40T2VHlf8CpnQq7Oc2BG6w ShTJWhuNYRjIA1TBvS+VcWmcU2hcG5ypwnUBmvi7IQq3PSZG3zzmxOTU X-Gm-Gg: AYBFou3Wjab9l+nSZ/x4iLgfCgGFmcTZMAyyhGQtIjiXt4bU7A6OHAlmYWnLo7I6Pn6 RmKk3K7R/TCGSQm+tveU7I/dnxgf1LjSXD7EssHtASQcGs7WxyyAQQd1t1fkJL8ryMVKK6IvUGJ QM3DyMBzZHbIkzxK3YlA0FZlh+C88V2TAeR0iTk6zjuvddpBcGlNjnE841jMiUaSUl5F2ISTAUp wmrOpKs0Av72W3n4CfFTJ8XaCOduSBxJHiKy6VZfPLb1kJx4GWSqMO9olkbjjGJVONqNW+LK3hF pWNweGxTFlkkY+0vGBproMQSfeiesJ5sMcJZf+EflJGJOm21iNYv3xPzfY5aAWKW79C7waait7V Ai5O+eizO7+NTmXy9VY8Sej2609y5z3Jo7Qpt3hfUqbFP5hY6dau16lKkAdxKx5odmJfatMMcPA VtspO7/U/HCmzEsmbZbCrmeKLdxhZTWJeGdDkbfRCES/xmFkwVaY73xmatH6fS0D5A43O5l71xg i6Ct2qHKJ0= X-Received: by 2002:a17:90b:564e:b0:3a0:d9ee:a2e9 with SMTP id 98e67ed59e1d1-3a4d18c09b8mr1192177a91.45.1790777052463; Wed, 30 Sep 2026 07:04:12 -0700 (PDT) Received: from ancienth-X870E-Nova-WiFi ([125.186.72.2]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cc7dab202f1sm1031140a12.27.2026.09.30.07.04.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2026 07:04:11 -0700 (PDT) From: Daehyeon Ko <4ncienth@gmail.com> To: Paul Moore , =?UTF-8?q?Ondrej=20Mosn=C3=A1=C4=8Dek?= Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , netdev@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Daehyeon Ko <4ncienth@gmail.com> Subject: [PATCH net] cipso: adjust cached option offsets when removing CIPSO Date: Wed, 30 Sep 2026 23:04:00 +0900 Message-ID: <20260930140400.2955466-1-4ncienth@gmail.com> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit cipso_v4_skbuff_delattr() shifts every IPv4 option after CIPSO left by cipso_len, but leaves the cached srr, rr, ts and router_alert offsets at their old locations. With a valid eight-byte CIPSO option followed by a seven-byte RR option, RR moves from offset 28 to 20 while opt->rr remains 28. The stale offset then points into packet payload, letting the sender control both the length and bytes copied by __ip_options_echo(). Setting the length to 255 produced this condensed KASAN result: BUG: KASAN: stack-out-of-bounds in __ip_options_echo Write of size 255 Call Trace: __ip_options_echo run_cipso_stale_offset [net_candidate_probe] The destination holds 40 bytes of option data. In an existing uninstrumented x86-64 v7.2 build, __icmp_send() places that buffer immediately before its stack canary, and the 255-byte copy also crosses the saved return address. A canary mismatch unconditionally panics; no canary disclosure or control-flow exploit was demonstrated. Mirror cipso_v4_delopt() and subtract cipso_len from each cached offset that follows CIPSO. cipso_len is the logical distance moved by the first memmove(); hdr_len_delta includes padding, while the later header move and network-header reset relocate the bytes and their base together. The adjusted input leaves rr at 20 with length 7 and completes without a sanitizer report. Natural remote reachability requires a configured SELinux/NetLabel gateway and a later option consumer; the retained test invokes the real mutation and echo consumer directly because the available rootfs has no SELinux policy or netlabelctl. Fixes: 89aa3619d141 ("cipso: make cipso_v4_skbuff_delattr() fully remove the CIPSO options") Cc: stable@vger.kernel.org Assisted-by: LLM Signed-off-by: Daehyeon Ko <4ncienth@gmail.com> --- net/ipv4/cipso_ipv4.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c index a05aa075de1a5..135b57c2c4f9e 100644 --- a/net/ipv4/cipso_ipv4.c +++ b/net/ipv4/cipso_ipv4.c @@ -2272,6 +2272,14 @@ int cipso_v4_skbuff_delattr(struct sk_buff *skb) new_hdr_len_actual = hdr_len_actual - cipso_len; new_hdr_len = (new_hdr_len_actual + 3) & ~3; hdr_len_delta = (iph->ihl << 2) - new_hdr_len; + if (opt->srr > opt->cipso) + opt->srr -= cipso_len; + if (opt->rr > opt->cipso) + opt->rr -= cipso_len; + if (opt->ts > opt->cipso) + opt->ts -= cipso_len; + if (opt->router_alert > opt->cipso) + opt->router_alert -= cipso_len; /* 1. shift any options after CIPSO to the left */ memmove(cipso_ptr, cipso_ptr + cipso_len, base-commit: 99b43ede9e355ba35244cc9470bf1819774ce39d -- 2.55.0