From nobody Tue Dec 2 00:25:45 2025 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (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 417E13148C4 for ; Tue, 25 Nov 2025 11:07:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764068827; cv=none; b=PfrKKZf2ODzCCxNQr8C/GKA/+i2dPYng1qTbnesQao9nD4ZJ7EFKrKNabDNgbumrWl0HGX8VEA9yXbAmPwhQCcKbt3kckcWNN2cfzc156trZr36yNfbj6HTb6ueaXv54KjRnW5P8SyAwcM/ZzI3GfnbmTG+6bGdPmeIrToXvbK0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764068827; c=relaxed/simple; bh=L9HPfnmCaa9Wx+qV68LGk57WzAw5+2CezY0Arw9lXZ0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HNU0sRn4s3WrveCzUo7KVoW3rByCuwGes/Q1TWJs+TrXo7lRVZe4zVp82wQRZ+zzza/bfStoiEOtH/WBZFeqyuD5xGhl0Qv7CBO2a/l7hFKC1ijvg7GF+R5qiH6/kARMA0UWOmwhc06lZRXiHnc59tGjw4r/MCQLFKmTbK81X64= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=V/3ZxB/w; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V/3ZxB/w" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-7b7828bf7bcso6591166b3a.2 for ; Tue, 25 Nov 2025 03:07:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764068825; x=1764673625; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hdqtBr6Mx6sSTGEgWgcW+ye1nlIlewHMmFMpzodq+Tw=; b=V/3ZxB/wI66MxI4etCGRB396pcYFFvt2yLzqZUCjoHpvx1GpW+ouV2r+PAM982h4W+ BRD2cXTU0ha3sNz9wsBo6fre7bo62FmkU65fvwpaa/5UbIJRrUp2iRoJhzYAcTGCgHXI cEjIobVWucm3Cd0wpahE2sj6Yb7ypBxvZSIKfbxSNyZHXGcZaMXqnUp6d95J7KgV8bo1 VmvLYg6ZqCW+VoKbd+wRIiAwOqXvjbZJXWB5dhBV0AUKOdu3ww4HNGosf1RNQ4Gk4Zpl nzxiBKrXNtg+bF2As83uAPFv6Aq9E9nAnp8UxduXDR5PrPVymEgBkGkbd2QdAcHcaCK/ mt9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764068825; x=1764673625; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=hdqtBr6Mx6sSTGEgWgcW+ye1nlIlewHMmFMpzodq+Tw=; b=ilzMKmTuBhGw0QWQn+KXjVVzvKS117GhCoKeen1iEEaLdLc3cNIbLd3+rFEoCol0eU DSaUfsph/9ajxyN9/Vm2M9L8VnqTjn+N0iDKkVMoQuDAnqPw0c9+7BvvpLoKYjNvHdZY Yv1YOCoP9QngKYYfx0Y89sHqeDWSZhZPTSh1U2usE6HtwJFlQPOXn6N7AS0tluIF1AV8 MJ7LhRUREv9fzmG7gSXWoG5MJSGQ/FX22i2caprmjDoh67pPyl0MKi9U2ASkb27pbxEG m25avQMbJAjKYPfkhIQaf3MVBw2oGBE7AX0aQ3sF/NUFDPUeKzbTbG5wMd323MgqSOw6 YfaQ== X-Forwarded-Encrypted: i=1; AJvYcCV5gLeIuqFk9qj346F5HD/u4Bce9US7Szf0qWgsPE0jMp2x5UC7AAHcchCFzRcnLqGo2AS+j/Qxafp1Gtw=@vger.kernel.org X-Gm-Message-State: AOJu0Yz6XimJCnrIF+0Nr95jp2KMFLfI7glZR9WDpjNlonEdhxBaDJUB ffYW2xn3RmlfjR9oLzc4l8b7Uk6dSiqKGwe0FimaG7Fa/m331NwXr5m0 X-Gm-Gg: ASbGnct4ItNjvWvN2yBpeJgBanBONa4z2b+vDO+4ANsAxpFW8D+MH98ZADeFPFBmUIO xPE6aBe9yXCnRxso8ZXlUlxN2UUfxEKN9AhmJHurMmxD12CZZncRdvFLudpAA2dv6rDFdY5xyo7 xMLSQhac7AaA8trrI2fMgzwTDKxHl/5z7v7rNeBtDHv+xFvTsnaK6ij2ax7dspCxPiy6BOj+5vN 1zmudoi455FFrYLFP6UPWx0QjR8xC4Mz7FiMkTHd8QR8z+oKnaFN1tq91yMb00G67owssz2f8Tt rCTxptJQz2Pd6P/pKvcTPUXzKSwBaW6VU4SuVlL+KqhAhiwy0d3lNXiBdChgNCRk7biSRQ84jJ9 s3IlFWTZkWOTNE1bhSW0QVjoM742gozKemENQ4ltfqRZIeFDMh+2RVNF3Vu70+IOgSwJQTK2dxP EfZR8swaY= X-Google-Smtp-Source: AGHT+IEBoZOJ3Du/HVGBmLdKe9fbLVemr1Gp9nIx/LJjBWtf9/MgyRHnPkMwn9WTCnAD6lZf5wXDWg== X-Received: by 2002:a05:6a20:a111:b0:350:7238:7e30 with SMTP id adf61e73a8af0-3614ed3e0ecmr18830825637.35.1764068825329; Tue, 25 Nov 2025 03:07:05 -0800 (PST) Received: from hsukr3.. ([2405:201:d019:4042:c1a3:cd97:974e:2371]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7c3f145845csm17743758b3a.61.2025.11.25.03.07.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Nov 2025 03:07:04 -0800 (PST) From: Sukrut Heroorkar To: Jan Kara , linux-kernel@vger.kernel.org (open list) Cc: shuah@kernel.org, david.hunter.linux@gmail.com, Al Viro , Jan Kara , Sukrut Heroorkar Subject: [PATCH 5.15.y 1/2] udf_rename(): only access the child content on cross-directory rename Date: Tue, 25 Nov 2025 16:36:36 +0530 Message-ID: <20251125110638.15758-2-hsukrut3@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251125110638.15758-1-hsukrut3@gmail.com> References: <20251125110638.15758-1-hsukrut3@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Al Viro [ Upstream commit 9d35cebb794bb7be93db76c3383979c7deacfef9 ] We can't really afford locking the source on same-directory rename; currently vfs_rename() tries to do that, but it will have to be changed. The logics in udf_rename() is lazy and goes looking for ".." in source even in same-directory case. It's not hard to get rid of that, leaving that behaviour only for cross-directory case; that VFS can get locks safely (and will keep doing that after the coming changes). Reviewed-by: Jan Kara Signed-off-by: Al Viro Stable-dep-of: 6756af923e06 ("udf: Verify inode link counts before performi= ng rename") Signed-off-by: Sukrut Heroorkar --- fs/udf/namei.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/udf/namei.c b/fs/udf/namei.c index 5e39cbc74524..f4aded54a994 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c @@ -751,7 +751,7 @@ static int udf_rename(struct user_namespace *mnt_userns= , struct inode *old_dir, struct inode *old_inode =3D d_inode(old_dentry); struct inode *new_inode =3D d_inode(new_dentry); struct udf_fileident_iter oiter, niter, diriter; - bool has_diriter =3D false; + bool has_diriter =3D false, is_dir =3D false; int retval; struct kernel_lb_addr tloc; =20 @@ -774,6 +774,9 @@ static int udf_rename(struct user_namespace *mnt_userns= , struct inode *old_dir, if (!empty_dir(new_inode)) goto out_oiter; } + is_dir =3D true; + } + if (is_dir && old_dir !=3D new_dir) { retval =3D udf_fiiter_find_entry(old_inode, &dotdot_name, &diriter); if (retval =3D=3D -ENOENT) { @@ -859,7 +862,9 @@ static int udf_rename(struct user_namespace *mnt_userns= , struct inode *old_dir, cpu_to_lelb(UDF_I(new_dir)->i_location); udf_fiiter_write_fi(&diriter, NULL); udf_fiiter_release(&diriter); + } =20 + if (is_dir) { inode_dec_link_count(old_dir); if (new_inode) inode_dec_link_count(new_inode); --=20 2.43.0