From nobody Thu Nov 21 21:36:25 2024 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 492131E5711 for ; Mon, 18 Nov 2024 22:28:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731968920; cv=none; b=dgkGrDEZAoQo6Wfihdv3lCMaUF0QWHm4v9Cov5RsD8tyvSz8oVMox8pdEgQ2ZmsEcZyV8znQz7L9ZGB92khRmXxbvt+cUHGlUGI3HQP54Te48j0MUSIO7ibrCuQxXAf9/nsIddpim4j3JhKKu11w+yYk1gZhWZRt6BJu7nVagEE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731968920; c=relaxed/simple; bh=AMRwCOm6PPsMK1+VolimqEuMDwoiKrof204t0pu7GY0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=iF/Dsc/mPhezoZxftD85yNj1gNCSKtRDRYzwQdr8uSxIdXrqNS4iqxlO9Z+q5iHF0+5vlVJZEyCxao02SH7ZkZi+sQvgnx0mhBGDnmTLmrognYVCYdwE00vwIvaNelMKkk3Hp+hnwIEoXkASW1CLzE7x2/S2SLHtNlFWmQLEawU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=NhOZx2qh; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="NhOZx2qh" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4315839a7c9so1933635e9.3 for ; Mon, 18 Nov 2024 14:28:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1731968915; x=1732573715; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=aELIIOy3P0XH2d0/thP7GBbWQkXjiSTD8BNOrpNwIQg=; b=NhOZx2qh8pw8Vqnl8A34eIB+i4o5cGnBS2X4VcWjtUpoTW2IJAvMQHBj7rkRtz8MdR KueZKl2wYtqlIJ/I087OfqMSNv9XHWzj1tYgqZIaBVBbpAdspW1CdpQ83NQF3t5R/8B5 hApuOlRREsCLP8txcc6QmS5MdUvJqxW5RsrHYsQ7AjFz99ECSNcGhWuBQez+JwaDHuMD l2mIzd5TDcLklvCjmyl5WFSsA6WWOq256ezlBL3piELaU6d/W4zEh8ggtPUVU4K0/8A5 aMyQtPNhsOFkdQWbltGy9KuvrfoWyvRJnKoMOaZScqcjKrFTK0jC9fE8XKv+UPZxtsob SOlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731968915; x=1732573715; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aELIIOy3P0XH2d0/thP7GBbWQkXjiSTD8BNOrpNwIQg=; b=xCE0PIkEEXqz3g1uLmDA8jQ1h8E93ho85pgUs0l7+pxNcSFRygCbYQIGcmMXZFjBcw G3EKG3EN50IeXWk2J6SMtXeWpfgOvAx4gin2e3QzKk2zxI6VMiAp+gPEW4N1TR1OgJw/ 1cxgHUPH6Q4VKUx+ZDFxOg/9hKX75+6DfZed10WvMw241RY1kvnX6VPYg3bwfJWHeAj/ iPd8R32ldoQrHjgbZ6VyVYoTwsUJAF6jNQWBV4bG3drUwRgqVdMeZ/YfOMqNWlRPiIBo tMAvP/x5zbEqg0uyWuw+YzTtACh+DzwvH2WNJG1V5phXJGSugawC3iV2TC5l5DyYJmmD ZMgw== X-Forwarded-Encrypted: i=1; AJvYcCW7+Oe7D+is5cP1apJbYWjBPoDGKp4+l+jdy68nn+4reV3k74dlqy0CZec05b9+j9AMhU00uR8/f6FBsbc=@vger.kernel.org X-Gm-Message-State: AOJu0YzTb9nblwDlys1FjXWgok3a7LoP/XA7N5/JtY0bhgIl0SMeLSZ4 jBbUChTVBcC8MWaOoogjvTJrUh9biZZeHRkBJXaD/gvsSagup8BBEZruVr+P0Kc= X-Google-Smtp-Source: AGHT+IG051lv97ph0aZr4al15OTxoT+XUgzRS4h6XjL8falTMSmWXyru1OZtOCYZDfSMFASCZhXhuA== X-Received: by 2002:a05:600c:1f14:b0:42c:b1ee:4b04 with SMTP id 5b1f17b1804b1-432df79193emr100670675e9.28.1731968915579; Mon, 18 Nov 2024 14:28:35 -0800 (PST) Received: from raven.intern.cm-ag (p200300dc6f12b600023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f12:b600:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432da265907sm178325795e9.13.2024.11.18.14.28.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2024 14:28:35 -0800 (PST) From: Max Kellermann To: xiubli@redhat.com, idryomov@gmail.com, ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, dario@cure53.de Cc: stable@vger.kernel.org, Max Kellermann Subject: [PATCH] fs/ceph/mds_client: give up on paths longer than PATH_MAX Date: Mon, 18 Nov 2024 23:28:28 +0100 Message-ID: <20241118222828.240530-1-max.kellermann@ionos.com> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: stable@vger.kernel.org Reported-by: Dario Wei=C3=9Fer Signed-off-by: Max Kellermann --- fs/ceph/mds_client.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index c4a5fd94bbbb..4f6ac015edcd 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -2808,12 +2808,11 @@ char *ceph_mdsc_build_path(struct ceph_mds_client *= mdsc, struct dentry *dentry, =20 if (pos < 0) { /* - * A rename didn't occur, but somehow we didn't end up where - * we thought we would. Throw a warning and try again. + * The path is longer than PATH_MAX and this function + * cannot ever succeed. Creating paths that long is + * possible with Ceph, but Linux cannot use them. */ - pr_warn_client(cl, "did not end path lookup where expected (pos =3D %d)\= n", - pos); - goto retry; + return ERR_PTR(-ENAMETOOLONG); } =20 *pbase =3D base; --=20 2.45.2