]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.18.11/revert-ubifs-xattr-don-t-operate-on-deleted-inodes.patch
fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.18.11 / revert-ubifs-xattr-don-t-operate-on-deleted-inodes.patch
1 From f061c1cc404a618858a77aea233fde0aeaad2f2d Mon Sep 17 00:00:00 2001
2 From: Richard Weinberger <richard@nod.at>
3 Date: Sun, 16 Sep 2018 23:57:35 +0200
4 Subject: Revert "ubifs: xattr: Don't operate on deleted inodes"
5
6 From: Richard Weinberger <richard@nod.at>
7
8 commit f061c1cc404a618858a77aea233fde0aeaad2f2d upstream.
9
10 This reverts commit 11a6fc3dc743e22fb50f2196ec55bee5140d3c52.
11 UBIFS wants to assert that xattr operations are only issued on files
12 with positive link count. The said patch made this operations return
13 -ENOENT for unlinked files such that the asserts will no longer trigger.
14 This was wrong since xattr operations are perfectly fine on unlinked
15 files.
16 Instead the assertions need to be fixed/removed.
17
18 Cc: <stable@vger.kernel.org>
19 Fixes: 11a6fc3dc743 ("ubifs: xattr: Don't operate on deleted inodes")
20 Reported-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
21 Tested-by: Joel Stanley <joel@jms.id.au>
22 Signed-off-by: Richard Weinberger <richard@nod.at>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24
25 ---
26 fs/ubifs/xattr.c | 24 ------------------------
27 1 file changed, 24 deletions(-)
28
29 --- a/fs/ubifs/xattr.c
30 +++ b/fs/ubifs/xattr.c
31 @@ -152,12 +152,6 @@ static int create_xattr(struct ubifs_inf
32 ui->data_len = size;
33
34 mutex_lock(&host_ui->ui_mutex);
35 -
36 - if (!host->i_nlink) {
37 - err = -ENOENT;
38 - goto out_noent;
39 - }
40 -
41 host->i_ctime = current_time(host);
42 host_ui->xattr_cnt += 1;
43 host_ui->xattr_size += CALC_DENT_SIZE(fname_len(nm));
44 @@ -190,7 +184,6 @@ out_cancel:
45 host_ui->xattr_size -= CALC_XATTR_BYTES(size);
46 host_ui->xattr_names -= fname_len(nm);
47 host_ui->flags &= ~UBIFS_CRYPT_FL;
48 -out_noent:
49 mutex_unlock(&host_ui->ui_mutex);
50 out_free:
51 make_bad_inode(inode);
52 @@ -242,12 +235,6 @@ static int change_xattr(struct ubifs_inf
53 mutex_unlock(&ui->ui_mutex);
54
55 mutex_lock(&host_ui->ui_mutex);
56 -
57 - if (!host->i_nlink) {
58 - err = -ENOENT;
59 - goto out_noent;
60 - }
61 -
62 host->i_ctime = current_time(host);
63 host_ui->xattr_size -= CALC_XATTR_BYTES(old_size);
64 host_ui->xattr_size += CALC_XATTR_BYTES(size);
65 @@ -269,7 +256,6 @@ static int change_xattr(struct ubifs_inf
66 out_cancel:
67 host_ui->xattr_size -= CALC_XATTR_BYTES(size);
68 host_ui->xattr_size += CALC_XATTR_BYTES(old_size);
69 -out_noent:
70 mutex_unlock(&host_ui->ui_mutex);
71 make_bad_inode(inode);
72 out_free:
73 @@ -496,12 +482,6 @@ static int remove_xattr(struct ubifs_inf
74 return err;
75
76 mutex_lock(&host_ui->ui_mutex);
77 -
78 - if (!host->i_nlink) {
79 - err = -ENOENT;
80 - goto out_noent;
81 - }
82 -
83 host->i_ctime = current_time(host);
84 host_ui->xattr_cnt -= 1;
85 host_ui->xattr_size -= CALC_DENT_SIZE(fname_len(nm));
86 @@ -521,7 +501,6 @@ out_cancel:
87 host_ui->xattr_size += CALC_DENT_SIZE(fname_len(nm));
88 host_ui->xattr_size += CALC_XATTR_BYTES(ui->data_len);
89 host_ui->xattr_names += fname_len(nm);
90 -out_noent:
91 mutex_unlock(&host_ui->ui_mutex);
92 ubifs_release_budget(c, &req);
93 make_bad_inode(inode);
94 @@ -561,9 +540,6 @@ static int ubifs_xattr_remove(struct ino
95
96 ubifs_assert(inode_is_locked(host));
97
98 - if (!host->i_nlink)
99 - return -ENOENT;
100 -
101 if (fname_len(&nm) > UBIFS_MAX_NLEN)
102 return -ENAMETOOLONG;
103