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 757CD80063 for ; Tue, 1 Dec 2026 15:40:19 +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 6B1FcxG5020243; Tue, 1 Dec 2026 18:39:00 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6B1FcxG5020243 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="LsYoq3cs" Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6B1FcxlN020239 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 1 Dec 2026 18:38:59 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6B1FcxlN020239 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-c505ee61160so1119882666b.0 for ; Tue, 01 Dec 2026 07:38:59 -0800 (PST) X-Gm-Message-State: APuU4Z8uLMwJr2JEZV+NgNtFDwnf4a0/zmQRqJhl67kZN2PQW6z1fk1U 7KpULEvy71UT9vN0rrhgpMBoLVraTaKuy0moRQuAtC9VhSuzKbpuMQ0vJhP2CMZybfKiwg0v9JI IX4mLoav6NZwDv0/UoC0FQbuIZksBbRaHK32REq4ToDHaYKhgsR//hg== X-Gm-Gg: AZFdTZcwT9zrxAnh8CrL0zTIpHKvKCfOKCllW/LVkpy39WKKJ2IJP4VSHcEm7Jc0t+d F2MHA2qAfmMQhdX2ZlpYEAg2mxH/cM79IRUcaRJgy0J3Y0sDGeuGkih6Imu+x7xKa2k8Db0Q7Ol xWTKybQ1YEDCrt4XWZE+h1Pi/ZIx7bMMv+yrwavm93aEUDc1t0TrMTxNjhzeQaUvt+HQnKiigFF PMq/grs7Waiy9JId0/NCMnUNmyZhfgAKF9StYjaOqF3SyzVSdNW+p/DxQKS06FDMTP2ex3IwpoH LHycWnRTEj5TNnyVcAtRVWzWN7GNAGLEGbWdpTuZ0+uFB3XPq5j64+DRrNlEhXynqehR1CYaTVq v4SbvNjusWPU2dxVavGFp3hvV X-Received: by 2002:a17:906:3588:b0:c41:6de7:7dee with SMTP id a640c23a62f3a-c513a3ab1a7mr2231422266b.7.1796139538854; Tue, 01 Dec 2026 07:38:58 -0800 (PST) X-Received: by 2002:a17:906:3588:b0:c41:6de7:7dee with SMTP id a640c23a62f3a-c513a3ab1a7mr2231420166b.7.1796139538326; Tue, 01 Dec 2026 07:38:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1796139538; cv=none; d=google.com; s=arc-20260327; b=FJeisfGTeF33P42wye0hqEphQTcn7kZxVaFMjqyNh2QcqWsMpXp9k+m0eH9i4aPHjG LyKGoZMWtsNjnUiDM/v3gIPbNF9iwJt4/MsRQw5fh18IYoJ85eelJNnnePMMYVret16q yNivpeOSBp8SIUd7wFk8ELWnWvYIlIz5r7bJbRD8k8wblgIjohQJHUQ8tSi6lezhZL6u J/NYMhAR7L/rN2B0A6u761ngWF1WqEJqyMsE02/sOWVGYERTo9Qa9WkjrlUkD9jhmifZ y7fTfxj4JtGb+yRkyLfh6A8GL+fG86XzzkcOeIJuW7lnqYs1+HHe1K6soZYaTeaaJxIl nOAg== 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=w/MyYqxwUdjkYMu7Ymtm0XDsEpFDhUxVUclLVKEDqA4=; fh=/QSWnKFFIPNLStgUoDwCQRaXnWcMIG7fyKJgHY+VEpU=; b=MxFin2+YB/xe/hFRn4RfuGsRy0mFX0pRm6QZ6qdjAr6TLQ3SSvzYV/PNt4QSIdYWj9 FWfmt39PWO3f/u8cYE2UfVwKezTlx66GPA+WpxgQvQmGTN5mw8mwFo1kGq7nJvGHFYOF /cFKRi4EbJSFSgCy8EiEntqUmoebSlQA8ndnHsLtOu/HN5zZhhLChRbSbenbLJKFXG6W KQ5Rgf9zu/MrN4v2uXcT6aHNW8Rdy70jLDQDfbHAIqkQt8eq8boo6Vlvn6J3qb1zJcLf gwpDQP52yVMcyTFYcnenu50jwxKfYOlVei7ViqyptecJ+O9Bg9es2KdrMl8aisfTNz2n 3iFQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=LsYoq3cs; 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-c513afe4384si2393352966b.107.2026.12.01.07.38.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 07:38:58 -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=LsYoq3cs; 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=w/MyYqxwUdjkYMu7Ymtm0XDsEpFDhUxVUclLVKEDqA4=; b=LsYoq3csmDDn o6C9Cb0qwJe76lxW+VgKF7Vo6Id9bCj9b2fs3TjikZ6dDSw3nzKfR30R9ePlTibr6TUrG1ygx/Q8v jfo+CrDdyXZzjyOPiZ7zwWXwr3pABXN0lm0zikSiqCbV3AQfsVawj0pbDqrInBQ29OKhqo7mWsRjl O2gum8TBUX2jItEFFmfXSAa+gXtYQb9lDh4UA3mNXZCUGW1SMyU80q/umqIHShHdydvJBLwfzhHku gTQ61xfyamgz0sWkEQ6qGuuNeVtieJd44kqMR/FAM64dlGJVDccbZExyU0KK8dPOPwTACJ1xh7K36 onb6+uJtdL+Nl/Kxylm16A==; 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 1xYPvB-0081OE-2g; Tue, 01 Dec 2026 16:37:44 +0100 From: Eva Kurchatova To: khorenko@virtuozzo.com, vladimir.riabchun@virtuozzo.com Date: Tue, 1 Dec 2026 14:10:25 +0200 Message-ID: <20261201153749.2872789-11-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 10/15] ms/netlabel: validate unlabeled address and mask attribute lengths 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: Chenguang Zhao [ Upstream commit 9772589b57e44aedc240211c5c3f7a684a034d3a ] netlbl_unlabel_addrinfo_get() used the address attribute length to determine whether the attribute data could be read as an IPv4 or IPv6 address, but did not independently validate the corresponding mask attribute length. A crafted Generic Netlink request could therefore provide a valid IPv4/IPv6 address attribute with a shorter mask attribute, which would later be read as a full struct in_addr or struct in6_addr. NLA_BINARY policy lengths are maximum lengths by default, so use NLA_POLICY_EXACT_LEN() for the unlabeled IPv4/IPv6 address and mask attributes. This rejects short attributes during policy validation and also exposes the exact length requirements through policy introspection. Fixes: 8cc44579d1bd ("NetLabel: Introduce static network labels for unlabeled connections") Signed-off-by: Chenguang Zhao Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin (cherry picked from commit 71c52da13c3737493b42d20d9f33de34e03b3156) https://virtuozzo.atlassian.net/browse/VSTOR-158163 Feature: fix ms/net Signed-off-by: Eva Kurchatova --- net/netlabel/netlabel_unlabeled.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/net/netlabel/netlabel_unlabeled.c b/net/netlabel/netlabel_unlabeled.c index c81addca1840..c9684ddc2395 100644 --- a/net/netlabel/netlabel_unlabeled.c +++ b/net/netlabel/netlabel_unlabeled.c @@ -114,14 +114,14 @@ static struct genl_family netlbl_unlabel_gnl_family; /* NetLabel Netlink attribute policy */ static const struct nla_policy netlbl_unlabel_genl_policy[NLBL_UNLABEL_A_MAX + 1] = { [NLBL_UNLABEL_A_ACPTFLG] = { .type = NLA_U8 }, - [NLBL_UNLABEL_A_IPV6ADDR] = { .type = NLA_BINARY, - .len = sizeof(struct in6_addr) }, - [NLBL_UNLABEL_A_IPV6MASK] = { .type = NLA_BINARY, - .len = sizeof(struct in6_addr) }, - [NLBL_UNLABEL_A_IPV4ADDR] = { .type = NLA_BINARY, - .len = sizeof(struct in_addr) }, - [NLBL_UNLABEL_A_IPV4MASK] = { .type = NLA_BINARY, - .len = sizeof(struct in_addr) }, + [NLBL_UNLABEL_A_IPV6ADDR] = + NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)), + [NLBL_UNLABEL_A_IPV6MASK] = + NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)), + [NLBL_UNLABEL_A_IPV4ADDR] = + NLA_POLICY_EXACT_LEN(sizeof(struct in_addr)), + [NLBL_UNLABEL_A_IPV4MASK] = + NLA_POLICY_EXACT_LEN(sizeof(struct in_addr)), [NLBL_UNLABEL_A_IFACE] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 }, [NLBL_UNLABEL_A_SECCTX] = { .type = NLA_BINARY } @@ -764,24 +764,14 @@ static int netlbl_unlabel_addrinfo_get(struct genl_info *info, void **mask, u32 *len) { - u32 addr_len; - if (info->attrs[NLBL_UNLABEL_A_IPV4ADDR] && info->attrs[NLBL_UNLABEL_A_IPV4MASK]) { - addr_len = nla_len(info->attrs[NLBL_UNLABEL_A_IPV4ADDR]); - if (addr_len != sizeof(struct in_addr) && - addr_len != nla_len(info->attrs[NLBL_UNLABEL_A_IPV4MASK])) - return -EINVAL; - *len = addr_len; + *len = sizeof(struct in_addr); *addr = nla_data(info->attrs[NLBL_UNLABEL_A_IPV4ADDR]); *mask = nla_data(info->attrs[NLBL_UNLABEL_A_IPV4MASK]); return 0; } else if (info->attrs[NLBL_UNLABEL_A_IPV6ADDR]) { - addr_len = nla_len(info->attrs[NLBL_UNLABEL_A_IPV6ADDR]); - if (addr_len != sizeof(struct in6_addr) && - addr_len != nla_len(info->attrs[NLBL_UNLABEL_A_IPV6MASK])) - return -EINVAL; - *len = addr_len; + *len = sizeof(struct in6_addr); *addr = nla_data(info->attrs[NLBL_UNLABEL_A_IPV6ADDR]); *mask = nla_data(info->attrs[NLBL_UNLABEL_A_IPV6MASK]); return 0; -- 2.56.1 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel