From nobody Sun May 24 22:35:57 2026 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 D509D3F2115 for ; Wed, 20 May 2026 17:01:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779296521; cv=none; b=qKE7+S6+aZERCIdi573n6S7CDfy39SBEZ6OYNYwHhQPBjTp+EjAu9Mv1hM2oI1RRgstFvMgg+X6SlqKzA5Di08nW/6ODzVc2G1J4oZ6ZwL7O8XR0ETDycP9wc6NXxp3AvqP8uKJlplMlB7LnTwrKlp7WgB+Pj5VvCxcNe0CJM7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779296521; c=relaxed/simple; bh=/ueMGJeV3M+6NahfGnGox48rRXqZcRqd6BgSiC2a7hc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M0Q05Lu58Z/xI5Mjyj88044GKt9rNxroCri3qluIZzJbIfe6q5tL2toU0tX+8PYgv38FAuloMBhRB8uOv42OhzsYMT49aPiWnQmXIBnXr8lCtHAGZCU7HtM2Kzg5pw6ofh/Wxd8CrX+Ss2gbOmAWcVXd6VnxnrZ1BFrCEyOaLE4= 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=DtmaWfQZ; arc=none smtp.client-ip=209.85.210.180 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="DtmaWfQZ" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-835537a9278so198890b3a.1 for ; Wed, 20 May 2026 10:01:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779296519; x=1779901319; 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=jJ22iTBZ4sCbgDlyf2sEL0oOtpVHxxbzLq25uqVdqz4=; b=DtmaWfQZaFEhYr840qTQN0WrHYRG6GizccDaku3qnglVi5lqFHN8v81D5dom2bITq6 JPqG/gylF69XE2MqqOE1aqFtpQksUAHIkEsspugi8V4l6UzJU/J+C/j6Gey/0dlbcbGO CtRUSh9dnNgNRbuweM8+8oRVlRabprrRXNcX2DjzhUf5YfQAKKAC++VkfxPmPPUwGd2u OT3FbHTk4Nt3/FeK3Df3ieyCOtcFy3BFHiT3o010S+7bKwwCMkSaHKKgAj2zHDLVoWHv wCNgIPt5hZDnrXtQji7p8ov0H+d8WHz9eapasJBTOh07C8JyJxYznQpXrCRejlIyoD7q Woqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779296519; x=1779901319; 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=jJ22iTBZ4sCbgDlyf2sEL0oOtpVHxxbzLq25uqVdqz4=; b=TV/SHYybanptPL++F2ivFMzLPQPGJ2RPC4gACqcg3qZABEPC374z+yMOtO4vHqRRWJ jg2RlIOp0COhOauBVtKzhBZP5dz73thRkRWqkq0BvxC/MfOMAmNXSBSigwaGYVVIYlkH /RAnRfA+b9QxhPNER7i5j1gSwKgS8ARoKqcHYsP5gnlRd6xq3wi3ZUFe8HvstZpdfniw Fk8T4oPUc6T1kLnPCU3K2z4Gx1Ws7b8+2h8tZ8vADfBQU247v1FxtyzdbINKcOtPY3l5 EtX35jafa8r/FjzbpOnYx4CHBrpi+2qii7n2K1FXyOJfpCORNeKk1Rx4aCf9xmDik6yE 28BA== X-Forwarded-Encrypted: i=1; AFNElJ+f8o9D5M7wbxU38I/OZSwqh1wR78hSRP2dk4GrH0Ni8OljOWIEqN5Hmbqqel915s+IkH1ZDTKtpFIJDbU=@vger.kernel.org X-Gm-Message-State: AOJu0YybsIlJKR3hrqu6oNMh6tYNCr/pw1EaqeHuz4ogyqMejbZZMA0z 73xyqNz7b92JwHngECor8lVBMusXhhD3NONGK6Ia/nNkQ+sx4bzY1aIt1KrZiw== X-Gm-Gg: Acq92OGicpA0gASuQfat2D3FsVewx8APPGG378J9KiTfBoNxqRA5W70IEXoHFJTgJ5V 1gsCEF56TuTHO9MKcslI30E00MCrp3HhYRdkdaWAcNnPQYNZHcwKqDD3Nw1mle6rPTXHBfxBxNP Nv1EIA7ed7XezEXYCjEm+d4Sqv1DysxJ9RXnk5t2mNmc3dtt78qma15x6OkbT9KcoHc6PkQ0zu8 MKIcsXtwZzF+/sjKojRaY7eYRTrT8/ZT5hEAVVA3CW0KmzatVgOH+i0t50e4PnQeTO0ld38WmBw Z9YTX7dbUI1oxXgBFvKbKdxaExNd0ZLnaXeqTsDKTKF/JkaZYbj5BDq3Hvel9VMTUYfORiyNycr chj4HgkXoSHswbxCT7XydPrpfsJQaJx0J+oBqASP4JkgX1evQNqGfFyxFS/v+jERlOTn3D1vPz3 YAckGBgxiUMyKzOjlOf+LOIIQkXGM= X-Received: by 2002:a05:6a00:4c94:b0:834:e09b:de73 with SMTP id d2e1a72fcca58-83f33dda422mr13141557b3a.7.1779296518692; Wed, 20 May 2026 10:01:58 -0700 (PDT) Received: from ser8.. ([221.156.231.192]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83f1942a83fsm22125954b3a.0.2026.05.20.10.01.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2026 10:01:58 -0700 (PDT) From: DaeMyung Kang To: Namjae Jeon Cc: Hyunchul Lee , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, DaeMyung Kang Subject: [PATCH 1/3] ntfs: free volume-wide resources on fill_super failure Date: Thu, 21 May 2026 02:01:49 +0900 Message-ID: <20260520170151.4115308-2-charsyam@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260520170151.4115308-1-charsyam@gmail.com> References: <20260520170151.4115308-1-charsyam@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" ntfs_fill_super()'s err_out_now path frees only the volume struct via kfree(vol), leaving several vol-owned allocations behind on mount failure. vol->nls_map is loaded by ntfs_init_fs_context() via load_nls_default() or replaced by an explicit nls=3D option in ntfs_parse_param(). vol->volume_label is allocated by load_system_files() once the $Volume name attribute has been parsed. vol->lcn_empty_bits_per_page is allocated before load_system_files() and was freed only from the upper error label. Move these per-volume frees to err_out_now so every failure path releases them exactly once. Signed-off-by: DaeMyung Kang Reviewed-by: Hyunchul Lee --- super.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/super.c b/super.c index f93f0f8bcc45..6cf09bbe017d 100644 --- a/super.c +++ b/super.c @@ -2638,8 +2638,6 @@ static int ntfs_fill_super(struct super_block *sb, st= ruct fs_context *fc) } /* Error exit code path. */ unl_upcase_iput_tmp_ino_err_out_now: - if (vol->lcn_empty_bits_per_page) - kvfree(vol->lcn_empty_bits_per_page); /* * Decrease the number of upcase users and destroy the global default * upcase table if necessary. @@ -2659,6 +2657,9 @@ iput_tmp_ino_err_out_now: /* Errors at this stage are irrelevant. */ err_out_now: sb->s_fs_info =3D NULL; + kvfree(vol->lcn_empty_bits_per_page); + kfree(vol->volume_label); + unload_nls(vol->nls_map); kfree(vol); ntfs_debug("Failed, returning -EINVAL."); lockdep_on(); --=20 2.43.0 From nobody Sun May 24 22:35:57 2026 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (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 6CD3A3F2115 for ; Wed, 20 May 2026 17:02:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779296525; cv=none; b=BxVoKzZ81NhUmKv98kGG+M5c+FUMy+QQDfUpNbs1qC2pX7mRlXeLy8ZTmQlGvW6qpl4kX94CMLJ2VPTWrpzxx7Cd6NFk5txKstMFXGSjs6N7zgQy41dKHnkcXvr4UgIZFWvCoJ9b+pk977DxJ31zU9wD5FW+TBI/b3buEe5E3GE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779296525; c=relaxed/simple; bh=8URWsIbc9eMr1h4MiC2gKQRQm01Rp5RlLgLSqJKTM78=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aVmbA6ugtyXJ5bOAImkwMnHcFkguCY1esYH9LdU9GffEq6i4Kg8IMelU68Z4jvyDaEgg8ClS6iIvyL9/apJ0DH/sxwuLhWTzmLfQUiYP7TnprruVG3nNv8/WEBZZj3Ee5RXRsxaHcB4hfnp5gVrHcarzW8xekHcLDFVJsOe7d0E= 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=MDI+46cj; arc=none smtp.client-ip=209.85.210.176 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="MDI+46cj" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-83bbc41c7b7so211478b3a.2 for ; Wed, 20 May 2026 10:02:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779296524; x=1779901324; 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=AEkJeL9Z8UZWA2zeOFYFIhYl2cIC1COc0WCjFwNppF0=; b=MDI+46cjm0xUQLUTD31Yw9vAqLrN4oydWqn1sgeQbleQuQKvSHDh7L2zjRMK9C2qiD 9PB2Ki3hZOKnlV8IUH2+gyvoawkJBXej8DhAFaTIWT92PkEew4QVFJKmdMLuKfaJwBMm gXq6AbGF4914iO7UGdOI2eHmyhLgN5kt8I/ReIDUhLfeBNZXN8zvoySdbIYFFD7tqrgY GM90586Rjx5qsCwSedIxgqO5dvce/mt6Tx9/7tSq23hALs+o1WwG4IH00KWm+4lIKa/l nKNvmmTred1PTRk1l3pCvI5haDjBV2B0I0zHnmRjGeUNCM7mKXhFEcATtULDlyaFAp0r gG2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779296524; x=1779901324; 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=AEkJeL9Z8UZWA2zeOFYFIhYl2cIC1COc0WCjFwNppF0=; b=BjoLnwDOoyIso0Jfb0xqTSK+lHsE0LkcfHOl6W4qXyUphyeYwfODu/+4bgf8gXAtnX Cf4PuFeiabNyx0SkFeaxfTFDydSPFjcEWdcaUhk63GYTSDmorsv+6fOwkEcep39k80in uPJuguVc2LMsOYIIoiWi1yzc2UJrURQ3fh4WO5JfuiWqvkiZrNo9a1Xm4woa+YMgbKDe SFczRMZXWtk41+YJh/VnxiaiVXCve1jzAUKzNew2cPBZhc1y4RqcYdF0peoffzcmJM46 aQDfrE8LHGgrcE/gwvWiQrXcwl7/aOhVdxtWTVj7/axWd8g+mwrkW+JIVNPqnXzl+/gB 3/lA== X-Forwarded-Encrypted: i=1; AFNElJ8q8P/84VhhwasSXmM4n1JtB+H8HouoeN2rKCTC8aQIIiy+Tn/6M1hTUK0RhvsN3tESQnUF/PXW1UDTLc0=@vger.kernel.org X-Gm-Message-State: AOJu0Yzv1dMDy11rXBsxOoMqxwIkiAKLFCUCNMDeoebZd2IKoKGXwLuC uedqq/v+umSj326jU1/gP5pR3caiLr8TLV4GUKBr8Ksj5ZWMMu2iBxxL X-Gm-Gg: Acq92OFimgwGahxOGv6S9L3AaLRf++sXI+nmFJIzNbEAck/5nL0gl7h/6Yvz8BheHQQ RnkA/hXh1n18jxuq6SWcZ4OLDxXpv2SyYhvw29SyUZhPQeFUl0XKCbSfH25PvE61lKYmbGTzcJv Wv75ImuCeHge5D5BJK6aY0hPzOmYz7SPOCHVR72WP60temMsTLnZYj9TACBjpkMdfLLDHwKwx4N PZJbmj1g5o6ASZ0xEEluoT8flikkDT17g4u05q3GXydMiEBhCODgKkHtoZ+/2fBBgwJVxKFzatw hAlhlDqzNL/E3F4D+u/FlRO1KIqFVtb9EmhETv2MDVvzp4FUvG2n/pa9NvO9UbCds8Tt5YkicEc yIwuAO8aYPxU20mkRrAEiMnPG6g5HI3qLSowWKT1qz5t+63WyjeauI5e8lFn/ X-Received: by 2002:a05:6a00:2d95:b0:839:6474:c69f with SMTP id d2e1a72fcca58-83f33dd90e5mr13115560b3a.7.1779296523693; Wed, 20 May 2026 10:02:03 -0700 (PDT) Received: from ser8.. ([221.156.231.192]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83f1942a83fsm22125954b3a.0.2026.05.20.10.02.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2026 10:02:03 -0700 (PDT) From: DaeMyung Kang To: Namjae Jeon Cc: Hyunchul Lee , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, DaeMyung Kang Subject: [PATCH 2/3] ntfs: wake free-cluster waiters when precalc allocation fails Date: Thu, 21 May 2026 02:01:50 +0900 Message-ID: <20260520170151.4115308-3-charsyam@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260520170151.4115308-1-charsyam@gmail.com> References: <20260520170151.4115308-1-charsyam@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" get_nr_free_clusters() is run from the precalc_free_clusters() worker queued at the end of ntfs_fill_super(). It is also the only place that publishes the result by atomic64_set(&vol->free_clusters, ...), sets NVolSetFreeClusterKnown(), and wakes vol->free_waitq. The initial kzalloc(sizeof(*ra), ...) can fail before that publication happens. Callers that need the free count wait on NVolFreeClusterKnown(), so this failure can leave statfs, write, and allocation paths blocked forever. On the OOM path, publish a conservative free count of zero, initialize the per-bitmap-page free counters to zero, set NVolFreeClusterKnown, and wake the wait queue so callers fail with -ENOSPC rather than block forever. Signed-off-by: DaeMyung Kang --- super.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/super.c b/super.c index 6cf09bbe017d..c90cb5673f98 100644 --- a/super.c +++ b/super.c @@ -1980,8 +1980,23 @@ s64 get_nr_free_clusters(struct ntfs_volume *vol) return atomic64_read(&vol->free_clusters); =20 ra =3D kzalloc(sizeof(*ra), GFP_NOFS); - if (!ra) + if (!ra) { + max_index =3D (((vol->nr_clusters + 7) >> 3) + + PAGE_SIZE - 1) >> PAGE_SHIFT; + + /* + * Publish a conservative free count and wake any waiters; the + * NVolFreeClusterKnown flag is the sole signal the wait_event + * loops in statfs/allocation paths use, so failing to set it + * here would leave those callers blocked forever. + */ + memset(vol->lcn_empty_bits_per_page, 0, + max_index * sizeof(*vol->lcn_empty_bits_per_page)); + atomic64_set(&vol->free_clusters, 0); + NVolSetFreeClusterKnown(vol); + wake_up_all(&vol->free_waitq); return 0; + } =20 file_ra_state_init(ra, mapping); =20 --=20 2.43.0 From nobody Sun May 24 22:35:57 2026 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 048413BED1E for ; Wed, 20 May 2026 17:02:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779296532; cv=none; b=k9RxDW757C2pJbrYYBnOSr366c3FU5IDdXF0fSPnGZLkTGJ8Akfax70KeWqcgldLS8nsLdI83+o89fKXYSxLs79xc7CiZ2NQP+dcMUDjv18s1fvZ1gxHhrAhAmboBzqEnOh69aiGo0K51cGSItN5t6O+WrFjAMD6qKxQl9DNh98= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779296532; c=relaxed/simple; bh=O6G8WdCik1llgicpPWOHlMhn4UH0TvFLdwTcDPDeTxc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HuDouMHgMcWZLFwewzL/1pHS+wsOCbAtFNDaN5HfS/L9lXib4fPuUvbCC2KTRVmJFwYHwLbjB78wLjktsk/Wq/xIWV65DW99DhKw+2TKswn6p0lCx9f5KoBOkeqlIhEsAyrxXGKRfoIeRYV86h8tzMZ+SFCtINUQ0vy6w83s8Xs= 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=lLWssbL7; arc=none smtp.client-ip=209.85.210.174 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="lLWssbL7" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-83d53f307fdso181792b3a.3 for ; Wed, 20 May 2026 10:02:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779296530; x=1779901330; 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=Isi+zER6DUs/rJzPlPArDIqwo3ghYelS1e5SbW3Q7HY=; b=lLWssbL7MqLchIaJxHv61XneXA7J+PhyI3L0DD28xCVwc8uLluYiH7BjkUK/jBJLCF T3pjOw37Mdp9nzbisDLHybO3HsqkUdWqbfKMJ0ZoI6dp1GrM+zVCUUkEB+WrVsvN1TsM +4O7bAbb5+OBd2986whFypWN7rZyVHQT0RQWrJ9rOd3koDmV6+uM8UYNqeQcb2kQXl5J mvwCjxWUNsq37kSKacikYkV1y+lBKs5J65vxNHZYPOjlzXPfPHV9kfdz23kkAlgecLoD k16XTA0qnu/T3x2OVhf58/5xlmf9NhYxRSXPNPa3P/CiT2BpSHMnGgfu8YEanM0OCG9L 1/kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779296530; x=1779901330; 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=Isi+zER6DUs/rJzPlPArDIqwo3ghYelS1e5SbW3Q7HY=; b=cw72VQYPK28jFs3mRFi9HUGXDGT21GG66udzro0QbKz7LlN2qgPVVK54koFqvfA+JD 25TQWmS+eH5ldzQ0/rrY0EWKeIgNMr3fHH3dEOgL2StEVenSKiiInHVIaB8LWxDtIN6E 2kfRBux98rVnaOSzyR+EqS5q02Iah3Tls+XCi8ci0Ui8hdH2WS9UmdT21nWBtqck9X0i eBEhbv/KUilpSlEEjmuQ03JwUvxVa+d2OffB9gIYfdaeSErVwQN8qA/lXSRxtp9w7Dw2 qREA4+sU9g/TxopSPKDYsa4jPhSU6KMAVPzfqwsNiwMS3vbudQ9Gzx/GPR7cQRLwBKtM E/Gw== X-Forwarded-Encrypted: i=1; AFNElJ+W7KpwNNgxm4vgEcb0PZlpGR9Vr9q8GwiCNxCIkklQgVXdYwHLkp7mNSmP2sef7F0zyxZpBsp3FGfnDoI=@vger.kernel.org X-Gm-Message-State: AOJu0YwEiGuWEILyQmG2LT8RG8RY1x+kfbG/DW62kTZ8Xss6a9DvbOoZ XVhsHyZJjabacAK7rGmu7ca80NQCOg+ReBciLwnAjDjIWeiw6SLPQyHk X-Gm-Gg: Acq92OHJgToTRBErhj+GgXj/FGM8KiVMN6RdJJroySDRLEuKIbLs/eHLn28b+TN8Gzy fFqWqIiRqlwu+Ep7jPXtCR3mm52ihCngYchtREqFTI/kiICQQUgonh9WdRa7lk+8rNw+vs73KIn kc1CrPMslBFKqeGXkhqXu/4A7UvS/TowFFqN3AA9+Hif6inMuQrYf61uDOmZPvoTUmsE1SgOniM 8mm3Tir5i1nfZDzjJwHyaA/wHsS4f2aTxbkOmfE1osNe45ePSV0kabZ3+UCNSAReGzcQlQM3qSS 7VAzvThovwyoyo//V9CF6i9Q/npM4SXGzYmgdAepehaWDpKwStBN/NDGDk14Bsm6DU81QO0Dvxe G2gIHiG1l9JGgG7eeBcVkKPMlY29GpZbkzy7tUnI7Iulhgh+Hbg== X-Received: by 2002:a05:6a00:2d8a:b0:82d:1faf:775f with SMTP id d2e1a72fcca58-83f33da4fbfmr13178543b3a.5.1779296530240; Wed, 20 May 2026 10:02:10 -0700 (PDT) Received: from ser8.. ([221.156.231.192]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83f1942a83fsm22125954b3a.0.2026.05.20.10.02.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2026 10:02:09 -0700 (PDT) From: DaeMyung Kang To: Namjae Jeon Cc: Hyunchul Lee , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, DaeMyung Kang Subject: [PATCH 3/3] ntfs: only alias volume $UpCase to default on exact match Date: Thu, 21 May 2026 02:01:51 +0900 Message-ID: <20260520170151.4115308-4-charsyam@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260520170151.4115308-1-charsyam@gmail.com> References: <20260520170151.4115308-1-charsyam@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" load_and_init_upcase() currently aliases vol->upcase to the global default upcase whenever the shared prefix matches, and then truncates vol->upcase_len to that shorter prefix. The result is correct only by accident: upcase[] accesses in name collation are gated by upcase_len, so the prefix-equality alias produces the same fold output as keeping the volume's own shorter table. Still, prefix equality is not equality: the volume table is logically distinct from the default and should not be replaced by it unless they are byte-for-byte identical. Use memcmp() to compare the complete table in one expression and drop the now-redundant upcase_len rewrite. No user-visible change is expected for compliant volumes whose $UpCase has exactly default_upcase_len entries; shorter volume tables are no longer aliased to the default. Signed-off-by: DaeMyung Kang Reviewed-by: Hyunchul Lee --- super.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/super.c b/super.c index c90cb5673f98..811640cf5669 100644 --- a/super.c +++ b/super.c @@ -1344,7 +1344,6 @@ static bool load_and_init_upcase(struct ntfs_volume *= vol) #endif pgoff_t index, max_index; unsigned int size; - int i, max; =20 ntfs_debug("Entering."); /* Read upcase table and setup vol->upcase and vol->upcase_len. */ @@ -1405,16 +1404,11 @@ read_partial_upcase_page: mutex_unlock(&ntfs_lock); return true; } - max =3D default_upcase_len; - if (max > vol->upcase_len) - max =3D vol->upcase_len; - for (i =3D 0; i < max; i++) - if (vol->upcase[i] !=3D default_upcase[i]) - break; - if (i =3D=3D max) { + if (default_upcase_len =3D=3D vol->upcase_len && + !memcmp(vol->upcase, default_upcase, + default_upcase_len * sizeof(*default_upcase))) { kvfree(vol->upcase); vol->upcase =3D default_upcase; - vol->upcase_len =3D max; ntfs_nr_upcase_users++; mutex_unlock(&ntfs_lock); ntfs_debug("Volume specified $UpCase matches default. Using default."); --=20 2.43.0