From: "Luís Henriques" <lhenriques@suse.de>
To: Jeff Layton <jlayton@kernel.org>, Xiubo Li <xiubli@redhat.com>,
Ilya Dryomov <idryomov@gmail.com>
Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org,
"Luís Henriques" <lhenriques@suse.de>
Subject: [PATCH 2/3] ceph: fix use-after-free in ceph_readdir
Date: Fri, 4 Mar 2022 16:14:02 +0000 [thread overview]
Message-ID: <20220304161403.19295-3-lhenriques@suse.de> (raw)
In-Reply-To: <20220304161403.19295-1-lhenriques@suse.de>
After calling ceph_mdsc_put_request() on dfi->last_readdir, this field
should be set to NULL, otherwise we may end-up freeing it twince and get
the following splat:
refcount_t: underflow; use-after-free.
WARNING: CPU: 0 PID: 229 at lib/refcount.c:28 refcount_warn_saturate+0xa6/0xf0
...
Call Trace:
<TASK>
ceph_readdir+0xd35/0x1460 [ceph]
? _raw_spin_unlock+0x12/0x30
? preempt_count_add+0x73/0xa0
? _raw_spin_unlock+0x12/0x30
? __mark_inode_dirty+0x27c/0x3a0
iterate_dir+0x7d/0x190
__x64_sys_getdents64+0x80/0x120
? compat_fillonedir+0x160/0x160
do_syscall_64+0x43/0x90
entry_SYSCALL_64_after_hwframe+0x44/0xae
Signed-off-by: Luís Henriques <lhenriques@suse.de>
---
fs/ceph/dir.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 0bcb677d2199..934402f5e9e6 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -555,6 +555,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
le32_to_cpu(rde->inode.in->mode) >> 12)) {
dout("filldir stopping us...\n");
ceph_mdsc_put_request(dfi->last_readdir);
+ dfi->last_readdir = NULL;
err = 0;
goto out;
}
next prev parent reply other threads:[~2022-03-04 16:13 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-04 16:14 [PATCH 0/3] ceph: minor fixes and encrypted snapshot names Luís Henriques
2022-03-04 16:14 ` [PATCH 1/3] ceph: fix error path in ceph_readdir() Luís Henriques
2022-03-04 18:17 ` Jeff Layton
2022-03-05 14:30 ` Luís Henriques
2022-03-04 16:14 ` Luís Henriques [this message]
2022-03-04 18:20 ` [PATCH 2/3] ceph: fix use-after-free in ceph_readdir Jeff Layton
2022-03-05 12:43 ` Xiubo Li
2022-03-05 14:32 ` Luís Henriques
2022-03-04 16:14 ` [PATCH 3/3] ceph: add support for encrypted snapshot names Luís Henriques
2022-03-04 18:25 ` Jeff Layton
2022-03-05 14:34 ` Luís Henriques
2022-03-05 12:43 ` Xiubo Li
2022-03-04 16:26 ` [PATCH 0/3] ceph: minor fixes and " Luís Henriques
2022-03-04 18:30 ` Jeff Layton
2022-03-05 14:56 ` Luís Henriques
2022-03-07 0:49 ` Xiubo Li
2022-03-07 14:20 ` Luís Henriques
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220304161403.19295-3-lhenriques@suse.de \
--to=lhenriques@suse.de \
--cc=ceph-devel@vger.kernel.org \
--cc=idryomov@gmail.com \
--cc=jlayton@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xiubli@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox