Message ID | 20240404123602.2369488-1-edumazet@google.com |
---|---|
State | New |
Headers | show |
Series | [net] Bluetooth: validate setsockopt( BT_PKT_STATUS / BT_DEFER_SETUP) user input | expand |
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 43daf965a01e4ac5c9329150080b00dcd63c7e1c..9d013f01865fd2509f28eac3bceadf682f0a5edb 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -843,6 +843,10 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, break; } + if (optlen < sizeof(u32)) { + err = -EINVAL; + break; + } if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break; @@ -890,6 +894,10 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, break; case BT_PKT_STATUS: + if (optlen < sizeof(u32)) { + err = -EINVAL; + break; + } if (copy_from_sockptr(&opt, optval, sizeof(u32))) { err = -EFAULT; break;