linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][bpf-next] bpf: fix null pointer dereference on pointer offload
@ 2018-11-13  9:29 Colin King
  2018-11-15  0:52 ` Jakub Kicinski
  2018-11-17  4:49 ` Alexei Starovoitov
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2018-11-13  9:29 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, netdev; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Pointer offload is being null checked however the following statement
dereferences the potentially null pointer offload when assigning
offload->dev_state.  Fix this by only assigning it if offload is not
null.

Detected by CoverityScan, CID#1475437 ("Dereference after null check")

Fixes: 00db12c3d141 ("bpf: call verifier_prep from its callback in struct bpf_offload_dev")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 kernel/bpf/offload.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c
index 52c5617e3716..54cf2b9c44a4 100644
--- a/kernel/bpf/offload.c
+++ b/kernel/bpf/offload.c
@@ -130,9 +130,10 @@ int bpf_prog_offload_verifier_prep(struct bpf_prog *prog)
 
 	down_read(&bpf_devs_lock);
 	offload = prog->aux->offload;
-	if (offload)
+	if (offload) {
 		ret = offload->offdev->ops->prepare(prog);
-	offload->dev_state = !ret;
+		offload->dev_state = !ret;
+	}
 	up_read(&bpf_devs_lock);
 
 	return ret;
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH][bpf-next] bpf: fix null pointer dereference on pointer offload
  2018-11-13  9:29 [PATCH][bpf-next] bpf: fix null pointer dereference on pointer offload Colin King
@ 2018-11-15  0:52 ` Jakub Kicinski
  2018-11-17  4:49 ` Alexei Starovoitov
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2018-11-15  0:52 UTC (permalink / raw)
  To: Colin King
  Cc: Alexei Starovoitov, Daniel Borkmann, netdev, kernel-janitors,
	linux-kernel

On Tue, 13 Nov 2018 09:29:26 +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Pointer offload is being null checked however the following statement
> dereferences the potentially null pointer offload when assigning
> offload->dev_state.  Fix this by only assigning it if offload is not
> null.
> 
> Detected by CoverityScan, CID#1475437 ("Dereference after null check")
> 
> Fixes: 00db12c3d141 ("bpf: call verifier_prep from its callback in struct bpf_offload_dev")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>

Thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][bpf-next] bpf: fix null pointer dereference on pointer offload
  2018-11-13  9:29 [PATCH][bpf-next] bpf: fix null pointer dereference on pointer offload Colin King
  2018-11-15  0:52 ` Jakub Kicinski
@ 2018-11-17  4:49 ` Alexei Starovoitov
  1 sibling, 0 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2018-11-17  4:49 UTC (permalink / raw)
  To: Colin King
  Cc: Alexei Starovoitov, Daniel Borkmann, netdev, kernel-janitors,
	linux-kernel

On Tue, Nov 13, 2018 at 09:29:26AM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Pointer offload is being null checked however the following statement
> dereferences the potentially null pointer offload when assigning
> offload->dev_state.  Fix this by only assigning it if offload is not
> null.
> 
> Detected by CoverityScan, CID#1475437 ("Dereference after null check")
> 
> Fixes: 00db12c3d141 ("bpf: call verifier_prep from its callback in struct bpf_offload_dev")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied, Thanks


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-11-17  4:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-13  9:29 [PATCH][bpf-next] bpf: fix null pointer dereference on pointer offload Colin King
2018-11-15  0:52 ` Jakub Kicinski
2018-11-17  4:49 ` Alexei Starovoitov

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).