From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1273129614D; Wed, 23 Apr 2025 15:27:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745422050; cv=none; b=oXjDlKRsLSSPLeSAXtXTdgllCCByz+J5KXRnSsDcUux2i8XKNM6N8PKjpaqq2+zY/wwdZ6QmUZ6tmbL+qhoTgKRO1FiA3g2Ihhkx3qzqiyP7U6qlLduKMfEMTC7b22sA7H/bGXSJSKvcWGvT+zPC9Y0oQz/zj+41tCI86/l8s6k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745422050; c=relaxed/simple; bh=gz8ND9px3DP8WKm7ovnoRmwc6YDKp9ScN4qeZW2c1vM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BbFhFywZcXgiFfJ/Lp3dg0Gu37WUN6RWXFkzC1vvUZgHbN9XAobLQdZBTx9Z9qXTtnkhsq5vozjVu0iTmNg6nDQ1aBuWVl+1wA8HM6jjFOjoNHaQrb5QyBbIOLyLuictNqGjXhqc6AwopSTOsxFBiQTjhWznWXyZSoEp1BJRdRE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=sXl8bjYD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="sXl8bjYD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A94EC4CEE2; Wed, 23 Apr 2025 15:27:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745422050; bh=gz8ND9px3DP8WKm7ovnoRmwc6YDKp9ScN4qeZW2c1vM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sXl8bjYDOFBiLetRb7jqMVDewNZinmgJk8tVXrZHHtcRI3zhpOZzPhZfoeuji8N+X zXdQJn2M4Jt8vjV1lHFxMnFWtM9utQdeq/QYTmNd/H0zL+sg+0tL0648jhFFK+Su7T vtB8L+yNNgUnkTRRSbDn3/DkQkvQMgbOXokaHLvk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+b07a9da40df1576b8048@syzkaller.appspotmail.com, Ilya Maximets , Eelco Chaudron , Aaron Conole , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 269/393] net: openvswitch: fix nested key length validation in the set() action Date: Wed, 23 Apr 2025 16:42:45 +0200 Message-ID: <20250423142654.471868019@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250423142643.246005366@linuxfoundation.org> References: <20250423142643.246005366@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ilya Maximets [ Upstream commit 65d91192aa66f05710cfddf6a14b5a25ee554dba ] It's not safe to access nla_len(ovs_key) if the data is smaller than the netlink header. Check that the attribute is OK first. Fixes: ccb1352e76cf ("net: Add Open vSwitch kernel components.") Reported-by: syzbot+b07a9da40df1576b8048@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=b07a9da40df1576b8048 Tested-by: syzbot+b07a9da40df1576b8048@syzkaller.appspotmail.com Signed-off-by: Ilya Maximets Reviewed-by: Eelco Chaudron Acked-by: Aaron Conole Link: https://patch.msgid.link/20250412104052.2073688-1-i.maximets@ovn.org Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/openvswitch/flow_netlink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c index 9c13e14034d3b..089ab1826e1d5 100644 --- a/net/openvswitch/flow_netlink.c +++ b/net/openvswitch/flow_netlink.c @@ -2862,7 +2862,8 @@ static int validate_set(const struct nlattr *a, size_t key_len; /* There can be only one key in a action */ - if (nla_total_size(nla_len(ovs_key)) != nla_len(a)) + if (!nla_ok(ovs_key, nla_len(a)) || + nla_total_size(nla_len(ovs_key)) != nla_len(a)) return -EINVAL; key_len = nla_len(ovs_key); -- 2.39.5