aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/cell/spufs
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2007-12-20 02:39:59 -0500
committerPaul Mackerras <paulus@samba.org>2007-12-21 03:46:22 -0500
commitcbea92383d0d55fb4b4eb5833488bfee325254d6 (patch)
tree988bf369946836d95a549059d2d01998d252e673 /arch/powerpc/platforms/cell/spufs
parent18789fb1c3311dd8c25acb6eb5ccab05771843f2 (diff)
[POWERPC] spufs: Don't leak kernel stack through an empty {i,m}box_info read
Based on an original patch from Arnd Bergmann <arnd.bergmann@de.ibm.com> If there's no entry in the mailbox, then a read on the _info file will return data from an uninitialised variable. This change returns EOF if there's no mailbox info available instead. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/platforms/cell/spufs')
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index ba6101ae73a2..3fcd06418b01 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -2026,13 +2026,13 @@ static const struct file_operations spufs_caps_fops = {
2026static ssize_t __spufs_mbox_info_read(struct spu_context *ctx, 2026static ssize_t __spufs_mbox_info_read(struct spu_context *ctx,
2027 char __user *buf, size_t len, loff_t *pos) 2027 char __user *buf, size_t len, loff_t *pos)
2028{ 2028{
2029 u32 mbox_stat;
2030 u32 data; 2029 u32 data;
2031 2030
2032 mbox_stat = ctx->csa.prob.mb_stat_R; 2031 /* EOF if there's no entry in the mbox */
2033 if (mbox_stat & 0x0000ff) { 2032 if (!(ctx->csa.prob.mb_stat_R & 0x0000ff))
2034 data = ctx->csa.prob.pu_mb_R; 2033 return 0;
2035 } 2034
2035 data = ctx->csa.prob.pu_mb_R;
2036 2036
2037 return simple_read_from_buffer(buf, len, pos, &data, sizeof data); 2037 return simple_read_from_buffer(buf, len, pos, &data, sizeof data);
2038} 2038}
@@ -2066,13 +2066,13 @@ static const struct file_operations spufs_mbox_info_fops = {
2066static ssize_t __spufs_ibox_info_read(struct spu_context *ctx, 2066static ssize_t __spufs_ibox_info_read(struct spu_context *ctx,
2067 char __user *buf, size_t len, loff_t *pos) 2067 char __user *buf, size_t len, loff_t *pos)
2068{ 2068{
2069 u32 ibox_stat;
2070 u32 data; 2069 u32 data;
2071 2070
2072 ibox_stat = ctx->csa.prob.mb_stat_R; 2071 /* EOF if there's no entry in the ibox */
2073 if (ibox_stat & 0xff0000) { 2072 if (!(ctx->csa.prob.mb_stat_R & 0xff0000))
2074 data = ctx->csa.priv2.puint_mb_R; 2073 return 0;
2075 } 2074
2075 data = ctx->csa.priv2.puint_mb_R;
2076 2076
2077 return simple_read_from_buffer(buf, len, pos, &data, sizeof data); 2077 return simple_read_from_buffer(buf, len, pos, &data, sizeof data);
2078} 2078}