Skip to content

Commit 2a575f1

Browse files
jtlaytonidryomov
authored andcommitted
ceph: fix potential bad pointer deref in async dirops cb's
The new async dirops callback routines can pass ERR_PTR values to ceph_mdsc_free_path, which could cause an oops. Make ceph_mdsc_free_path ignore ERR_PTR values. Also, ensure that the pr_warn messages look sane even if ceph_mdsc_build_path fails. Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Jeff Layton <[email protected]> Reviewed-by: Ilya Dryomov <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 8ae0299 commit 2a575f1

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

fs/ceph/dir.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,8 +1051,8 @@ static void ceph_async_unlink_cb(struct ceph_mds_client *mdsc,
10511051

10521052
/* If op failed, mark everyone involved for errors */
10531053
if (result) {
1054-
int pathlen;
1055-
u64 base;
1054+
int pathlen = 0;
1055+
u64 base = 0;
10561056
char *path = ceph_mdsc_build_path(req->r_dentry, &pathlen,
10571057
&base, 0);
10581058

fs/ceph/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,8 @@ static void ceph_async_create_cb(struct ceph_mds_client *mdsc,
527527

528528
if (result) {
529529
struct dentry *dentry = req->r_dentry;
530-
int pathlen;
531-
u64 base;
530+
int pathlen = 0;
531+
u64 base = 0;
532532
char *path = ceph_mdsc_build_path(req->r_dentry, &pathlen,
533533
&base, 0);
534534

fs/ceph/mds_client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ extern void ceph_mdsc_pre_umount(struct ceph_mds_client *mdsc);
521521

522522
static inline void ceph_mdsc_free_path(char *path, int len)
523523
{
524-
if (path)
524+
if (!IS_ERR_OR_NULL(path))
525525
__putname(path - (PATH_MAX - 1 - len));
526526
}
527527

0 commit comments

Comments
 (0)