Received: from mail-vs1-f73.google.com (mail-vs1-f73.google.com [209.85.217.73]) (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 93D661607A4 for ; Tue, 2 Jun 2026 16:15:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780416951; cv=none; b=Ry3WS5XXKrY4ruGogOdl02OLffZK17Rc4CKbXbmlVbWfunfiSybC22TumBGucX8rsfjjJpLuhWNKsIWY9O/cMb2JzbZ9BFCN5kYt+z/7+wd328p2yUv0PbIxX52GZ1X3FTXzs/M8JqJH5i9UlP2dKPZyu+MLaGBG4Xcc9Mv1bJc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780416951; c=relaxed/simple; bh=2WNNRDg5Td4dZV1G777UiAywtY99HUA9g/cLa3kYY1o=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=uy6LzeBP+iY6WLXrM5Nw6J3jlKPzuals3D+vfSEUhIz4Qf8jZbPdCFpsk0utOuwB0cnCCKDwrF7su1+VkbI9Oe2Aim4q1yjL+vSnyCGB3YknBi09aGcTsVQ7WJlLnBLQS1uHAFS+CR59aPt2wSweuWniz48ExcsxpvtLFKjQFqY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ljnnSuPO; arc=none smtp.client-ip=209.85.217.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ljnnSuPO" Received: by mail-vs1-f73.google.com with SMTP id ada2fe7eead31-6cfb918a9d7so3693259137.0 for ; Tue, 02 Jun 2026 09:15:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780416949; x=1781021749; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=MxrawKuRjeiYmLI/CyOt3uFMjVo+B1MjcqZQlFolkBk=; b=ljnnSuPOxbtWrrU7loeoL+p8kuoO0UFxLmQ6OIv4tehBYZRRTrHkZ+HS/RXoGceQZD mg/WIM4igLLu+QMra77xk872Gmq70DUH812wMRkgHicuXR631ByX1TPoPO3Ui7HkV6UF 2VqkwyaVrSh5frfN6EUzxsAU8qw1IgpK1kUEZFyZEJEke1KNycGOdYt/RvqIDQ6fxteK JXm+/gQSuGLPUzAQtQNAOxGxycqPWe0AzaYrdM57w9PjiqUibXTkDjL4lTZHvb3iRkln iQdSEnfcdMa9NpCB3Wf+c0Ta+SbhhXhppz4QFg9DptsTGKIe33kMot8kxJeaoejVY+JM dWgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780416949; x=1781021749; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=MxrawKuRjeiYmLI/CyOt3uFMjVo+B1MjcqZQlFolkBk=; b=OgbVsigwxHAn3hIzc+vYk08UvP9JSGXUFZNMufozeocXQ/6IHOWsHVQzVq6XFSMcaq jyTw8mDeBgrfv3CWvw7Q8y9yPgUD4xLp+L4DkdL/HrHBJAVVrUgrdue/nfBjuFTckPYE 6GzryoxpmVpO6ZE5iu778bKNxoDf5GfGg6ImpY3ENgreegVas9AeE3vLU5EQXzn3F1Be 8I/CbxE4u/UAYrC/z1daoJNwRAiDbLOvda6D1b2eX3K9azB3emTDGpkcUkxOND2FZ93a PqCr207EgQgFWw5dI/0DhnlB/yeLCUXQKCrocX2c/zrkE6d+17gjO2Er+SS6wy/e7IXB Bmvg== X-Forwarded-Encrypted: i=1; AFNElJ9t0a58C6zQkK8DjwIxscTWDBH2g7MyhB5VecZJ0QZ9JDzqcFxqYZTg6WGQ9sQs7FruBsCBrHw=@vger.kernel.org X-Gm-Message-State: AOJu0YxHxrLtMP7owON+4hkvDu8QK2enES0Ysd8tHfX+wipNGpQAUmFI W49MHfGmQjdQq1XP8971GNAxlhB6CJL6xU7Ca5klXLBUjKJKpTpTpHatmbb3W9lchofWMxHt/WF Wnw6hASuwwLC4Zg== X-Received: from qvbdl10.prod.google.com ([2002:ad4:4e0a:0:b0:8cc:fcc:6e7c]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6102:509e:b0:606:49d:1861 with SMTP id ada2fe7eead31-6ea2e790569mr542394137.27.1780416947986; Tue, 02 Jun 2026 09:15:47 -0700 (PDT) Date: Tue, 2 Jun 2026 16:15:47 +0000 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.54.0.929.g9b7fa37559-goog Message-ID: <20260602161547.2642155-1-edumazet@google.com> Subject: [PATCH v2 net] ipv4: restrict IPOPT_SSRR and IPOPT_LSRR options From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Ido Schimmel , David Ahern , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet , Tamir Shahar , Amit Klein Content-Type: text/plain; charset="UTF-8" This patch restricts setting Loose Source and Record Route (LSRR) and Strict Source and Record Route (SSRR) IP options to users with CAP_NET_RAW capability. This prevents unprivileged applications from forcing packets to route through attacker-controlled nodes to leak TCP ISN and possibly other protocol information. While LSRR and SSRR are commonly filtered in many network environments, they may still be supported and forwarded along some network paths. RFC 7126 (Recommendations on Filtering of IPv4 Packets Containing IPv4 Options) recommend to drop these options in 4.3 and 4.4. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: Tamir Shahar Reported-by: Amit Klein Signed-off-by: Eric Dumazet --- v2: use Ido's suggestion. v1: https://lore.kernel.org/netdev/20260601124157.699463-1-edumazet@google.com/ net/ipv4/ip_options.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index be8815ce3ac242372eeae4a97091cda26d40ceb0..09d745112c1526a1f151cd917f97dc1e236d6d22 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c @@ -530,6 +530,10 @@ int ip_options_get(struct net *net, struct ip_options_rcu **optp, kfree(opt); return -EINVAL; } + if (opt->opt.srr && !ns_capable(net->user_ns, CAP_NET_RAW)) { + kfree(opt); + return -EPERM; + } kfree(*optp); *optp = opt; return 0; -- 2.54.0.929.g9b7fa37559-goog