Five remoteproc/rpmsg fixes.
One was reported by Russell (the Kconfig fixes) and one by Omar (the endpoint
leak).
Ohad Ben-Cohen (5):
remoteproc: make sure we're parsing a 32bit firmware
remoteproc/omap: two Kconfig fixes
rpmsg: fix name service endpoint leak
rpmsg: validate incoming message length before propagating
rpmsg: fix published buffer length in rpmsg_recv_done
drivers/remoteproc/Kconfig | 3 +-
drivers/remoteproc/remoteproc_core.c | 8 ++++++
drivers/rpmsg/virtio_rpmsg_bus.c | 42 ++++++++++++++++++++++++++++-----
3 files changed, 44 insertions(+), 9 deletions(-)
--
1.7.5.4
Five trivial remoteproc/rpmsg fixes.
One was reported by Russell (the Kconfig fixes) and one by Omar (the endpoint
leak).
Ohad Ben-Cohen (5):
remoteproc: make sure we're parsing a 32bit firmware
remoteproc/omap: two Kconfig fixes
rpmsg: fix name service endpoint leak
rpmsg: validate incoming message length before propagating
rpmsg: fix published buffer length in rpmsg_recv_done
drivers/remoteproc/Kconfig | 3 +-
drivers/remoteproc/remoteproc_core.c | 8 ++++++
drivers/rpmsg/virtio_rpmsg_bus.c | 42 ++++++++++++++++++++++++++++-----
3 files changed, 44 insertions(+), 9 deletions(-)
--
1.7.5.4
Make sure we're parsing a 32bit image, since we only support
the ELF32 binary format at this point.
This should prevent unexpected behavior with non 32bit binaries.
Signed-off-by: Ohad Ben-Cohen <redacted>
Cc: Grant Likely <redacted>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Mark Grosen <redacted>
Cc: Suman Anna <redacted>
Cc: Fernando Guzman Lugo <redacted>
Cc: Rob Clark <redacted>
Cc: Ludovic BARRE <redacted>
Cc: Loic PALLARDY <redacted>
Cc: Omar Ramirez Luna <redacted>
---
drivers/remoteproc/remoteproc_core.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
@@ -840,6 +840,7 @@ static int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw)constchar*name=rproc->firmware;structdevice*dev=rproc->dev;structelf32_hdr*ehdr;+charclass;if(!fw){dev_err(dev,"failed to load %s\n",name);
@@ -853,6 +854,13 @@ static int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw)ehdr=(structelf32_hdr*)fw->data;+/* We only support ELF32 at this point */+class=ehdr->e_ident[EI_CLASS];+if(class!=ELFCLASS32){+dev_err(dev,"Unsupported class: %d\n",class);+return-EINVAL;+}+/* We assume the firmware has the same endianess as the host */# ifdef __LITTLE_ENDIANif(ehdr->e_ident[EI_DATA]!=ELFDATA2LSB){
1. Depend on OMAP_IOMMU instead of selecting it, to fix an unmet
direct dependency of it (and its imminent build error)
2. Set default to 'no' (achieved implicitly by dropping the 'default'
line)
Reported-by: Russell King <redacted>
Signed-off-by: Ohad Ben-Cohen <redacted>
Cc: Grant Likely <redacted>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Mark Grosen <redacted>
Cc: Suman Anna <redacted>
Cc: Fernando Guzman Lugo <redacted>
Cc: Rob Clark <redacted>
Cc: Ludovic BARRE <redacted>
Cc: Loic PALLARDY <redacted>
Cc: Omar Ramirez Luna <redacted>
Cc: Russell King <redacted>
---
drivers/remoteproc/Kconfig | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
The name service endpoint wasn't destroyed, so fix it.
This is achieved by introducing an internal __rpmsg_destroy_ept
function which doesn't assume the given ept is bound to an rpmsg
channel (much like the existing __rpmsg_create_ept).
This is needed because the name service ept belongs to the rpmsg bus,
and is never bound with a specific rpdev.
Reported-by: Omar Ramirez Luna <redacted>
Signed-off-by: Ohad Ben-Cohen <redacted>
Cc: Grant Likely <redacted>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Mark Grosen <redacted>
Cc: Suman Anna <redacted>
Cc: Fernando Guzman Lugo <redacted>
Cc: Rob Clark <redacted>
Cc: Ludovic BARRE <redacted>
Cc: Loic PALLARDY <redacted>
Cc: Omar Ramirez Luna <redacted>
---
drivers/rpmsg/virtio_rpmsg_bus.c | 29 +++++++++++++++++++++++------
1 files changed, 23 insertions(+), 6 deletions(-)
@@ -778,6 +778,16 @@ static void rpmsg_recv_done(struct virtqueue *rvq)print_hex_dump(KERN_DEBUG,"rpmsg_virtio RX: ",DUMP_PREFIX_NONE,16,1,msg,sizeof(*msg)+msg->len,true);+/*+*Wecurrentlyusefixed-sizedbuffers,sotriviallysanitize+*thereportedpayloadlength.+*/+if(len>RPMSG_BUF_SIZE||+msg->len>(len-sizeof(structrpmsg_hdr))){+dev_warn(dev,"inbound msg too big: (%d, %d)\n",len,msg->len);+return;+}+/* use the dst addr to fetch the callback of the appropriate user */mutex_lock(&vrp->endpoints_lock);ept=idr_find(&vrp->endpoints,msg->dst);
After processing an incoming message, always publish the real size
of its containing buffer when putting it back on the available rx ring.
Using any different value might erroneously limit the remote processor
(leading it to think the buffer is smaller than it really is).
Signed-off-by: Ohad Ben-Cohen <redacted>
Cc: Grant Likely <redacted>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Mark Grosen <redacted>
Cc: Suman Anna <redacted>
Cc: Fernando Guzman Lugo <redacted>
Cc: Rob Clark <redacted>
Cc: Ludovic BARRE <redacted>
Cc: Loic PALLARDY <redacted>
Cc: Omar Ramirez Luna <redacted>
---
drivers/rpmsg/virtio_rpmsg_bus.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
@@ -798,7 +798,8 @@ static void rpmsg_recv_done(struct virtqueue *rvq)elsedev_warn(dev,"msg received with no recepient\n");-sg_init_one(&sg,msg,sizeof(*msg)+len);+/* publish the real size of the buffer */+sg_init_one(&sg,msg,RPMSG_BUF_SIZE);/* add the buffer back to the remote processor's virtqueue */err=virtqueue_add_buf(vrp->rvq,&sg,0,1,msg,GFP_KERNEL);