Commit 938da621 authored by Andrew Morton's avatar Andrew Morton Committed by David Mosberger

[PATCH] zr36120: fix improper access to userspace

From: Hollis Blanchard <hollisb@us.ibm.com>

Fix a direct userspace access, found by the Stanford checker.
parent ff94d27a
...@@ -1693,12 +1693,12 @@ long vbi_read(struct video_device* dev, char* buf, unsigned long count, int nonb ...@@ -1693,12 +1693,12 @@ long vbi_read(struct video_device* dev, char* buf, unsigned long count, int nonb
for (x=0; optr+1<eptr && x<-done->w; x++) for (x=0; optr+1<eptr && x<-done->w; x++)
{ {
unsigned char a = iptr[x*2]; unsigned char a = iptr[x*2];
*optr++ = a; __put_user(a, optr++);
*optr++ = a; __put_user(a, optr++);
} }
/* and clear the rest of the line */ /* and clear the rest of the line */
for (x*=2; optr<eptr && x<done->bpl; x++) for (x*=2; optr<eptr && x<done->bpl; x++)
*optr++ = 0; __put_user(0, optr++);
/* next line */ /* next line */
iptr += done->bpl; iptr += done->bpl;
} }
...@@ -1715,10 +1715,10 @@ long vbi_read(struct video_device* dev, char* buf, unsigned long count, int nonb ...@@ -1715,10 +1715,10 @@ long vbi_read(struct video_device* dev, char* buf, unsigned long count, int nonb
{ {
/* copy to doubled data to userland */ /* copy to doubled data to userland */
for (x=0; optr<eptr && x<-done->w; x++) for (x=0; optr<eptr && x<-done->w; x++)
*optr++ = iptr[x*2]; __put_user(iptr[x*2], optr++);
/* and clear the rest of the line */ /* and clear the rest of the line */
for (;optr<eptr && x<done->bpl; x++) for (;optr<eptr && x<done->bpl; x++)
*optr++ = 0; __put_user(0, optr++);
/* next line */ /* next line */
iptr += done->bpl; iptr += done->bpl;
} }
...@@ -1727,7 +1727,7 @@ long vbi_read(struct video_device* dev, char* buf, unsigned long count, int nonb ...@@ -1727,7 +1727,7 @@ long vbi_read(struct video_device* dev, char* buf, unsigned long count, int nonb
/* API compliance: /* API compliance:
* place the framenumber (half fieldnr) in the last long * place the framenumber (half fieldnr) in the last long
*/ */
((ulong*)eptr)[-1] = done->fieldnr/2; __put_user(done->fieldnr/2, ((ulong*)eptr)[-1]);
} }
/* keep the engine running */ /* keep the engine running */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment