USB: serial: cypress_m8: fix memory corruption with small endpoint
commit e1a9d791fd66ab2431b9e6f6f835823809869047 upstream.
Make sure that the interrupt-out endpoint max packet size is at least
eight bytes to avoid user-controlled slab corruption or NULL-pointer
dereference should a malicious device report a smaller size.
Fixes: 3416eaa1f8 ("USB: cypress_m8: Packet format is separate from characteristic size")
Cc: stable@vger.kernel.org # 2.6.26
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
[ johan: adjust context for 6.18 ]
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Ulrich Hecht <uli@kernel.org>
This commit is contained in:
1 parent
1315277b57
commit
dd6741d035
1 file changed
+8
@@ -450,6 +450,14 @@ static int cypress_generic_port_probe(struct usb_serial_port *port)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/*
|
||||
* The buffer must be large enough for the one or two-byte header (and
|
||||
* following data), but assume anything smaller than eight bytes is
|
||||
* broken.
|
||||
*/
|
||||
if (port->interrupt_out_size < 8)
|
||||
return -EINVAL;
|
||||
|
||||
priv = kzalloc(sizeof(struct cypress_private), GFP_KERNEL);
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
Reference in new issue
Block a user