namei.c (dad7017a840d8d198074338224cd418d37b8f79d) namei.c (ba9ea771ec8a9da4e3aa5cb8c8549fc3b15b2641)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2011 Novell Inc.
4 * Copyright (C) 2016 Red Hat, Inc.
5 */
6
7#include <linux/fs.h>
8#include <linux/cred.h>

--- 185 unchanged lines hidden (view full) ---

194 return real;
195}
196
197static bool ovl_is_opaquedir(struct ovl_fs *ofs, struct path *path)
198{
199 return ovl_path_check_dir_xattr(ofs, path, OVL_XATTR_OPAQUE);
200}
201
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2011 Novell Inc.
4 * Copyright (C) 2016 Red Hat, Inc.
5 */
6
7#include <linux/fs.h>
8#include <linux/cred.h>

--- 185 unchanged lines hidden (view full) ---

194 return real;
195}
196
197static bool ovl_is_opaquedir(struct ovl_fs *ofs, struct path *path)
198{
199 return ovl_path_check_dir_xattr(ofs, path, OVL_XATTR_OPAQUE);
200}
201
202static struct dentry *ovl_lookup_positive_unlocked(const char *name,
202static struct dentry *ovl_lookup_positive_unlocked(struct ovl_lookup_data *d,
203 const char *name,
203 struct dentry *base, int len,
204 bool drop_negative)
205{
204 struct dentry *base, int len,
205 bool drop_negative)
206{
206 struct dentry *ret = lookup_one_len_unlocked(name, base, len);
207 struct dentry *ret = lookup_one_unlocked(mnt_user_ns(d->mnt), name, base, len);
207
208 if (!IS_ERR(ret) && d_flags_negative(smp_load_acquire(&ret->d_flags))) {
209 if (drop_negative && ret->d_lockref.count == 1) {
210 spin_lock(&ret->d_lock);
211 /* Recheck condition under lock */
212 if (d_is_negative(ret) && ret->d_lockref.count == 1)
213 __d_drop(ret);
214 spin_unlock(&ret->d_lock);

--- 9 unchanged lines hidden (view full) ---

224 size_t prelen, const char *post,
225 struct dentry **ret, bool drop_negative)
226{
227 struct dentry *this;
228 struct path path;
229 int err;
230 bool last_element = !post[0];
231
208
209 if (!IS_ERR(ret) && d_flags_negative(smp_load_acquire(&ret->d_flags))) {
210 if (drop_negative && ret->d_lockref.count == 1) {
211 spin_lock(&ret->d_lock);
212 /* Recheck condition under lock */
213 if (d_is_negative(ret) && ret->d_lockref.count == 1)
214 __d_drop(ret);
215 spin_unlock(&ret->d_lock);

--- 9 unchanged lines hidden (view full) ---

225 size_t prelen, const char *post,
226 struct dentry **ret, bool drop_negative)
227{
228 struct dentry *this;
229 struct path path;
230 int err;
231 bool last_element = !post[0];
232
232 this = ovl_lookup_positive_unlocked(name, base, namelen, drop_negative);
233 this = ovl_lookup_positive_unlocked(d, name, base, namelen, drop_negative);
233 if (IS_ERR(this)) {
234 err = PTR_ERR(this);
235 this = NULL;
236 if (err == -ENOENT || err == -ENAMETOOLONG)
237 goto out;
238 goto out_err;
239 }
240

--- 463 unchanged lines hidden (view full) ---

704 struct qstr name;
705 bool is_dir = d_is_dir(origin);
706 int err;
707
708 err = ovl_get_index_name(ofs, origin, &name);
709 if (err)
710 return ERR_PTR(err);
711
234 if (IS_ERR(this)) {
235 err = PTR_ERR(this);
236 this = NULL;
237 if (err == -ENOENT || err == -ENAMETOOLONG)
238 goto out;
239 goto out_err;
240 }
241

--- 463 unchanged lines hidden (view full) ---

705 struct qstr name;
706 bool is_dir = d_is_dir(origin);
707 int err;
708
709 err = ovl_get_index_name(ofs, origin, &name);
710 if (err)
711 return ERR_PTR(err);
712
712 index = lookup_positive_unlocked(name.name, ofs->indexdir, name.len);
713 index = lookup_one_positive_unlocked(ovl_upper_mnt_userns(ofs), name.name,
714 ofs->indexdir, name.len);
713 if (IS_ERR(index)) {
714 err = PTR_ERR(index);
715 if (err == -ENOENT) {
716 index = NULL;
717 goto out;
718 }
719 pr_warn_ratelimited("failed inode index lookup (ino=%lu, key=%.*s, err=%i);\n"
720 "overlayfs: mount with '-o index=off' to disable inodes index.\n",

--- 448 unchanged lines hidden (view full) ---

1169 return true;
1170
1171 old_cred = ovl_override_creds(dentry->d_sb);
1172 /* Positive upper -> have to look up lower to see whether it exists */
1173 for (i = 0; !done && !positive && i < poe->numlower; i++) {
1174 struct dentry *this;
1175 struct dentry *lowerdir = poe->lowerstack[i].dentry;
1176
715 if (IS_ERR(index)) {
716 err = PTR_ERR(index);
717 if (err == -ENOENT) {
718 index = NULL;
719 goto out;
720 }
721 pr_warn_ratelimited("failed inode index lookup (ino=%lu, key=%.*s, err=%i);\n"
722 "overlayfs: mount with '-o index=off' to disable inodes index.\n",

--- 448 unchanged lines hidden (view full) ---

1171 return true;
1172
1173 old_cred = ovl_override_creds(dentry->d_sb);
1174 /* Positive upper -> have to look up lower to see whether it exists */
1175 for (i = 0; !done && !positive && i < poe->numlower; i++) {
1176 struct dentry *this;
1177 struct dentry *lowerdir = poe->lowerstack[i].dentry;
1178
1177 this = lookup_positive_unlocked(name->name, lowerdir,
1178 name->len);
1179 this = lookup_one_positive_unlocked(mnt_user_ns(poe->lowerstack[i].layer->mnt),
1180 name->name, lowerdir, name->len);
1179 if (IS_ERR(this)) {
1180 switch (PTR_ERR(this)) {
1181 case -ENOENT:
1182 case -ENAMETOOLONG:
1183 break;
1184
1185 default:
1186 /*

--- 16 unchanged lines hidden ---
1181 if (IS_ERR(this)) {
1182 switch (PTR_ERR(this)) {
1183 case -ENOENT:
1184 case -ENAMETOOLONG:
1185 break;
1186
1187 default:
1188 /*

--- 16 unchanged lines hidden ---