* [PATCH net] bpf/xskmap: Return ERR_PTR for failure case instead of NULL.
@ 2019-09-24 16:24 Jonathan Lemon
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Lemon @ 2019-09-24 16:24 UTC (permalink / raw)
To: daniel, bjorn.topel, netdev; +Cc: kernel-team
When kzalloc() failed, NULL was returned to the caller, which
tested the pointer with IS_ERR(), which didn't match, so the
pointer was used later, resulting in a NULL dereference.
Return ERR_PTR(-ENOMEM) instead of NULL.
Reported-by: syzbot+491c1b7565ba9069ecae@syzkaller.appspotmail.com
Fixes: 0402acd683c6 ("xsk: remove AF_XDP socket from map when the socket is released")
Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
---
kernel/bpf/xskmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/bpf/xskmap.c b/kernel/bpf/xskmap.c
index 942c662e2eed..82a1ffe15dfa 100644
--- a/kernel/bpf/xskmap.c
+++ b/kernel/bpf/xskmap.c
@@ -37,7 +37,7 @@ static struct xsk_map_node *xsk_map_node_alloc(struct xsk_map *map,
node = kzalloc(sizeof(*node), GFP_ATOMIC | __GFP_NOWARN);
if (!node)
- return NULL;
+ return ERR_PTR(-ENOMEM);
err = xsk_map_inc(map);
if (err) {
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] bpf/xskmap: Return ERR_PTR for failure case instead of NULL.
2019-09-24 19:30 ` Björn Töpel
@ 2019-09-25 20:19 ` Daniel Borkmann
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2019-09-25 20:19 UTC (permalink / raw)
To: Björn Töpel
Cc: Jonathan Lemon, netdev, Alexei Starovoitov, kernel-team, bpf,
Karlsson, Magnus, syzkaller-bugs, syzbot+491c1b7565ba9069ecae
On Tue, Sep 24, 2019 at 09:30:44PM +0200, Björn Töpel wrote:
> On 2019-09-24 18:25, Jonathan Lemon wrote:
> > When kzalloc() failed, NULL was returned to the caller, which
> > tested the pointer with IS_ERR(), which didn't match, so the
> > pointer was used later, resulting in a NULL dereference.
> >
> > Return ERR_PTR(-ENOMEM) instead of NULL.
> >
> > Reported-by: syzbot+491c1b7565ba9069ecae@syzkaller.appspotmail.com
> > Fixes: 0402acd683c6 ("xsk: remove AF_XDP socket from map when the socket is released")
> > Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
>
> Thanks Jonathan! You beat me to it! :-P
>
> Acked-by: Björn Töpel <bjorn.topel@intel.com>
Applied, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] bpf/xskmap: Return ERR_PTR for failure case instead of NULL.
2019-09-24 16:25 Jonathan Lemon
@ 2019-09-24 19:30 ` Björn Töpel
2019-09-25 20:19 ` Daniel Borkmann
0 siblings, 1 reply; 4+ messages in thread
From: Björn Töpel @ 2019-09-24 19:30 UTC (permalink / raw)
To: Jonathan Lemon, daniel, netdev, Alexei Starovoitov
Cc: kernel-team, bpf, Karlsson, Magnus, syzkaller-bugs,
syzbot+491c1b7565ba9069ecae
On 2019-09-24 18:25, Jonathan Lemon wrote:
> When kzalloc() failed, NULL was returned to the caller, which
> tested the pointer with IS_ERR(), which didn't match, so the
> pointer was used later, resulting in a NULL dereference.
>
> Return ERR_PTR(-ENOMEM) instead of NULL.
>
> Reported-by: syzbot+491c1b7565ba9069ecae@syzkaller.appspotmail.com
> Fixes: 0402acd683c6 ("xsk: remove AF_XDP socket from map when the socket is released")
> Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Thanks Jonathan! You beat me to it! :-P
Acked-by: Björn Töpel <bjorn.topel@intel.com>
> ---
> kernel/bpf/xskmap.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/xskmap.c b/kernel/bpf/xskmap.c
> index 942c662e2eed..82a1ffe15dfa 100644
> --- a/kernel/bpf/xskmap.c
> +++ b/kernel/bpf/xskmap.c
> @@ -37,7 +37,7 @@ static struct xsk_map_node *xsk_map_node_alloc(struct xsk_map *map,
>
> node = kzalloc(sizeof(*node), GFP_ATOMIC | __GFP_NOWARN);
> if (!node)
> - return NULL;
> + return ERR_PTR(-ENOMEM);
>
> err = xsk_map_inc(map);
> if (err) {
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net] bpf/xskmap: Return ERR_PTR for failure case instead of NULL.
@ 2019-09-24 16:25 Jonathan Lemon
2019-09-24 19:30 ` Björn Töpel
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Lemon @ 2019-09-24 16:25 UTC (permalink / raw)
To: daniel, bjorn.topel, netdev; +Cc: kernel-team
When kzalloc() failed, NULL was returned to the caller, which
tested the pointer with IS_ERR(), which didn't match, so the
pointer was used later, resulting in a NULL dereference.
Return ERR_PTR(-ENOMEM) instead of NULL.
Reported-by: syzbot+491c1b7565ba9069ecae@syzkaller.appspotmail.com
Fixes: 0402acd683c6 ("xsk: remove AF_XDP socket from map when the socket is released")
Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
---
kernel/bpf/xskmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/bpf/xskmap.c b/kernel/bpf/xskmap.c
index 942c662e2eed..82a1ffe15dfa 100644
--- a/kernel/bpf/xskmap.c
+++ b/kernel/bpf/xskmap.c
@@ -37,7 +37,7 @@ static struct xsk_map_node *xsk_map_node_alloc(struct xsk_map *map,
node = kzalloc(sizeof(*node), GFP_ATOMIC | __GFP_NOWARN);
if (!node)
- return NULL;
+ return ERR_PTR(-ENOMEM);
err = xsk_map_inc(map);
if (err) {
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-09-25 20:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-24 16:24 [PATCH net] bpf/xskmap: Return ERR_PTR for failure case instead of NULL Jonathan Lemon
2019-09-24 16:25 Jonathan Lemon
2019-09-24 19:30 ` Björn Töpel
2019-09-25 20:19 ` Daniel Borkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).