projects
/
firefly-linux-kernel-4.4.55.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
f2fs: fix readdir incorrectness
[firefly-linux-kernel-4.4.55.git]
/
fs
/
compat.c
diff --git
a/fs/compat.c
b/fs/compat.c
index 93f7d021b716c01d0b2a9844f209aca7093c3e46..6af20de2c1a3c29d5cc7c251d8fb3fa2182de445 100644
(file)
--- a/
fs/compat.c
+++ b/
fs/compat.c
@@
-47,6
+47,7
@@
#include <linux/fs_struct.h>
#include <linux/slab.h>
#include <linux/pagemap.h>
#include <linux/fs_struct.h>
#include <linux/slab.h>
#include <linux/pagemap.h>
+#include <linux/aio.h>
#include <asm/uaccess.h>
#include <asm/mmu_context.h>
#include <asm/uaccess.h>
#include <asm/mmu_context.h>
@@
-831,6
+832,7
@@
struct compat_old_linux_dirent {
};
struct compat_readdir_callback {
};
struct compat_readdir_callback {
+ struct dir_context ctx;
struct compat_old_linux_dirent __user *dirent;
int result;
};
struct compat_old_linux_dirent __user *dirent;
int result;
};
@@
-872,15
+874,15
@@
asmlinkage long compat_sys_old_readdir(unsigned int fd,
{
int error;
struct fd f = fdget(fd);
{
int error;
struct fd f = fdget(fd);
- struct compat_readdir_callback buf;
+ struct compat_readdir_callback buf = {
+ .ctx.actor = compat_fillonedir,
+ .dirent = dirent
+ };
if (!f.file)
return -EBADF;
if (!f.file)
return -EBADF;
- buf.result = 0;
- buf.dirent = dirent;
-
- error = vfs_readdir(f.file, compat_fillonedir, &buf);
+ error = iterate_dir(f.file, &buf.ctx);
if (buf.result)
error = buf.result;
if (buf.result)
error = buf.result;
@@
-896,6
+898,7
@@
struct compat_linux_dirent {
};
struct compat_getdents_callback {
};
struct compat_getdents_callback {
+ struct dir_context ctx;
struct compat_linux_dirent __user *current_dir;
struct compat_linux_dirent __user *previous;
int count;
struct compat_linux_dirent __user *current_dir;
struct compat_linux_dirent __user *previous;
int count;
@@
-950,7
+953,11
@@
asmlinkage long compat_sys_getdents(unsigned int fd,
{
struct fd f;
struct compat_linux_dirent __user * lastdirent;
{
struct fd f;
struct compat_linux_dirent __user * lastdirent;
- struct compat_getdents_callback buf;
+ struct compat_getdents_callback buf = {
+ .ctx.actor = compat_filldir,
+ .current_dir = dirent,
+ .count = count
+ };
int error;
if (!access_ok(VERIFY_WRITE, dirent, count))
int error;
if (!access_ok(VERIFY_WRITE, dirent, count))
@@
-960,17
+967,12
@@
asmlinkage long compat_sys_getdents(unsigned int fd,
if (!f.file)
return -EBADF;
if (!f.file)
return -EBADF;
- buf.current_dir = dirent;
- buf.previous = NULL;
- buf.count = count;
- buf.error = 0;
-
- error = vfs_readdir(f.file, compat_filldir, &buf);
+ error = iterate_dir(f.file, &buf.ctx);
if (error >= 0)
error = buf.error;
lastdirent = buf.previous;
if (lastdirent) {
if (error >= 0)
error = buf.error;
lastdirent = buf.previous;
if (lastdirent) {
- if (put_user(
f.file->f_
pos, &lastdirent->d_off))
+ if (put_user(
buf.ctx.
pos, &lastdirent->d_off))
error = -EFAULT;
else
error = count - buf.count;
error = -EFAULT;
else
error = count - buf.count;
@@
-982,6
+984,7
@@
asmlinkage long compat_sys_getdents(unsigned int fd,
#ifndef __ARCH_OMIT_COMPAT_SYS_GETDENTS64
struct compat_getdents_callback64 {
#ifndef __ARCH_OMIT_COMPAT_SYS_GETDENTS64
struct compat_getdents_callback64 {
+ struct dir_context ctx;
struct linux_dirent64 __user *current_dir;
struct linux_dirent64 __user *previous;
int count;
struct linux_dirent64 __user *current_dir;
struct linux_dirent64 __user *previous;
int count;
@@
-1035,7
+1038,11
@@
asmlinkage long compat_sys_getdents64(unsigned int fd,
{
struct fd f;
struct linux_dirent64 __user * lastdirent;
{
struct fd f;
struct linux_dirent64 __user * lastdirent;
- struct compat_getdents_callback64 buf;
+ struct compat_getdents_callback64 buf = {
+ .ctx.actor = compat_filldir64,
+ .current_dir = dirent,
+ .count = count
+ };
int error;
if (!access_ok(VERIFY_WRITE, dirent, count))
int error;
if (!access_ok(VERIFY_WRITE, dirent, count))
@@
-1045,17
+1052,12
@@
asmlinkage long compat_sys_getdents64(unsigned int fd,
if (!f.file)
return -EBADF;
if (!f.file)
return -EBADF;
- buf.current_dir = dirent;
- buf.previous = NULL;
- buf.count = count;
- buf.error = 0;
-
- error = vfs_readdir(f.file, compat_filldir64, &buf);
+ error = iterate_dir(f.file, &buf.ctx);
if (error >= 0)
error = buf.error;
lastdirent = buf.previous;
if (lastdirent) {
if (error >= 0)
error = buf.error;
lastdirent = buf.previous;
if (lastdirent) {
- typeof(lastdirent->d_off) d_off =
f.file->f_
pos;
+ typeof(lastdirent->d_off) d_off =
buf.ctx.
pos;
if (__put_user_unaligned(d_off, &lastdirent->d_off))
error = -EFAULT;
else
if (__put_user_unaligned(d_off, &lastdirent->d_off))
error = -EFAULT;
else