mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
ANDROID: fuse: Support errors from fuse daemon in canonical path
Previously errors from the daemon in FUSE_CANONICAL_PATH were simply
ignored. In order to block inotifys, it is useful to be able to return
errors from this opcode.
Bug: 238619640
Test: inotify no longer works on /storage/emulated/0/Android/media but
does on child folders
Change-Id: I1c65814f4ad0ccef330bca9764c2db15c71bf2be
Signed-off-by: Paul Lawrence <paullawrence@google.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1941,7 +1941,7 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud,
|
||||
err = copy_out_args(cs, req->args, nbytes);
|
||||
fuse_copy_finish(cs);
|
||||
|
||||
if (!err && req->in.h.opcode == FUSE_CANONICAL_PATH) {
|
||||
if (!err && req->in.h.opcode == FUSE_CANONICAL_PATH && !oh.error) {
|
||||
char *path = (char *)req->args->out_args[0].value;
|
||||
|
||||
path[req->args->out_args[0].size - 1] = 0;
|
||||
|
||||
@@ -395,7 +395,7 @@ static struct vfsmount *fuse_dentry_automount(struct path *path)
|
||||
* look up paths on its own. Instead, we handle the lookup as a special case
|
||||
* inside of the write request.
|
||||
*/
|
||||
static void fuse_dentry_canonical_path(const struct path *path,
|
||||
static int fuse_dentry_canonical_path(const struct path *path,
|
||||
struct path *canonical_path)
|
||||
{
|
||||
struct inode *inode = d_inode(path->dentry);
|
||||
@@ -414,12 +414,12 @@ static void fuse_dentry_canonical_path(const struct path *path,
|
||||
fuse_canonical_path_finalize, path,
|
||||
canonical_path);
|
||||
if (fer.ret)
|
||||
return;
|
||||
return PTR_ERR(fer.result);
|
||||
#endif
|
||||
|
||||
path_name = (char *)get_zeroed_page(GFP_KERNEL);
|
||||
if (!path_name)
|
||||
goto default_path;
|
||||
return -ENOMEM;
|
||||
|
||||
args.opcode = FUSE_CANONICAL_PATH;
|
||||
args.nodeid = get_node_id(inode);
|
||||
@@ -433,11 +433,14 @@ static void fuse_dentry_canonical_path(const struct path *path,
|
||||
err = fuse_simple_request(fm, &args);
|
||||
free_page((unsigned long)path_name);
|
||||
if (err > 0)
|
||||
return;
|
||||
default_path:
|
||||
return 0;
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
canonical_path->dentry = path->dentry;
|
||||
canonical_path->mnt = path->mnt;
|
||||
path_get(canonical_path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct dentry_operations fuse_dentry_operations = {
|
||||
|
||||
@@ -763,8 +763,11 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,
|
||||
/* support stacked filesystems */
|
||||
if (path.dentry && path.dentry->d_op) {
|
||||
if (path.dentry->d_op->d_canonical_path) {
|
||||
path.dentry->d_op->d_canonical_path(&path,
|
||||
ret = path.dentry->d_op->d_canonical_path(&path,
|
||||
&alteredpath);
|
||||
if (ret)
|
||||
goto path_put_and_out;
|
||||
|
||||
canonical_path = &alteredpath;
|
||||
path_put(&path);
|
||||
}
|
||||
@@ -776,6 +779,7 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,
|
||||
|
||||
/* create/update an inode mark */
|
||||
ret = inotify_update_watch(group, inode, mask);
|
||||
path_put_and_out:
|
||||
path_put(canonical_path);
|
||||
fput_and_out:
|
||||
fdput(f);
|
||||
|
||||
@@ -153,7 +153,7 @@ struct dentry_operations {
|
||||
struct vfsmount *(*d_automount)(struct path *);
|
||||
int (*d_manage)(const struct path *, bool);
|
||||
struct dentry *(*d_real)(struct dentry *, const struct inode *);
|
||||
void (*d_canonical_path)(const struct path *, struct path *);
|
||||
int (*d_canonical_path)(const struct path *, struct path *);
|
||||
ANDROID_KABI_RESERVE(1);
|
||||
ANDROID_KABI_RESERVE(2);
|
||||
ANDROID_KABI_RESERVE(3);
|
||||
|
||||
@@ -105,7 +105,11 @@ static inline int fsnotify_file(struct file *file, __u32 mask)
|
||||
struct path lower_path;
|
||||
int ret;
|
||||
|
||||
path->dentry->d_op->d_canonical_path(path, &lower_path);
|
||||
ret = path->dentry->d_op->d_canonical_path(path,
|
||||
&lower_path);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = fsnotify_parent(lower_path.dentry, mask,
|
||||
&lower_path, FSNOTIFY_EVENT_PATH);
|
||||
path_put(&lower_path);
|
||||
|
||||
Reference in New Issue
Block a user