kernel: bump 4.9 to 4.9.130
[openwrt/staging/mkresin.git] / target / linux / generic / pending-4.14 / 192-Revert-ubifs-xattr-Don-t-operate-on-deleted-inodes.patch
1 From a99708737f566c70651015332e89d0d3b1eb5529 Mon Sep 17 00:00:00 2001
2 From: Koen Vandeputte <koen.vandeputte@ncentric.com>
3 Date: Mon, 17 Sep 2018 10:13:09 +0200
4 Subject: [PATCH] Revert "ubifs: xattr: Don't operate on deleted inodes"
5
6 This reverts commit 8a23348d76a1e7716da6e76383281ac82fc071cf.
7
8 UBIFS wants to assert that xattr operations are only issued on files
9 with positive link count. The said patch made this operations return
10 -ENOENT for unlinked files such that the asserts will no longer trigger.
11 This was wrong since xattr operations are perfectly fine on unlinked
12 files.
13 Instead the assertions need to be fixed/removed.
14
15 Fixes: 11a6fc3dc743 ("ubifs: xattr: Don't operate on deleted inodes")
16 Reported-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
17 Signed-off-by: Richard Weinberger <richard@nod.at>
18 ---
19 fs/ubifs/xattr.c | 24 ------------------------
20 1 file changed, 24 deletions(-)
21
22 --- a/fs/ubifs/xattr.c
23 +++ b/fs/ubifs/xattr.c
24 @@ -152,12 +152,6 @@ static int create_xattr(struct ubifs_inf
25 ui->data_len = size;
26
27 mutex_lock(&host_ui->ui_mutex);
28 -
29 - if (!host->i_nlink) {
30 - err = -ENOENT;
31 - goto out_noent;
32 - }
33 -
34 host->i_ctime = current_time(host);
35 host_ui->xattr_cnt += 1;
36 host_ui->xattr_size += CALC_DENT_SIZE(fname_len(nm));
37 @@ -189,7 +183,6 @@ out_cancel:
38 host_ui->xattr_size -= CALC_XATTR_BYTES(size);
39 host_ui->xattr_names -= fname_len(nm);
40 host_ui->flags &= ~UBIFS_CRYPT_FL;
41 -out_noent:
42 mutex_unlock(&host_ui->ui_mutex);
43 out_free:
44 make_bad_inode(inode);
45 @@ -241,12 +234,6 @@ static int change_xattr(struct ubifs_inf
46 mutex_unlock(&ui->ui_mutex);
47
48 mutex_lock(&host_ui->ui_mutex);
49 -
50 - if (!host->i_nlink) {
51 - err = -ENOENT;
52 - goto out_noent;
53 - }
54 -
55 host->i_ctime = current_time(host);
56 host_ui->xattr_size -= CALC_XATTR_BYTES(old_size);
57 host_ui->xattr_size += CALC_XATTR_BYTES(size);
58 @@ -268,7 +255,6 @@ static int change_xattr(struct ubifs_inf
59 out_cancel:
60 host_ui->xattr_size -= CALC_XATTR_BYTES(size);
61 host_ui->xattr_size += CALC_XATTR_BYTES(old_size);
62 -out_noent:
63 mutex_unlock(&host_ui->ui_mutex);
64 make_bad_inode(inode);
65 out_free:
66 @@ -497,12 +483,6 @@ static int remove_xattr(struct ubifs_inf
67 return err;
68
69 mutex_lock(&host_ui->ui_mutex);
70 -
71 - if (!host->i_nlink) {
72 - err = -ENOENT;
73 - goto out_noent;
74 - }
75 -
76 host->i_ctime = current_time(host);
77 host_ui->xattr_cnt -= 1;
78 host_ui->xattr_size -= CALC_DENT_SIZE(fname_len(nm));
79 @@ -522,7 +502,6 @@ out_cancel:
80 host_ui->xattr_size += CALC_DENT_SIZE(fname_len(nm));
81 host_ui->xattr_size += CALC_XATTR_BYTES(ui->data_len);
82 host_ui->xattr_names += fname_len(nm);
83 -out_noent:
84 mutex_unlock(&host_ui->ui_mutex);
85 ubifs_release_budget(c, &req);
86 make_bad_inode(inode);
87 @@ -562,9 +541,6 @@ static int ubifs_xattr_remove(struct ino
88
89 ubifs_assert(inode_is_locked(host));
90
91 - if (!host->i_nlink)
92 - return -ENOENT;
93 -
94 if (fname_len(&nm) > UBIFS_MAX_NLEN)
95 return -ENAMETOOLONG;
96