Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1280092 > unrolled thread
| Started by | Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> |
|---|---|
| First post | 2015-11-30 17:40 +0100 |
| Last post | 2015-12-03 05:50 +0100 |
| Articles | 4 — 4 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH] sctp: use GFP_USER for user-controlled kmalloc Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> - 2015-11-30 17:40 +0100
RE: [PATCH] sctp: use GFP_USER for user-controlled kmalloc David Laight <David.Laight@ACULAB.COM> - 2015-12-01 11:50 +0100
Re: [PATCH] sctp: use GFP_USER for user-controlled kmalloc Daniel Borkmann <daniel@iogearbox.net> - 2015-12-01 12:30 +0100
Re: [PATCH] sctp: use GFP_USER for user-controlled kmalloc David Miller <davem@davemloft.net> - 2015-12-03 05:50 +0100
| From | Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> |
|---|---|
| Date | 2015-11-30 17:40 +0100 |
| Subject | [PATCH] sctp: use GFP_USER for user-controlled kmalloc |
| Message-ID | <qAzEC-62E-13@gated-at.bofh.it> |
Dmitry Vyukov reported that the user could trigger a kernel warning by using a large len value for getsockopt SCTP_GET_LOCAL_ADDRS, as that value directly affects the value used as a kmalloc() parameter. This patch thus switches the allocation flags from all user-controllable kmalloc size to GFP_USER to put some more restrictions on it and also disables the warn, as they are not necessary. Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> --- net/sctp/socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 897c01c029cab3d5805cc56b0964c70e06f4143a..676b3bb092e16848fd1c822e1c999af4a2ef198d 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -972,7 +972,7 @@ static int sctp_setsockopt_bindx(struct sock *sk, return -EFAULT; /* Alloc space for the address array in kernel memory. */ - kaddrs = kmalloc(addrs_size, GFP_KERNEL); + kaddrs = kmalloc(addrs_size, GFP_USER | __GFP_NOWARN); if (unlikely(!kaddrs)) return -ENOMEM; @@ -4928,7 +4928,7 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len, to = optval + offsetof(struct sctp_getaddrs, addrs); space_left = len - offsetof(struct sctp_getaddrs, addrs); - addrs = kmalloc(space_left, GFP_KERNEL); + addrs = kmalloc(space_left, GFP_USER | __GFP_NOWARN); if (!addrs) return -ENOMEM; -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | David Laight <David.Laight@ACULAB.COM> |
|---|---|
| Date | 2015-12-01 11:50 +0100 |
| Message-ID | <qAQFs-8sH-23@gated-at.bofh.it> |
| In reply to | #1280092 |
From: Marcelo Ricardo Leitner > Sent: 30 November 2015 16:33 > Dmitry Vyukov reported that the user could trigger a kernel warning by > using a large len value for getsockopt SCTP_GET_LOCAL_ADDRS, as that > value directly affects the value used as a kmalloc() parameter. > > This patch thus switches the allocation flags from all user-controllable > kmalloc size to GFP_USER to put some more restrictions on it and also > disables the warn, as they are not necessary. ISTM that the code should put some 'sanity limit' on that size before allocating the kernel buffer. David -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Daniel Borkmann <daniel@iogearbox.net> |
|---|---|
| Date | 2015-12-01 12:30 +0100 |
| Message-ID | <qARia-ww-1@gated-at.bofh.it> |
| In reply to | #1280748 |
On 12/01/2015 11:46 AM, David Laight wrote: > From: Marcelo Ricardo Leitner >> Sent: 30 November 2015 16:33 >> Dmitry Vyukov reported that the user could trigger a kernel warning by >> using a large len value for getsockopt SCTP_GET_LOCAL_ADDRS, as that >> value directly affects the value used as a kmalloc() parameter. >> >> This patch thus switches the allocation flags from all user-controllable >> kmalloc size to GFP_USER to put some more restrictions on it and also >> disables the warn, as they are not necessary. > > ISTM that the code should put some 'sanity limit' on that > size before allocating the kernel buffer. One could do that in addition, but this buffer has just a short lifetime and by using GFP_USER hardwall restrictions apply already. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2015-12-03 05:50 +0100 |
| Message-ID | <qBu0a-at-13@gated-at.bofh.it> |
| In reply to | #1280092 |
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Date: Mon, 30 Nov 2015 14:32:54 -0200 > Dmitry Vyukov reported that the user could trigger a kernel warning by > using a large len value for getsockopt SCTP_GET_LOCAL_ADDRS, as that > value directly affects the value used as a kmalloc() parameter. > > This patch thus switches the allocation flags from all user-controllable > kmalloc size to GFP_USER to put some more restrictions on it and also > disables the warn, as they are not necessary. > > Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> > Acked-by: Daniel Borkmann <daniel@iogearbox.net> Applied. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web