Skip to content

Commit 550f7ca

Browse files
MaxKellermannidryomov
authored andcommitted
ceph: give up on paths longer than PATH_MAX
If the full path to be built by ceph_mdsc_build_path() happens to be longer than PATH_MAX, then this function will enter an endless (retry) loop, effectively blocking the whole task. Most of the machine becomes unusable, making this a very simple and effective DoS vulnerability. I cannot imagine why this retry was ever implemented, but it seems rather useless and harmful to me. Let's remove it and fail with ENAMETOOLONG instead. Cc: [email protected] Reported-by: Dario Weißer <[email protected]> Signed-off-by: Max Kellermann <[email protected]> Reviewed-by: Alex Markuze <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent d6fd6f8 commit 550f7ca

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

fs/ceph/mds_client.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2800,12 +2800,11 @@ char *ceph_mdsc_build_path(struct ceph_mds_client *mdsc, struct dentry *dentry,
28002800

28012801
if (pos < 0) {
28022802
/*
2803-
* A rename didn't occur, but somehow we didn't end up where
2804-
* we thought we would. Throw a warning and try again.
2803+
* The path is longer than PATH_MAX and this function
2804+
* cannot ever succeed. Creating paths that long is
2805+
* possible with Ceph, but Linux cannot use them.
28052806
*/
2806-
pr_warn_client(cl, "did not end path lookup where expected (pos = %d)\n",
2807-
pos);
2808-
goto retry;
2807+
return ERR_PTR(-ENAMETOOLONG);
28092808
}
28102809

28112810
*pbase = base;

0 commit comments

Comments
 (0)