aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2018-09-16 17:57:35 -0400
committerRichard Weinberger <richard@nod.at>2018-09-20 15:37:41 -0400
commitf061c1cc404a618858a77aea233fde0aeaad2f2d (patch)
tree7ac48f3f8f78b182bb1c44e628c9bf690bcd0995
parentd3bdc016c598e09a4ddf17805d17d43759b0a582 (diff)
Revert "ubifs: xattr: Don't operate on deleted inodes"
This reverts commit 11a6fc3dc743e22fb50f2196ec55bee5140d3c52. UBIFS wants to assert that xattr operations are only issued on files with positive link count. The said patch made this operations return -ENOENT for unlinked files such that the asserts will no longer trigger. This was wrong since xattr operations are perfectly fine on unlinked files. Instead the assertions need to be fixed/removed. Cc: <stable@vger.kernel.org> Fixes: 11a6fc3dc743 ("ubifs: xattr: Don't operate on deleted inodes") Reported-by: Koen Vandeputte <koen.vandeputte@ncentric.com> Tested-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Richard Weinberger <richard@nod.at>
-rw-r--r--fs/ubifs/xattr.c24
1 files changed, 0 insertions, 24 deletions
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index 61afdfee4b28..f5ad1ede7990 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -152,12 +152,6 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
152 ui->data_len = size; 152 ui->data_len = size;
153 153
154 mutex_lock(&host_ui->ui_mutex); 154 mutex_lock(&host_ui->ui_mutex);
155
156 if (!host->i_nlink) {
157 err = -ENOENT;
158 goto out_noent;
159 }
160
161 host->i_ctime = current_time(host); 155 host->i_ctime = current_time(host);
162 host_ui->xattr_cnt += 1; 156 host_ui->xattr_cnt += 1;
163 host_ui->xattr_size += CALC_DENT_SIZE(fname_len(nm)); 157 host_ui->xattr_size += CALC_DENT_SIZE(fname_len(nm));
@@ -190,7 +184,6 @@ out_cancel:
190 host_ui->xattr_size -= CALC_XATTR_BYTES(size); 184 host_ui->xattr_size -= CALC_XATTR_BYTES(size);
191 host_ui->xattr_names -= fname_len(nm); 185 host_ui->xattr_names -= fname_len(nm);
192 host_ui->flags &= ~UBIFS_CRYPT_FL; 186 host_ui->flags &= ~UBIFS_CRYPT_FL;
193out_noent:
194 mutex_unlock(&host_ui->ui_mutex); 187 mutex_unlock(&host_ui->ui_mutex);
195out_free: 188out_free:
196 make_bad_inode(inode); 189 make_bad_inode(inode);
@@ -242,12 +235,6 @@ static int change_xattr(struct ubifs_info *c, struct inode *host,
242 mutex_unlock(&ui->ui_mutex); 235 mutex_unlock(&ui->ui_mutex);
243 236
244 mutex_lock(&host_ui->ui_mutex); 237 mutex_lock(&host_ui->ui_mutex);
245
246 if (!host->i_nlink) {
247 err = -ENOENT;
248 goto out_noent;
249 }
250
251 host->i_ctime = current_time(host); 238 host->i_ctime = current_time(host);
252 host_ui->xattr_size -= CALC_XATTR_BYTES(old_size); 239 host_ui->xattr_size -= CALC_XATTR_BYTES(old_size);
253 host_ui->xattr_size += CALC_XATTR_BYTES(size); 240 host_ui->xattr_size += CALC_XATTR_BYTES(size);
@@ -269,7 +256,6 @@ static int change_xattr(struct ubifs_info *c, struct inode *host,
269out_cancel: 256out_cancel:
270 host_ui->xattr_size -= CALC_XATTR_BYTES(size); 257 host_ui->xattr_size -= CALC_XATTR_BYTES(size);
271 host_ui->xattr_size += CALC_XATTR_BYTES(old_size); 258 host_ui->xattr_size += CALC_XATTR_BYTES(old_size);
272out_noent:
273 mutex_unlock(&host_ui->ui_mutex); 259 mutex_unlock(&host_ui->ui_mutex);
274 make_bad_inode(inode); 260 make_bad_inode(inode);
275out_free: 261out_free:
@@ -496,12 +482,6 @@ static int remove_xattr(struct ubifs_info *c, struct inode *host,
496 return err; 482 return err;
497 483
498 mutex_lock(&host_ui->ui_mutex); 484 mutex_lock(&host_ui->ui_mutex);
499
500 if (!host->i_nlink) {
501 err = -ENOENT;
502 goto out_noent;
503 }
504
505 host->i_ctime = current_time(host); 485 host->i_ctime = current_time(host);
506 host_ui->xattr_cnt -= 1; 486 host_ui->xattr_cnt -= 1;
507 host_ui->xattr_size -= CALC_DENT_SIZE(fname_len(nm)); 487 host_ui->xattr_size -= CALC_DENT_SIZE(fname_len(nm));
@@ -521,7 +501,6 @@ out_cancel:
521 host_ui->xattr_size += CALC_DENT_SIZE(fname_len(nm)); 501 host_ui->xattr_size += CALC_DENT_SIZE(fname_len(nm));
522 host_ui->xattr_size += CALC_XATTR_BYTES(ui->data_len); 502 host_ui->xattr_size += CALC_XATTR_BYTES(ui->data_len);
523 host_ui->xattr_names += fname_len(nm); 503 host_ui->xattr_names += fname_len(nm);
524out_noent:
525 mutex_unlock(&host_ui->ui_mutex); 504 mutex_unlock(&host_ui->ui_mutex);
526 ubifs_release_budget(c, &req); 505 ubifs_release_budget(c, &req);
527 make_bad_inode(inode); 506 make_bad_inode(inode);
@@ -561,9 +540,6 @@ static int ubifs_xattr_remove(struct inode *host, const char *name)
561 540
562 ubifs_assert(c, inode_is_locked(host)); 541 ubifs_assert(c, inode_is_locked(host));
563 542
564 if (!host->i_nlink)
565 return -ENOENT;
566
567 if (fname_len(&nm) > UBIFS_MAX_NLEN) 543 if (fname_len(&nm) > UBIFS_MAX_NLEN)
568 return -ENAMETOOLONG; 544 return -ENAMETOOLONG;
569 545