From: Dipendra Khadka <kdipendra88@gmail.com>
To: kuba@kernel.org, davem@davemloft.net, edumazet@google.com,
pabeni@redhat.com
Cc: Dipendra Khadka <kdipendra88@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kernel-mentees@lists.linuxfoundation.org,
syzbot+44c2416196b7c607f226@syzkaller.appspotmail.com
Subject: [PATCH v2] Fixes the null pointer deferences in nsim_bpf
Date: Fri, 10 Nov 2023 11:18:23 +0000 [thread overview]
Message-ID: <20231110111823.2775-1-kdipendra88@gmail.com> (raw)
In-Reply-To: <20231110084425.2123-1-kdipendra88@gmail.com>
Syzkaller found a null pointer dereference in nsim_bpf
originating from the lack of a null check for state.
This patch fixes the issue by adding a check for state
in two functions nsim_prog_set_loaded() and nsim_setup_prog_hw_checks()
Reported-by: syzbot+44c2416196b7c607f226@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com./bug?extid=44c2416196b7c607f226
Fixes: 31d3ad832948 ("netdevsim: add bpf offload support")
Signed-off-by: Dipendra Khadka <kdipendra88@gmail.com>
---
drivers/net/netdevsim/bpf.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/net/netdevsim/bpf.c b/drivers/net/netdevsim/bpf.c
index f60eb97e3a62..5d755da3c736 100644
--- a/drivers/net/netdevsim/bpf.c
+++ b/drivers/net/netdevsim/bpf.c
@@ -97,7 +97,8 @@ static void nsim_prog_set_loaded(struct bpf_prog *prog, bool loaded)
return;
state = prog->aux->offload->dev_priv;
- state->is_loaded = loaded;
+ if (state)
+ state->is_loaded = loaded;
}
static int
@@ -317,9 +318,11 @@ nsim_setup_prog_hw_checks(struct netdevsim *ns, struct netdev_bpf *bpf)
}
state = bpf->prog->aux->offload->dev_priv;
- if (WARN_ON(strcmp(state->state, "xlated"))) {
- NSIM_EA(bpf->extack, "offloading program in bad state");
- return -EINVAL;
+ if (state) {
+ if (WARN_ON(strcmp(state->state, "xlated"))) {
+ NSIM_EA(bpf->extack, "offloading program in bad state");
+ return -EINVAL;
+ }
}
return 0;
}
--
2.34.1
next prev parent reply other threads:[~2023-11-10 11:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-10 8:44 [PATCH] Fixes the null pointer deferences in nsim_bpf Dipendra Khadka
2023-11-10 8:52 ` Eric Dumazet
2023-11-10 11:18 ` Dipendra Khadka [this message]
2023-11-10 19:12 ` [PATCH v2] " Jakub Kicinski
2023-11-10 19:20 ` Stanislav Fomichev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231110111823.2775-1-kdipendra88@gmail.com \
--to=kdipendra88@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=syzbot+44c2416196b7c607f226@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).