Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 2 | /* |
| 3 | * |
| 4 | * Copyright (C) 2011 Novell Inc. |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <linux/fs.h> |
| 8 | #include <linux/namei.h> |
| 9 | #include <linux/xattr.h> |
| 10 | #include <linux/security.h> |
| 11 | #include <linux/cred.h> |
Miklos Szeredi | 3ea22a7 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 12 | #include <linux/module.h> |
Miklos Szeredi | 38b2569 | 2016-09-01 11:11:59 +0200 | [diff] [blame] | 13 | #include <linux/posix_acl.h> |
| 14 | #include <linux/posix_acl_xattr.h> |
Richard Weinberger | 6a45b36 | 2016-09-16 11:45:24 +0200 | [diff] [blame] | 15 | #include <linux/atomic.h> |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 16 | #include <linux/ratelimit.h> |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 17 | #include "overlayfs.h" |
| 18 | |
Miklos Szeredi | 3ea22a7 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 19 | static unsigned short ovl_redirect_max = 256; |
| 20 | module_param_named(redirect_max, ovl_redirect_max, ushort, 0644); |
Nicolas Schier | 253e748 | 2019-06-17 09:39:00 +0200 | [diff] [blame] | 21 | MODULE_PARM_DESC(redirect_max, |
Miklos Szeredi | 3ea22a7 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 22 | "Maximum length of absolute redirect xattr value"); |
| 23 | |
Vivek Goyal | 4120fe6 | 2018-05-11 11:49:32 -0400 | [diff] [blame] | 24 | static int ovl_set_redirect(struct dentry *dentry, bool samedir); |
| 25 | |
Amir Goldstein | 415543d | 2017-06-21 15:28:42 +0300 | [diff] [blame] | 26 | int ovl_cleanup(struct inode *wdir, struct dentry *wdentry) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 27 | { |
| 28 | int err; |
| 29 | |
| 30 | dget(wdentry); |
David Howells | e36cb0b | 2015-01-29 12:02:35 +0000 | [diff] [blame] | 31 | if (d_is_dir(wdentry)) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 32 | err = ovl_do_rmdir(wdir, wdentry); |
| 33 | else |
| 34 | err = ovl_do_unlink(wdir, wdentry); |
| 35 | dput(wdentry); |
| 36 | |
| 37 | if (err) { |
lijiazi | 1bd0a3a | 2019-12-16 19:12:32 +0800 | [diff] [blame] | 38 | pr_err("cleanup of '%pd2' failed (%i)\n", |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 39 | wdentry, err); |
| 40 | } |
Amir Goldstein | 415543d | 2017-06-21 15:28:42 +0300 | [diff] [blame] | 41 | |
| 42 | return err; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 43 | } |
| 44 | |
Amir Goldstein | cad218a | 2020-02-20 09:00:19 +0200 | [diff] [blame] | 45 | struct dentry *ovl_lookup_temp(struct dentry *workdir) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 46 | { |
| 47 | struct dentry *temp; |
| 48 | char name[20]; |
Richard Weinberger | 6a45b36 | 2016-09-16 11:45:24 +0200 | [diff] [blame] | 49 | static atomic_t temp_id = ATOMIC_INIT(0); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 50 | |
Richard Weinberger | 6a45b36 | 2016-09-16 11:45:24 +0200 | [diff] [blame] | 51 | /* counter is allowed to wrap, since temp dentries are ephemeral */ |
| 52 | snprintf(name, sizeof(name), "#%x", atomic_inc_return(&temp_id)); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 53 | |
| 54 | temp = lookup_one_len(name, workdir, strlen(name)); |
| 55 | if (!IS_ERR(temp) && temp->d_inode) { |
lijiazi | 1bd0a3a | 2019-12-16 19:12:32 +0800 | [diff] [blame] | 56 | pr_err("workdir/%s already exists\n", name); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 57 | dput(temp); |
| 58 | temp = ERR_PTR(-EIO); |
| 59 | } |
| 60 | |
| 61 | return temp; |
| 62 | } |
| 63 | |
| 64 | /* caller holds i_mutex on workdir */ |
Chengguang Xu | c21c839 | 2020-04-24 10:55:17 +0800 | [diff] [blame] | 65 | static struct dentry *ovl_whiteout(struct ovl_fs *ofs) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 66 | { |
| 67 | int err; |
| 68 | struct dentry *whiteout; |
Chengguang Xu | c21c839 | 2020-04-24 10:55:17 +0800 | [diff] [blame] | 69 | struct dentry *workdir = ofs->workdir; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 70 | struct inode *wdir = workdir->d_inode; |
| 71 | |
Chengguang Xu | c21c839 | 2020-04-24 10:55:17 +0800 | [diff] [blame] | 72 | if (!ofs->whiteout) { |
| 73 | whiteout = ovl_lookup_temp(workdir); |
| 74 | if (IS_ERR(whiteout)) |
| 75 | goto out; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 76 | |
Chengguang Xu | c21c839 | 2020-04-24 10:55:17 +0800 | [diff] [blame] | 77 | err = ovl_do_whiteout(wdir, whiteout); |
| 78 | if (err) { |
| 79 | dput(whiteout); |
| 80 | whiteout = ERR_PTR(err); |
| 81 | goto out; |
| 82 | } |
| 83 | ofs->whiteout = whiteout; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 84 | } |
| 85 | |
Chengguang Xu | c21c839 | 2020-04-24 10:55:17 +0800 | [diff] [blame] | 86 | if (ofs->share_whiteout) { |
| 87 | whiteout = ovl_lookup_temp(workdir); |
| 88 | if (IS_ERR(whiteout)) |
| 89 | goto out; |
| 90 | |
| 91 | err = ovl_do_link(ofs->whiteout, wdir, whiteout); |
| 92 | if (!err) |
| 93 | goto out; |
| 94 | |
| 95 | if (err != -EMLINK) { |
| 96 | pr_warn("Failed to link whiteout - disabling whiteout inode sharing(nlink=%u, err=%i)\n", |
| 97 | ofs->whiteout->d_inode->i_nlink, err); |
| 98 | ofs->share_whiteout = false; |
| 99 | } |
| 100 | dput(whiteout); |
| 101 | } |
| 102 | whiteout = ofs->whiteout; |
| 103 | ofs->whiteout = NULL; |
| 104 | out: |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 105 | return whiteout; |
| 106 | } |
| 107 | |
Amir Goldstein | e7dd0e7 | 2017-10-24 17:38:33 +0300 | [diff] [blame] | 108 | /* Caller must hold i_mutex on both workdir and dir */ |
Chengguang Xu | c21c839 | 2020-04-24 10:55:17 +0800 | [diff] [blame] | 109 | int ovl_cleanup_and_whiteout(struct ovl_fs *ofs, struct inode *dir, |
Amir Goldstein | e7dd0e7 | 2017-10-24 17:38:33 +0300 | [diff] [blame] | 110 | struct dentry *dentry) |
| 111 | { |
Chengguang Xu | c21c839 | 2020-04-24 10:55:17 +0800 | [diff] [blame] | 112 | struct inode *wdir = ofs->workdir->d_inode; |
Amir Goldstein | e7dd0e7 | 2017-10-24 17:38:33 +0300 | [diff] [blame] | 113 | struct dentry *whiteout; |
| 114 | int err; |
| 115 | int flags = 0; |
| 116 | |
Chengguang Xu | c21c839 | 2020-04-24 10:55:17 +0800 | [diff] [blame] | 117 | whiteout = ovl_whiteout(ofs); |
Amir Goldstein | e7dd0e7 | 2017-10-24 17:38:33 +0300 | [diff] [blame] | 118 | err = PTR_ERR(whiteout); |
| 119 | if (IS_ERR(whiteout)) |
| 120 | return err; |
| 121 | |
| 122 | if (d_is_dir(dentry)) |
| 123 | flags = RENAME_EXCHANGE; |
| 124 | |
| 125 | err = ovl_do_rename(wdir, whiteout, dir, dentry, flags); |
| 126 | if (err) |
| 127 | goto kill_whiteout; |
| 128 | if (flags) |
| 129 | ovl_cleanup(wdir, dentry); |
| 130 | |
| 131 | out: |
| 132 | dput(whiteout); |
| 133 | return err; |
| 134 | |
| 135 | kill_whiteout: |
| 136 | ovl_cleanup(wdir, whiteout); |
| 137 | goto out; |
| 138 | } |
| 139 | |
Al Viro | f73cc77 | 2018-05-16 18:19:53 +0300 | [diff] [blame] | 140 | static int ovl_mkdir_real(struct inode *dir, struct dentry **newdentry, |
| 141 | umode_t mode) |
| 142 | { |
| 143 | int err; |
| 144 | struct dentry *d, *dentry = *newdentry; |
| 145 | |
| 146 | err = ovl_do_mkdir(dir, dentry, mode); |
| 147 | if (err) |
| 148 | return err; |
| 149 | |
| 150 | if (likely(!d_unhashed(dentry))) |
| 151 | return 0; |
| 152 | |
| 153 | /* |
| 154 | * vfs_mkdir() may succeed and leave the dentry passed |
| 155 | * to it unhashed and negative. If that happens, try to |
| 156 | * lookup a new hashed and positive dentry. |
| 157 | */ |
| 158 | d = lookup_one_len(dentry->d_name.name, dentry->d_parent, |
| 159 | dentry->d_name.len); |
| 160 | if (IS_ERR(d)) { |
lijiazi | 1bd0a3a | 2019-12-16 19:12:32 +0800 | [diff] [blame] | 161 | pr_warn("failed lookup after mkdir (%pd2, err=%i).\n", |
Al Viro | f73cc77 | 2018-05-16 18:19:53 +0300 | [diff] [blame] | 162 | dentry, err); |
| 163 | return PTR_ERR(d); |
| 164 | } |
| 165 | dput(dentry); |
| 166 | *newdentry = d; |
| 167 | |
| 168 | return 0; |
| 169 | } |
| 170 | |
Miklos Szeredi | 95a1c81 | 2018-05-16 17:51:25 +0300 | [diff] [blame] | 171 | struct dentry *ovl_create_real(struct inode *dir, struct dentry *newdentry, |
| 172 | struct ovl_cattr *attr) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 173 | { |
| 174 | int err; |
| 175 | |
Miklos Szeredi | 95a1c81 | 2018-05-16 17:51:25 +0300 | [diff] [blame] | 176 | if (IS_ERR(newdentry)) |
| 177 | return newdentry; |
| 178 | |
| 179 | err = -ESTALE; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 180 | if (newdentry->d_inode) |
Miklos Szeredi | 95a1c81 | 2018-05-16 17:51:25 +0300 | [diff] [blame] | 181 | goto out; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 182 | |
Amir Goldstein | 471ec5d | 2018-05-16 17:35:02 +0300 | [diff] [blame] | 183 | if (attr->hardlink) { |
| 184 | err = ovl_do_link(attr->hardlink, dir, newdentry); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 185 | } else { |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 186 | switch (attr->mode & S_IFMT) { |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 187 | case S_IFREG: |
Amir Goldstein | 6cf0076 | 2018-05-16 17:04:00 +0300 | [diff] [blame] | 188 | err = ovl_do_create(dir, newdentry, attr->mode); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 189 | break; |
| 190 | |
| 191 | case S_IFDIR: |
Al Viro | f73cc77 | 2018-05-16 18:19:53 +0300 | [diff] [blame] | 192 | /* mkdir is special... */ |
| 193 | err = ovl_mkdir_real(dir, &newdentry, attr->mode); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 194 | break; |
| 195 | |
| 196 | case S_IFCHR: |
| 197 | case S_IFBLK: |
| 198 | case S_IFIFO: |
| 199 | case S_IFSOCK: |
Amir Goldstein | 6cf0076 | 2018-05-16 17:04:00 +0300 | [diff] [blame] | 200 | err = ovl_do_mknod(dir, newdentry, attr->mode, |
| 201 | attr->rdev); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 202 | break; |
| 203 | |
| 204 | case S_IFLNK: |
Amir Goldstein | 6cf0076 | 2018-05-16 17:04:00 +0300 | [diff] [blame] | 205 | err = ovl_do_symlink(dir, newdentry, attr->link); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 206 | break; |
| 207 | |
| 208 | default: |
| 209 | err = -EPERM; |
| 210 | } |
| 211 | } |
| 212 | if (!err && WARN_ON(!newdentry->d_inode)) { |
| 213 | /* |
| 214 | * Not quite sure if non-instantiated dentry is legal or not. |
| 215 | * VFS doesn't seem to care so check and warn here. |
| 216 | */ |
Miklos Szeredi | dd8ac699 | 2018-05-31 11:06:11 +0200 | [diff] [blame] | 217 | err = -EIO; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 218 | } |
Miklos Szeredi | 95a1c81 | 2018-05-16 17:51:25 +0300 | [diff] [blame] | 219 | out: |
| 220 | if (err) { |
| 221 | dput(newdentry); |
| 222 | return ERR_PTR(err); |
| 223 | } |
| 224 | return newdentry; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 225 | } |
| 226 | |
Amir Goldstein | 137ec52 | 2018-05-16 17:51:25 +0300 | [diff] [blame] | 227 | struct dentry *ovl_create_temp(struct dentry *workdir, struct ovl_cattr *attr) |
| 228 | { |
| 229 | return ovl_create_real(d_inode(workdir), ovl_lookup_temp(workdir), |
| 230 | attr); |
| 231 | } |
| 232 | |
Amir Goldstein | 21a2287 | 2017-05-17 00:12:41 +0300 | [diff] [blame] | 233 | static int ovl_set_opaque_xerr(struct dentry *dentry, struct dentry *upper, |
| 234 | int xerr) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 235 | { |
Miklos Szeredi | 5cf5b47 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 236 | int err; |
| 237 | |
Amir Goldstein | 21a2287 | 2017-05-17 00:12:41 +0300 | [diff] [blame] | 238 | err = ovl_check_setxattr(dentry, upper, OVL_XATTR_OPAQUE, "y", 1, xerr); |
Miklos Szeredi | 5cf5b47 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 239 | if (!err) |
| 240 | ovl_dentry_set_opaque(dentry); |
| 241 | |
| 242 | return err; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 243 | } |
| 244 | |
Amir Goldstein | 21a2287 | 2017-05-17 00:12:41 +0300 | [diff] [blame] | 245 | static int ovl_set_opaque(struct dentry *dentry, struct dentry *upperdentry) |
| 246 | { |
| 247 | /* |
| 248 | * Fail with -EIO when trying to create opaque dir and upper doesn't |
| 249 | * support xattrs. ovl_rename() calls ovl_set_opaque_xerr(-EXDEV) to |
| 250 | * return a specific error for noxattr case. |
| 251 | */ |
| 252 | return ovl_set_opaque_xerr(dentry, upperdentry, -EIO); |
| 253 | } |
| 254 | |
Amir Goldstein | 01b39dc | 2018-05-11 11:15:15 +0300 | [diff] [blame] | 255 | /* |
| 256 | * Common operations required to be done after creation of file on upper. |
| 257 | * If @hardlink is false, then @inode is a pre-allocated inode, we may or |
| 258 | * may not use to instantiate the new dentry. |
| 259 | */ |
| 260 | static int ovl_instantiate(struct dentry *dentry, struct inode *inode, |
| 261 | struct dentry *newdentry, bool hardlink) |
Vivek Goyal | 72e4848 | 2016-06-16 10:09:14 -0400 | [diff] [blame] | 262 | { |
Amir Goldstein | 01b39dc | 2018-05-11 11:15:15 +0300 | [diff] [blame] | 263 | struct ovl_inode_params oip = { |
| 264 | .upperdentry = newdentry, |
| 265 | .newinode = inode, |
| 266 | }; |
| 267 | |
Miklos Szeredi | d9854c8 | 2018-07-18 15:44:40 +0200 | [diff] [blame] | 268 | ovl_dir_modified(dentry->d_parent, false); |
Miklos Szeredi | 55acc66 | 2017-07-04 22:03:18 +0200 | [diff] [blame] | 269 | ovl_dentry_set_upper_alias(dentry); |
Miklos Szeredi | f428884 | 2020-03-17 15:04:22 +0100 | [diff] [blame] | 270 | ovl_dentry_update_reval(dentry, newdentry, |
| 271 | DCACHE_OP_REVALIDATE | DCACHE_OP_WEAK_REVALIDATE); |
| 272 | |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 273 | if (!hardlink) { |
Amir Goldstein | 01b39dc | 2018-05-11 11:15:15 +0300 | [diff] [blame] | 274 | /* |
| 275 | * ovl_obtain_alias() can be called after ovl_create_real() |
| 276 | * and before we get here, so we may get an inode from cache |
| 277 | * with the same real upperdentry that is not the inode we |
| 278 | * pre-allocated. In this case we will use the cached inode |
| 279 | * to instantiate the new dentry. |
| 280 | * |
| 281 | * XXX: if we ever use ovl_obtain_alias() to decode directory |
| 282 | * file handles, need to use ovl_get_inode_locked() and |
| 283 | * d_instantiate_new() here to prevent from creating two |
| 284 | * hashed directory inode aliases. |
| 285 | */ |
| 286 | inode = ovl_get_inode(dentry->d_sb, &oip); |
Amir Goldstein | acf3062 | 2019-03-28 17:38:29 +0200 | [diff] [blame] | 287 | if (IS_ERR(inode)) |
Amir Goldstein | 01b39dc | 2018-05-11 11:15:15 +0300 | [diff] [blame] | 288 | return PTR_ERR(inode); |
Vivek Goyal | 28166ab | 2020-06-01 11:56:52 -0400 | [diff] [blame] | 289 | if (inode == oip.newinode) |
| 290 | ovl_set_flag(OVL_UPPERDATA, inode); |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 291 | } else { |
Miklos Szeredi | 09d8b58 | 2017-07-04 22:03:16 +0200 | [diff] [blame] | 292 | WARN_ON(ovl_inode_real(inode) != d_inode(newdentry)); |
| 293 | dput(newdentry); |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 294 | inc_nlink(inode); |
| 295 | } |
Amir Goldstein | 01b39dc | 2018-05-11 11:15:15 +0300 | [diff] [blame] | 296 | |
Vivek Goyal | 72e4848 | 2016-06-16 10:09:14 -0400 | [diff] [blame] | 297 | d_instantiate(dentry, inode); |
Amir Goldstein | 01b39dc | 2018-05-11 11:15:15 +0300 | [diff] [blame] | 298 | if (inode != oip.newinode) { |
lijiazi | 1bd0a3a | 2019-12-16 19:12:32 +0800 | [diff] [blame] | 299 | pr_warn_ratelimited("newly created inode found in cache (%pd2)\n", |
Amir Goldstein | 01b39dc | 2018-05-11 11:15:15 +0300 | [diff] [blame] | 300 | dentry); |
| 301 | } |
| 302 | |
Amir Goldstein | 5b6c905 | 2017-04-24 19:54:13 +0300 | [diff] [blame] | 303 | /* Force lookup of new upper hardlink to find its lower */ |
| 304 | if (hardlink) |
| 305 | d_drop(dentry); |
Amir Goldstein | 01b39dc | 2018-05-11 11:15:15 +0300 | [diff] [blame] | 306 | |
| 307 | return 0; |
Vivek Goyal | 72e4848 | 2016-06-16 10:09:14 -0400 | [diff] [blame] | 308 | } |
| 309 | |
Amir Goldstein | 97c684c | 2016-11-21 18:57:34 +0200 | [diff] [blame] | 310 | static bool ovl_type_merge(struct dentry *dentry) |
| 311 | { |
| 312 | return OVL_TYPE_MERGE(ovl_path_type(dentry)); |
| 313 | } |
| 314 | |
Amir Goldstein | ee1d6d37 | 2017-05-11 16:42:26 +0300 | [diff] [blame] | 315 | static bool ovl_type_origin(struct dentry *dentry) |
| 316 | { |
| 317 | return OVL_TYPE_ORIGIN(ovl_path_type(dentry)); |
| 318 | } |
| 319 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 320 | static int ovl_create_upper(struct dentry *dentry, struct inode *inode, |
Amir Goldstein | 471ec5d | 2018-05-16 17:35:02 +0300 | [diff] [blame] | 321 | struct ovl_cattr *attr) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 322 | { |
| 323 | struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); |
| 324 | struct inode *udir = upperdir->d_inode; |
| 325 | struct dentry *newdentry; |
| 326 | int err; |
| 327 | |
Amir Goldstein | 471ec5d | 2018-05-16 17:35:02 +0300 | [diff] [blame] | 328 | if (!attr->hardlink && !IS_POSIXACL(udir)) |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 329 | attr->mode &= ~current_umask(); |
Miklos Szeredi | 38b2569 | 2016-09-01 11:11:59 +0200 | [diff] [blame] | 330 | |
Al Viro | 5955102 | 2016-01-22 15:40:57 -0500 | [diff] [blame] | 331 | inode_lock_nested(udir, I_MUTEX_PARENT); |
Miklos Szeredi | 95a1c81 | 2018-05-16 17:51:25 +0300 | [diff] [blame] | 332 | newdentry = ovl_create_real(udir, |
| 333 | lookup_one_len(dentry->d_name.name, |
| 334 | upperdir, |
| 335 | dentry->d_name.len), |
| 336 | attr); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 337 | err = PTR_ERR(newdentry); |
| 338 | if (IS_ERR(newdentry)) |
| 339 | goto out_unlock; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 340 | |
Amir Goldstein | 4a99f3c | 2017-04-24 22:26:40 +0300 | [diff] [blame] | 341 | if (ovl_type_merge(dentry->d_parent) && d_is_dir(newdentry)) { |
Amir Goldstein | 97c684c | 2016-11-21 18:57:34 +0200 | [diff] [blame] | 342 | /* Setting opaque here is just an optimization, allow to fail */ |
| 343 | ovl_set_opaque(dentry, newdentry); |
| 344 | } |
| 345 | |
Amir Goldstein | 01b39dc | 2018-05-11 11:15:15 +0300 | [diff] [blame] | 346 | err = ovl_instantiate(dentry, inode, newdentry, !!attr->hardlink); |
| 347 | if (err) |
| 348 | goto out_cleanup; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 349 | out_unlock: |
Al Viro | 5955102 | 2016-01-22 15:40:57 -0500 | [diff] [blame] | 350 | inode_unlock(udir); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 351 | return err; |
Amir Goldstein | 01b39dc | 2018-05-11 11:15:15 +0300 | [diff] [blame] | 352 | |
| 353 | out_cleanup: |
| 354 | ovl_cleanup(udir, newdentry); |
| 355 | dput(newdentry); |
| 356 | goto out_unlock; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 357 | } |
| 358 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 359 | static struct dentry *ovl_clear_empty(struct dentry *dentry, |
| 360 | struct list_head *list) |
| 361 | { |
| 362 | struct dentry *workdir = ovl_workdir(dentry); |
| 363 | struct inode *wdir = workdir->d_inode; |
| 364 | struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); |
| 365 | struct inode *udir = upperdir->d_inode; |
| 366 | struct path upperpath; |
| 367 | struct dentry *upper; |
| 368 | struct dentry *opaquedir; |
| 369 | struct kstat stat; |
| 370 | int err; |
| 371 | |
Miklos Szeredi | cc6f67b | 2015-05-19 14:30:12 +0200 | [diff] [blame] | 372 | if (WARN_ON(!workdir)) |
| 373 | return ERR_PTR(-EROFS); |
| 374 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 375 | err = ovl_lock_rename_workdir(workdir, upperdir); |
| 376 | if (err) |
| 377 | goto out; |
| 378 | |
| 379 | ovl_path_upper(dentry, &upperpath); |
David Howells | a528d35 | 2017-01-31 16:46:22 +0000 | [diff] [blame] | 380 | err = vfs_getattr(&upperpath, &stat, |
| 381 | STATX_BASIC_STATS, AT_STATX_SYNC_AS_STAT); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 382 | if (err) |
| 383 | goto out_unlock; |
| 384 | |
| 385 | err = -ESTALE; |
| 386 | if (!S_ISDIR(stat.mode)) |
| 387 | goto out_unlock; |
| 388 | upper = upperpath.dentry; |
| 389 | if (upper->d_parent->d_inode != udir) |
| 390 | goto out_unlock; |
| 391 | |
Amir Goldstein | 137ec52 | 2018-05-16 17:51:25 +0300 | [diff] [blame] | 392 | opaquedir = ovl_create_temp(workdir, OVL_CATTR(stat.mode)); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 393 | err = PTR_ERR(opaquedir); |
| 394 | if (IS_ERR(opaquedir)) |
| 395 | goto out_unlock; |
| 396 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 397 | err = ovl_copy_xattr(upper, opaquedir); |
| 398 | if (err) |
| 399 | goto out_cleanup; |
| 400 | |
Miklos Szeredi | 5cf5b47 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 401 | err = ovl_set_opaque(dentry, opaquedir); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 402 | if (err) |
| 403 | goto out_cleanup; |
| 404 | |
Al Viro | 5955102 | 2016-01-22 15:40:57 -0500 | [diff] [blame] | 405 | inode_lock(opaquedir->d_inode); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 406 | err = ovl_set_attr(opaquedir, &stat); |
Al Viro | 5955102 | 2016-01-22 15:40:57 -0500 | [diff] [blame] | 407 | inode_unlock(opaquedir->d_inode); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 408 | if (err) |
| 409 | goto out_cleanup; |
| 410 | |
| 411 | err = ovl_do_rename(wdir, opaquedir, udir, upper, RENAME_EXCHANGE); |
| 412 | if (err) |
| 413 | goto out_cleanup; |
| 414 | |
| 415 | ovl_cleanup_whiteouts(upper, list); |
| 416 | ovl_cleanup(wdir, upper); |
| 417 | unlock_rename(workdir, upperdir); |
| 418 | |
| 419 | /* dentry's upper doesn't match now, get rid of it */ |
| 420 | d_drop(dentry); |
| 421 | |
| 422 | return opaquedir; |
| 423 | |
| 424 | out_cleanup: |
| 425 | ovl_cleanup(wdir, opaquedir); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 426 | dput(opaquedir); |
| 427 | out_unlock: |
| 428 | unlock_rename(workdir, upperdir); |
| 429 | out: |
| 430 | return ERR_PTR(err); |
| 431 | } |
| 432 | |
Miklos Szeredi | 38b2569 | 2016-09-01 11:11:59 +0200 | [diff] [blame] | 433 | static int ovl_set_upper_acl(struct dentry *upperdentry, const char *name, |
| 434 | const struct posix_acl *acl) |
| 435 | { |
| 436 | void *buffer; |
| 437 | size_t size; |
| 438 | int err; |
| 439 | |
| 440 | if (!IS_ENABLED(CONFIG_FS_POSIX_ACL) || !acl) |
| 441 | return 0; |
| 442 | |
Chengguang Xu | 14fa085 | 2018-06-22 09:49:36 +0800 | [diff] [blame] | 443 | size = posix_acl_xattr_size(acl->a_count); |
Miklos Szeredi | 38b2569 | 2016-09-01 11:11:59 +0200 | [diff] [blame] | 444 | buffer = kmalloc(size, GFP_KERNEL); |
| 445 | if (!buffer) |
| 446 | return -ENOMEM; |
| 447 | |
Chengguang Xu | 14fa085 | 2018-06-22 09:49:36 +0800 | [diff] [blame] | 448 | err = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); |
Miklos Szeredi | 38b2569 | 2016-09-01 11:11:59 +0200 | [diff] [blame] | 449 | if (err < 0) |
| 450 | goto out_free; |
| 451 | |
| 452 | err = vfs_setxattr(upperdentry, name, buffer, size, XATTR_CREATE); |
| 453 | out_free: |
| 454 | kfree(buffer); |
| 455 | return err; |
| 456 | } |
| 457 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 458 | static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode, |
Amir Goldstein | 471ec5d | 2018-05-16 17:35:02 +0300 | [diff] [blame] | 459 | struct ovl_cattr *cattr) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 460 | { |
| 461 | struct dentry *workdir = ovl_workdir(dentry); |
| 462 | struct inode *wdir = workdir->d_inode; |
| 463 | struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); |
| 464 | struct inode *udir = upperdir->d_inode; |
| 465 | struct dentry *upper; |
| 466 | struct dentry *newdentry; |
| 467 | int err; |
Miklos Szeredi | 38b2569 | 2016-09-01 11:11:59 +0200 | [diff] [blame] | 468 | struct posix_acl *acl, *default_acl; |
Amir Goldstein | 471ec5d | 2018-05-16 17:35:02 +0300 | [diff] [blame] | 469 | bool hardlink = !!cattr->hardlink; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 470 | |
Miklos Szeredi | cc6f67b | 2015-05-19 14:30:12 +0200 | [diff] [blame] | 471 | if (WARN_ON(!workdir)) |
| 472 | return -EROFS; |
| 473 | |
Miklos Szeredi | 38b2569 | 2016-09-01 11:11:59 +0200 | [diff] [blame] | 474 | if (!hardlink) { |
| 475 | err = posix_acl_create(dentry->d_parent->d_inode, |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 476 | &cattr->mode, &default_acl, &acl); |
Miklos Szeredi | 38b2569 | 2016-09-01 11:11:59 +0200 | [diff] [blame] | 477 | if (err) |
| 478 | return err; |
| 479 | } |
| 480 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 481 | err = ovl_lock_rename_workdir(workdir, upperdir); |
| 482 | if (err) |
| 483 | goto out; |
| 484 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 485 | upper = lookup_one_len(dentry->d_name.name, upperdir, |
| 486 | dentry->d_name.len); |
| 487 | err = PTR_ERR(upper); |
| 488 | if (IS_ERR(upper)) |
Miklos Szeredi | 95a1c81 | 2018-05-16 17:51:25 +0300 | [diff] [blame] | 489 | goto out_unlock; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 490 | |
Miklos Szeredi | 5e12758 | 2018-10-31 12:15:23 +0100 | [diff] [blame] | 491 | err = -ESTALE; |
| 492 | if (d_is_negative(upper) || !IS_WHITEOUT(d_inode(upper))) |
| 493 | goto out_dput; |
| 494 | |
Amir Goldstein | 137ec52 | 2018-05-16 17:51:25 +0300 | [diff] [blame] | 495 | newdentry = ovl_create_temp(workdir, cattr); |
Miklos Szeredi | 95a1c81 | 2018-05-16 17:51:25 +0300 | [diff] [blame] | 496 | err = PTR_ERR(newdentry); |
| 497 | if (IS_ERR(newdentry)) |
| 498 | goto out_dput; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 499 | |
Miklos Szeredi | bb0d2b8 | 2016-07-29 12:05:23 +0200 | [diff] [blame] | 500 | /* |
| 501 | * mode could have been mutilated due to umask (e.g. sgid directory) |
| 502 | */ |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 503 | if (!hardlink && |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 504 | !S_ISLNK(cattr->mode) && |
| 505 | newdentry->d_inode->i_mode != cattr->mode) { |
Miklos Szeredi | bb0d2b8 | 2016-07-29 12:05:23 +0200 | [diff] [blame] | 506 | struct iattr attr = { |
| 507 | .ia_valid = ATTR_MODE, |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 508 | .ia_mode = cattr->mode, |
Miklos Szeredi | bb0d2b8 | 2016-07-29 12:05:23 +0200 | [diff] [blame] | 509 | }; |
| 510 | inode_lock(newdentry->d_inode); |
| 511 | err = notify_change(newdentry, &attr, NULL); |
| 512 | inode_unlock(newdentry->d_inode); |
| 513 | if (err) |
| 514 | goto out_cleanup; |
| 515 | } |
Miklos Szeredi | 38b2569 | 2016-09-01 11:11:59 +0200 | [diff] [blame] | 516 | if (!hardlink) { |
| 517 | err = ovl_set_upper_acl(newdentry, XATTR_NAME_POSIX_ACL_ACCESS, |
| 518 | acl); |
| 519 | if (err) |
| 520 | goto out_cleanup; |
| 521 | |
| 522 | err = ovl_set_upper_acl(newdentry, XATTR_NAME_POSIX_ACL_DEFAULT, |
| 523 | default_acl); |
| 524 | if (err) |
| 525 | goto out_cleanup; |
| 526 | } |
Miklos Szeredi | bb0d2b8 | 2016-07-29 12:05:23 +0200 | [diff] [blame] | 527 | |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 528 | if (!hardlink && S_ISDIR(cattr->mode)) { |
Miklos Szeredi | 5cf5b47 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 529 | err = ovl_set_opaque(dentry, newdentry); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 530 | if (err) |
| 531 | goto out_cleanup; |
| 532 | |
| 533 | err = ovl_do_rename(wdir, newdentry, udir, upper, |
| 534 | RENAME_EXCHANGE); |
| 535 | if (err) |
| 536 | goto out_cleanup; |
| 537 | |
| 538 | ovl_cleanup(wdir, upper); |
| 539 | } else { |
| 540 | err = ovl_do_rename(wdir, newdentry, udir, upper, 0); |
| 541 | if (err) |
| 542 | goto out_cleanup; |
| 543 | } |
Amir Goldstein | 01b39dc | 2018-05-11 11:15:15 +0300 | [diff] [blame] | 544 | err = ovl_instantiate(dentry, inode, newdentry, hardlink); |
| 545 | if (err) |
| 546 | goto out_cleanup; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 547 | out_dput: |
Miklos Szeredi | 95a1c81 | 2018-05-16 17:51:25 +0300 | [diff] [blame] | 548 | dput(upper); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 549 | out_unlock: |
| 550 | unlock_rename(workdir, upperdir); |
| 551 | out: |
Miklos Szeredi | 38b2569 | 2016-09-01 11:11:59 +0200 | [diff] [blame] | 552 | if (!hardlink) { |
| 553 | posix_acl_release(acl); |
| 554 | posix_acl_release(default_acl); |
| 555 | } |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 556 | return err; |
| 557 | |
| 558 | out_cleanup: |
| 559 | ovl_cleanup(wdir, newdentry); |
Miklos Szeredi | 95a1c81 | 2018-05-16 17:51:25 +0300 | [diff] [blame] | 560 | dput(newdentry); |
| 561 | goto out_dput; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 562 | } |
| 563 | |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 564 | static int ovl_create_or_link(struct dentry *dentry, struct inode *inode, |
Amir Goldstein | 471ec5d | 2018-05-16 17:35:02 +0300 | [diff] [blame] | 565 | struct ovl_cattr *attr, bool origin) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 566 | { |
| 567 | int err; |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 568 | const struct cred *old_cred; |
| 569 | struct cred *override_cred; |
Amir Goldstein | ea3dad1 | 2017-07-11 15:58:34 +0300 | [diff] [blame] | 570 | struct dentry *parent = dentry->d_parent; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 571 | |
Amir Goldstein | ea3dad1 | 2017-07-11 15:58:34 +0300 | [diff] [blame] | 572 | err = ovl_copy_up(parent); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 573 | if (err) |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 574 | return err; |
Miklos Szeredi | bb0d2b8 | 2016-07-29 12:05:23 +0200 | [diff] [blame] | 575 | |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 576 | old_cred = ovl_override_creds(dentry->d_sb); |
Amir Goldstein | ea3dad1 | 2017-07-11 15:58:34 +0300 | [diff] [blame] | 577 | |
| 578 | /* |
| 579 | * When linking a file with copy up origin into a new parent, mark the |
| 580 | * new parent dir "impure". |
| 581 | */ |
| 582 | if (origin) { |
| 583 | err = ovl_set_impure(parent, ovl_dentry_upper(parent)); |
| 584 | if (err) |
| 585 | goto out_revert_creds; |
| 586 | } |
| 587 | |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 588 | err = -ENOMEM; |
| 589 | override_cred = prepare_creds(); |
| 590 | if (override_cred) { |
Miklos Szeredi | bb0d2b8 | 2016-07-29 12:05:23 +0200 | [diff] [blame] | 591 | override_cred->fsuid = inode->i_uid; |
| 592 | override_cred->fsgid = inode->i_gid; |
Amir Goldstein | 471ec5d | 2018-05-16 17:35:02 +0300 | [diff] [blame] | 593 | if (!attr->hardlink) { |
Vivek Goyal | 2602625 | 2016-07-13 10:44:52 -0400 | [diff] [blame] | 594 | err = security_dentry_create_files_as(dentry, |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 595 | attr->mode, &dentry->d_name, old_cred, |
Vivek Goyal | 2602625 | 2016-07-13 10:44:52 -0400 | [diff] [blame] | 596 | override_cred); |
| 597 | if (err) { |
| 598 | put_cred(override_cred); |
| 599 | goto out_revert_creds; |
| 600 | } |
| 601 | } |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 602 | put_cred(override_creds(override_cred)); |
| 603 | put_cred(override_cred); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 604 | |
Miklos Szeredi | c412ce4 | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 605 | if (!ovl_dentry_is_whiteout(dentry)) |
Amir Goldstein | 471ec5d | 2018-05-16 17:35:02 +0300 | [diff] [blame] | 606 | err = ovl_create_upper(dentry, inode, attr); |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 607 | else |
Amir Goldstein | 471ec5d | 2018-05-16 17:35:02 +0300 | [diff] [blame] | 608 | err = ovl_create_over_whiteout(dentry, inode, attr); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 609 | } |
Vivek Goyal | 2602625 | 2016-07-13 10:44:52 -0400 | [diff] [blame] | 610 | out_revert_creds: |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 611 | revert_creds(old_cred); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 612 | return err; |
| 613 | } |
| 614 | |
| 615 | static int ovl_create_object(struct dentry *dentry, int mode, dev_t rdev, |
| 616 | const char *link) |
| 617 | { |
| 618 | int err; |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 619 | struct inode *inode; |
Amir Goldstein | 471ec5d | 2018-05-16 17:35:02 +0300 | [diff] [blame] | 620 | struct ovl_cattr attr = { |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 621 | .rdev = rdev, |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 622 | .link = link, |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 623 | }; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 624 | |
| 625 | err = ovl_want_write(dentry); |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 626 | if (err) |
| 627 | goto out; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 628 | |
Amir Goldstein | 01b39dc | 2018-05-11 11:15:15 +0300 | [diff] [blame] | 629 | /* Preallocate inode to be used by ovl_get_inode() */ |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 630 | err = -ENOMEM; |
Miklos Szeredi | ca4c8a3 | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 631 | inode = ovl_new_inode(dentry->d_sb, mode, rdev); |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 632 | if (!inode) |
| 633 | goto out_drop_write; |
| 634 | |
Miklos Szeredi | 6faf05c | 2018-08-22 10:55:22 +0200 | [diff] [blame] | 635 | spin_lock(&inode->i_lock); |
| 636 | inode->i_state |= I_CREATING; |
| 637 | spin_unlock(&inode->i_lock); |
| 638 | |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 639 | inode_init_owner(inode, dentry->d_parent->d_inode, mode); |
Al Viro | 32a3d84 | 2016-12-04 17:33:17 +0000 | [diff] [blame] | 640 | attr.mode = inode->i_mode; |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 641 | |
Amir Goldstein | 471ec5d | 2018-05-16 17:35:02 +0300 | [diff] [blame] | 642 | err = ovl_create_or_link(dentry, inode, &attr, false); |
Amir Goldstein | 01b39dc | 2018-05-11 11:15:15 +0300 | [diff] [blame] | 643 | /* Did we end up using the preallocated inode? */ |
| 644 | if (inode != d_inode(dentry)) |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 645 | iput(inode); |
| 646 | |
| 647 | out_drop_write: |
| 648 | ovl_drop_write(dentry); |
| 649 | out: |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 650 | return err; |
| 651 | } |
| 652 | |
| 653 | static int ovl_create(struct inode *dir, struct dentry *dentry, umode_t mode, |
| 654 | bool excl) |
| 655 | { |
| 656 | return ovl_create_object(dentry, (mode & 07777) | S_IFREG, 0, NULL); |
| 657 | } |
| 658 | |
| 659 | static int ovl_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) |
| 660 | { |
| 661 | return ovl_create_object(dentry, (mode & 07777) | S_IFDIR, 0, NULL); |
| 662 | } |
| 663 | |
| 664 | static int ovl_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, |
| 665 | dev_t rdev) |
| 666 | { |
| 667 | /* Don't allow creation of "whiteout" on overlay */ |
| 668 | if (S_ISCHR(mode) && rdev == WHITEOUT_DEV) |
| 669 | return -EPERM; |
| 670 | |
| 671 | return ovl_create_object(dentry, mode, rdev, NULL); |
| 672 | } |
| 673 | |
| 674 | static int ovl_symlink(struct inode *dir, struct dentry *dentry, |
| 675 | const char *link) |
| 676 | { |
| 677 | return ovl_create_object(dentry, S_IFLNK, 0, link); |
| 678 | } |
| 679 | |
Amir Goldstein | 91ff20f | 2018-11-14 16:01:34 +0200 | [diff] [blame] | 680 | static int ovl_set_link_redirect(struct dentry *dentry) |
| 681 | { |
| 682 | const struct cred *old_cred; |
| 683 | int err; |
| 684 | |
| 685 | old_cred = ovl_override_creds(dentry->d_sb); |
| 686 | err = ovl_set_redirect(dentry, false); |
| 687 | revert_creds(old_cred); |
| 688 | |
| 689 | return err; |
| 690 | } |
| 691 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 692 | static int ovl_link(struct dentry *old, struct inode *newdir, |
| 693 | struct dentry *new) |
| 694 | { |
| 695 | int err; |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 696 | struct inode *inode; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 697 | |
| 698 | err = ovl_want_write(old); |
| 699 | if (err) |
| 700 | goto out; |
| 701 | |
| 702 | err = ovl_copy_up(old); |
| 703 | if (err) |
| 704 | goto out_drop_write; |
| 705 | |
Amir Goldstein | 6cd0787 | 2018-10-18 09:45:49 +0300 | [diff] [blame] | 706 | err = ovl_copy_up(new->d_parent); |
| 707 | if (err) |
| 708 | goto out_drop_write; |
| 709 | |
Vivek Goyal | 4120fe6 | 2018-05-11 11:49:32 -0400 | [diff] [blame] | 710 | if (ovl_is_metacopy_dentry(old)) { |
Amir Goldstein | 91ff20f | 2018-11-14 16:01:34 +0200 | [diff] [blame] | 711 | err = ovl_set_link_redirect(old); |
Vivek Goyal | 4120fe6 | 2018-05-11 11:49:32 -0400 | [diff] [blame] | 712 | if (err) |
| 713 | goto out_drop_write; |
| 714 | } |
| 715 | |
Amir Goldstein | 0e32992 | 2018-10-18 18:37:13 +0300 | [diff] [blame] | 716 | err = ovl_nlink_start(old); |
Amir Goldstein | 5f8415d | 2017-06-20 15:35:14 +0300 | [diff] [blame] | 717 | if (err) |
| 718 | goto out_drop_write; |
| 719 | |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 720 | inode = d_inode(old); |
| 721 | ihold(inode); |
| 722 | |
Amir Goldstein | 471ec5d | 2018-05-16 17:35:02 +0300 | [diff] [blame] | 723 | err = ovl_create_or_link(new, inode, |
| 724 | &(struct ovl_cattr) {.hardlink = ovl_dentry_upper(old)}, |
| 725 | ovl_type_origin(old)); |
Miklos Szeredi | 51f7e52 | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 726 | if (err) |
| 727 | iput(inode); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 728 | |
Amir Goldstein | 0e32992 | 2018-10-18 18:37:13 +0300 | [diff] [blame] | 729 | ovl_nlink_end(old); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 730 | out_drop_write: |
| 731 | ovl_drop_write(old); |
| 732 | out: |
| 733 | return err; |
| 734 | } |
| 735 | |
Miklos Szeredi | 9020df3 | 2017-07-04 22:03:16 +0200 | [diff] [blame] | 736 | static bool ovl_matches_upper(struct dentry *dentry, struct dentry *upper) |
| 737 | { |
| 738 | return d_inode(ovl_dentry_upper(dentry)) == d_inode(upper); |
| 739 | } |
| 740 | |
Amir Goldstein | 6d0a8a9 | 2017-11-10 13:18:07 +0200 | [diff] [blame] | 741 | static int ovl_remove_and_whiteout(struct dentry *dentry, |
| 742 | struct list_head *list) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 743 | { |
Chengguang Xu | c21c839 | 2020-04-24 10:55:17 +0800 | [diff] [blame] | 744 | struct ovl_fs *ofs = OVL_FS(dentry->d_sb); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 745 | struct dentry *workdir = ovl_workdir(dentry); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 746 | struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 747 | struct dentry *upper; |
| 748 | struct dentry *opaquedir = NULL; |
| 749 | int err; |
| 750 | |
Miklos Szeredi | cc6f67b | 2015-05-19 14:30:12 +0200 | [diff] [blame] | 751 | if (WARN_ON(!workdir)) |
| 752 | return -EROFS; |
| 753 | |
Amir Goldstein | 6d0a8a9 | 2017-11-10 13:18:07 +0200 | [diff] [blame] | 754 | if (!list_empty(list)) { |
| 755 | opaquedir = ovl_clear_empty(dentry, list); |
Miklos Szeredi | 30c17eb | 2016-07-29 12:05:25 +0200 | [diff] [blame] | 756 | err = PTR_ERR(opaquedir); |
| 757 | if (IS_ERR(opaquedir)) |
| 758 | goto out; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 759 | } |
| 760 | |
| 761 | err = ovl_lock_rename_workdir(workdir, upperdir); |
| 762 | if (err) |
| 763 | goto out_dput; |
| 764 | |
Maxim Patlasov | cfc9fde | 2016-07-21 18:24:26 -0700 | [diff] [blame] | 765 | upper = lookup_one_len(dentry->d_name.name, upperdir, |
| 766 | dentry->d_name.len); |
| 767 | err = PTR_ERR(upper); |
| 768 | if (IS_ERR(upper)) |
| 769 | goto out_unlock; |
| 770 | |
| 771 | err = -ESTALE; |
| 772 | if ((opaquedir && upper != opaquedir) || |
| 773 | (!opaquedir && ovl_dentry_upper(dentry) && |
Miklos Szeredi | 9020df3 | 2017-07-04 22:03:16 +0200 | [diff] [blame] | 774 | !ovl_matches_upper(dentry, upper))) { |
Maxim Patlasov | cfc9fde | 2016-07-21 18:24:26 -0700 | [diff] [blame] | 775 | goto out_dput_upper; |
| 776 | } |
| 777 | |
Chengguang Xu | c21c839 | 2020-04-24 10:55:17 +0800 | [diff] [blame] | 778 | err = ovl_cleanup_and_whiteout(ofs, d_inode(upperdir), upper); |
Maxim Patlasov | cfc9fde | 2016-07-21 18:24:26 -0700 | [diff] [blame] | 779 | if (err) |
Amir Goldstein | e7dd0e7 | 2017-10-24 17:38:33 +0300 | [diff] [blame] | 780 | goto out_d_drop; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 781 | |
Miklos Szeredi | d9854c8 | 2018-07-18 15:44:40 +0200 | [diff] [blame] | 782 | ovl_dir_modified(dentry->d_parent, true); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 783 | out_d_drop: |
| 784 | d_drop(dentry); |
Maxim Patlasov | cfc9fde | 2016-07-21 18:24:26 -0700 | [diff] [blame] | 785 | out_dput_upper: |
| 786 | dput(upper); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 787 | out_unlock: |
| 788 | unlock_rename(workdir, upperdir); |
| 789 | out_dput: |
| 790 | dput(opaquedir); |
| 791 | out: |
| 792 | return err; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 793 | } |
| 794 | |
Amir Goldstein | 6d0a8a9 | 2017-11-10 13:18:07 +0200 | [diff] [blame] | 795 | static int ovl_remove_upper(struct dentry *dentry, bool is_dir, |
| 796 | struct list_head *list) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 797 | { |
| 798 | struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); |
| 799 | struct inode *dir = upperdir->d_inode; |
Miklos Szeredi | 11f3710 | 2016-03-21 17:31:44 +0100 | [diff] [blame] | 800 | struct dentry *upper; |
Amir Goldstein | d159511 | 2016-10-26 12:34:06 +0300 | [diff] [blame] | 801 | struct dentry *opaquedir = NULL; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 802 | int err; |
| 803 | |
Amir Goldstein | 6d0a8a9 | 2017-11-10 13:18:07 +0200 | [diff] [blame] | 804 | if (!list_empty(list)) { |
| 805 | opaquedir = ovl_clear_empty(dentry, list); |
Amir Goldstein | d159511 | 2016-10-26 12:34:06 +0300 | [diff] [blame] | 806 | err = PTR_ERR(opaquedir); |
| 807 | if (IS_ERR(opaquedir)) |
| 808 | goto out; |
| 809 | } |
| 810 | |
Al Viro | 5955102 | 2016-01-22 15:40:57 -0500 | [diff] [blame] | 811 | inode_lock_nested(dir, I_MUTEX_PARENT); |
Miklos Szeredi | 11f3710 | 2016-03-21 17:31:44 +0100 | [diff] [blame] | 812 | upper = lookup_one_len(dentry->d_name.name, upperdir, |
| 813 | dentry->d_name.len); |
| 814 | err = PTR_ERR(upper); |
| 815 | if (IS_ERR(upper)) |
| 816 | goto out_unlock; |
| 817 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 818 | err = -ESTALE; |
Amir Goldstein | d159511 | 2016-10-26 12:34:06 +0300 | [diff] [blame] | 819 | if ((opaquedir && upper != opaquedir) || |
Miklos Szeredi | 9020df3 | 2017-07-04 22:03:16 +0200 | [diff] [blame] | 820 | (!opaquedir && !ovl_matches_upper(dentry, upper))) |
Amir Goldstein | d159511 | 2016-10-26 12:34:06 +0300 | [diff] [blame] | 821 | goto out_dput_upper; |
| 822 | |
| 823 | if (is_dir) |
| 824 | err = vfs_rmdir(dir, upper); |
| 825 | else |
| 826 | err = vfs_unlink(dir, upper, NULL); |
Miklos Szeredi | d9854c8 | 2018-07-18 15:44:40 +0200 | [diff] [blame] | 827 | ovl_dir_modified(dentry->d_parent, ovl_type_origin(dentry)); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 828 | |
| 829 | /* |
| 830 | * Keeping this dentry hashed would mean having to release |
| 831 | * upperpath/lowerpath, which could only be done if we are the |
| 832 | * sole user of this dentry. Too tricky... Just unhash for |
| 833 | * now. |
| 834 | */ |
Rui Wang | ce9113b | 2016-01-08 23:09:59 +0800 | [diff] [blame] | 835 | if (!err) |
| 836 | d_drop(dentry); |
Amir Goldstein | d159511 | 2016-10-26 12:34:06 +0300 | [diff] [blame] | 837 | out_dput_upper: |
| 838 | dput(upper); |
Miklos Szeredi | 11f3710 | 2016-03-21 17:31:44 +0100 | [diff] [blame] | 839 | out_unlock: |
Al Viro | 5955102 | 2016-01-22 15:40:57 -0500 | [diff] [blame] | 840 | inode_unlock(dir); |
Amir Goldstein | d159511 | 2016-10-26 12:34:06 +0300 | [diff] [blame] | 841 | dput(opaquedir); |
| 842 | out: |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 843 | return err; |
| 844 | } |
| 845 | |
Amir Goldstein | 6d0a8a9 | 2017-11-10 13:18:07 +0200 | [diff] [blame] | 846 | static bool ovl_pure_upper(struct dentry *dentry) |
| 847 | { |
| 848 | return !ovl_dentry_lower(dentry) && |
| 849 | !ovl_test_flag(OVL_WHITEOUTS, d_inode(dentry)); |
| 850 | } |
| 851 | |
Miklos Szeredi | 83552ea | 2020-03-27 16:51:02 +0100 | [diff] [blame] | 852 | static void ovl_drop_nlink(struct dentry *dentry) |
| 853 | { |
| 854 | struct inode *inode = d_inode(dentry); |
| 855 | struct dentry *alias; |
| 856 | |
| 857 | /* Try to find another, hashed alias */ |
| 858 | spin_lock(&inode->i_lock); |
| 859 | hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) { |
| 860 | if (alias != dentry && !d_unhashed(alias)) |
| 861 | break; |
| 862 | } |
| 863 | spin_unlock(&inode->i_lock); |
| 864 | |
| 865 | /* |
| 866 | * Changes to underlying layers may cause i_nlink to lose sync with |
| 867 | * reality. In this case prevent the link count from going to zero |
| 868 | * prematurely. |
| 869 | */ |
| 870 | if (inode->i_nlink > !!alias) |
| 871 | drop_nlink(inode); |
| 872 | } |
| 873 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 874 | static int ovl_do_remove(struct dentry *dentry, bool is_dir) |
| 875 | { |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 876 | int err; |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 877 | const struct cred *old_cred; |
Miklos Szeredi | d9854c8 | 2018-07-18 15:44:40 +0200 | [diff] [blame] | 878 | struct dentry *upperdentry; |
Amir Goldstein | 6d0a8a9 | 2017-11-10 13:18:07 +0200 | [diff] [blame] | 879 | bool lower_positive = ovl_lower_positive(dentry); |
| 880 | LIST_HEAD(list); |
| 881 | |
| 882 | /* No need to clean pure upper removed by vfs_rmdir() */ |
| 883 | if (is_dir && (lower_positive || !ovl_pure_upper(dentry))) { |
| 884 | err = ovl_check_empty_dir(dentry, &list); |
| 885 | if (err) |
| 886 | goto out; |
| 887 | } |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 888 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 889 | err = ovl_want_write(dentry); |
| 890 | if (err) |
| 891 | goto out; |
| 892 | |
| 893 | err = ovl_copy_up(dentry->d_parent); |
| 894 | if (err) |
| 895 | goto out_drop_write; |
| 896 | |
Amir Goldstein | 0e32992 | 2018-10-18 18:37:13 +0300 | [diff] [blame] | 897 | err = ovl_nlink_start(dentry); |
Amir Goldstein | 5f8415d | 2017-06-20 15:35:14 +0300 | [diff] [blame] | 898 | if (err) |
| 899 | goto out_drop_write; |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 900 | |
| 901 | old_cred = ovl_override_creds(dentry->d_sb); |
Amir Goldstein | 6d0a8a9 | 2017-11-10 13:18:07 +0200 | [diff] [blame] | 902 | if (!lower_positive) |
| 903 | err = ovl_remove_upper(dentry, is_dir, &list); |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 904 | else |
Amir Goldstein | 6d0a8a9 | 2017-11-10 13:18:07 +0200 | [diff] [blame] | 905 | err = ovl_remove_and_whiteout(dentry, &list); |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 906 | revert_creds(old_cred); |
Miklos Szeredi | dbc816d | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 907 | if (!err) { |
| 908 | if (is_dir) |
| 909 | clear_nlink(dentry->d_inode); |
| 910 | else |
Miklos Szeredi | 83552ea | 2020-03-27 16:51:02 +0100 | [diff] [blame] | 911 | ovl_drop_nlink(dentry); |
Miklos Szeredi | dbc816d | 2016-07-29 12:05:24 +0200 | [diff] [blame] | 912 | } |
Amir Goldstein | 0e32992 | 2018-10-18 18:37:13 +0300 | [diff] [blame] | 913 | ovl_nlink_end(dentry); |
Miklos Szeredi | d9854c8 | 2018-07-18 15:44:40 +0200 | [diff] [blame] | 914 | |
| 915 | /* |
| 916 | * Copy ctime |
| 917 | * |
| 918 | * Note: we fail to update ctime if there was no copy-up, only a |
| 919 | * whiteout |
| 920 | */ |
| 921 | upperdentry = ovl_dentry_upper(dentry); |
| 922 | if (upperdentry) |
| 923 | ovl_copyattr(d_inode(upperdentry), d_inode(dentry)); |
| 924 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 925 | out_drop_write: |
| 926 | ovl_drop_write(dentry); |
| 927 | out: |
Amir Goldstein | 6d0a8a9 | 2017-11-10 13:18:07 +0200 | [diff] [blame] | 928 | ovl_cache_free(&list); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 929 | return err; |
| 930 | } |
| 931 | |
| 932 | static int ovl_unlink(struct inode *dir, struct dentry *dentry) |
| 933 | { |
| 934 | return ovl_do_remove(dentry, false); |
| 935 | } |
| 936 | |
| 937 | static int ovl_rmdir(struct inode *dir, struct dentry *dentry) |
| 938 | { |
| 939 | return ovl_do_remove(dentry, true); |
| 940 | } |
| 941 | |
Miklos Szeredi | 370e55a | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 942 | static bool ovl_type_merge_or_lower(struct dentry *dentry) |
| 943 | { |
| 944 | enum ovl_path_type type = ovl_path_type(dentry); |
| 945 | |
| 946 | return OVL_TYPE_MERGE(type) || !OVL_TYPE_UPPER(type); |
| 947 | } |
| 948 | |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 949 | static bool ovl_can_move(struct dentry *dentry) |
| 950 | { |
| 951 | return ovl_redirect_dir(dentry->d_sb) || |
| 952 | !d_is_dir(dentry) || !ovl_type_merge_or_lower(dentry); |
| 953 | } |
| 954 | |
Vivek Goyal | 7bb0838 | 2018-05-11 11:49:32 -0400 | [diff] [blame] | 955 | static char *ovl_get_redirect(struct dentry *dentry, bool abs_redirect) |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 956 | { |
| 957 | char *buf, *ret; |
| 958 | struct dentry *d, *tmp; |
Miklos Szeredi | 3ea22a7 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 959 | int buflen = ovl_redirect_max + 1; |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 960 | |
Vivek Goyal | 7bb0838 | 2018-05-11 11:49:32 -0400 | [diff] [blame] | 961 | if (!abs_redirect) { |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 962 | ret = kstrndup(dentry->d_name.name, dentry->d_name.len, |
| 963 | GFP_KERNEL); |
| 964 | goto out; |
| 965 | } |
| 966 | |
Michal Hocko | 0ee931c | 2017-09-13 16:28:29 -0700 | [diff] [blame] | 967 | buf = ret = kmalloc(buflen, GFP_KERNEL); |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 968 | if (!buf) |
| 969 | goto out; |
| 970 | |
| 971 | buflen--; |
| 972 | buf[buflen] = '\0'; |
| 973 | for (d = dget(dentry); !IS_ROOT(d);) { |
| 974 | const char *name; |
| 975 | int thislen; |
| 976 | |
| 977 | spin_lock(&d->d_lock); |
| 978 | name = ovl_dentry_get_redirect(d); |
| 979 | if (name) { |
| 980 | thislen = strlen(name); |
| 981 | } else { |
| 982 | name = d->d_name.name; |
| 983 | thislen = d->d_name.len; |
| 984 | } |
| 985 | |
| 986 | /* If path is too long, fall back to userspace move */ |
| 987 | if (thislen + (name[0] != '/') > buflen) { |
| 988 | ret = ERR_PTR(-EXDEV); |
| 989 | spin_unlock(&d->d_lock); |
| 990 | goto out_put; |
| 991 | } |
| 992 | |
| 993 | buflen -= thislen; |
| 994 | memcpy(&buf[buflen], name, thislen); |
| 995 | tmp = dget_dlock(d->d_parent); |
| 996 | spin_unlock(&d->d_lock); |
| 997 | |
| 998 | dput(d); |
| 999 | d = tmp; |
| 1000 | |
| 1001 | /* Absolute redirect: finished */ |
| 1002 | if (buf[buflen] == '/') |
| 1003 | break; |
| 1004 | buflen--; |
| 1005 | buf[buflen] = '/'; |
| 1006 | } |
| 1007 | ret = kstrdup(&buf[buflen], GFP_KERNEL); |
| 1008 | out_put: |
| 1009 | dput(d); |
| 1010 | kfree(buf); |
| 1011 | out: |
| 1012 | return ret ? ret : ERR_PTR(-ENOMEM); |
| 1013 | } |
| 1014 | |
Vivek Goyal | 7bb0838 | 2018-05-11 11:49:32 -0400 | [diff] [blame] | 1015 | static bool ovl_need_absolute_redirect(struct dentry *dentry, bool samedir) |
| 1016 | { |
| 1017 | struct dentry *lowerdentry; |
| 1018 | |
| 1019 | if (!samedir) |
| 1020 | return true; |
| 1021 | |
| 1022 | if (d_is_dir(dentry)) |
| 1023 | return false; |
| 1024 | |
| 1025 | /* |
| 1026 | * For non-dir hardlinked files, we need absolute redirects |
| 1027 | * in general as two upper hardlinks could be in different |
| 1028 | * dirs. We could put a relative redirect now and convert |
| 1029 | * it to absolute redirect later. But when nlink > 1 and |
| 1030 | * indexing is on, that means relative redirect needs to be |
| 1031 | * converted to absolute during copy up of another lower |
| 1032 | * hardllink as well. |
| 1033 | * |
| 1034 | * So without optimizing too much, just check if lower is |
| 1035 | * a hard link or not. If lower is hard link, put absolute |
| 1036 | * redirect. |
| 1037 | */ |
| 1038 | lowerdentry = ovl_dentry_lower(dentry); |
| 1039 | return (d_inode(lowerdentry)->i_nlink > 1); |
| 1040 | } |
| 1041 | |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 1042 | static int ovl_set_redirect(struct dentry *dentry, bool samedir) |
| 1043 | { |
| 1044 | int err; |
| 1045 | const char *redirect = ovl_dentry_get_redirect(dentry); |
Vivek Goyal | 7bb0838 | 2018-05-11 11:49:32 -0400 | [diff] [blame] | 1046 | bool absolute_redirect = ovl_need_absolute_redirect(dentry, samedir); |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 1047 | |
Vivek Goyal | 7bb0838 | 2018-05-11 11:49:32 -0400 | [diff] [blame] | 1048 | if (redirect && (!absolute_redirect || redirect[0] == '/')) |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 1049 | return 0; |
| 1050 | |
Vivek Goyal | 7bb0838 | 2018-05-11 11:49:32 -0400 | [diff] [blame] | 1051 | redirect = ovl_get_redirect(dentry, absolute_redirect); |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 1052 | if (IS_ERR(redirect)) |
| 1053 | return PTR_ERR(redirect); |
| 1054 | |
Amir Goldstein | 21a2287 | 2017-05-17 00:12:41 +0300 | [diff] [blame] | 1055 | err = ovl_check_setxattr(dentry, ovl_dentry_upper(dentry), |
| 1056 | OVL_XATTR_REDIRECT, |
| 1057 | redirect, strlen(redirect), -EXDEV); |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 1058 | if (!err) { |
| 1059 | spin_lock(&dentry->d_lock); |
| 1060 | ovl_dentry_set_redirect(dentry, redirect); |
| 1061 | spin_unlock(&dentry->d_lock); |
| 1062 | } else { |
| 1063 | kfree(redirect); |
lijiazi | 1bd0a3a | 2019-12-16 19:12:32 +0800 | [diff] [blame] | 1064 | pr_warn_ratelimited("failed to set redirect (%i)\n", |
Amir Goldstein | da2e6b7 | 2017-11-22 20:27:34 +0200 | [diff] [blame] | 1065 | err); |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 1066 | /* Fall back to userspace copy-up */ |
| 1067 | err = -EXDEV; |
| 1068 | } |
| 1069 | return err; |
| 1070 | } |
| 1071 | |
Miklos Szeredi | 6c02cb5 | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 1072 | static int ovl_rename(struct inode *olddir, struct dentry *old, |
| 1073 | struct inode *newdir, struct dentry *new, |
| 1074 | unsigned int flags) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1075 | { |
| 1076 | int err; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1077 | struct dentry *old_upperdir; |
| 1078 | struct dentry *new_upperdir; |
| 1079 | struct dentry *olddentry; |
| 1080 | struct dentry *newdentry; |
| 1081 | struct dentry *trap; |
| 1082 | bool old_opaque; |
| 1083 | bool new_opaque; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1084 | bool cleanup_whiteout = false; |
Amir Goldstein | 0e32992 | 2018-10-18 18:37:13 +0300 | [diff] [blame] | 1085 | bool update_nlink = false; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1086 | bool overwrite = !(flags & RENAME_EXCHANGE); |
David Howells | e36cb0b | 2015-01-29 12:02:35 +0000 | [diff] [blame] | 1087 | bool is_dir = d_is_dir(old); |
Miklos Szeredi | 370e55a | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 1088 | bool new_is_dir = d_is_dir(new); |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 1089 | bool samedir = olddir == newdir; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1090 | struct dentry *opaquedir = NULL; |
| 1091 | const struct cred *old_cred = NULL; |
Amir Goldstein | 6d0a8a9 | 2017-11-10 13:18:07 +0200 | [diff] [blame] | 1092 | LIST_HEAD(list); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1093 | |
| 1094 | err = -EINVAL; |
| 1095 | if (flags & ~(RENAME_EXCHANGE | RENAME_NOREPLACE)) |
| 1096 | goto out; |
| 1097 | |
| 1098 | flags &= ~RENAME_NOREPLACE; |
| 1099 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1100 | /* Don't copy up directory trees */ |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1101 | err = -EXDEV; |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 1102 | if (!ovl_can_move(old)) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1103 | goto out; |
Miklos Szeredi | a6c6065 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 1104 | if (!overwrite && !ovl_can_move(new)) |
Miklos Szeredi | 370e55a | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 1105 | goto out; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1106 | |
Amir Goldstein | 6d0a8a9 | 2017-11-10 13:18:07 +0200 | [diff] [blame] | 1107 | if (overwrite && new_is_dir && !ovl_pure_upper(new)) { |
| 1108 | err = ovl_check_empty_dir(new, &list); |
| 1109 | if (err) |
| 1110 | goto out; |
| 1111 | } |
| 1112 | |
| 1113 | if (overwrite) { |
| 1114 | if (ovl_lower_positive(old)) { |
| 1115 | if (!ovl_dentry_is_whiteout(new)) { |
| 1116 | /* Whiteout source */ |
| 1117 | flags |= RENAME_WHITEOUT; |
| 1118 | } else { |
| 1119 | /* Switch whiteouts */ |
| 1120 | flags |= RENAME_EXCHANGE; |
| 1121 | } |
| 1122 | } else if (is_dir && ovl_dentry_is_whiteout(new)) { |
| 1123 | flags |= RENAME_EXCHANGE; |
| 1124 | cleanup_whiteout = true; |
| 1125 | } |
| 1126 | } |
| 1127 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1128 | err = ovl_want_write(old); |
| 1129 | if (err) |
| 1130 | goto out; |
| 1131 | |
| 1132 | err = ovl_copy_up(old); |
| 1133 | if (err) |
| 1134 | goto out_drop_write; |
| 1135 | |
| 1136 | err = ovl_copy_up(new->d_parent); |
| 1137 | if (err) |
| 1138 | goto out_drop_write; |
| 1139 | if (!overwrite) { |
| 1140 | err = ovl_copy_up(new); |
| 1141 | if (err) |
| 1142 | goto out_drop_write; |
Amir Goldstein | 0e32992 | 2018-10-18 18:37:13 +0300 | [diff] [blame] | 1143 | } else if (d_inode(new)) { |
| 1144 | err = ovl_nlink_start(new); |
Amir Goldstein | 5f8415d | 2017-06-20 15:35:14 +0300 | [diff] [blame] | 1145 | if (err) |
| 1146 | goto out_drop_write; |
Amir Goldstein | 0e32992 | 2018-10-18 18:37:13 +0300 | [diff] [blame] | 1147 | |
| 1148 | update_nlink = true; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1149 | } |
| 1150 | |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 1151 | old_cred = ovl_override_creds(old->d_sb); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1152 | |
Amir Goldstein | 6d0a8a9 | 2017-11-10 13:18:07 +0200 | [diff] [blame] | 1153 | if (!list_empty(&list)) { |
| 1154 | opaquedir = ovl_clear_empty(new, &list); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1155 | err = PTR_ERR(opaquedir); |
| 1156 | if (IS_ERR(opaquedir)) { |
| 1157 | opaquedir = NULL; |
| 1158 | goto out_revert_creds; |
| 1159 | } |
| 1160 | } |
| 1161 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1162 | old_upperdir = ovl_dentry_upper(old->d_parent); |
| 1163 | new_upperdir = ovl_dentry_upper(new->d_parent); |
| 1164 | |
Amir Goldstein | ee1d6d37 | 2017-05-11 16:42:26 +0300 | [diff] [blame] | 1165 | if (!samedir) { |
| 1166 | /* |
| 1167 | * When moving a merge dir or non-dir with copy up origin into |
Amir Goldstein | f3a1568 | 2017-05-24 15:29:33 +0300 | [diff] [blame] | 1168 | * a new parent, we are marking the new parent dir "impure". |
| 1169 | * When ovl_iterate() iterates an "impure" upper dir, it will |
| 1170 | * lookup the origin inodes of the entries to fill d_ino. |
Amir Goldstein | ee1d6d37 | 2017-05-11 16:42:26 +0300 | [diff] [blame] | 1171 | */ |
Amir Goldstein | f3a1568 | 2017-05-24 15:29:33 +0300 | [diff] [blame] | 1172 | if (ovl_type_origin(old)) { |
Amir Goldstein | ee1d6d37 | 2017-05-11 16:42:26 +0300 | [diff] [blame] | 1173 | err = ovl_set_impure(new->d_parent, new_upperdir); |
| 1174 | if (err) |
| 1175 | goto out_revert_creds; |
| 1176 | } |
Amir Goldstein | f3a1568 | 2017-05-24 15:29:33 +0300 | [diff] [blame] | 1177 | if (!overwrite && ovl_type_origin(new)) { |
Amir Goldstein | ee1d6d37 | 2017-05-11 16:42:26 +0300 | [diff] [blame] | 1178 | err = ovl_set_impure(old->d_parent, old_upperdir); |
| 1179 | if (err) |
| 1180 | goto out_revert_creds; |
| 1181 | } |
| 1182 | } |
| 1183 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1184 | trap = lock_rename(new_upperdir, old_upperdir); |
| 1185 | |
Miklos Szeredi | 11f3710 | 2016-03-21 17:31:44 +0100 | [diff] [blame] | 1186 | olddentry = lookup_one_len(old->d_name.name, old_upperdir, |
| 1187 | old->d_name.len); |
| 1188 | err = PTR_ERR(olddentry); |
| 1189 | if (IS_ERR(olddentry)) |
| 1190 | goto out_unlock; |
| 1191 | |
| 1192 | err = -ESTALE; |
Miklos Szeredi | 9020df3 | 2017-07-04 22:03:16 +0200 | [diff] [blame] | 1193 | if (!ovl_matches_upper(old, olddentry)) |
Miklos Szeredi | 11f3710 | 2016-03-21 17:31:44 +0100 | [diff] [blame] | 1194 | goto out_dput_old; |
| 1195 | |
| 1196 | newdentry = lookup_one_len(new->d_name.name, new_upperdir, |
| 1197 | new->d_name.len); |
| 1198 | err = PTR_ERR(newdentry); |
| 1199 | if (IS_ERR(newdentry)) |
| 1200 | goto out_dput_old; |
| 1201 | |
Miklos Szeredi | 3ee23ff | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 1202 | old_opaque = ovl_dentry_is_opaque(old); |
| 1203 | new_opaque = ovl_dentry_is_opaque(new); |
| 1204 | |
Miklos Szeredi | 11f3710 | 2016-03-21 17:31:44 +0100 | [diff] [blame] | 1205 | err = -ESTALE; |
Miklos Szeredi | 09d8b58 | 2017-07-04 22:03:16 +0200 | [diff] [blame] | 1206 | if (d_inode(new) && ovl_dentry_upper(new)) { |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1207 | if (opaquedir) { |
Miklos Szeredi | 11f3710 | 2016-03-21 17:31:44 +0100 | [diff] [blame] | 1208 | if (newdentry != opaquedir) |
| 1209 | goto out_dput; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1210 | } else { |
Miklos Szeredi | 9020df3 | 2017-07-04 22:03:16 +0200 | [diff] [blame] | 1211 | if (!ovl_matches_upper(new, newdentry)) |
Miklos Szeredi | 11f3710 | 2016-03-21 17:31:44 +0100 | [diff] [blame] | 1212 | goto out_dput; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1213 | } |
| 1214 | } else { |
Miklos Szeredi | 11f3710 | 2016-03-21 17:31:44 +0100 | [diff] [blame] | 1215 | if (!d_is_negative(newdentry) && |
| 1216 | (!new_opaque || !ovl_is_whiteout(newdentry))) |
| 1217 | goto out_dput; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1218 | } |
| 1219 | |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1220 | if (olddentry == trap) |
| 1221 | goto out_dput; |
| 1222 | if (newdentry == trap) |
| 1223 | goto out_dput; |
| 1224 | |
Amir Goldstein | 6889ee5 | 2019-12-06 08:33:36 +0200 | [diff] [blame] | 1225 | if (olddentry->d_inode == newdentry->d_inode) |
Miklos Szeredi | 804032f | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 1226 | goto out_dput; |
| 1227 | |
Miklos Szeredi | 5cf5b47 | 2016-12-16 11:02:57 +0100 | [diff] [blame] | 1228 | err = 0; |
Vivek Goyal | 7bb0838 | 2018-05-11 11:49:32 -0400 | [diff] [blame] | 1229 | if (ovl_type_merge_or_lower(old)) |
| 1230 | err = ovl_set_redirect(old, samedir); |
| 1231 | else if (is_dir && !old_opaque && ovl_type_merge(new->d_parent)) |
| 1232 | err = ovl_set_opaque_xerr(old, olddentry, -EXDEV); |
| 1233 | if (err) |
| 1234 | goto out_dput; |
| 1235 | |
| 1236 | if (!overwrite && ovl_type_merge_or_lower(new)) |
| 1237 | err = ovl_set_redirect(new, samedir); |
| 1238 | else if (!overwrite && new_is_dir && !new_opaque && |
| 1239 | ovl_type_merge(old->d_parent)) |
| 1240 | err = ovl_set_opaque_xerr(new, newdentry, -EXDEV); |
| 1241 | if (err) |
| 1242 | goto out_dput; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1243 | |
Miklos Szeredi | 3ee23ff | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 1244 | err = ovl_do_rename(old_upperdir->d_inode, olddentry, |
| 1245 | new_upperdir->d_inode, newdentry, flags); |
| 1246 | if (err) |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1247 | goto out_dput; |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1248 | |
| 1249 | if (cleanup_whiteout) |
| 1250 | ovl_cleanup(old_upperdir->d_inode, newdentry); |
| 1251 | |
Amir Goldstein | f681eb1 | 2017-06-05 22:44:49 +0300 | [diff] [blame] | 1252 | if (overwrite && d_inode(new)) { |
| 1253 | if (new_is_dir) |
| 1254 | clear_nlink(d_inode(new)); |
| 1255 | else |
Miklos Szeredi | 83552ea | 2020-03-27 16:51:02 +0100 | [diff] [blame] | 1256 | ovl_drop_nlink(new); |
Amir Goldstein | f681eb1 | 2017-06-05 22:44:49 +0300 | [diff] [blame] | 1257 | } |
| 1258 | |
Miklos Szeredi | d9854c8 | 2018-07-18 15:44:40 +0200 | [diff] [blame] | 1259 | ovl_dir_modified(old->d_parent, ovl_type_origin(old) || |
| 1260 | (!overwrite && ovl_type_origin(new))); |
| 1261 | ovl_dir_modified(new->d_parent, ovl_type_origin(old) || |
| 1262 | (d_inode(new) && ovl_type_origin(new))); |
| 1263 | |
| 1264 | /* copy ctime: */ |
| 1265 | ovl_copyattr(d_inode(olddentry), d_inode(old)); |
| 1266 | if (d_inode(new) && ovl_dentry_upper(new)) |
| 1267 | ovl_copyattr(d_inode(newdentry), d_inode(new)); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1268 | |
| 1269 | out_dput: |
| 1270 | dput(newdentry); |
Miklos Szeredi | 11f3710 | 2016-03-21 17:31:44 +0100 | [diff] [blame] | 1271 | out_dput_old: |
| 1272 | dput(olddentry); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1273 | out_unlock: |
| 1274 | unlock_rename(new_upperdir, old_upperdir); |
| 1275 | out_revert_creds: |
Vivek Goyal | 1175b6b | 2016-07-01 16:34:28 -0400 | [diff] [blame] | 1276 | revert_creds(old_cred); |
Amir Goldstein | 0e32992 | 2018-10-18 18:37:13 +0300 | [diff] [blame] | 1277 | if (update_nlink) |
| 1278 | ovl_nlink_end(new); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1279 | out_drop_write: |
| 1280 | ovl_drop_write(old); |
| 1281 | out: |
| 1282 | dput(opaquedir); |
Amir Goldstein | 6d0a8a9 | 2017-11-10 13:18:07 +0200 | [diff] [blame] | 1283 | ovl_cache_free(&list); |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1284 | return err; |
| 1285 | } |
| 1286 | |
| 1287 | const struct inode_operations ovl_dir_inode_operations = { |
| 1288 | .lookup = ovl_lookup, |
| 1289 | .mkdir = ovl_mkdir, |
| 1290 | .symlink = ovl_symlink, |
| 1291 | .unlink = ovl_unlink, |
| 1292 | .rmdir = ovl_rmdir, |
Miklos Szeredi | 6c02cb5 | 2016-12-16 11:02:55 +0100 | [diff] [blame] | 1293 | .rename = ovl_rename, |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1294 | .link = ovl_link, |
| 1295 | .setattr = ovl_setattr, |
| 1296 | .create = ovl_create, |
| 1297 | .mknod = ovl_mknod, |
| 1298 | .permission = ovl_permission, |
Miklos Szeredi | 5b71209 | 2017-05-05 11:38:58 +0200 | [diff] [blame] | 1299 | .getattr = ovl_getattr, |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1300 | .listxattr = ovl_listxattr, |
Vivek Goyal | 39a25b2 | 2016-07-01 16:34:26 -0400 | [diff] [blame] | 1301 | .get_acl = ovl_get_acl, |
Miklos Szeredi | d719e8f | 2016-07-29 12:05:23 +0200 | [diff] [blame] | 1302 | .update_time = ovl_update_time, |
Miklos Szeredi | e9be9d5 | 2014-10-24 00:14:38 +0200 | [diff] [blame] | 1303 | }; |