aboutsummaryrefslogtreecommitdiffstats
path: root/arch/parisc/kernel/sys_parisc32.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/parisc/kernel/sys_parisc32.c')
-rw-r--r--arch/parisc/kernel/sys_parisc32.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/arch/parisc/kernel/sys_parisc32.c b/arch/parisc/kernel/sys_parisc32.c
index ce3245f87fdd..bb23ff71c28e 100644
--- a/arch/parisc/kernel/sys_parisc32.c
+++ b/arch/parisc/kernel/sys_parisc32.c
@@ -311,14 +311,13 @@ struct readdir32_callback {
311 int count; 311 int count;
312}; 312};
313 313
314#define ROUND_UP(x,a) ((__typeof__(x))(((unsigned long)(x) + ((a) - 1)) & ~((a) - 1)))
315#define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de))) 314#define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
316static int filldir32 (void *__buf, const char *name, int namlen, 315static int filldir32 (void *__buf, const char *name, int namlen,
317 loff_t offset, u64 ino, unsigned int d_type) 316 loff_t offset, u64 ino, unsigned int d_type)
318{ 317{
319 struct linux32_dirent __user * dirent; 318 struct linux32_dirent __user * dirent;
320 struct getdents32_callback * buf = (struct getdents32_callback *) __buf; 319 struct getdents32_callback * buf = (struct getdents32_callback *) __buf;
321 int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1, 4); 320 int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 1, 4);
322 u32 d_ino; 321 u32 d_ino;
323 322
324 buf->error = -EINVAL; /* only used if we fail.. */ 323 buf->error = -EINVAL; /* only used if we fail.. */
@@ -350,6 +349,10 @@ sys32_getdents (unsigned int fd, void __user * dirent, unsigned int count)
350 struct getdents32_callback buf; 349 struct getdents32_callback buf;
351 int error; 350 int error;
352 351
352 error = -EFAULT;
353 if (!access_ok(VERIFY_WRITE, dirent, count))
354 goto out;
355
353 error = -EBADF; 356 error = -EBADF;
354 file = fget(fd); 357 file = fget(fd);
355 if (!file) 358 if (!file)
@@ -366,8 +369,10 @@ sys32_getdents (unsigned int fd, void __user * dirent, unsigned int count)
366 error = buf.error; 369 error = buf.error;
367 lastdirent = buf.previous; 370 lastdirent = buf.previous;
368 if (lastdirent) { 371 if (lastdirent) {
369 put_user(file->f_pos, &lastdirent->d_off); 372 if (put_user(file->f_pos, &lastdirent->d_off))
370 error = count - buf.count; 373 error = -EFAULT;
374 else
375 error = count - buf.count;
371 } 376 }
372 377
373out_putf: 378out_putf: