From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id E041080063 for ; Tue, 1 Dec 2026 15:40:17 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6B1Fd7hS020277; Tue, 1 Dec 2026 18:39:08 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6B1Fd7hS020277 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="kyWdwGNM" Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6B1Fd5j8020267 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 1 Dec 2026 18:39:05 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6B1Fd5j8020267 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-c51f4e52de1so261728766b.0 for ; Tue, 01 Dec 2026 07:39:05 -0800 (PST) X-Gm-Message-State: APuU4Z9AIC+sSbKFjD47Q5ASskpPr34+MfgBa3KRvBbNgRbdjPG2ZAPi lGXgmtEQZVjPqCvctVE0ArqDqFyJ6Sj3EE0gkRSlfBbNLZiuRxagkU+9M6bBvecRrEQMum0nrfD hX/1u08ErvHmhkcEu3hasG/2nNXRwNU+h1ZyV28e6eXmimC5REwv38A== X-Gm-Gg: AZFdTZflTklsN/WKH1c1NiLqQmFkwgYYWDwrn9xZyYw6P/t4JucSAcJN4AwZKAN8iiv j0mv7m73LcAenx4HclAb2qX2smNOGgD3pl85PWmh4yQYQbCOyJrEan2a/oZ5MTqBsQDWbEU4vh1 pbb8fm70MVBIunxOeZrknojkm/ZnBtHeANN5v4845DGA6SLTIpfb9RKjs/ZgzxKTg5mj2O+HA8x StORO8dQZTAw9GH8rNoudwwTC81SgAkhFlAefkwgU/2TKqQhnLejaLz3kp3+upTGVsqatqHbqfB ISnwe9MTD3kxcqNgcsMuVnmc5zxS+oLQqj46RKcgMyKSrq6LMi6vUyeoO0AC0UI++9mhLxjBA/Z r5ERzYD7BA4lRI79cNYbEhlx20A== X-Received: by 2002:a17:906:ad8:b0:c2e:4397:7c82 with SMTP id a640c23a62f3a-c513a5e6a7fmr2174910566b.6.1796139545591; Tue, 01 Dec 2026 07:39:05 -0800 (PST) X-Received: by 2002:a17:906:ad8:b0:c2e:4397:7c82 with SMTP id a640c23a62f3a-c513a5e6a7fmr2174908966b.6.1796139545122; Tue, 01 Dec 2026 07:39:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1796139545; cv=none; d=google.com; s=arc-20260327; b=GaumelEWfrowB4SZzzke5nu+0ioRg80WGw+9tdz6VgMv9NhUC3jEs0qrwJApu43GHD eppVZ1QCkhadNygSDTvbXaxCFd0lHJKgXy9N18yOYDDHr+DqhppVk14HsP571zFuBb3E DBQ2PNnDFRfKV1sK8G+Jt6Q0ujwRySn8g63cKGTGhs/ZjCNtsbp+kvx8w7VCoYlAvonk bKJnxg9X/hUKYLBy+N0GrD13QCkfHmPVi6NGnhTB+u3pEBMQB7sQYYtniKHjk+SHCB4r RGurl/w6fgqsWT0qk6XlsWNAT7t8K/vccQlC54N+kxTvbklCl4wFZ7p15aVklFNCZ6Vx +Hkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=0jzEPC1YRNH5wxG51TutQPzE1MZuJwca8K/nWqbtG6I=; fh=/QSWnKFFIPNLStgUoDwCQRaXnWcMIG7fyKJgHY+VEpU=; b=kqqVObvuNEmrRlDx+Qq3dzuJ/Hh2WXWEniiRmR39Lwak6Dndvf8P+vRBDmlG+o63+B UB3DGF6qm1cjHzLS07GoBleQgMI0tecqn1tQf20lo0ASiyFzeH9lAbq8mwet95En5aJJ w7KlZcA8GbJRwHb/evcpOw/j5UtIyQer9s72s0ebVEEVdBfM2jxdiOq03Cay+IMikZ99 BlDZofdzSC9b0b5ofvy9jFOp9t56GUlgIHn25XNb6PTDCPasXQMV4OP6wq1XtHe1czos 1EdkdWGra+AR0HsmKv6jL8VzXz8wO2hV9zfBpbinKSSKKmmK0nwKH/MbrNm/1QRSZaMa Jz2w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=kyWdwGNM; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id a640c23a62f3a-c513b06d67dsi2344065466b.213.2026.12.01.07.39.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 07:39:05 -0800 (PST) Received-SPF: pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=kyWdwGNM; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=0jzEPC1YRNH5wxG51TutQPzE1MZuJwca8K/nWqbtG6I=; b=kyWdwGNMpaIa HePfmPtmLW2EjylGa6zPcq+Ai4uJnIl4+rGYTHlx4CgyNPee8tfyqDC1Cr0xDz6B0GYrWR4CxjoLv JPsIEOh+TKo6FvcpKai1JzkG1U7OxBcOTC7E8+YQGT+97I8lEde1FF0xE299ZdYbcZ0V0SB/iD3GL q18Xx9oyYfRLM6z1f4c0hZeZaqoyb7CtWngaSB3CmuWgAITh+11uzqHeXBYu/MoVpUx6aMxThKqOZ ATnIQPgg1r2Y1LSucW2O8AbmSuG92yYQGZLqXDt6JjlJAJP1EGBCsjSGfmw+u/zALbjlNNKHYPRQ7 vQv8096dt1JyOCXCObRhQw==; Received: from ch-vpn.virtuozzo.com ([130.117.225.6] helo=LekKit-T14) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xYPvC-0081OE-3B; Tue, 01 Dec 2026 16:37:45 +0100 From: Eva Kurchatova To: khorenko@virtuozzo.com, vladimir.riabchun@virtuozzo.com Date: Tue, 1 Dec 2026 14:10:29 +0200 Message-ID: <20261201153749.2872789-15-eva.kurchatova@virtuozzo.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261201153749.2872789-1-eva.kurchatova@virtuozzo.com> References: <20261201153749.2872789-1-eva.kurchatova@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2 v2 14/15] ms/cipso: fix optlen corruption in cipso_v4_delopt() X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org From: Qihang [ Upstream commit 1f1f8e8c5176234fa31858cd25f2e9b88aac0a45 ] cipso_v4_delopt() recomputes the option length by walking the option buffer after the CIPSO option has been moved out. The walk then reads the stale bytes at the tail of the buffer as option data, and a crafted setsockopt(IP_OPTIONS) buffer can make it treat one of them as an option length, increasing opt->opt.optlen beyond the valid option data. The corrupted length stays on the socket and is later used as the copy length by getsockopt(IP_OPTIONS) and by the udp/raw/ping sendmsg paths, where it exceeds the size of the buffers they copy into. Compute the new length from the intact options before the move and subtract the CIPSO length, and fill the padding with IPOPT_END. Assisted-by: LLM Fixes: 014ab19a69c32 ("selinux: Set socket NetLabel based on connection endpoint") Cc: stable@vger.kernel.org Signed-off-by: Qihang Acked-by: Paul Moore Signed-off-by: Dave Miller Signed-off-by: Sasha Levin (cherry picked from commit 699141380f7f249b7ee594198d9bea6bcd4862ea) Taken as a prerequisite of 1f2c5183fc090 ("cipso: stop modifying live ip_options_rcu"). https://virtuozzo.atlassian.net/browse/VSTOR-158162 Feature: fix ms/net Signed-off-by: Eva Kurchatova --- net/ipv4/cipso_ipv4.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c index 740af8541d2f..15b8bb57feef 100644 --- a/net/ipv4/cipso_ipv4.c +++ b/net/ipv4/cipso_ipv4.c @@ -2015,6 +2015,10 @@ static int cipso_v4_delopt(struct ip_options_rcu __rcu **opt_ptr) cipso_ptr = &opt->opt.__data[cipso_off]; cipso_len = cipso_ptr[1]; + optlen_new = cipso_v4_get_actual_opt_len(opt->opt.__data, + opt->opt.optlen); + optlen_new -= cipso_len; + if (opt->opt.srr > opt->opt.cipso) opt->opt.srr -= cipso_len; if (opt->opt.rr > opt->opt.cipso) @@ -2028,11 +2032,12 @@ static int cipso_v4_delopt(struct ip_options_rcu __rcu **opt_ptr) memmove(cipso_ptr, cipso_ptr + cipso_len, opt->opt.optlen - cipso_off - cipso_len); - optlen_new = cipso_v4_get_actual_opt_len(opt->opt.__data, - opt->opt.optlen); hdr_delta = opt->opt.optlen; opt->opt.optlen = (optlen_new + 3) & ~3; hdr_delta -= opt->opt.optlen; + + memset(&opt->opt.__data[optlen_new], IPOPT_END, + opt->opt.optlen - optlen_new); } else { /* only the cipso option was present on the socket so we can * remove the entire option struct */ -- 2.56.1 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel