Patch "enic: Validate length of nl attributes in enic_set_vf_port" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    enic: Validate length of nl attributes in enic_set_vf_port

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     enic-validate-length-of-nl-attributes-in-enic_set_vf.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 1f2181bc5f29c04cf1935787f154268aa768d415
Author: Roded Zats <rzats@xxxxxxxxxxxxxxxxxxxx>
Date:   Wed May 22 10:30:44 2024 +0300

    enic: Validate length of nl attributes in enic_set_vf_port
    
    [ Upstream commit e8021b94b0412c37bcc79027c2e382086b6ce449 ]
    
    enic_set_vf_port assumes that the nl attribute IFLA_PORT_PROFILE
    is of length PORT_PROFILE_MAX and that the nl attributes
    IFLA_PORT_INSTANCE_UUID, IFLA_PORT_HOST_UUID are of length PORT_UUID_MAX.
    These attributes are validated (in the function do_setlink in rtnetlink.c)
    using the nla_policy ifla_port_policy. The policy defines IFLA_PORT_PROFILE
    as NLA_STRING, IFLA_PORT_INSTANCE_UUID as NLA_BINARY and
    IFLA_PORT_HOST_UUID as NLA_STRING. That means that the length validation
    using the policy is for the max size of the attributes and not on exact
    size so the length of these attributes might be less than the sizes that
    enic_set_vf_port expects. This might cause an out of bands
    read access in the memcpys of the data of these
    attributes in enic_set_vf_port.
    
    Fixes: f8bd909183ac ("net: Add ndo_{set|get}_vf_port support for enic dynamic vnics")
    Signed-off-by: Roded Zats <rzats@xxxxxxxxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240522073044.33519-1-rzats@xxxxxxxxxxxxxxxxxxxx
    Signed-off-by: Paolo Abeni <pabeni@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 548d8095c0a79..b695f3f233286 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -1117,18 +1117,30 @@ static int enic_set_vf_port(struct net_device *netdev, int vf,
 	pp->request = nla_get_u8(port[IFLA_PORT_REQUEST]);
 
 	if (port[IFLA_PORT_PROFILE]) {
+		if (nla_len(port[IFLA_PORT_PROFILE]) != PORT_PROFILE_MAX) {
+			memcpy(pp, &prev_pp, sizeof(*pp));
+			return -EINVAL;
+		}
 		pp->set |= ENIC_SET_NAME;
 		memcpy(pp->name, nla_data(port[IFLA_PORT_PROFILE]),
 			PORT_PROFILE_MAX);
 	}
 
 	if (port[IFLA_PORT_INSTANCE_UUID]) {
+		if (nla_len(port[IFLA_PORT_INSTANCE_UUID]) != PORT_UUID_MAX) {
+			memcpy(pp, &prev_pp, sizeof(*pp));
+			return -EINVAL;
+		}
 		pp->set |= ENIC_SET_INSTANCE;
 		memcpy(pp->instance_uuid,
 			nla_data(port[IFLA_PORT_INSTANCE_UUID]), PORT_UUID_MAX);
 	}
 
 	if (port[IFLA_PORT_HOST_UUID]) {
+		if (nla_len(port[IFLA_PORT_HOST_UUID]) != PORT_UUID_MAX) {
+			memcpy(pp, &prev_pp, sizeof(*pp));
+			return -EINVAL;
+		}
 		pp->set |= ENIC_SET_HOST;
 		memcpy(pp->host_uuid,
 			nla_data(port[IFLA_PORT_HOST_UUID]), PORT_UUID_MAX);




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux