Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 Novell Inc. |
| 3 | * Copyright (C) 2016 Red Hat, 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> |
Ingo Molnar | 5b825c3 | 2017-02-02 17:54:15 +0100 | [diff] [blame] | 11 | #include <linux/cred.h> |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 12 | #include <linux/namei.h> |
| 13 | #include <linux/xattr.h> |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 14 | #include <linux/ratelimit.h> |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 15 | #include <linux/mount.h> |
| 16 | #include <linux/exportfs.h> |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 17 | #include "overlayfs.h" |
| 18 | #include "ovl_entry.h" |
| 19 | |
Miklos Szeredi | e28edc4 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 20 | struct ovl_lookup_data { |
| 21 | struct qstr name; |
| 22 | bool is_dir; |
| 23 | bool opaque; |
| 24 | bool stop; |
| 25 | bool last; |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 26 | char *redirect; |
Miklos Szeredi | e28edc4 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 27 | }; |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 28 | |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 29 | static int ovl_check_redirect(struct dentry *dentry, struct ovl_lookup_data *d, |
| 30 | size_t prelen, const char *post) |
| 31 | { |
| 32 | int res; |
| 33 | char *s, *next, *buf = NULL; |
| 34 | |
| 35 | res = vfs_getxattr(dentry, OVL_XATTR_REDIRECT, NULL, 0); |
| 36 | if (res < 0) { |
| 37 | if (res == -ENODATA || res == -EOPNOTSUPP) |
| 38 | return 0; |
| 39 | goto fail; |
| 40 | } |
| 41 | buf = kzalloc(prelen + res + strlen(post) + 1, GFP_TEMPORARY); |
| 42 | if (!buf) |
| 43 | return -ENOMEM; |
| 44 | |
| 45 | if (res == 0) |
| 46 | goto invalid; |
| 47 | |
| 48 | res = vfs_getxattr(dentry, OVL_XATTR_REDIRECT, buf, res); |
| 49 | if (res < 0) |
| 50 | goto fail; |
| 51 | if (res == 0) |
| 52 | goto invalid; |
| 53 | if (buf[0] == '/') { |
| 54 | for (s = buf; *s++ == '/'; s = next) { |
| 55 | next = strchrnul(s, '/'); |
| 56 | if (s == next) |
| 57 | goto invalid; |
| 58 | } |
| 59 | } else { |
| 60 | if (strchr(buf, '/') != NULL) |
| 61 | goto invalid; |
| 62 | |
| 63 | memmove(buf + prelen, buf, res); |
| 64 | memcpy(buf, d->name.name, prelen); |
| 65 | } |
| 66 | |
| 67 | strcat(buf, post); |
| 68 | kfree(d->redirect); |
| 69 | d->redirect = buf; |
| 70 | d->name.name = d->redirect; |
| 71 | d->name.len = strlen(d->redirect); |
| 72 | |
| 73 | return 0; |
| 74 | |
| 75 | err_free: |
| 76 | kfree(buf); |
| 77 | return 0; |
| 78 | fail: |
| 79 | pr_warn_ratelimited("overlayfs: failed to get redirect (%i)\n", res); |
| 80 | goto err_free; |
| 81 | invalid: |
| 82 | pr_warn_ratelimited("overlayfs: invalid redirect (%s)\n", buf); |
| 83 | goto err_free; |
| 84 | } |
| 85 | |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 86 | static int ovl_acceptable(void *ctx, struct dentry *dentry) |
| 87 | { |
| 88 | return 1; |
| 89 | } |
| 90 | |
Amir Goldstein | 8b88a2e | 2017-06-21 15:28:37 +0300 | [diff] [blame] | 91 | static struct ovl_fh *ovl_get_origin_fh(struct dentry *dentry) |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 92 | { |
| 93 | int res; |
| 94 | struct ovl_fh *fh = NULL; |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 95 | |
| 96 | res = vfs_getxattr(dentry, OVL_XATTR_ORIGIN, NULL, 0); |
| 97 | if (res < 0) { |
| 98 | if (res == -ENODATA || res == -EOPNOTSUPP) |
| 99 | return NULL; |
| 100 | goto fail; |
| 101 | } |
| 102 | /* Zero size value means "copied up but origin unknown" */ |
| 103 | if (res == 0) |
| 104 | return NULL; |
| 105 | |
Amir Goldstein | 8b88a2e | 2017-06-21 15:28:37 +0300 | [diff] [blame] | 106 | fh = kzalloc(res, GFP_TEMPORARY); |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 107 | if (!fh) |
| 108 | return ERR_PTR(-ENOMEM); |
| 109 | |
| 110 | res = vfs_getxattr(dentry, OVL_XATTR_ORIGIN, fh, res); |
| 111 | if (res < 0) |
| 112 | goto fail; |
| 113 | |
| 114 | if (res < sizeof(struct ovl_fh) || res < fh->len) |
| 115 | goto invalid; |
| 116 | |
| 117 | if (fh->magic != OVL_FH_MAGIC) |
| 118 | goto invalid; |
| 119 | |
| 120 | /* Treat larger version and unknown flags as "origin unknown" */ |
| 121 | if (fh->version > OVL_FH_VERSION || fh->flags & ~OVL_FH_FLAG_ALL) |
| 122 | goto out; |
| 123 | |
| 124 | /* Treat endianness mismatch as "origin unknown" */ |
| 125 | if (!(fh->flags & OVL_FH_FLAG_ANY_ENDIAN) && |
| 126 | (fh->flags & OVL_FH_FLAG_BIG_ENDIAN) != OVL_FH_FLAG_CPU_ENDIAN) |
| 127 | goto out; |
| 128 | |
Amir Goldstein | 8b88a2e | 2017-06-21 15:28:37 +0300 | [diff] [blame] | 129 | return fh; |
| 130 | |
| 131 | out: |
| 132 | kfree(fh); |
| 133 | return NULL; |
| 134 | |
| 135 | fail: |
| 136 | pr_warn_ratelimited("overlayfs: failed to get origin (%i)\n", res); |
| 137 | goto out; |
| 138 | invalid: |
| 139 | pr_warn_ratelimited("overlayfs: invalid origin (%*phN)\n", res, fh); |
| 140 | goto out; |
| 141 | } |
| 142 | |
| 143 | static struct dentry *ovl_get_origin(struct dentry *dentry, |
| 144 | struct vfsmount *mnt) |
| 145 | { |
| 146 | struct dentry *origin = NULL; |
| 147 | struct ovl_fh *fh = ovl_get_origin_fh(dentry); |
| 148 | int bytes; |
| 149 | |
| 150 | if (IS_ERR_OR_NULL(fh)) |
| 151 | return (struct dentry *)fh; |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 152 | |
| 153 | /* |
| 154 | * Make sure that the stored uuid matches the uuid of the lower |
| 155 | * layer where file handle will be decoded. |
| 156 | */ |
Christoph Hellwig | 8578709 | 2017-05-10 15:06:33 +0200 | [diff] [blame] | 157 | if (!uuid_equal(&fh->uuid, &mnt->mnt_sb->s_uuid)) |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 158 | goto out; |
| 159 | |
Amir Goldstein | 8b88a2e | 2017-06-21 15:28:37 +0300 | [diff] [blame] | 160 | bytes = (fh->len - offsetof(struct ovl_fh, fid)); |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 161 | origin = exportfs_decode_fh(mnt, (struct fid *)fh->fid, |
| 162 | bytes >> 2, (int)fh->type, |
| 163 | ovl_acceptable, NULL); |
| 164 | if (IS_ERR(origin)) { |
| 165 | /* Treat stale file handle as "origin unknown" */ |
| 166 | if (origin == ERR_PTR(-ESTALE)) |
| 167 | origin = NULL; |
| 168 | goto out; |
| 169 | } |
| 170 | |
| 171 | if (ovl_dentry_weird(origin) || |
Amir Goldstein | 8b88a2e | 2017-06-21 15:28:37 +0300 | [diff] [blame] | 172 | ((d_inode(origin)->i_mode ^ d_inode(dentry)->i_mode) & S_IFMT)) |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 173 | goto invalid; |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 174 | |
| 175 | out: |
| 176 | kfree(fh); |
| 177 | return origin; |
| 178 | |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 179 | invalid: |
Amir Goldstein | 8b88a2e | 2017-06-21 15:28:37 +0300 | [diff] [blame] | 180 | pr_warn_ratelimited("overlayfs: invalid origin (%pd2)\n", origin); |
| 181 | dput(origin); |
| 182 | origin = NULL; |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 183 | goto out; |
| 184 | } |
| 185 | |
Amir Goldstein | ee1d6d37 | 2017-05-11 16:42:26 +0300 | [diff] [blame] | 186 | static bool ovl_is_opaquedir(struct dentry *dentry) |
| 187 | { |
| 188 | return ovl_check_dir_xattr(dentry, OVL_XATTR_OPAQUE); |
| 189 | } |
| 190 | |
Miklos Szeredi | e28edc4 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 191 | static int ovl_lookup_single(struct dentry *base, struct ovl_lookup_data *d, |
| 192 | const char *name, unsigned int namelen, |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 193 | size_t prelen, const char *post, |
Miklos Szeredi | e28edc4 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 194 | struct dentry **ret) |
| 195 | { |
| 196 | struct dentry *this; |
| 197 | int err; |
| 198 | |
| 199 | this = lookup_one_len_unlocked(name, base, namelen); |
| 200 | if (IS_ERR(this)) { |
| 201 | err = PTR_ERR(this); |
| 202 | this = NULL; |
| 203 | if (err == -ENOENT || err == -ENAMETOOLONG) |
| 204 | goto out; |
| 205 | goto out_err; |
| 206 | } |
| 207 | if (!this->d_inode) |
| 208 | goto put_and_out; |
| 209 | |
| 210 | if (ovl_dentry_weird(this)) { |
| 211 | /* Don't support traversing automounts and other weirdness */ |
| 212 | err = -EREMOTE; |
| 213 | goto out_err; |
| 214 | } |
| 215 | if (ovl_is_whiteout(this)) { |
| 216 | d->stop = d->opaque = true; |
| 217 | goto put_and_out; |
| 218 | } |
| 219 | if (!d_can_lookup(this)) { |
| 220 | d->stop = true; |
| 221 | if (d->is_dir) |
| 222 | goto put_and_out; |
| 223 | goto out; |
| 224 | } |
| 225 | d->is_dir = true; |
| 226 | if (!d->last && ovl_is_opaquedir(this)) { |
| 227 | d->stop = d->opaque = true; |
| 228 | goto out; |
| 229 | } |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 230 | err = ovl_check_redirect(this, d, prelen, post); |
| 231 | if (err) |
| 232 | goto out_err; |
Miklos Szeredi | e28edc4 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 233 | out: |
| 234 | *ret = this; |
| 235 | return 0; |
| 236 | |
| 237 | put_and_out: |
| 238 | dput(this); |
| 239 | this = NULL; |
| 240 | goto out; |
| 241 | |
| 242 | out_err: |
| 243 | dput(this); |
| 244 | return err; |
| 245 | } |
| 246 | |
| 247 | static int ovl_lookup_layer(struct dentry *base, struct ovl_lookup_data *d, |
| 248 | struct dentry **ret) |
| 249 | { |
Amir Goldstein | 4c7d0c9 | 2017-01-18 15:19:54 +0100 | [diff] [blame] | 250 | /* Counting down from the end, since the prefix can change */ |
| 251 | size_t rem = d->name.len - 1; |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 252 | struct dentry *dentry = NULL; |
| 253 | int err; |
| 254 | |
Amir Goldstein | 4c7d0c9 | 2017-01-18 15:19:54 +0100 | [diff] [blame] | 255 | if (d->name.name[0] != '/') |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 256 | return ovl_lookup_single(base, d, d->name.name, d->name.len, |
| 257 | 0, "", ret); |
| 258 | |
Amir Goldstein | 4c7d0c9 | 2017-01-18 15:19:54 +0100 | [diff] [blame] | 259 | while (!IS_ERR_OR_NULL(base) && d_can_lookup(base)) { |
| 260 | const char *s = d->name.name + d->name.len - rem; |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 261 | const char *next = strchrnul(s, '/'); |
Amir Goldstein | 4c7d0c9 | 2017-01-18 15:19:54 +0100 | [diff] [blame] | 262 | size_t thislen = next - s; |
| 263 | bool end = !next[0]; |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 264 | |
Amir Goldstein | 4c7d0c9 | 2017-01-18 15:19:54 +0100 | [diff] [blame] | 265 | /* Verify we did not go off the rails */ |
| 266 | if (WARN_ON(s[-1] != '/')) |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 267 | return -EIO; |
| 268 | |
Amir Goldstein | 4c7d0c9 | 2017-01-18 15:19:54 +0100 | [diff] [blame] | 269 | err = ovl_lookup_single(base, d, s, thislen, |
| 270 | d->name.len - rem, next, &base); |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 271 | dput(dentry); |
| 272 | if (err) |
| 273 | return err; |
| 274 | dentry = base; |
Amir Goldstein | 4c7d0c9 | 2017-01-18 15:19:54 +0100 | [diff] [blame] | 275 | if (end) |
| 276 | break; |
| 277 | |
| 278 | rem -= thislen + 1; |
| 279 | |
| 280 | if (WARN_ON(rem >= d->name.len)) |
| 281 | return -EIO; |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 282 | } |
| 283 | *ret = dentry; |
| 284 | return 0; |
Miklos Szeredi | e28edc4 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 285 | } |
| 286 | |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 287 | |
Amir Goldstein | 415543d | 2017-06-21 15:28:42 +0300 | [diff] [blame] | 288 | static int ovl_check_origin(struct dentry *upperdentry, |
| 289 | struct path *lowerstack, unsigned int numlower, |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 290 | struct path **stackp, unsigned int *ctrp) |
| 291 | { |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 292 | struct vfsmount *mnt; |
Amir Goldstein | f7d3dac | 2017-06-21 15:28:34 +0300 | [diff] [blame] | 293 | struct dentry *origin = NULL; |
| 294 | int i; |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 295 | |
Amir Goldstein | f7d3dac | 2017-06-21 15:28:34 +0300 | [diff] [blame] | 296 | |
Amir Goldstein | 415543d | 2017-06-21 15:28:42 +0300 | [diff] [blame] | 297 | for (i = 0; i < numlower; i++) { |
| 298 | mnt = lowerstack[i].mnt; |
Amir Goldstein | f7d3dac | 2017-06-21 15:28:34 +0300 | [diff] [blame] | 299 | origin = ovl_get_origin(upperdentry, mnt); |
| 300 | if (IS_ERR(origin)) |
| 301 | return PTR_ERR(origin); |
| 302 | |
| 303 | if (origin) |
| 304 | break; |
| 305 | } |
| 306 | |
| 307 | if (!origin) |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 308 | return 0; |
| 309 | |
Amir Goldstein | 415543d | 2017-06-21 15:28:42 +0300 | [diff] [blame] | 310 | BUG_ON(*ctrp); |
| 311 | if (!*stackp) |
| 312 | *stackp = kmalloc(sizeof(struct path), GFP_TEMPORARY); |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 313 | if (!*stackp) { |
| 314 | dput(origin); |
| 315 | return -ENOMEM; |
| 316 | } |
| 317 | **stackp = (struct path) { .dentry = origin, .mnt = mnt }; |
| 318 | *ctrp = 1; |
| 319 | |
| 320 | return 0; |
| 321 | } |
| 322 | |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 323 | /* |
Amir Goldstein | 8b88a2e | 2017-06-21 15:28:37 +0300 | [diff] [blame] | 324 | * Verify that @fh matches the origin file handle stored in OVL_XATTR_ORIGIN. |
| 325 | * Return 0 on match, -ESTALE on mismatch, < 0 on error. |
| 326 | */ |
| 327 | static int ovl_verify_origin_fh(struct dentry *dentry, const struct ovl_fh *fh) |
| 328 | { |
| 329 | struct ovl_fh *ofh = ovl_get_origin_fh(dentry); |
| 330 | int err = 0; |
| 331 | |
| 332 | if (!ofh) |
| 333 | return -ENODATA; |
| 334 | |
| 335 | if (IS_ERR(ofh)) |
| 336 | return PTR_ERR(ofh); |
| 337 | |
| 338 | if (fh->len != ofh->len || memcmp(fh, ofh, fh->len)) |
| 339 | err = -ESTALE; |
| 340 | |
| 341 | kfree(ofh); |
| 342 | return err; |
| 343 | } |
| 344 | |
| 345 | /* |
| 346 | * Verify that an inode matches the origin file handle stored in upper inode. |
| 347 | * |
| 348 | * If @set is true and there is no stored file handle, encode and store origin |
| 349 | * file handle in OVL_XATTR_ORIGIN. |
| 350 | * |
| 351 | * Return 0 on match, -ESTALE on mismatch, < 0 on error. |
| 352 | */ |
| 353 | int ovl_verify_origin(struct dentry *dentry, struct vfsmount *mnt, |
Amir Goldstein | 54fb347 | 2017-06-21 15:28:38 +0300 | [diff] [blame] | 354 | struct dentry *origin, bool is_upper, bool set) |
Amir Goldstein | 8b88a2e | 2017-06-21 15:28:37 +0300 | [diff] [blame] | 355 | { |
| 356 | struct inode *inode; |
| 357 | struct ovl_fh *fh; |
| 358 | int err; |
| 359 | |
Amir Goldstein | 54fb347 | 2017-06-21 15:28:38 +0300 | [diff] [blame] | 360 | fh = ovl_encode_fh(origin, is_upper); |
Amir Goldstein | 8b88a2e | 2017-06-21 15:28:37 +0300 | [diff] [blame] | 361 | err = PTR_ERR(fh); |
| 362 | if (IS_ERR(fh)) |
| 363 | goto fail; |
| 364 | |
| 365 | err = ovl_verify_origin_fh(dentry, fh); |
| 366 | if (set && err == -ENODATA) |
| 367 | err = ovl_do_setxattr(dentry, OVL_XATTR_ORIGIN, fh, fh->len, 0); |
| 368 | if (err) |
| 369 | goto fail; |
| 370 | |
| 371 | out: |
| 372 | kfree(fh); |
| 373 | return err; |
| 374 | |
| 375 | fail: |
| 376 | inode = d_inode(origin); |
| 377 | pr_warn_ratelimited("overlayfs: failed to verify origin (%pd2, ino=%lu, err=%i)\n", |
| 378 | origin, inode ? inode->i_ino : 0, err); |
| 379 | goto out; |
| 380 | } |
| 381 | |
| 382 | /* |
Amir Goldstein | 415543d | 2017-06-21 15:28:42 +0300 | [diff] [blame] | 383 | * Verify that an index entry name matches the origin file handle stored in |
| 384 | * OVL_XATTR_ORIGIN and that origin file handle can be decoded to lower path. |
| 385 | * Return 0 on match, -ESTALE on mismatch or stale origin, < 0 on error. |
| 386 | */ |
| 387 | int ovl_verify_index(struct dentry *index, struct path *lowerstack, |
| 388 | unsigned int numlower) |
| 389 | { |
| 390 | struct ovl_fh *fh = NULL; |
| 391 | size_t len; |
| 392 | struct path origin = { }; |
| 393 | struct path *stack = &origin; |
| 394 | unsigned int ctr = 0; |
| 395 | int err; |
| 396 | |
| 397 | if (!d_inode(index)) |
| 398 | return 0; |
| 399 | |
Amir Goldstein | 61b6747 | 2017-07-18 21:07:42 +0300 | [diff] [blame] | 400 | /* |
| 401 | * Directory index entries are going to be used for looking up |
| 402 | * redirected upper dirs by lower dir fh when decoding an overlay |
| 403 | * file handle of a merge dir. Whiteout index entries are going to be |
| 404 | * used as an indication that an exported overlay file handle should |
| 405 | * be treated as stale (i.e. after unlink of the overlay inode). |
| 406 | * We don't know the verification rules for directory and whiteout |
| 407 | * index entries, because they have not been implemented yet, so return |
| 408 | * EROFS if those entries are found to avoid corrupting an index that |
| 409 | * was created by a newer kernel. |
| 410 | */ |
| 411 | err = -EROFS; |
| 412 | if (d_is_dir(index) || ovl_is_whiteout(index)) |
Amir Goldstein | 415543d | 2017-06-21 15:28:42 +0300 | [diff] [blame] | 413 | goto fail; |
| 414 | |
| 415 | err = -EINVAL; |
| 416 | if (index->d_name.len < sizeof(struct ovl_fh)*2) |
| 417 | goto fail; |
| 418 | |
| 419 | err = -ENOMEM; |
| 420 | len = index->d_name.len / 2; |
| 421 | fh = kzalloc(len, GFP_TEMPORARY); |
| 422 | if (!fh) |
| 423 | goto fail; |
| 424 | |
| 425 | err = -EINVAL; |
| 426 | if (hex2bin((u8 *)fh, index->d_name.name, len) || len != fh->len) |
| 427 | goto fail; |
| 428 | |
| 429 | err = ovl_verify_origin_fh(index, fh); |
| 430 | if (err) |
| 431 | goto fail; |
| 432 | |
| 433 | err = ovl_check_origin(index, lowerstack, numlower, &stack, &ctr); |
| 434 | if (!err && !ctr) |
| 435 | err = -ESTALE; |
| 436 | if (err) |
| 437 | goto fail; |
| 438 | |
Amir Goldstein | caf70cb | 2017-06-21 13:46:12 +0300 | [diff] [blame] | 439 | /* Check if index is orphan and don't warn before cleaning it */ |
| 440 | if (d_inode(index)->i_nlink == 1 && |
| 441 | ovl_get_nlink(index, origin.dentry, 0) == 0) |
| 442 | err = -ENOENT; |
| 443 | |
Amir Goldstein | 415543d | 2017-06-21 15:28:42 +0300 | [diff] [blame] | 444 | dput(origin.dentry); |
| 445 | out: |
| 446 | kfree(fh); |
| 447 | return err; |
| 448 | |
| 449 | fail: |
Amir Goldstein | 61b6747 | 2017-07-18 21:07:42 +0300 | [diff] [blame] | 450 | pr_warn_ratelimited("overlayfs: failed to verify index (%pd2, ftype=%x, err=%i)\n", |
| 451 | index, d_inode(index)->i_mode & S_IFMT, err); |
Amir Goldstein | 415543d | 2017-06-21 15:28:42 +0300 | [diff] [blame] | 452 | goto out; |
| 453 | } |
| 454 | |
| 455 | /* |
Amir Goldstein | 359f392 | 2017-06-21 15:28:41 +0300 | [diff] [blame] | 456 | * Lookup in indexdir for the index entry of a lower real inode or a copy up |
| 457 | * origin inode. The index entry name is the hex representation of the lower |
| 458 | * inode file handle. |
| 459 | * |
| 460 | * If the index dentry in negative, then either no lower aliases have been |
| 461 | * copied up yet, or aliases have been copied up in older kernels and are |
| 462 | * not indexed. |
| 463 | * |
| 464 | * If the index dentry for a copy up origin inode is positive, but points |
| 465 | * to an inode different than the upper inode, then either the upper inode |
| 466 | * has been copied up and not indexed or it was indexed, but since then |
| 467 | * index dir was cleared. Either way, that index cannot be used to indentify |
| 468 | * the overlay inode. |
| 469 | */ |
| 470 | int ovl_get_index_name(struct dentry *origin, struct qstr *name) |
| 471 | { |
| 472 | int err; |
| 473 | struct ovl_fh *fh; |
| 474 | char *n, *s; |
| 475 | |
| 476 | fh = ovl_encode_fh(origin, false); |
| 477 | if (IS_ERR(fh)) |
| 478 | return PTR_ERR(fh); |
| 479 | |
| 480 | err = -ENOMEM; |
| 481 | n = kzalloc(fh->len * 2, GFP_TEMPORARY); |
| 482 | if (n) { |
| 483 | s = bin2hex(n, fh, fh->len); |
| 484 | *name = (struct qstr) QSTR_INIT(n, s - n); |
| 485 | err = 0; |
| 486 | } |
| 487 | kfree(fh); |
| 488 | |
| 489 | return err; |
| 490 | |
| 491 | } |
| 492 | |
| 493 | static struct dentry *ovl_lookup_index(struct dentry *dentry, |
| 494 | struct dentry *upper, |
| 495 | struct dentry *origin) |
| 496 | { |
| 497 | struct ovl_fs *ofs = dentry->d_sb->s_fs_info; |
| 498 | struct dentry *index; |
| 499 | struct inode *inode; |
| 500 | struct qstr name; |
| 501 | int err; |
| 502 | |
| 503 | err = ovl_get_index_name(origin, &name); |
| 504 | if (err) |
| 505 | return ERR_PTR(err); |
| 506 | |
| 507 | index = lookup_one_len_unlocked(name.name, ofs->indexdir, name.len); |
| 508 | if (IS_ERR(index)) { |
| 509 | pr_warn_ratelimited("overlayfs: failed inode index lookup (ino=%lu, key=%*s, err=%i);\n" |
| 510 | "overlayfs: mount with '-o index=off' to disable inodes index.\n", |
| 511 | d_inode(origin)->i_ino, name.len, name.name, |
| 512 | err); |
| 513 | goto out; |
| 514 | } |
| 515 | |
Amir Goldstein | 0e08255 | 2017-07-18 21:07:43 +0300 | [diff] [blame] | 516 | inode = d_inode(index); |
Amir Goldstein | 359f392 | 2017-06-21 15:28:41 +0300 | [diff] [blame] | 517 | if (d_is_negative(index)) { |
| 518 | if (upper && d_inode(origin)->i_nlink > 1) { |
| 519 | pr_warn_ratelimited("overlayfs: hard link with origin but no index (ino=%lu).\n", |
| 520 | d_inode(origin)->i_ino); |
| 521 | goto fail; |
| 522 | } |
| 523 | |
| 524 | dput(index); |
| 525 | index = NULL; |
Amir Goldstein | 0e08255 | 2017-07-18 21:07:43 +0300 | [diff] [blame] | 526 | } else if (upper && d_inode(upper) != inode) { |
| 527 | pr_warn_ratelimited("overlayfs: wrong index found (index=%pd2, ino=%lu, upper ino=%lu).\n", |
| 528 | index, inode->i_ino, d_inode(upper)->i_ino); |
| 529 | goto fail; |
| 530 | } else if (ovl_dentry_weird(index) || ovl_is_whiteout(index) || |
| 531 | ((inode->i_mode ^ d_inode(origin)->i_mode) & S_IFMT)) { |
| 532 | /* |
| 533 | * Index should always be of the same file type as origin |
| 534 | * except for the case of a whiteout index. A whiteout |
| 535 | * index should only exist if all lower aliases have been |
| 536 | * unlinked, which means that finding a lower origin on lookup |
| 537 | * whose index is a whiteout should be treated as an error. |
| 538 | */ |
| 539 | pr_warn_ratelimited("overlayfs: bad index found (index=%pd2, ftype=%x, origin ftype=%x).\n", |
| 540 | index, d_inode(index)->i_mode & S_IFMT, |
| 541 | d_inode(origin)->i_mode & S_IFMT); |
Amir Goldstein | 359f392 | 2017-06-21 15:28:41 +0300 | [diff] [blame] | 542 | goto fail; |
| 543 | } |
| 544 | |
| 545 | out: |
| 546 | kfree(name.name); |
| 547 | return index; |
| 548 | |
| 549 | fail: |
| 550 | dput(index); |
| 551 | index = ERR_PTR(-EIO); |
| 552 | goto out; |
| 553 | } |
| 554 | |
| 555 | /* |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 556 | * Returns next layer in stack starting from top. |
| 557 | * Returns -1 if this is the last layer. |
| 558 | */ |
| 559 | int ovl_path_next(int idx, struct dentry *dentry, struct path *path) |
| 560 | { |
| 561 | struct ovl_entry *oe = dentry->d_fsdata; |
| 562 | |
| 563 | BUG_ON(idx < 0); |
| 564 | if (idx == 0) { |
| 565 | ovl_path_upper(dentry, path); |
| 566 | if (path->dentry) |
| 567 | return oe->numlower ? 1 : -1; |
| 568 | idx++; |
| 569 | } |
| 570 | BUG_ON(idx > oe->numlower); |
| 571 | *path = oe->lowerstack[idx - 1]; |
| 572 | |
| 573 | return (idx < oe->numlower) ? idx + 1 : -1; |
| 574 | } |
| 575 | |
| 576 | struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, |
| 577 | unsigned int flags) |
| 578 | { |
| 579 | struct ovl_entry *oe; |
| 580 | const struct cred *old_cred; |
Miklos Szeredi | 6b2d5fe | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 581 | struct ovl_fs *ofs = dentry->d_sb->s_fs_info; |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 582 | struct ovl_entry *poe = dentry->d_parent->d_fsdata; |
Amir Goldstein | c22205d | 2017-04-26 23:40:52 +0300 | [diff] [blame] | 583 | struct ovl_entry *roe = dentry->d_sb->s_root->d_fsdata; |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 584 | struct path *stack = NULL; |
| 585 | struct dentry *upperdir, *upperdentry = NULL; |
Amir Goldstein | 359f392 | 2017-06-21 15:28:41 +0300 | [diff] [blame] | 586 | struct dentry *index = NULL; |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 587 | unsigned int ctr = 0; |
| 588 | struct inode *inode = NULL; |
| 589 | bool upperopaque = false; |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 590 | char *upperredirect = NULL; |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 591 | struct dentry *this; |
| 592 | unsigned int i; |
| 593 | int err; |
Miklos Szeredi | e28edc4 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 594 | struct ovl_lookup_data d = { |
| 595 | .name = dentry->d_name, |
| 596 | .is_dir = false, |
| 597 | .opaque = false, |
| 598 | .stop = false, |
| 599 | .last = !poe->numlower, |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 600 | .redirect = NULL, |
Miklos Szeredi | e28edc4 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 601 | }; |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 602 | |
Miklos Szeredi | 6b2d5fe | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 603 | if (dentry->d_name.len > ofs->namelen) |
| 604 | return ERR_PTR(-ENAMETOOLONG); |
| 605 | |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 606 | old_cred = ovl_override_creds(dentry->d_sb); |
Miklos Szeredi | 09d8b58 | 2017-07-04 22:03:16 +0200 | [diff] [blame] | 607 | upperdir = ovl_dentry_upper(dentry->d_parent); |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 608 | if (upperdir) { |
Miklos Szeredi | e28edc4 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 609 | err = ovl_lookup_layer(upperdir, &d, &upperdentry); |
| 610 | if (err) |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 611 | goto out; |
| 612 | |
Miklos Szeredi | e28edc4 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 613 | if (upperdentry && unlikely(ovl_dentry_remote(upperdentry))) { |
| 614 | dput(upperdentry); |
| 615 | err = -EREMOTE; |
| 616 | goto out; |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 617 | } |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 618 | if (upperdentry && !d.is_dir) { |
| 619 | BUG_ON(!d.stop || d.redirect); |
Amir Goldstein | f7d3dac | 2017-06-21 15:28:34 +0300 | [diff] [blame] | 620 | /* |
| 621 | * Lookup copy up origin by decoding origin file handle. |
| 622 | * We may get a disconnected dentry, which is fine, |
| 623 | * because we only need to hold the origin inode in |
| 624 | * cache and use its inode number. We may even get a |
| 625 | * connected dentry, that is not under any of the lower |
| 626 | * layers root. That is also fine for using it's inode |
| 627 | * number - it's the same as if we held a reference |
| 628 | * to a dentry in lower layer that was moved under us. |
| 629 | */ |
Amir Goldstein | 415543d | 2017-06-21 15:28:42 +0300 | [diff] [blame] | 630 | err = ovl_check_origin(upperdentry, roe->lowerstack, |
| 631 | roe->numlower, &stack, &ctr); |
Amir Goldstein | a9d0195 | 2017-04-30 14:46:31 +0300 | [diff] [blame] | 632 | if (err) |
| 633 | goto out; |
| 634 | } |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 635 | |
| 636 | if (d.redirect) { |
| 637 | upperredirect = kstrdup(d.redirect, GFP_KERNEL); |
| 638 | if (!upperredirect) |
| 639 | goto out_put_upper; |
| 640 | if (d.redirect[0] == '/') |
Amir Goldstein | c22205d | 2017-04-26 23:40:52 +0300 | [diff] [blame] | 641 | poe = roe; |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 642 | } |
Miklos Szeredi | e28edc4 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 643 | upperopaque = d.opaque; |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 644 | } |
| 645 | |
Miklos Szeredi | e28edc4 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 646 | if (!d.stop && poe->numlower) { |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 647 | err = -ENOMEM; |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 648 | stack = kcalloc(ofs->numlower, sizeof(struct path), |
Miklos Szeredi | e28edc4 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 649 | GFP_TEMPORARY); |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 650 | if (!stack) |
| 651 | goto out_put_upper; |
| 652 | } |
| 653 | |
Miklos Szeredi | e28edc4 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 654 | for (i = 0; !d.stop && i < poe->numlower; i++) { |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 655 | struct path lowerpath = poe->lowerstack[i]; |
| 656 | |
Miklos Szeredi | e28edc4 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 657 | d.last = i == poe->numlower - 1; |
| 658 | err = ovl_lookup_layer(lowerpath.dentry, &d, &this); |
| 659 | if (err) |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 660 | goto out_put; |
Miklos Szeredi | 6b2d5fe | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 661 | |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 662 | if (!this) |
| 663 | continue; |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 664 | |
| 665 | stack[ctr].dentry = this; |
| 666 | stack[ctr].mnt = lowerpath.mnt; |
| 667 | ctr++; |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 668 | |
| 669 | if (d.stop) |
| 670 | break; |
| 671 | |
Amir Goldstein | c22205d | 2017-04-26 23:40:52 +0300 | [diff] [blame] | 672 | if (d.redirect && d.redirect[0] == '/' && poe != roe) { |
| 673 | poe = roe; |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 674 | |
| 675 | /* Find the current layer on the root dentry */ |
| 676 | for (i = 0; i < poe->numlower; i++) |
| 677 | if (poe->lowerstack[i].mnt == lowerpath.mnt) |
| 678 | break; |
| 679 | if (WARN_ON(i == poe->numlower)) |
| 680 | break; |
| 681 | } |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 682 | } |
| 683 | |
Amir Goldstein | 359f392 | 2017-06-21 15:28:41 +0300 | [diff] [blame] | 684 | /* Lookup index by lower inode and verify it matches upper inode */ |
| 685 | if (ctr && !d.is_dir && ovl_indexdir(dentry->d_sb)) { |
| 686 | struct dentry *origin = stack[0].dentry; |
| 687 | |
| 688 | index = ovl_lookup_index(dentry, upperdentry, origin); |
| 689 | if (IS_ERR(index)) { |
| 690 | err = PTR_ERR(index); |
| 691 | index = NULL; |
| 692 | goto out_put; |
| 693 | } |
| 694 | } |
| 695 | |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 696 | oe = ovl_alloc_entry(ctr); |
| 697 | err = -ENOMEM; |
| 698 | if (!oe) |
| 699 | goto out_put; |
| 700 | |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 701 | oe->opaque = upperopaque; |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 702 | memcpy(oe->lowerstack, stack, sizeof(struct path) * ctr); |
Miklos Szeredi | e6d2ebd | 2017-07-04 22:03:16 +0200 | [diff] [blame] | 703 | dentry->d_fsdata = oe; |
| 704 | |
Miklos Szeredi | 55acc66 | 2017-07-04 22:03:18 +0200 | [diff] [blame] | 705 | if (upperdentry) |
| 706 | ovl_dentry_set_upper_alias(dentry); |
| 707 | else if (index) |
Amir Goldstein | 359f392 | 2017-06-21 15:28:41 +0300 | [diff] [blame] | 708 | upperdentry = dget(index); |
| 709 | |
Miklos Szeredi | e6d2ebd | 2017-07-04 22:03:16 +0200 | [diff] [blame] | 710 | if (upperdentry || ctr) { |
Miklos Szeredi | 09d8b58 | 2017-07-04 22:03:16 +0200 | [diff] [blame] | 711 | inode = ovl_get_inode(dentry, upperdentry); |
Miklos Szeredi | b9ac5c27 | 2017-07-04 22:03:17 +0200 | [diff] [blame] | 712 | err = PTR_ERR(inode); |
| 713 | if (IS_ERR(inode)) |
Miklos Szeredi | e6d2ebd | 2017-07-04 22:03:16 +0200 | [diff] [blame] | 714 | goto out_free_oe; |
Miklos Szeredi | cf31c46 | 2017-07-04 22:03:16 +0200 | [diff] [blame] | 715 | |
| 716 | OVL_I(inode)->redirect = upperredirect; |
Amir Goldstein | 359f392 | 2017-06-21 15:28:41 +0300 | [diff] [blame] | 717 | if (index) |
| 718 | ovl_set_flag(OVL_INDEX, inode); |
Miklos Szeredi | e6d2ebd | 2017-07-04 22:03:16 +0200 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | revert_creds(old_cred); |
Amir Goldstein | 359f392 | 2017-06-21 15:28:41 +0300 | [diff] [blame] | 722 | dput(index); |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 723 | kfree(stack); |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 724 | kfree(d.redirect); |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 725 | d_add(dentry, inode); |
| 726 | |
| 727 | return NULL; |
| 728 | |
| 729 | out_free_oe: |
Miklos Szeredi | e6d2ebd | 2017-07-04 22:03:16 +0200 | [diff] [blame] | 730 | dentry->d_fsdata = NULL; |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 731 | kfree(oe); |
| 732 | out_put: |
Amir Goldstein | 359f392 | 2017-06-21 15:28:41 +0300 | [diff] [blame] | 733 | dput(index); |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 734 | for (i = 0; i < ctr; i++) |
| 735 | dput(stack[i].dentry); |
| 736 | kfree(stack); |
| 737 | out_put_upper: |
| 738 | dput(upperdentry); |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 739 | kfree(upperredirect); |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 740 | out: |
Miklos Szeredi | 02b69b2 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 741 | kfree(d.redirect); |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 742 | revert_creds(old_cred); |
| 743 | return ERR_PTR(err); |
| 744 | } |
| 745 | |
| 746 | bool ovl_lower_positive(struct dentry *dentry) |
| 747 | { |
| 748 | struct ovl_entry *oe = dentry->d_fsdata; |
| 749 | struct ovl_entry *poe = dentry->d_parent->d_fsdata; |
| 750 | const struct qstr *name = &dentry->d_name; |
| 751 | unsigned int i; |
| 752 | bool positive = false; |
| 753 | bool done = false; |
| 754 | |
| 755 | /* |
| 756 | * If dentry is negative, then lower is positive iff this is a |
| 757 | * whiteout. |
| 758 | */ |
| 759 | if (!dentry->d_inode) |
| 760 | return oe->opaque; |
| 761 | |
| 762 | /* Negative upper -> positive lower */ |
Miklos Szeredi | 09d8b58 | 2017-07-04 22:03:16 +0200 | [diff] [blame] | 763 | if (!ovl_dentry_upper(dentry)) |
Miklos Szeredi | bbb1e54 | 2016-12-16 11:02:56 +0100 | [diff] [blame] | 764 | return true; |
| 765 | |
| 766 | /* Positive upper -> have to look up lower to see whether it exists */ |
| 767 | for (i = 0; !done && !positive && i < poe->numlower; i++) { |
| 768 | struct dentry *this; |
| 769 | struct dentry *lowerdir = poe->lowerstack[i].dentry; |
| 770 | |
| 771 | this = lookup_one_len_unlocked(name->name, lowerdir, |
| 772 | name->len); |
| 773 | if (IS_ERR(this)) { |
| 774 | switch (PTR_ERR(this)) { |
| 775 | case -ENOENT: |
| 776 | case -ENAMETOOLONG: |
| 777 | break; |
| 778 | |
| 779 | default: |
| 780 | /* |
| 781 | * Assume something is there, we just couldn't |
| 782 | * access it. |
| 783 | */ |
| 784 | positive = true; |
| 785 | break; |
| 786 | } |
| 787 | } else { |
| 788 | if (this->d_inode) { |
| 789 | positive = !ovl_is_whiteout(this); |
| 790 | done = true; |
| 791 | } |
| 792 | dput(this); |
| 793 | } |
| 794 | } |
| 795 | |
| 796 | return positive; |
| 797 | } |