mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
Bluetooth: Check MTU value in l2cap_sock_setsockopt_old
If user tries to set an invalid MTU value, l2cap_sock_setsockopt_old should return -EINVAL. Signed-off-by: Andre Guedes <[email protected]> Signed-off-by: Gustavo Padovan <[email protected]>
This commit is contained in:
parent
6fcb06a28d
commit
682877c31f
1 changed files with 21 additions and 0 deletions
|
|
@ -445,6 +445,22 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
|
|||
return err;
|
||||
}
|
||||
|
||||
static bool l2cap_valid_mtu(struct l2cap_chan *chan, u16 mtu)
|
||||
{
|
||||
switch (chan->scid) {
|
||||
case L2CAP_CID_LE_DATA:
|
||||
if (mtu < L2CAP_LE_DEFAULT_MTU)
|
||||
return false;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (mtu < L2CAP_DEFAULT_MIN_MTU)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __user *optval, unsigned int optlen)
|
||||
{
|
||||
struct sock *sk = sock->sk;
|
||||
|
|
@ -483,6 +499,11 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us
|
|||
break;
|
||||
}
|
||||
|
||||
if (!l2cap_valid_mtu(chan, opts.imtu)) {
|
||||
err = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
chan->mode = opts.mode;
|
||||
switch (chan->mode) {
|
||||
case L2CAP_MODE_BASIC:
|
||||
|
|
|
|||
Loading…
Reference in a new issue