Merge branch 'for-linus' of git://oss.sgi.com:8090/xfs/xfs-2.6 into for-linus
[sfrench/cifs-2.6.git] / arch / parisc / kernel / sys_parisc32.c
index ce3245f87fddf832f9385a53b691ae7585a7d2a4..bb23ff71c28e31f7f4fae940e701710dbbbabd06 100644 (file)
@@ -311,14 +311,13 @@ struct readdir32_callback {
        int count;
 };
 
-#define ROUND_UP(x,a)  ((__typeof__(x))(((unsigned long)(x) + ((a) - 1)) & ~((a) - 1)))
 #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
 static int filldir32 (void *__buf, const char *name, int namlen,
                        loff_t offset, u64 ino, unsigned int d_type)
 {
        struct linux32_dirent __user * dirent;
        struct getdents32_callback * buf = (struct getdents32_callback *) __buf;
-       int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1, 4);
+       int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 1, 4);
        u32 d_ino;
 
        buf->error = -EINVAL;   /* only used if we fail.. */
@@ -350,6 +349,10 @@ sys32_getdents (unsigned int fd, void __user * dirent, unsigned int count)
        struct getdents32_callback buf;
        int error;
 
+       error = -EFAULT;
+       if (!access_ok(VERIFY_WRITE, dirent, count))
+               goto out;
+
        error = -EBADF;
        file = fget(fd);
        if (!file)
@@ -366,8 +369,10 @@ sys32_getdents (unsigned int fd, void __user * dirent, unsigned int count)
        error = buf.error;
        lastdirent = buf.previous;
        if (lastdirent) {
-               put_user(file->f_pos, &lastdirent->d_off);
-               error = count - buf.count;
+               if (put_user(file->f_pos, &lastdirent->d_off))
+                       error = -EFAULT;
+               else
+                       error = count - buf.count;
        }
 
 out_putf: