]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.18.127/reiserfs-propagate-errors-from-fill_with_dentries-pr.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.18.127 / reiserfs-propagate-errors-from-fill_with_dentries-pr.patch
1 From 07de97c619b593ad8e0e9f08ecdb1d8e7ae18229 Mon Sep 17 00:00:00 2001
2 From: Jann Horn <jannh@google.com>
3 Date: Tue, 30 Oct 2018 15:06:38 -0700
4 Subject: reiserfs: propagate errors from fill_with_dentries() properly
5
6 [ Upstream commit b10298d56c9623f9b173f19959732d3184b35f4f ]
7
8 fill_with_dentries() failed to propagate errors up to
9 reiserfs_for_each_xattr() properly. Plumb them through.
10
11 Note that reiserfs_for_each_xattr() is only used by
12 reiserfs_delete_xattrs() and reiserfs_chown_xattrs(). The result of
13 reiserfs_delete_xattrs() is discarded anyway, the only difference there is
14 whether a warning is printed to dmesg. The result of
15 reiserfs_chown_xattrs() does matter because it can block chowning of the
16 file to which the xattrs belong; but either way, the resulting state can
17 have misaligned ownership, so my patch doesn't improve things greatly.
18
19 Credit for making me look at this code goes to Al Viro, who pointed out
20 that the ->actor calling convention is suboptimal and should be changed.
21
22 Link: http://lkml.kernel.org/r/20180802163335.83312-1-jannh@google.com
23 Signed-off-by: Jann Horn <jannh@google.com>
24 Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
25 Cc: Jeff Mahoney <jeffm@suse.com>
26 Cc: Eric Biggers <ebiggers@google.com>
27 Cc: Al Viro <viro@zeniv.linux.org.uk>
28 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
29 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
30 Signed-off-by: Sasha Levin <sashal@kernel.org>
31 ---
32 fs/reiserfs/xattr.c | 7 +++++++
33 1 file changed, 7 insertions(+)
34
35 diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
36 index 59b29acb6419..0ec755043174 100644
37 --- a/fs/reiserfs/xattr.c
38 +++ b/fs/reiserfs/xattr.c
39 @@ -184,6 +184,7 @@ struct reiserfs_dentry_buf {
40 struct dir_context ctx;
41 struct dentry *xadir;
42 int count;
43 + int err;
44 struct dentry *dentries[8];
45 };
46
47 @@ -205,6 +206,7 @@ fill_with_dentries(void *buf, const char *name, int namelen, loff_t offset,
48
49 dentry = lookup_one_len(name, dbuf->xadir, namelen);
50 if (IS_ERR(dentry)) {
51 + dbuf->err = PTR_ERR(dentry);
52 return PTR_ERR(dentry);
53 } else if (!dentry->d_inode) {
54 /* A directory entry exists, but no file? */
55 @@ -213,6 +215,7 @@ fill_with_dentries(void *buf, const char *name, int namelen, loff_t offset,
56 "not found for file %s.\n",
57 dentry->d_name.name, dbuf->xadir->d_name.name);
58 dput(dentry);
59 + dbuf->err = -EIO;
60 return -EIO;
61 }
62
63 @@ -260,6 +263,10 @@ static int reiserfs_for_each_xattr(struct inode *inode,
64 err = reiserfs_readdir_inode(dir->d_inode, &buf.ctx);
65 if (err)
66 break;
67 + if (buf.err) {
68 + err = buf.err;
69 + break;
70 + }
71 if (!buf.count)
72 break;
73 for (i = 0; !err && i < buf.count && buf.dentries[i]; i++) {
74 --
75 2.17.1
76