Skip to contentSkip to conversation

remoteproc: warn on kick missing

PATCH In review Nikita Shubin 3 participants 4 messages Feb 6, 2020 – Feb 7, 2020 Remote processor (remoteproc)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remoteproc: warn on kick missing

.kick method not set in rproc_ops will result in:

8<--- cut here ---

Unable to handle kernel NULL pointer dereference

in rproc_virtio_notify, after firmware loading.

At least a warning needed on attempt to call missing method.

---
 drivers/remoteproc/remoteproc_virtio.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/remoteproc/remoteproc_virtio.c +6 -0
index 8c07cb2ca8ba..77a81f331e3f 100644
@@ -32,6 +32,12 @@ static bool rproc_virtio_notify(struct virtqueue *vq)
 
        dev_dbg(&rproc->dev, "kicking vq index: %d\n", notifyid);
 
+       if (unlikely(rproc->ops->kick == NULL)) {
+               WARN_ONCE(rproc->ops->kick == NULL, ".kick method not defined for %s",
+                       rproc->name);
+               return false;
+       }
+
        rproc->ops->kick(rproc, notifyid);
        return true;
 }

--
2.24.1

Confidentiality Notice: This message (including attachments) is a private communication solely for use of the intended recipient(s). If you are not the intended recipient(s) or believe you received this message in error, notify the sender immediately and then delete this message. Any other use, retention, dissemination or copying is prohibited and may be a violation of law, including the Electronic Communication Privacy Act of 1986. ��

#1 lore raw

Sorry for malformed message, please ignore it.

06.02.2020, 08:53, "Nikita Shubin" <[email protected]>:

Quoted 35 lines

.kick method not set in rproc_ops will result in:

8<--- cut here ---

Unable to handle kernel NULL pointer dereference

in rproc_virtio_notify, after firmware loading.

At least a warning needed on attempt to call missing method.

---
 drivers/remoteproc/remoteproc_virtio.c | 6 ++++++

 1 file changed, 6 insertions(+)
drivers/remoteproc/remoteproc_virtio.c +6 -1
index 8c07cb2ca8ba..77a81f331e3f 100644
@@ -32,6 +32,12 @@ static bool rproc_virtio_notify(struct virtqueue *vq)
 
         dev_dbg(&rproc->dev, "kicking vq index: %d\n", notifyid);
 
+ if (unlikely(rproc->ops->kick == NULL)) {
+ WARN_ONCE(rproc->ops->kick == NULL, ".kick method not defined for %s",
+ rproc->name);
+ return false;
+ }
+
         rproc->ops->kick(rproc, notifyid);
         return true;
  }
--

2.24.1

Confidentiality Notice: This message (including attachments) is a private communication solely for use of the intended recipient(s). If you are not the intended recipient(s) or believe you received this message in error, notify the sender immediately and then delete this message. Any other use, retention, dissemination or copying is prohibited and may be a violation of law, including the Electronic Communication Privacy Act of 1986. ­­

#2 lore raw
In reply to Nikita Shubin
Quoted 8 lines · Nikita Shubin

.kick method not set in rproc_ops will result in:

8<--- cut here ---

Unable to handle kernel NULL pointer dereference

in rproc_virtio_notify, after firmware loading.

At least a warning needed on attempt to call missing method.

Is this not a fatal error only happening during development? In which case the NULL pointer dereference will come with an oops with sufficient information to pinpoint what's going on?

Regards,
Bjorn

Quoted 27 lines
---
 drivers/remoteproc/remoteproc_virtio.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/remoteproc/remoteproc_virtio.c +6 -1
index 8c07cb2ca8ba..77a81f331e3f 100644
@@ -32,6 +32,12 @@ static bool rproc_virtio_notify(struct virtqueue *vq)
 
        dev_dbg(&rproc->dev, "kicking vq index: %d\n", notifyid);
 
+       if (unlikely(rproc->ops->kick == NULL)) {
+               WARN_ONCE(rproc->ops->kick == NULL, ".kick method not defined for %s",
+                       rproc->name);
+               return false;
+       }
+
        rproc->ops->kick(rproc, notifyid);
        return true;
 }
--

2.24.1

Confidentiality Notice: This message (including attachments) is a private communication solely for use of the intended recipient(s). If you are not the intended recipient(s) or believe you received this message in error, notify the sender immediately and then delete this message. Any other use, retention, dissemination or copying is prohibited and may be a violation of law, including the Electronic Communication Privacy Act of 1986. ??

#3 lore raw
Quoted 7 lines · Bjorn Andersson
Quoted 5 lines · Nikita Shubin

.kick method not set in rproc_ops will result in:

8<--- cut here ---

Unable to handle kernel NULL pointer dereference
Quoted 7 lines
Quoted 3 lines

in rproc_virtio_notify, after firmware loading.

At least a warning needed on attempt to call missing method.

Is this not a fatal error only happening during development? In which case the NULL pointer dereference will come with an oops with sufficient information to pinpoint what's going on?

Hello, Bjorn.

This error is happenning if no kick method was defined for struct rproc_ops, like, for example, in imx_rproc.

Looks, like if we have a resource table with defined vring's in it, a virtqueue will be allocated in rp_find_vq, passing rproc_virtio_notify.

But may be it's a better way to refuse calling vring_new_virtqueue if kick method method is not defined. To avoid explicit load in rproc_virtio_notify.

Quoted 31 lines

Regards,
Bjorn

Quoted 27 lines
---
 drivers/remoteproc/remoteproc_virtio.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/remoteproc/remoteproc_virtio.c +6 -1
index 8c07cb2ca8ba..77a81f331e3f 100644
@@ -32,6 +32,12 @@ static bool rproc_virtio_notify(struct virtqueue *vq)
 
        dev_dbg(&rproc->dev, "kicking vq index: %d\n", notifyid);
 
+       if (unlikely(rproc->ops->kick == NULL)) {
+               WARN_ONCE(rproc->ops->kick == NULL, ".kick method not defined for %s",
+                       rproc->name);
+               return false;
+       }
+
        rproc->ops->kick(rproc, notifyid);
        return true;
 }
--

2.24.1

Confidentiality Notice: This message (including attachments) is a private communication solely for use of the intended recipient(s). If you are not the intended recipient(s) or believe you received this message in error, notify the sender immediately and then delete this message. Any other use, retention, dissemination or copying is prohibited and may be a violation of law, including the Electronic Communication Privacy Act of 1986. ??