Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright (C) 2011 Novell Inc. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 as published by |
| 7 | * the Free Software Foundation. |
| 8 | */ |
| 9 | |
| 10 | #include <linux/fs.h> |
| 11 | #include <linux/namei.h> |
| 12 | #include <linux/xattr.h> |
| 13 | #include <linux/security.h> |
| 14 | #include <linux/cred.h> |
Miklos Szeredi | 3ea22a7 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 15 | #include <linux/module.h> |
Miklos Szeredi | 38b2569 | 2016-09-01 11:11:59 +0200 | [diff] [blame] | 16 | #include <linux/posix_acl.h> |
| 17 | #include <linux/posix_acl_xattr.h> |
Richard Weinberger | 6a45b36 | 2016-09-16 11:45:24 +0200 | [diff] [blame] | 18 | #include <linux/atomic.h> |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 19 | #include <linux/ratelimit.h> |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 20 | #include "overlayfs.h" |
| 21 | |
Miklos Szeredi | 3ea22a7 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 22 | static unsigned short ovl_redirect_max = 256; |
| 23 | module_param_named(redirect_max, ovl_redirect_max, ushort, 0644); |
| 24 | MODULE_PARM_DESC(ovl_redirect_max, |
| 25 | "Maximum length of absolute redirect xattr value"); |
| 26 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 27 | void ovl_cleanup(struct inode *wdir, struct dentry *wdentry) |
| 28 | { |
| 29 | int err; |
| 30 | |
| 31 | dget(wdentry); |
David Howells | e36cb0b | 2015-01-29 12:02:35 +0000 | [diff] [blame] | 32 | if (d_is_dir(wdentry)) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 33 | err = ovl_do_rmdir(wdir, wdentry); |
| 34 | else |
| 35 | err = ovl_do_unlink(wdir, wdentry); |
| 36 | dput(wdentry); |
| 37 | |
| 38 | if (err) { |
| 39 | pr_err("overlayfs: cleanup of '%pd2' failed (%i)\n", |
| 40 | wdentry, err); |
| 41 | } |
| 42 | } |
| 43 | |
Miklos Szeredi | 3d27573 | 2017-05-19 09:33:49 +0200 | [diff] [blame^] | 44 | struct dentry *ovl_lookup_temp(struct dentry *workdir) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 45 | { |
| 46 | struct dentry *temp; |
| 47 | char name[20]; |
Richard Weinberger | 6a45b36 | 2016-09-16 11:45:24 +0200 | [diff] [blame] | 48 | static atomic_t temp_id = ATOMIC_INIT(0); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 49 | |
Richard Weinberger | 6a45b36 | 2016-09-16 11:45:24 +0200 | [diff] [blame] | 50 | /* counter is allowed to wrap, since temp dentries are ephemeral */ |
| 51 | snprintf(name, sizeof(name), "#%x", atomic_inc_return(&temp_id)); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 52 | |
| 53 | temp = lookup_one_len(name, workdir, strlen(name)); |
| 54 | if (!IS_ERR(temp) && temp->d_inode) { |
| 55 | pr_err("overlayfs: workdir/%s already exists\n", name); |
| 56 | dput(temp); |
| 57 | temp = ERR_PTR(-EIO); |
| 58 | } |
| 59 | |
| 60 | return temp; |
| 61 | } |
| 62 | |
| 63 | /* caller holds i_mutex on workdir */ |
| 64 | static struct dentry *ovl_whiteout(struct dentry *workdir, |
| 65 | struct dentry *dentry) |
| 66 | { |
| 67 | int err; |
| 68 | struct dentry *whiteout; |
| 69 | struct inode *wdir = workdir->d_inode; |
| 70 | |
Miklos Szeredi | 3d27573 | 2017-05-19 09:33:49 +0200 | [diff] [blame^] | 71 | whiteout = ovl_lookup_temp(workdir); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 72 | if (IS_ERR(whiteout)) |
| 73 | return whiteout; |
| 74 | |
| 75 | err = ovl_do_whiteout(wdir, whiteout); |
| 76 | if (err) { |
| 77 | dput(whiteout); |
| 78 | whiteout = ERR_PTR(err); |
| 79 | } |
| 80 | |
| 81 | return whiteout; |
| 82 | } |
| 83 | |
| 84 | int ovl_create_real(struct inode *dir, struct dentry *newdentry, |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 85 | struct cattr *attr, struct dentry *hardlink, bool debug) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 86 | { |
| 87 | int err; |
| 88 | |
| 89 | if (newdentry->d_inode) |
| 90 | return -ESTALE; |
| 91 | |
| 92 | if (hardlink) { |
| 93 | err = ovl_do_link(hardlink, dir, newdentry, debug); |
| 94 | } else { |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 95 | switch (attr->mode & S_IFMT) { |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 96 | case S_IFREG: |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 97 | err = ovl_do_create(dir, newdentry, attr->mode, debug); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 98 | break; |
| 99 | |
| 100 | case S_IFDIR: |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 101 | err = ovl_do_mkdir(dir, newdentry, attr->mode, debug); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 102 | break; |
| 103 | |
| 104 | case S_IFCHR: |
| 105 | case S_IFBLK: |
| 106 | case S_IFIFO: |
| 107 | case S_IFSOCK: |
| 108 | err = ovl_do_mknod(dir, newdentry, |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 109 | attr->mode, attr->rdev, debug); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 110 | break; |
| 111 | |
| 112 | case S_IFLNK: |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 113 | err = ovl_do_symlink(dir, newdentry, attr->link, debug); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 114 | break; |
| 115 | |
| 116 | default: |
| 117 | err = -EPERM; |
| 118 | } |
| 119 | } |
| 120 | if (!err && WARN_ON(!newdentry->d_inode)) { |
| 121 | /* |
| 122 | * Not quite sure if non-instantiated dentry is legal or not. |
| 123 | * VFS doesn't seem to care so check and warn here. |
| 124 | */ |
| 125 | err = -ENOENT; |
| 126 | } |
| 127 | return err; |
| 128 | } |
| 129 | |
Amir Goldstein | 21a2287 | 2017-05-17 00:12:41 +0300 | [diff] [blame] | 130 | static int ovl_set_opaque_xerr(struct dentry *dentry, struct dentry *upper, |
| 131 | int xerr) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 132 | { |
Miklos Szeredi | 5cf5b47 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 133 | int err; |
| 134 | |
Amir Goldstein | 21a2287 | 2017-05-17 00:12:41 +0300 | [diff] [blame] | 135 | err = ovl_check_setxattr(dentry, upper, OVL_XATTR_OPAQUE, "y", 1, xerr); |
Miklos Szeredi | 5cf5b47 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 136 | if (!err) |
| 137 | ovl_dentry_set_opaque(dentry); |
| 138 | |
| 139 | return err; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 140 | } |
| 141 | |
Amir Goldstein | 21a2287 | 2017-05-17 00:12:41 +0300 | [diff] [blame] | 142 | static int ovl_set_opaque(struct dentry *dentry, struct dentry *upperdentry) |
| 143 | { |
| 144 | /* |
| 145 | * Fail with -EIO when trying to create opaque dir and upper doesn't |
| 146 | * support xattrs. ovl_rename() calls ovl_set_opaque_xerr(-EXDEV) to |
| 147 | * return a specific error for noxattr case. |
| 148 | */ |
| 149 | return ovl_set_opaque_xerr(dentry, upperdentry, -EIO); |
| 150 | } |
| 151 | |
Vivek Goyal | 72e4848 | 2016-06-16 10:09:14 -0400 | [diff] [blame] | 152 | /* Common operations required to be done after creation of file on upper */ |
| 153 | static void ovl_instantiate(struct dentry *dentry, struct inode *inode, |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 154 | struct dentry *newdentry, bool hardlink) |
Vivek Goyal | 72e4848 | 2016-06-16 10:09:14 -0400 | [diff] [blame] | 155 | { |
| 156 | ovl_dentry_version_inc(dentry->d_parent); |
| 157 | ovl_dentry_update(dentry, newdentry); |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 158 | if (!hardlink) { |
| 159 | ovl_inode_update(inode, d_inode(newdentry)); |
| 160 | ovl_copyattr(newdentry->d_inode, inode); |
| 161 | } else { |
| 162 | WARN_ON(ovl_inode_real(inode, NULL) != d_inode(newdentry)); |
| 163 | inc_nlink(inode); |
| 164 | } |
Vivek Goyal | 72e4848 | 2016-06-16 10:09:14 -0400 | [diff] [blame] | 165 | d_instantiate(dentry, inode); |
Amir Goldstein | 5b6c905 | 2017-04-24 19:54:13 +0300 | [diff] [blame] | 166 | /* Force lookup of new upper hardlink to find its lower */ |
| 167 | if (hardlink) |
| 168 | d_drop(dentry); |
Vivek Goyal | 72e4848 | 2016-06-16 10:09:14 -0400 | [diff] [blame] | 169 | } |
| 170 | |
Amir Goldstein | 97c684c | 2016-11-21 18:57:34 +0200 | [diff] [blame] | 171 | static bool ovl_type_merge(struct dentry *dentry) |
| 172 | { |
| 173 | return OVL_TYPE_MERGE(ovl_path_type(dentry)); |
| 174 | } |
| 175 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 176 | static int ovl_create_upper(struct dentry *dentry, struct inode *inode, |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 177 | struct cattr *attr, struct dentry *hardlink) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 178 | { |
| 179 | struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); |
| 180 | struct inode *udir = upperdir->d_inode; |
| 181 | struct dentry *newdentry; |
| 182 | int err; |
| 183 | |
Miklos Szeredi | 38b2569 | 2016-09-01 11:11:59 +0200 | [diff] [blame] | 184 | if (!hardlink && !IS_POSIXACL(udir)) |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 185 | attr->mode &= ~current_umask(); |
Miklos Szeredi | 38b2569 | 2016-09-01 11:11:59 +0200 | [diff] [blame] | 186 | |
Al Viro | 5955102 | 2016-01-22 15:40:57 -0500 | [diff] [blame] | 187 | inode_lock_nested(udir, I_MUTEX_PARENT); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 188 | newdentry = lookup_one_len(dentry->d_name.name, upperdir, |
| 189 | dentry->d_name.len); |
| 190 | err = PTR_ERR(newdentry); |
| 191 | if (IS_ERR(newdentry)) |
| 192 | goto out_unlock; |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 193 | err = ovl_create_real(udir, newdentry, attr, hardlink, false); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 194 | if (err) |
| 195 | goto out_dput; |
| 196 | |
Amir Goldstein | 4a99f3c | 2017-04-24 22:26:40 +0300 | [diff] [blame] | 197 | if (ovl_type_merge(dentry->d_parent) && d_is_dir(newdentry)) { |
Amir Goldstein | 97c684c | 2016-11-21 18:57:34 +0200 | [diff] [blame] | 198 | /* Setting opaque here is just an optimization, allow to fail */ |
| 199 | ovl_set_opaque(dentry, newdentry); |
| 200 | } |
| 201 | |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 202 | ovl_instantiate(dentry, inode, newdentry, !!hardlink); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 203 | newdentry = NULL; |
| 204 | out_dput: |
| 205 | dput(newdentry); |
| 206 | out_unlock: |
Al Viro | 5955102 | 2016-01-22 15:40:57 -0500 | [diff] [blame] | 207 | inode_unlock(udir); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 208 | return err; |
| 209 | } |
| 210 | |
| 211 | static int ovl_lock_rename_workdir(struct dentry *workdir, |
| 212 | struct dentry *upperdir) |
| 213 | { |
| 214 | /* Workdir should not be the same as upperdir */ |
| 215 | if (workdir == upperdir) |
| 216 | goto err; |
| 217 | |
| 218 | /* Workdir should not be subdir of upperdir and vice versa */ |
| 219 | if (lock_rename(workdir, upperdir) != NULL) |
| 220 | goto err_unlock; |
| 221 | |
| 222 | return 0; |
| 223 | |
| 224 | err_unlock: |
| 225 | unlock_rename(workdir, upperdir); |
| 226 | err: |
| 227 | pr_err("overlayfs: failed to lock workdir+upperdir\n"); |
| 228 | return -EIO; |
| 229 | } |
| 230 | |
| 231 | static struct dentry *ovl_clear_empty(struct dentry *dentry, |
| 232 | struct list_head *list) |
| 233 | { |
| 234 | struct dentry *workdir = ovl_workdir(dentry); |
| 235 | struct inode *wdir = workdir->d_inode; |
| 236 | struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); |
| 237 | struct inode *udir = upperdir->d_inode; |
| 238 | struct path upperpath; |
| 239 | struct dentry *upper; |
| 240 | struct dentry *opaquedir; |
| 241 | struct kstat stat; |
| 242 | int err; |
| 243 | |
Miklos Szeredi | cc6f67b | 2015-05-19 14:30:12 +0200 | [diff] [blame] | 244 | if (WARN_ON(!workdir)) |
| 245 | return ERR_PTR(-EROFS); |
| 246 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 247 | err = ovl_lock_rename_workdir(workdir, upperdir); |
| 248 | if (err) |
| 249 | goto out; |
| 250 | |
| 251 | ovl_path_upper(dentry, &upperpath); |
David Howells | a528d35 | 2017-01-31 16:46:22 +0000 | [diff] [blame] | 252 | err = vfs_getattr(&upperpath, &stat, |
| 253 | STATX_BASIC_STATS, AT_STATX_SYNC_AS_STAT); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 254 | if (err) |
| 255 | goto out_unlock; |
| 256 | |
| 257 | err = -ESTALE; |
| 258 | if (!S_ISDIR(stat.mode)) |
| 259 | goto out_unlock; |
| 260 | upper = upperpath.dentry; |
| 261 | if (upper->d_parent->d_inode != udir) |
| 262 | goto out_unlock; |
| 263 | |
Miklos Szeredi | 3d27573 | 2017-05-19 09:33:49 +0200 | [diff] [blame^] | 264 | opaquedir = ovl_lookup_temp(workdir); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 265 | err = PTR_ERR(opaquedir); |
| 266 | if (IS_ERR(opaquedir)) |
| 267 | goto out_unlock; |
| 268 | |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 269 | err = ovl_create_real(wdir, opaquedir, |
| 270 | &(struct cattr){.mode = stat.mode}, NULL, true); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 271 | if (err) |
| 272 | goto out_dput; |
| 273 | |
| 274 | err = ovl_copy_xattr(upper, opaquedir); |
| 275 | if (err) |
| 276 | goto out_cleanup; |
| 277 | |
Miklos Szeredi | 5cf5b47 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 278 | err = ovl_set_opaque(dentry, opaquedir); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 279 | if (err) |
| 280 | goto out_cleanup; |
| 281 | |
Al Viro | 5955102 | 2016-01-22 15:40:57 -0500 | [diff] [blame] | 282 | inode_lock(opaquedir->d_inode); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 283 | err = ovl_set_attr(opaquedir, &stat); |
Al Viro | 5955102 | 2016-01-22 15:40:57 -0500 | [diff] [blame] | 284 | inode_unlock(opaquedir->d_inode); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 285 | if (err) |
| 286 | goto out_cleanup; |
| 287 | |
| 288 | err = ovl_do_rename(wdir, opaquedir, udir, upper, RENAME_EXCHANGE); |
| 289 | if (err) |
| 290 | goto out_cleanup; |
| 291 | |
| 292 | ovl_cleanup_whiteouts(upper, list); |
| 293 | ovl_cleanup(wdir, upper); |
| 294 | unlock_rename(workdir, upperdir); |
| 295 | |
| 296 | /* dentry's upper doesn't match now, get rid of it */ |
| 297 | d_drop(dentry); |
| 298 | |
| 299 | return opaquedir; |
| 300 | |
| 301 | out_cleanup: |
| 302 | ovl_cleanup(wdir, opaquedir); |
| 303 | out_dput: |
| 304 | dput(opaquedir); |
| 305 | out_unlock: |
| 306 | unlock_rename(workdir, upperdir); |
| 307 | out: |
| 308 | return ERR_PTR(err); |
| 309 | } |
| 310 | |
Miklos Szeredi | a105d68 | 2014-11-20 16:39:59 +0100 | [diff] [blame] | 311 | static struct dentry *ovl_check_empty_and_clear(struct dentry *dentry) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 312 | { |
| 313 | int err; |
| 314 | struct dentry *ret = NULL; |
Miklos Szeredi | 30c17eb | 2016-07-29 12:05:25 +0200 | [diff] [blame] | 315 | enum ovl_path_type type = ovl_path_type(dentry); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 316 | LIST_HEAD(list); |
| 317 | |
| 318 | err = ovl_check_empty_dir(dentry, &list); |
Miklos Szeredi | 30c17eb | 2016-07-29 12:05:25 +0200 | [diff] [blame] | 319 | if (err) { |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 320 | ret = ERR_PTR(err); |
Miklos Szeredi | 30c17eb | 2016-07-29 12:05:25 +0200 | [diff] [blame] | 321 | goto out_free; |
Miklos Szeredi | a105d68 | 2014-11-20 16:39:59 +0100 | [diff] [blame] | 322 | } |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 323 | |
Miklos Szeredi | 30c17eb | 2016-07-29 12:05:25 +0200 | [diff] [blame] | 324 | /* |
| 325 | * When removing an empty opaque directory, then it makes no sense to |
| 326 | * replace it with an exact replica of itself. |
| 327 | * |
| 328 | * If no upperdentry then skip clearing whiteouts. |
| 329 | * |
| 330 | * Can race with copy-up, since we don't hold the upperdir mutex. |
| 331 | * Doesn't matter, since copy-up can't create a non-empty directory |
| 332 | * from an empty one. |
| 333 | */ |
| 334 | if (OVL_TYPE_UPPER(type) && OVL_TYPE_MERGE(type)) |
| 335 | ret = ovl_clear_empty(dentry, &list); |
| 336 | |
| 337 | out_free: |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 338 | ovl_cache_free(&list); |
| 339 | |
| 340 | return ret; |
| 341 | } |
| 342 | |
Miklos Szeredi | 38b2569 | 2016-09-01 11:11:59 +0200 | [diff] [blame] | 343 | static int ovl_set_upper_acl(struct dentry *upperdentry, const char *name, |
| 344 | const struct posix_acl *acl) |
| 345 | { |
| 346 | void *buffer; |
| 347 | size_t size; |
| 348 | int err; |
| 349 | |
| 350 | if (!IS_ENABLED(CONFIG_FS_POSIX_ACL) || !acl) |
| 351 | return 0; |
| 352 | |
| 353 | size = posix_acl_to_xattr(NULL, acl, NULL, 0); |
| 354 | buffer = kmalloc(size, GFP_KERNEL); |
| 355 | if (!buffer) |
| 356 | return -ENOMEM; |
| 357 | |
| 358 | size = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); |
| 359 | err = size; |
| 360 | if (err < 0) |
| 361 | goto out_free; |
| 362 | |
| 363 | err = vfs_setxattr(upperdentry, name, buffer, size, XATTR_CREATE); |
| 364 | out_free: |
| 365 | kfree(buffer); |
| 366 | return err; |
| 367 | } |
| 368 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 369 | static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode, |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 370 | struct cattr *cattr, |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 371 | struct dentry *hardlink) |
| 372 | { |
| 373 | struct dentry *workdir = ovl_workdir(dentry); |
| 374 | struct inode *wdir = workdir->d_inode; |
| 375 | struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); |
| 376 | struct inode *udir = upperdir->d_inode; |
| 377 | struct dentry *upper; |
| 378 | struct dentry *newdentry; |
| 379 | int err; |
Miklos Szeredi | 38b2569 | 2016-09-01 11:11:59 +0200 | [diff] [blame] | 380 | struct posix_acl *acl, *default_acl; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 381 | |
Miklos Szeredi | cc6f67b | 2015-05-19 14:30:12 +0200 | [diff] [blame] | 382 | if (WARN_ON(!workdir)) |
| 383 | return -EROFS; |
| 384 | |
Miklos Szeredi | 38b2569 | 2016-09-01 11:11:59 +0200 | [diff] [blame] | 385 | if (!hardlink) { |
| 386 | err = posix_acl_create(dentry->d_parent->d_inode, |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 387 | &cattr->mode, &default_acl, &acl); |
Miklos Szeredi | 38b2569 | 2016-09-01 11:11:59 +0200 | [diff] [blame] | 388 | if (err) |
| 389 | return err; |
| 390 | } |
| 391 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 392 | err = ovl_lock_rename_workdir(workdir, upperdir); |
| 393 | if (err) |
| 394 | goto out; |
| 395 | |
Miklos Szeredi | 3d27573 | 2017-05-19 09:33:49 +0200 | [diff] [blame^] | 396 | newdentry = ovl_lookup_temp(workdir); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 397 | err = PTR_ERR(newdentry); |
| 398 | if (IS_ERR(newdentry)) |
| 399 | goto out_unlock; |
| 400 | |
| 401 | upper = lookup_one_len(dentry->d_name.name, upperdir, |
| 402 | dentry->d_name.len); |
| 403 | err = PTR_ERR(upper); |
| 404 | if (IS_ERR(upper)) |
| 405 | goto out_dput; |
| 406 | |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 407 | err = ovl_create_real(wdir, newdentry, cattr, hardlink, true); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 408 | if (err) |
| 409 | goto out_dput2; |
| 410 | |
Miklos Szeredi | bb0d2b8 | 2016-07-29 12:05:23 +0200 | [diff] [blame] | 411 | /* |
| 412 | * mode could have been mutilated due to umask (e.g. sgid directory) |
| 413 | */ |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 414 | if (!hardlink && |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 415 | !S_ISLNK(cattr->mode) && |
| 416 | newdentry->d_inode->i_mode != cattr->mode) { |
Miklos Szeredi | bb0d2b8 | 2016-07-29 12:05:23 +0200 | [diff] [blame] | 417 | struct iattr attr = { |
| 418 | .ia_valid = ATTR_MODE, |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 419 | .ia_mode = cattr->mode, |
Miklos Szeredi | bb0d2b8 | 2016-07-29 12:05:23 +0200 | [diff] [blame] | 420 | }; |
| 421 | inode_lock(newdentry->d_inode); |
| 422 | err = notify_change(newdentry, &attr, NULL); |
| 423 | inode_unlock(newdentry->d_inode); |
| 424 | if (err) |
| 425 | goto out_cleanup; |
| 426 | } |
Miklos Szeredi | 38b2569 | 2016-09-01 11:11:59 +0200 | [diff] [blame] | 427 | if (!hardlink) { |
| 428 | err = ovl_set_upper_acl(newdentry, XATTR_NAME_POSIX_ACL_ACCESS, |
| 429 | acl); |
| 430 | if (err) |
| 431 | goto out_cleanup; |
| 432 | |
| 433 | err = ovl_set_upper_acl(newdentry, XATTR_NAME_POSIX_ACL_DEFAULT, |
| 434 | default_acl); |
| 435 | if (err) |
| 436 | goto out_cleanup; |
| 437 | } |
Miklos Szeredi | bb0d2b8 | 2016-07-29 12:05:23 +0200 | [diff] [blame] | 438 | |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 439 | if (!hardlink && S_ISDIR(cattr->mode)) { |
Miklos Szeredi | 5cf5b47 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 440 | err = ovl_set_opaque(dentry, newdentry); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 441 | if (err) |
| 442 | goto out_cleanup; |
| 443 | |
| 444 | err = ovl_do_rename(wdir, newdentry, udir, upper, |
| 445 | RENAME_EXCHANGE); |
| 446 | if (err) |
| 447 | goto out_cleanup; |
| 448 | |
| 449 | ovl_cleanup(wdir, upper); |
| 450 | } else { |
| 451 | err = ovl_do_rename(wdir, newdentry, udir, upper, 0); |
| 452 | if (err) |
| 453 | goto out_cleanup; |
| 454 | } |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 455 | ovl_instantiate(dentry, inode, newdentry, !!hardlink); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 456 | newdentry = NULL; |
| 457 | out_dput2: |
| 458 | dput(upper); |
| 459 | out_dput: |
| 460 | dput(newdentry); |
| 461 | out_unlock: |
| 462 | unlock_rename(workdir, upperdir); |
| 463 | out: |
Miklos Szeredi | 38b2569 | 2016-09-01 11:11:59 +0200 | [diff] [blame] | 464 | if (!hardlink) { |
| 465 | posix_acl_release(acl); |
| 466 | posix_acl_release(default_acl); |
| 467 | } |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 468 | return err; |
| 469 | |
| 470 | out_cleanup: |
| 471 | ovl_cleanup(wdir, newdentry); |
| 472 | goto out_dput2; |
| 473 | } |
| 474 | |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 475 | static int ovl_create_or_link(struct dentry *dentry, struct inode *inode, |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 476 | struct cattr *attr, struct dentry *hardlink) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 477 | { |
| 478 | int err; |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 479 | const struct cred *old_cred; |
| 480 | struct cred *override_cred; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 481 | |
| 482 | err = ovl_copy_up(dentry->d_parent); |
| 483 | if (err) |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 484 | return err; |
Miklos Szeredi | bb0d2b8 | 2016-07-29 12:05:23 +0200 | [diff] [blame] | 485 | |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 486 | old_cred = ovl_override_creds(dentry->d_sb); |
| 487 | err = -ENOMEM; |
| 488 | override_cred = prepare_creds(); |
| 489 | if (override_cred) { |
Miklos Szeredi | bb0d2b8 | 2016-07-29 12:05:23 +0200 | [diff] [blame] | 490 | override_cred->fsuid = inode->i_uid; |
| 491 | override_cred->fsgid = inode->i_gid; |
Vivek Goyal | 2602625 | 2016-07-13 10:44:52 -0400 | [diff] [blame] | 492 | if (!hardlink) { |
| 493 | err = security_dentry_create_files_as(dentry, |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 494 | attr->mode, &dentry->d_name, old_cred, |
Vivek Goyal | 2602625 | 2016-07-13 10:44:52 -0400 | [diff] [blame] | 495 | override_cred); |
| 496 | if (err) { |
| 497 | put_cred(override_cred); |
| 498 | goto out_revert_creds; |
| 499 | } |
| 500 | } |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 501 | put_cred(override_creds(override_cred)); |
| 502 | put_cred(override_cred); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 503 | |
Miklos Szeredi | c412ce4 | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 504 | if (!ovl_dentry_is_whiteout(dentry)) |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 505 | err = ovl_create_upper(dentry, inode, attr, |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 506 | hardlink); |
| 507 | else |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 508 | err = ovl_create_over_whiteout(dentry, inode, attr, |
| 509 | hardlink); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 510 | } |
Vivek Goyal | 2602625 | 2016-07-13 10:44:52 -0400 | [diff] [blame] | 511 | out_revert_creds: |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 512 | revert_creds(old_cred); |
Miklos Szeredi | bb0d2b8 | 2016-07-29 12:05:23 +0200 | [diff] [blame] | 513 | if (!err) { |
| 514 | struct inode *realinode = d_inode(ovl_dentry_upper(dentry)); |
| 515 | |
| 516 | WARN_ON(inode->i_mode != realinode->i_mode); |
| 517 | WARN_ON(!uid_eq(inode->i_uid, realinode->i_uid)); |
| 518 | WARN_ON(!gid_eq(inode->i_gid, realinode->i_gid)); |
Miklos Szeredi | bb0d2b8 | 2016-07-29 12:05:23 +0200 | [diff] [blame] | 519 | } |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 520 | return err; |
| 521 | } |
| 522 | |
| 523 | static int ovl_create_object(struct dentry *dentry, int mode, dev_t rdev, |
| 524 | const char *link) |
| 525 | { |
| 526 | int err; |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 527 | struct inode *inode; |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 528 | struct cattr attr = { |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 529 | .rdev = rdev, |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 530 | .link = link, |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 531 | }; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 532 | |
| 533 | err = ovl_want_write(dentry); |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 534 | if (err) |
| 535 | goto out; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 536 | |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 537 | err = -ENOMEM; |
Miklos Szeredi | ca4c8a3 | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 538 | inode = ovl_new_inode(dentry->d_sb, mode, rdev); |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 539 | if (!inode) |
| 540 | goto out_drop_write; |
| 541 | |
| 542 | inode_init_owner(inode, dentry->d_parent->d_inode, mode); |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 543 | attr.mode = inode->i_mode; |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 544 | |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 545 | err = ovl_create_or_link(dentry, inode, &attr, NULL); |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 546 | if (err) |
| 547 | iput(inode); |
| 548 | |
| 549 | out_drop_write: |
| 550 | ovl_drop_write(dentry); |
| 551 | out: |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 552 | return err; |
| 553 | } |
| 554 | |
| 555 | static int ovl_create(struct inode *dir, struct dentry *dentry, umode_t mode, |
| 556 | bool excl) |
| 557 | { |
| 558 | return ovl_create_object(dentry, (mode & 07777) | S_IFREG, 0, NULL); |
| 559 | } |
| 560 | |
| 561 | static int ovl_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) |
| 562 | { |
| 563 | return ovl_create_object(dentry, (mode & 07777) | S_IFDIR, 0, NULL); |
| 564 | } |
| 565 | |
| 566 | static int ovl_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, |
| 567 | dev_t rdev) |
| 568 | { |
| 569 | /* Don't allow creation of "whiteout" on overlay */ |
| 570 | if (S_ISCHR(mode) && rdev == WHITEOUT_DEV) |
| 571 | return -EPERM; |
| 572 | |
| 573 | return ovl_create_object(dentry, mode, rdev, NULL); |
| 574 | } |
| 575 | |
| 576 | static int ovl_symlink(struct inode *dir, struct dentry *dentry, |
| 577 | const char *link) |
| 578 | { |
| 579 | return ovl_create_object(dentry, S_IFLNK, 0, link); |
| 580 | } |
| 581 | |
| 582 | static int ovl_link(struct dentry *old, struct inode *newdir, |
| 583 | struct dentry *new) |
| 584 | { |
| 585 | int err; |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 586 | struct inode *inode; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 587 | |
| 588 | err = ovl_want_write(old); |
| 589 | if (err) |
| 590 | goto out; |
| 591 | |
| 592 | err = ovl_copy_up(old); |
| 593 | if (err) |
| 594 | goto out_drop_write; |
| 595 | |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 596 | inode = d_inode(old); |
| 597 | ihold(inode); |
| 598 | |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 599 | err = ovl_create_or_link(new, inode, NULL, ovl_dentry_upper(old)); |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 600 | if (err) |
| 601 | iput(inode); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 602 | |
| 603 | out_drop_write: |
| 604 | ovl_drop_write(old); |
| 605 | out: |
| 606 | return err; |
| 607 | } |
| 608 | |
Miklos Szeredi | a105d68 | 2014-11-20 16:39:59 +0100 | [diff] [blame] | 609 | static int ovl_remove_and_whiteout(struct dentry *dentry, bool is_dir) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 610 | { |
| 611 | struct dentry *workdir = ovl_workdir(dentry); |
| 612 | struct inode *wdir = workdir->d_inode; |
| 613 | struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); |
| 614 | struct inode *udir = upperdir->d_inode; |
| 615 | struct dentry *whiteout; |
| 616 | struct dentry *upper; |
| 617 | struct dentry *opaquedir = NULL; |
| 618 | int err; |
Maxim Patlasov | cfc9fde | 2016-07-21 18:24:26 -0700 | [diff] [blame] | 619 | int flags = 0; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 620 | |
Miklos Szeredi | cc6f67b | 2015-05-19 14:30:12 +0200 | [diff] [blame] | 621 | if (WARN_ON(!workdir)) |
| 622 | return -EROFS; |
| 623 | |
Miklos Szeredi | d377c5e | 2015-05-14 10:04:44 +0200 | [diff] [blame] | 624 | if (is_dir) { |
Miklos Szeredi | 30c17eb | 2016-07-29 12:05:25 +0200 | [diff] [blame] | 625 | opaquedir = ovl_check_empty_and_clear(dentry); |
| 626 | err = PTR_ERR(opaquedir); |
| 627 | if (IS_ERR(opaquedir)) |
| 628 | goto out; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 629 | } |
| 630 | |
| 631 | err = ovl_lock_rename_workdir(workdir, upperdir); |
| 632 | if (err) |
| 633 | goto out_dput; |
| 634 | |
Maxim Patlasov | cfc9fde | 2016-07-21 18:24:26 -0700 | [diff] [blame] | 635 | upper = lookup_one_len(dentry->d_name.name, upperdir, |
| 636 | dentry->d_name.len); |
| 637 | err = PTR_ERR(upper); |
| 638 | if (IS_ERR(upper)) |
| 639 | goto out_unlock; |
| 640 | |
| 641 | err = -ESTALE; |
| 642 | if ((opaquedir && upper != opaquedir) || |
| 643 | (!opaquedir && ovl_dentry_upper(dentry) && |
| 644 | upper != ovl_dentry_upper(dentry))) { |
| 645 | goto out_dput_upper; |
| 646 | } |
| 647 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 648 | whiteout = ovl_whiteout(workdir, dentry); |
| 649 | err = PTR_ERR(whiteout); |
| 650 | if (IS_ERR(whiteout)) |
Maxim Patlasov | cfc9fde | 2016-07-21 18:24:26 -0700 | [diff] [blame] | 651 | goto out_dput_upper; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 652 | |
Maxim Patlasov | cfc9fde | 2016-07-21 18:24:26 -0700 | [diff] [blame] | 653 | if (d_is_dir(upper)) |
| 654 | flags = RENAME_EXCHANGE; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 655 | |
Maxim Patlasov | cfc9fde | 2016-07-21 18:24:26 -0700 | [diff] [blame] | 656 | err = ovl_do_rename(wdir, whiteout, udir, upper, flags); |
| 657 | if (err) |
| 658 | goto kill_whiteout; |
| 659 | if (flags) |
| 660 | ovl_cleanup(wdir, upper); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 661 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 662 | ovl_dentry_version_inc(dentry->d_parent); |
| 663 | out_d_drop: |
| 664 | d_drop(dentry); |
| 665 | dput(whiteout); |
Maxim Patlasov | cfc9fde | 2016-07-21 18:24:26 -0700 | [diff] [blame] | 666 | out_dput_upper: |
| 667 | dput(upper); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 668 | out_unlock: |
| 669 | unlock_rename(workdir, upperdir); |
| 670 | out_dput: |
| 671 | dput(opaquedir); |
| 672 | out: |
| 673 | return err; |
| 674 | |
| 675 | kill_whiteout: |
| 676 | ovl_cleanup(wdir, whiteout); |
| 677 | goto out_d_drop; |
| 678 | } |
| 679 | |
| 680 | static int ovl_remove_upper(struct dentry *dentry, bool is_dir) |
| 681 | { |
| 682 | struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); |
| 683 | struct inode *dir = upperdir->d_inode; |
Miklos Szeredi | 11f3710 | 2016-03-21 17:31:44 +0100 | [diff] [blame] | 684 | struct dentry *upper; |
Amir Goldstein | d159511 | 2016-10-26 12:34:06 +0300 | [diff] [blame] | 685 | struct dentry *opaquedir = NULL; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 686 | int err; |
| 687 | |
Amir Goldstein | d159511 | 2016-10-26 12:34:06 +0300 | [diff] [blame] | 688 | /* Redirect dir can be !ovl_lower_positive && OVL_TYPE_MERGE */ |
| 689 | if (is_dir && ovl_dentry_get_redirect(dentry)) { |
| 690 | opaquedir = ovl_check_empty_and_clear(dentry); |
| 691 | err = PTR_ERR(opaquedir); |
| 692 | if (IS_ERR(opaquedir)) |
| 693 | goto out; |
| 694 | } |
| 695 | |
Al Viro | 5955102 | 2016-01-22 15:40:57 -0500 | [diff] [blame] | 696 | inode_lock_nested(dir, I_MUTEX_PARENT); |
Miklos Szeredi | 11f3710 | 2016-03-21 17:31:44 +0100 | [diff] [blame] | 697 | upper = lookup_one_len(dentry->d_name.name, upperdir, |
| 698 | dentry->d_name.len); |
| 699 | err = PTR_ERR(upper); |
| 700 | if (IS_ERR(upper)) |
| 701 | goto out_unlock; |
| 702 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 703 | err = -ESTALE; |
Amir Goldstein | d159511 | 2016-10-26 12:34:06 +0300 | [diff] [blame] | 704 | if ((opaquedir && upper != opaquedir) || |
| 705 | (!opaquedir && upper != ovl_dentry_upper(dentry))) |
| 706 | goto out_dput_upper; |
| 707 | |
| 708 | if (is_dir) |
| 709 | err = vfs_rmdir(dir, upper); |
| 710 | else |
| 711 | err = vfs_unlink(dir, upper, NULL); |
| 712 | ovl_dentry_version_inc(dentry->d_parent); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 713 | |
| 714 | /* |
| 715 | * Keeping this dentry hashed would mean having to release |
| 716 | * upperpath/lowerpath, which could only be done if we are the |
| 717 | * sole user of this dentry. Too tricky... Just unhash for |
| 718 | * now. |
| 719 | */ |
Rui Wang | ce9113b | 2016-01-08 23:09:59 +0800 | [diff] [blame] | 720 | if (!err) |
| 721 | d_drop(dentry); |
Amir Goldstein | d159511 | 2016-10-26 12:34:06 +0300 | [diff] [blame] | 722 | out_dput_upper: |
| 723 | dput(upper); |
Miklos Szeredi | 11f3710 | 2016-03-21 17:31:44 +0100 | [diff] [blame] | 724 | out_unlock: |
Al Viro | 5955102 | 2016-01-22 15:40:57 -0500 | [diff] [blame] | 725 | inode_unlock(dir); |
Amir Goldstein | d159511 | 2016-10-26 12:34:06 +0300 | [diff] [blame] | 726 | dput(opaquedir); |
| 727 | out: |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 728 | return err; |
| 729 | } |
| 730 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 731 | static int ovl_do_remove(struct dentry *dentry, bool is_dir) |
| 732 | { |
| 733 | enum ovl_path_type type; |
| 734 | int err; |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 735 | const struct cred *old_cred; |
| 736 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 737 | err = ovl_want_write(dentry); |
| 738 | if (err) |
| 739 | goto out; |
| 740 | |
| 741 | err = ovl_copy_up(dentry->d_parent); |
| 742 | if (err) |
| 743 | goto out_drop_write; |
| 744 | |
| 745 | type = ovl_path_type(dentry); |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 746 | |
| 747 | old_cred = ovl_override_creds(dentry->d_sb); |
Miklos Szeredi | 2aff453 | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 748 | if (!ovl_lower_positive(dentry)) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 749 | err = ovl_remove_upper(dentry, is_dir); |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 750 | else |
Miklos Szeredi | a105d68 | 2014-11-20 16:39:59 +0100 | [diff] [blame] | 751 | err = ovl_remove_and_whiteout(dentry, is_dir); |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 752 | revert_creds(old_cred); |
Miklos Szeredi | dbc816d | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 753 | if (!err) { |
| 754 | if (is_dir) |
| 755 | clear_nlink(dentry->d_inode); |
| 756 | else |
| 757 | drop_nlink(dentry->d_inode); |
| 758 | } |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 759 | out_drop_write: |
| 760 | ovl_drop_write(dentry); |
| 761 | out: |
| 762 | return err; |
| 763 | } |
| 764 | |
| 765 | static int ovl_unlink(struct inode *dir, struct dentry *dentry) |
| 766 | { |
| 767 | return ovl_do_remove(dentry, false); |
| 768 | } |
| 769 | |
| 770 | static int ovl_rmdir(struct inode *dir, struct dentry *dentry) |
| 771 | { |
| 772 | return ovl_do_remove(dentry, true); |
| 773 | } |
| 774 | |
Miklos Szeredi | 370e55a | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 775 | static bool ovl_type_merge_or_lower(struct dentry *dentry) |
| 776 | { |
| 777 | enum ovl_path_type type = ovl_path_type(dentry); |
| 778 | |
| 779 | return OVL_TYPE_MERGE(type) || !OVL_TYPE_UPPER(type); |
| 780 | } |
| 781 | |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 782 | static bool ovl_can_move(struct dentry *dentry) |
| 783 | { |
| 784 | return ovl_redirect_dir(dentry->d_sb) || |
| 785 | !d_is_dir(dentry) || !ovl_type_merge_or_lower(dentry); |
| 786 | } |
| 787 | |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 788 | static char *ovl_get_redirect(struct dentry *dentry, bool samedir) |
| 789 | { |
| 790 | char *buf, *ret; |
| 791 | struct dentry *d, *tmp; |
Miklos Szeredi | 3ea22a7 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 792 | int buflen = ovl_redirect_max + 1; |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 793 | |
| 794 | if (samedir) { |
| 795 | ret = kstrndup(dentry->d_name.name, dentry->d_name.len, |
| 796 | GFP_KERNEL); |
| 797 | goto out; |
| 798 | } |
| 799 | |
| 800 | buf = ret = kmalloc(buflen, GFP_TEMPORARY); |
| 801 | if (!buf) |
| 802 | goto out; |
| 803 | |
| 804 | buflen--; |
| 805 | buf[buflen] = '\0'; |
| 806 | for (d = dget(dentry); !IS_ROOT(d);) { |
| 807 | const char *name; |
| 808 | int thislen; |
| 809 | |
| 810 | spin_lock(&d->d_lock); |
| 811 | name = ovl_dentry_get_redirect(d); |
| 812 | if (name) { |
| 813 | thislen = strlen(name); |
| 814 | } else { |
| 815 | name = d->d_name.name; |
| 816 | thislen = d->d_name.len; |
| 817 | } |
| 818 | |
| 819 | /* If path is too long, fall back to userspace move */ |
| 820 | if (thislen + (name[0] != '/') > buflen) { |
| 821 | ret = ERR_PTR(-EXDEV); |
| 822 | spin_unlock(&d->d_lock); |
| 823 | goto out_put; |
| 824 | } |
| 825 | |
| 826 | buflen -= thislen; |
| 827 | memcpy(&buf[buflen], name, thislen); |
| 828 | tmp = dget_dlock(d->d_parent); |
| 829 | spin_unlock(&d->d_lock); |
| 830 | |
| 831 | dput(d); |
| 832 | d = tmp; |
| 833 | |
| 834 | /* Absolute redirect: finished */ |
| 835 | if (buf[buflen] == '/') |
| 836 | break; |
| 837 | buflen--; |
| 838 | buf[buflen] = '/'; |
| 839 | } |
| 840 | ret = kstrdup(&buf[buflen], GFP_KERNEL); |
| 841 | out_put: |
| 842 | dput(d); |
| 843 | kfree(buf); |
| 844 | out: |
| 845 | return ret ? ret : ERR_PTR(-ENOMEM); |
| 846 | } |
| 847 | |
| 848 | static int ovl_set_redirect(struct dentry *dentry, bool samedir) |
| 849 | { |
| 850 | int err; |
| 851 | const char *redirect = ovl_dentry_get_redirect(dentry); |
| 852 | |
| 853 | if (redirect && (samedir || redirect[0] == '/')) |
| 854 | return 0; |
| 855 | |
| 856 | redirect = ovl_get_redirect(dentry, samedir); |
| 857 | if (IS_ERR(redirect)) |
| 858 | return PTR_ERR(redirect); |
| 859 | |
Amir Goldstein | 21a2287 | 2017-05-17 00:12:41 +0300 | [diff] [blame] | 860 | err = ovl_check_setxattr(dentry, ovl_dentry_upper(dentry), |
| 861 | OVL_XATTR_REDIRECT, |
| 862 | redirect, strlen(redirect), -EXDEV); |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 863 | if (!err) { |
| 864 | spin_lock(&dentry->d_lock); |
| 865 | ovl_dentry_set_redirect(dentry, redirect); |
| 866 | spin_unlock(&dentry->d_lock); |
| 867 | } else { |
| 868 | kfree(redirect); |
Amir Goldstein | 21a2287 | 2017-05-17 00:12:41 +0300 | [diff] [blame] | 869 | pr_warn_ratelimited("overlay: failed to set redirect (%i)\n", err); |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 870 | /* Fall back to userspace copy-up */ |
| 871 | err = -EXDEV; |
| 872 | } |
| 873 | return err; |
| 874 | } |
| 875 | |
Miklos Szeredi | 6c02cb5 | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 876 | static int ovl_rename(struct inode *olddir, struct dentry *old, |
| 877 | struct inode *newdir, struct dentry *new, |
| 878 | unsigned int flags) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 879 | { |
| 880 | int err; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 881 | struct dentry *old_upperdir; |
| 882 | struct dentry *new_upperdir; |
| 883 | struct dentry *olddentry; |
| 884 | struct dentry *newdentry; |
| 885 | struct dentry *trap; |
| 886 | bool old_opaque; |
| 887 | bool new_opaque; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 888 | bool cleanup_whiteout = false; |
| 889 | bool overwrite = !(flags & RENAME_EXCHANGE); |
David Howells | e36cb0b | 2015-01-29 12:02:35 +0000 | [diff] [blame] | 890 | bool is_dir = d_is_dir(old); |
Miklos Szeredi | 370e55a | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 891 | bool new_is_dir = d_is_dir(new); |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 892 | bool samedir = olddir == newdir; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 893 | struct dentry *opaquedir = NULL; |
| 894 | const struct cred *old_cred = NULL; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 895 | |
| 896 | err = -EINVAL; |
| 897 | if (flags & ~(RENAME_EXCHANGE | RENAME_NOREPLACE)) |
| 898 | goto out; |
| 899 | |
| 900 | flags &= ~RENAME_NOREPLACE; |
| 901 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 902 | /* Don't copy up directory trees */ |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 903 | err = -EXDEV; |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 904 | if (!ovl_can_move(old)) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 905 | goto out; |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 906 | if (!overwrite && !ovl_can_move(new)) |
Miklos Szeredi | 370e55a | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 907 | goto out; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 908 | |
| 909 | err = ovl_want_write(old); |
| 910 | if (err) |
| 911 | goto out; |
| 912 | |
| 913 | err = ovl_copy_up(old); |
| 914 | if (err) |
| 915 | goto out_drop_write; |
| 916 | |
| 917 | err = ovl_copy_up(new->d_parent); |
| 918 | if (err) |
| 919 | goto out_drop_write; |
| 920 | if (!overwrite) { |
| 921 | err = ovl_copy_up(new); |
| 922 | if (err) |
| 923 | goto out_drop_write; |
| 924 | } |
| 925 | |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 926 | old_cred = ovl_override_creds(old->d_sb); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 927 | |
Miklos Szeredi | 370e55a | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 928 | if (overwrite && new_is_dir && ovl_type_merge_or_lower(new)) { |
Miklos Szeredi | a105d68 | 2014-11-20 16:39:59 +0100 | [diff] [blame] | 929 | opaquedir = ovl_check_empty_and_clear(new); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 930 | err = PTR_ERR(opaquedir); |
| 931 | if (IS_ERR(opaquedir)) { |
| 932 | opaquedir = NULL; |
| 933 | goto out_revert_creds; |
| 934 | } |
| 935 | } |
| 936 | |
| 937 | if (overwrite) { |
Miklos Szeredi | 2aff453 | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 938 | if (ovl_lower_positive(old)) { |
Miklos Szeredi | c412ce4 | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 939 | if (!ovl_dentry_is_whiteout(new)) { |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 940 | /* Whiteout source */ |
| 941 | flags |= RENAME_WHITEOUT; |
| 942 | } else { |
| 943 | /* Switch whiteouts */ |
| 944 | flags |= RENAME_EXCHANGE; |
| 945 | } |
Miklos Szeredi | c412ce4 | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 946 | } else if (is_dir && ovl_dentry_is_whiteout(new)) { |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 947 | flags |= RENAME_EXCHANGE; |
| 948 | cleanup_whiteout = true; |
| 949 | } |
| 950 | } |
| 951 | |
| 952 | old_upperdir = ovl_dentry_upper(old->d_parent); |
| 953 | new_upperdir = ovl_dentry_upper(new->d_parent); |
| 954 | |
| 955 | trap = lock_rename(new_upperdir, old_upperdir); |
| 956 | |
Miklos Szeredi | 11f3710 | 2016-03-21 17:31:44 +0100 | [diff] [blame] | 957 | olddentry = lookup_one_len(old->d_name.name, old_upperdir, |
| 958 | old->d_name.len); |
| 959 | err = PTR_ERR(olddentry); |
| 960 | if (IS_ERR(olddentry)) |
| 961 | goto out_unlock; |
| 962 | |
| 963 | err = -ESTALE; |
| 964 | if (olddentry != ovl_dentry_upper(old)) |
| 965 | goto out_dput_old; |
| 966 | |
| 967 | newdentry = lookup_one_len(new->d_name.name, new_upperdir, |
| 968 | new->d_name.len); |
| 969 | err = PTR_ERR(newdentry); |
| 970 | if (IS_ERR(newdentry)) |
| 971 | goto out_dput_old; |
| 972 | |
Miklos Szeredi | 3ee23ff | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 973 | old_opaque = ovl_dentry_is_opaque(old); |
| 974 | new_opaque = ovl_dentry_is_opaque(new); |
| 975 | |
Miklos Szeredi | 11f3710 | 2016-03-21 17:31:44 +0100 | [diff] [blame] | 976 | err = -ESTALE; |
| 977 | if (ovl_dentry_upper(new)) { |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 978 | if (opaquedir) { |
Miklos Szeredi | 11f3710 | 2016-03-21 17:31:44 +0100 | [diff] [blame] | 979 | if (newdentry != opaquedir) |
| 980 | goto out_dput; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 981 | } else { |
Miklos Szeredi | 11f3710 | 2016-03-21 17:31:44 +0100 | [diff] [blame] | 982 | if (newdentry != ovl_dentry_upper(new)) |
| 983 | goto out_dput; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 984 | } |
| 985 | } else { |
Miklos Szeredi | 11f3710 | 2016-03-21 17:31:44 +0100 | [diff] [blame] | 986 | if (!d_is_negative(newdentry) && |
| 987 | (!new_opaque || !ovl_is_whiteout(newdentry))) |
| 988 | goto out_dput; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 989 | } |
| 990 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 991 | if (olddentry == trap) |
| 992 | goto out_dput; |
| 993 | if (newdentry == trap) |
| 994 | goto out_dput; |
| 995 | |
Miklos Szeredi | 804032f | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 996 | if (WARN_ON(olddentry->d_inode == newdentry->d_inode)) |
| 997 | goto out_dput; |
| 998 | |
Miklos Szeredi | 5cf5b47 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 999 | err = 0; |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 1000 | if (is_dir) { |
Miklos Szeredi | 5cf5b47 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 1001 | if (ovl_type_merge_or_lower(old)) |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 1002 | err = ovl_set_redirect(old, samedir); |
Amir Goldstein | 97c684c | 2016-11-21 18:57:34 +0200 | [diff] [blame] | 1003 | else if (!old_opaque && ovl_type_merge(new->d_parent)) |
Amir Goldstein | 21a2287 | 2017-05-17 00:12:41 +0300 | [diff] [blame] | 1004 | err = ovl_set_opaque_xerr(old, olddentry, -EXDEV); |
Miklos Szeredi | 5cf5b47 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 1005 | if (err) |
| 1006 | goto out_dput; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1007 | } |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 1008 | if (!overwrite && new_is_dir) { |
Miklos Szeredi | 5cf5b47 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 1009 | if (ovl_type_merge_or_lower(new)) |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 1010 | err = ovl_set_redirect(new, samedir); |
Amir Goldstein | 97c684c | 2016-11-21 18:57:34 +0200 | [diff] [blame] | 1011 | else if (!new_opaque && ovl_type_merge(old->d_parent)) |
Amir Goldstein | 21a2287 | 2017-05-17 00:12:41 +0300 | [diff] [blame] | 1012 | err = ovl_set_opaque_xerr(new, newdentry, -EXDEV); |
Miklos Szeredi | 5cf5b47 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 1013 | if (err) |
| 1014 | goto out_dput; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1015 | } |
| 1016 | |
Miklos Szeredi | 3ee23ff | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 1017 | err = ovl_do_rename(old_upperdir->d_inode, olddentry, |
| 1018 | new_upperdir->d_inode, newdentry, flags); |
| 1019 | if (err) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1020 | goto out_dput; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1021 | |
| 1022 | if (cleanup_whiteout) |
| 1023 | ovl_cleanup(old_upperdir->d_inode, newdentry); |
| 1024 | |
| 1025 | ovl_dentry_version_inc(old->d_parent); |
| 1026 | ovl_dentry_version_inc(new->d_parent); |
| 1027 | |
| 1028 | out_dput: |
| 1029 | dput(newdentry); |
Miklos Szeredi | 11f3710 | 2016-03-21 17:31:44 +0100 | [diff] [blame] | 1030 | out_dput_old: |
| 1031 | dput(olddentry); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1032 | out_unlock: |
| 1033 | unlock_rename(new_upperdir, old_upperdir); |
| 1034 | out_revert_creds: |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 1035 | revert_creds(old_cred); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1036 | out_drop_write: |
| 1037 | ovl_drop_write(old); |
| 1038 | out: |
| 1039 | dput(opaquedir); |
| 1040 | return err; |
| 1041 | } |
| 1042 | |
| 1043 | const struct inode_operations ovl_dir_inode_operations = { |
| 1044 | .lookup = ovl_lookup, |
| 1045 | .mkdir = ovl_mkdir, |
| 1046 | .symlink = ovl_symlink, |
| 1047 | .unlink = ovl_unlink, |
| 1048 | .rmdir = ovl_rmdir, |
Miklos Szeredi | 6c02cb5 | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 1049 | .rename = ovl_rename, |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1050 | .link = ovl_link, |
| 1051 | .setattr = ovl_setattr, |
| 1052 | .create = ovl_create, |
| 1053 | .mknod = ovl_mknod, |
| 1054 | .permission = ovl_permission, |
Miklos Szeredi | 5b71209 | 2017-05-05 11:38:58 +0200 | [diff] [blame] | 1055 | .getattr = ovl_getattr, |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1056 | .listxattr = ovl_listxattr, |
Vivek Goyal | 39a25b2 | 2016-07-01 16:34:26 -0400 | [diff] [blame] | 1057 | .get_acl = ovl_get_acl, |
Miklos Szeredi | d719e8f | 2016-07-29 12:05:23 +0200 | [diff] [blame] | 1058 | .update_time = ovl_update_time, |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1059 | }; |