[Cbe-oss-dev] [PATCH] return only valid data in ibox_info and mbox_info

Arnd Bergmann arnd at arndb.de
Tue Oct 16 22:33:46 EST 2007


When there is no data available in the outbound SPU mailboxes,
reading the respective info files leaks kernel stack data instead
of returning the mailbox contents. This changes the behavior of
spufs to return no data at all in that case, which is what the only
user (gdb) expects anyway.

I'm not sure if this is correct with regard to the SPU core dump
support, which uses the same code.

Signed-off-by: Arnd Bergmann <arnd.bergmann at de.ibm.com>

---

On Tuesday 16 October 2007, Arnd Bergmann wrote:
> On Tuesday 16 October 2007, Kazunori Asayama wrote:

> > 
> >     a. - mbox_info, ibox_info and wbox_info should return only valid
> >          entries; i.e. the man page is incorrect.
> > 
> >        - gdb should show the all data returned by mbox_info, ibox_info
> >          and wbox_info; i.e. the current implementation is correct.
> 
> Yes, we should fix the kernel for ibox_info and mbox_info, then adapt
> the man page. Another reason to do it this way is that the architecture
> does not specify how many elements can be in each mailbox, so we should
> not encode that into the kernel interface either.


--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -1779,13 +1779,15 @@ static ssize_t __spufs_mbox_info_read(struct spu_context *ctx,
 {
 	u32 mbox_stat;
 	u32 data;
+	u32 size = 0;
 
 	mbox_stat = ctx->csa.prob.mb_stat_R;
 	if (mbox_stat & 0x0000ff) {
+		size = sizeof data;
 		data = ctx->csa.prob.pu_mb_R;
 	}
 
-	return simple_read_from_buffer(buf, len, pos, &data, sizeof data);
+	return simple_read_from_buffer(buf, len, pos, &data, size);
 }
 
 static ssize_t spufs_mbox_info_read(struct file *file, char __user *buf,
@@ -1817,13 +1819,15 @@ static ssize_t __spufs_ibox_info_read(struct spu_context *ctx,
 {
 	u32 ibox_stat;
 	u32 data;
+	u32 size = 0;
 
 	ibox_stat = ctx->csa.prob.mb_stat_R;
 	if (ibox_stat & 0xff0000) {
+		size = sizeof data;
 		data = ctx->csa.priv2.puint_mb_R;
 	}
 
-	return simple_read_from_buffer(buf, len, pos, &data, sizeof data);
+	return simple_read_from_buffer(buf, len, pos, &data, size);
 }
 
 static ssize_t spufs_ibox_info_read(struct file *file, char __user *buf,



More information about the cbe-oss-dev mailing list