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 BA23C253F12; Tue, 29 Apr 2025 17:15:27 +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=1745946927; cv=none; b=gePvf56mfKzEtFQ8limhEiTt+y4nDNY34qQUrp9D7MppkmvZHKfuSOTAKDjdWXvJQli3h2SUirt/U2+6Uh4d7CLrX9/aVq6Zt8h5mKF6y/47CVHvOLdEp4TjToT/GLOvMH1eLtQUyLTAPLMHGqMJ9d1/wnL4shWObJj5/Rq4gF0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745946927; c=relaxed/simple; bh=UfX4OsDOGgMOsl3jiLNVK1D7aMZlq13Vn7I4afRVf6s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zzu7zTyHxzz0yMI8sZ8u50cEaPDMCxHB+xhphpC+eNNurujS3lvRDugZunIzhqXCcuNJ+sHqU8ngGIm2GrF17f3sDDl/v8mGvQmFd58b4mXP82jpRt+MpjksW3ee2VT4fiAgs9PMUqynRlCF3QzXPexvluUKIKGdnL80F1SNaKQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2vvNRuZs; 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="2vvNRuZs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43E82C4CEE3; Tue, 29 Apr 2025 17:15:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745946927; bh=UfX4OsDOGgMOsl3jiLNVK1D7aMZlq13Vn7I4afRVf6s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2vvNRuZs5Bfv0Zi/NZm+LVU7ZQ9ah+F/8t7UJ67Lrb3F8U4puuNZRC+0m7f7t/Lu6 1VTG+7QBo6qAfhoun+K4jC0zOhLOsg6zsacSfKZ08TEG1SsU9uGCsux3e0qDQytxAl ijMa2YeYBAzqwCLb1J/+enNet6PP7KDDR7TKkCb0= 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 5.10 115/286] net: openvswitch: fix nested key length validation in the set() action Date: Tue, 29 Apr 2025 18:40:19 +0200 Message-ID: <20250429161112.588609840@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161107.848008295@linuxfoundation.org> References: <20250429161107.848008295@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-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 cff18a5bbf386..3f8f43dbf44fc 100644 --- a/net/openvswitch/flow_netlink.c +++ b/net/openvswitch/flow_netlink.c @@ -2834,7 +2834,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