mirror of https://gitee.com/openkylin/linux.git
net: socket: add check for negative optlen in compat setsockopt
__sys_setsockopt() already checks for `optlen < 0`. Add an equivalent check to the compat path for robustness. This has to be `> INT_MAX` instead of `< 0` because the signedness of `optlen` is different here. Signed-off-by: Jann Horn <jannh@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
f5b51fe804
commit
52baf9878b
|
@ -388,8 +388,12 @@ static int __compat_sys_setsockopt(int fd, int level, int optname,
|
||||||
char __user *optval, unsigned int optlen)
|
char __user *optval, unsigned int optlen)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
struct socket *sock = sockfd_lookup(fd, &err);
|
struct socket *sock;
|
||||||
|
|
||||||
|
if (optlen > INT_MAX)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
sock = sockfd_lookup(fd, &err);
|
||||||
if (sock) {
|
if (sock) {
|
||||||
err = security_socket_setsockopt(sock, level, optname);
|
err = security_socket_setsockopt(sock, level, optname);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
Loading…
Reference in New Issue