sctp: use GFP_USER for user-controlled kmalloc
Commitcacc062152
("sctp: use GFP_USER for user-controlled kmalloc") missed two other spots. For connectx, as it's more likely to be used by kernel users of the API, it detects if GFP_USER should be used or not. Fixes:cacc062152
("sctp: use GFP_USER for user-controlled kmalloc") Reported-by: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
3358a5c0c1
commit
9ba0b9636d
|
@ -1301,8 +1301,9 @@ static int __sctp_setsockopt_connectx(struct sock *sk,
|
|||
int addrs_size,
|
||||
sctp_assoc_t *assoc_id)
|
||||
{
|
||||
int err = 0;
|
||||
struct sockaddr *kaddrs;
|
||||
gfp_t gfp = GFP_KERNEL;
|
||||
int err = 0;
|
||||
|
||||
pr_debug("%s: sk:%p addrs:%p addrs_size:%d\n",
|
||||
__func__, sk, addrs, addrs_size);
|
||||
|
@ -1315,7 +1316,9 @@ static int __sctp_setsockopt_connectx(struct sock *sk,
|
|||
return -EFAULT;
|
||||
|
||||
/* Alloc space for the address array in kernel memory. */
|
||||
kaddrs = kmalloc(addrs_size, GFP_KERNEL);
|
||||
if (sk->sk_socket->file)
|
||||
gfp = GFP_USER | __GFP_NOWARN;
|
||||
kaddrs = kmalloc(addrs_size, gfp);
|
||||
if (unlikely(!kaddrs))
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -5773,7 +5776,7 @@ static int sctp_getsockopt_assoc_ids(struct sock *sk, int len,
|
|||
|
||||
len = sizeof(struct sctp_assoc_ids) + sizeof(sctp_assoc_t) * num;
|
||||
|
||||
ids = kmalloc(len, GFP_KERNEL);
|
||||
ids = kmalloc(len, GFP_USER | __GFP_NOWARN);
|
||||
if (unlikely(!ids))
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
Loading…
Reference in New Issue