From nobody Sun May 24 20:33:33 2026 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 ED22C242D7F for ; Thu, 21 May 2026 13:00:26 +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=1779368428; cv=none; b=nrsmRpMbu9/xbOZfG/bQ5LGARtBahZdwlO82qsYl9R4AQ30o3bBxHVYOjMwSfb1bgegUWhHOZ2PARPQbYtT1iVQSj8kBxVhVvsEaS7zzrmAMBtboK3ovS3oc/cNwxvyx2YZG3+rt4bil18JlBB4di47SCanXQLgNop07FZep4T0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779368428; c=relaxed/simple; bh=akiy8XbXXAmzoEjb5CTW4EvpRBclQq/yv9STTM4bqds=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LSHotb1fV7bcS51a73iS2WGytZy7ZjWpUmw/24sQEkrsmkqTLm0R3A/TfGmyjZHLMzBfK10zEibYFph1l18Kj6EBIDDTQc3KAQc7JJmw0oiysTCnJP5lTFUHoOvS8p/eRwTMaAJ9xOREVkyh1ttIqyPKYcNriznaOGtAeL/dF8Y= 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=YUWcenCm; 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="YUWcenCm" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-835537a9278so221645b3a.1 for ; Thu, 21 May 2026 06:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779368426; x=1779973226; 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=IZYoe5azvMeyE1oweizu90sYcZTKsPgj4BdyeNWmQpc=; b=YUWcenCm7I1RyO25qeVbe/xBMFq212XlxCxdtws6MInIi+GDiMznJcqVf9C/AjpWfa iTi/h0YOUv/h04hSYVbeeQFVWahpOzcSluzmr0QQn2Mi7oUvPO1DygaqH+Fs/QWKHz9u I4aBoXjTOc9U+n95NfOXYylMcgKo3meO1iBCTQLhNNQd3Gjtkdgjohuz4HwXDCAs4Miu aX7y1a1q3M7cMEh0crr2zbMezS+9Yb8JCRTwx6ztBXLIquTpf2fH15I+KChUT4wylnb4 thGyh62PYZ3GcLrtsQ9zE9AtRiUNc/FAauMYwVhO/e9CZXgqj2Ons0qJojj8LfU9ls6Y /ugw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779368426; x=1779973226; 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=IZYoe5azvMeyE1oweizu90sYcZTKsPgj4BdyeNWmQpc=; b=URXRvNB/UEQI0+h20VY1CTtmqSQDM7GEC7MGc4JA5gA2tfSrf5UimznR785h6Rorvo Ewi6gG9wS+GaWLzOqDg/2FbJ4u8FEnrjZfDxh/r5i0Z60mHqKAUjh01wgodq1SBiY01O KzkU2pG407e80xja35gfkV0rKdpxMKsFeHZHqTntwGHABdUkzBlnumGW+5zrOzpIj8H3 eRQ/OsbsUZpdTsI1pR/TdYgGJbRpViACuDICWQMCNKY85dySyhcvWc40m3TqEi4qp1mt SWPe+tLVFT4I4oB7RIKs4iPRiouviDrcl5gOy+1QzK62qIORSGzm+mVCEzcPLudIwZKz 8ijg== X-Forwarded-Encrypted: i=1; AFNElJ9rowFFMH8Z7P5X+/EnrK7qxr0+RqOZMs973bVf5WMLZafox7IYaOSr8oYBbqStSRRrAls8VRfk1EW/AVA=@vger.kernel.org X-Gm-Message-State: AOJu0Yzs6qYdcgXkFxj6t4VTDBtb195VcuzdrIzByrvsGcb4rsqOTWqd SUosSIBKjkxp5ev09QPX8EnvDIgtGsiZe3hONNNDBUrlXH/QvIq3Ey+F X-Gm-Gg: Acq92OHdLZm5in0p+X70KRzk48opZlmEgjJLy4c5dD5vsrNK+Dga3YkfrPeEfXHYsEP waRBlocAKawZEa8oBDar4d5bLitY1Ep89NozquUCB+WSF1ud4FJV8BImb7xRmaWd9cAtGlufTc2 SKF7umHPfyZ9Jz/v9i8vQACbLrxBZ2lQK5j5WD31HPkjFTyGY5xoY22d3TnlOFAeefQQIJAcB/w CEOoT+38Y04cGrJMxC2yeDmaXapd+tLGpml8A7TK9Sy/jGcJ03rzZjpRdkp3npDjkvdaAEOmPci 5soinw6lz8vlFZoYzVIgPJt3yWtrnulSexbLxFnjbErTFE9FdPA14EwQ5K3KQIZbPjier7iTYtS bw9FtONJY/OfE1eR4Q3e55hKtiUfl7nIKHYNm0FwPVT6Il+3K9SOOOokGu2IaxmG+vuukNLJBpW bzEjfpa+d813lBY7Fe X-Received: by 2002:a05:6a21:4c03:b0:3a1:6a7c:dba5 with SMTP id adf61e73a8af0-3b308789ba5mr1883422637.6.1779368426032; Thu, 21 May 2026 06:00:26 -0700 (PDT) Received: from ser8.. ([221.156.231.192]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c851993d8a7sm284340a12.27.2026.05.21.06.00.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2026 06:00:25 -0700 (PDT) From: DaeMyung Kang To: Namjae Jeon , Hyunchul Lee Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, DaeMyung Kang Subject: [PATCH v3 1/3] ntfs: free volume-wide resources on fill_super failure Date: Thu, 21 May 2026 22:00:15 +0900 Message-ID: <20260521130017.713848-2-charsyam@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260521130017.713848-1-charsyam@gmail.com> References: <20260520170151.4115308-1-charsyam@gmail.com> <20260521130017.713848-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 every mount failure: - vol->nls_map, loaded by ntfs_init_fs_context() via load_nls_default() (or replaced by an explicit nls=3D option in ntfs_parse_param()), is never unload_nls()'d. - vol->volume_label, allocated by load_system_files() through ntfs_ucstonls() once the $Volume name attribute has been parsed, is not released by load_system_files()'s own error labels nor by the fill_super() inline cleanup that only runs on d_make_root() failure. Any later failure inside load_system_files() leaks it. - vol->lcn_empty_bits_per_page was kvfree()'d in unl_upcase_iput_tmp_ino_err_out_now without clearing the pointer, so it could not be folded into a single common cleanup. Because the failure paths never call ntfs_volume_free() and never reach the d_make_root() inline cleanup block (it sits above the label and is jumped over by the load_system_files() / kvmalloc failure gotos), these resources accumulate per failed mount attempt with no chance of recovery short of unloading the module. This is a silent leak: the inodes loaded prior to failure remain hashed but generic_shutdown_super() skips evict_inodes() when sb->s_root is unset, so no CHECK_DATA_CORRUPTION warning is emitted either. Move the per-volume frees down to err_out_now and drop the lcn_empty_bits_per_page kvfree() from the upper label so the cleanup is performed exactly once on every failure path. Using unconditional kvfree() / kfree() / unload_nls() is safe because they all accept NULL and the upper labels that previously freed nls_map (the d_make_root() inline cleanup) already clear the pointer. Signed-off-by: DaeMyung Kang --- fs/ntfs/super.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index 9e321cc2febe..7e3561265b47 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c @@ -2530,8 +2530,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. @@ -2551,6 +2549,9 @@ static int ntfs_fill_super(struct super_block *sb, st= ruct fs_context *fc) /* 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 20:33:33 2026 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) (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 528A43DB33B for ; Thu, 21 May 2026 13:00:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779368437; cv=none; b=VLND4oTl89+dgzEFx9+d9ZW9v9y+0nI2TlXXBDzdJKL3TWmn2jTjLA11/MRWRQFZLcWr3cJYK4H/KUaLGrE9L+ARmq0Cm3NDhGyMEvr0lX/eisoSzqD/YZA/VktXrSblPTuZu1wDTRr5XMybWRet1QlFZn92O0NFZivN72ue49g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779368437; c=relaxed/simple; bh=x/2x0r0BsLDAdOTno6N4SEpYiLbcdWoIiiKinLXvW9M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bw0GhzrESatYUIUzy7vhxClcmcsTYy3hd1U850UKWvi8Pu56sltmn5EeARqnyvFsUtDw4ZcqqNdbWelSI/0dlAUBKSEYXQSSt4JaeRnPwLJZgO5JSGrb6jY7AK0mq+O6TS5AtOKci0yYasKTfIe/dytcYcT4t+aguzxN9qe8b8o= 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=dy00ls3+; arc=none smtp.client-ip=209.85.215.179 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="dy00ls3+" Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-c8026ca8365so303622a12.3 for ; Thu, 21 May 2026 06:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779368435; x=1779973235; 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=bcTSmoZSiShVO6fj/a8g1RvNK8Nfba3FyLnR3wmldOM=; b=dy00ls3+HYQVcaB+rZ2HpNDC6ZezfqZ/lc1mjHjXhjT9mIqwSiAu7STCLU+FEbjrKz L52zPqsCMQEhMT68qy57rg3JqbExSM+KqaFTkLTEIgPljfy8xcoRRldQ4gG+zObemjHZ aBMBvSQWodTN5fBFAYbmom2UGoDgRd9Hr8gfGTdgu4Gr3Hayv+RXIT60gGPVD6RchTZ/ sZhhzwOvvyoEBNHMcsa47XJew3rCYBSuW6i9zbdfCkzQGoCm+AuirB1Qd8tx4I4xRgj5 F4n5/Yf2a0LmbKtd3APJp1OzoJff0urfcuRQ36cCuoyRqBndc/fLSd6ADvB7FS4cMdyR EJ4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779368435; x=1779973235; 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=bcTSmoZSiShVO6fj/a8g1RvNK8Nfba3FyLnR3wmldOM=; b=J6kKtHTPC3s4RqYdLcVb6eve6muCmL94NHIMdhReffEhydTo74huyKvj+xcw7mkapR AS5knTpoulXKZxjFnilhCjxN3ZSiCDfRljkEzK5jwm2e2XqUhmUpycJtdc9rdKMYGw3I E2fNo3inrr0r4j9jp4427TivuqWK7QHz7D7a1oxrD2+m9E+aPP5ug4DoQ9zhKEAbX/+R lXAiktwUiqhHilz2R//Qo708IiEbfucoLz15dZaq9zD4zKcHYE+8FJywaUrkUrE4ijir uvTXagrvel9FZQWZY/iXPn6NSF7qHqjvJSc9f+m+TyZKNcIBp7GbRqM5D4E0+7/jBizy SRZw== X-Forwarded-Encrypted: i=1; AFNElJ9SJLs/85G+Fzrgb9SynE48ElgkzzWR/vvM1WK0WSu3QX3gjF5v5Zj96zcs2diS8Kp8vyejZVK7JTkf+YE=@vger.kernel.org X-Gm-Message-State: AOJu0Yy5BPAfrilW8nWFokmCDrKqGJQEKFCdslWyieotK1ztA7CUh4Ap /YpECFwT0eVqpEBjN+RY6dNStoM5ODwXopJ7Xa9WAigaTSL94/V1SjkZ X-Gm-Gg: Acq92OHnM3RJG7O03LIaxywWPfhrmo19CMqQJsZEuOiISjE+O6DNGyL3UM3Da4XgEDC mCpli1N6jBKjq93vHoQTHvrfcOcK+Q6AUc63RaYwa7xT7XXTj/S7/fpX6cqu8HUQlx4sfYwQlJX GpWpeS2zq4Iqbce/Dr2ofBMWEexUi/RE4p3zCZhDkViqSV8NZm13Ec4gz5wMgh1mmsHEdbgamK4 PwEU9gy7Ct/bykikowW45CHS0ZCxtFnmXFBTvS2R0LMSmXfhVc94+ye1prS3Q5AeV9Ckc0DkO69 pJsbAHVBmfMsMQlJ/9IO5DmKdQ/iCersbxIj3o8bEhkQKUDcy4Wkz5HV+LPRHBwz/eZY7P2pSCa 8bJoMZM9X/6nxEKo9tMc0tTb+nZU2ZePCLLZVxb0Df3fLK+QbpvO77NCRKQoRKvrcxsEKBwwrxj gFZUWXBkxHoJdYSf+q X-Received: by 2002:a05:6a20:c98d:b0:3b3:203b:3068 with SMTP id adf61e73a8af0-3b3203b386fmr246779637.7.1779368435382; Thu, 21 May 2026 06:00:35 -0700 (PDT) Received: from ser8.. ([221.156.231.192]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c851993d8a7sm284340a12.27.2026.05.21.06.00.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2026 06:00:35 -0700 (PDT) From: DaeMyung Kang To: Namjae Jeon , Hyunchul Lee Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, DaeMyung Kang Subject: [PATCH v3 2/3] ntfs: avoid heap allocation for free-cluster readahead state Date: Thu, 21 May 2026 22:00:16 +0900 Message-ID: <20260521130017.713848-3-charsyam@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260521130017.713848-1-charsyam@gmail.com> References: <20260520170151.4115308-1-charsyam@gmail.com> <20260521130017.713848-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 function currently allocates a temporary file_ra_state with kzalloc() before that publication happens. If the allocation fails, get_nr_free_clusters() returns 0 without setting NVolFreeClusterKnown() or waking vol->free_waitq, so callers that wait for the free count can block forever. The readahead state is only used synchronously while scanning the bitmap and struct file_ra_state is small. Keep it on the stack and pass it to the readahead helper by address, eliminating the early allocation failure path. Zero-initialize the on-stack state because file_ra_state_init() only sets ra_pages and prev_pos. Signed-off-by: DaeMyung Kang --- fs/ntfs/super.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index 7e3561265b47..d2c4fb6ea0d4 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c @@ -1954,7 +1954,7 @@ s64 get_nr_free_clusters(struct ntfs_volume *vol) struct address_space *mapping =3D vol->lcnbmp_ino->i_mapping; struct folio *folio; pgoff_t index, max_index; - struct file_ra_state *ra; + struct file_ra_state ra =3D { 0 }; =20 ntfs_debug("Entering."); /* Serialize accesses to the cluster bitmap. */ @@ -1962,11 +1962,7 @@ s64 get_nr_free_clusters(struct ntfs_volume *vol) if (NVolFreeClusterKnown(vol)) return atomic64_read(&vol->free_clusters); =20 - ra =3D kzalloc(sizeof(*ra), GFP_NOFS); - if (!ra) - return 0; - - file_ra_state_init(ra, mapping); + file_ra_state_init(&ra, mapping); =20 /* * Convert the number of bits into bytes rounded up, then convert into @@ -1985,7 +1981,7 @@ s64 get_nr_free_clusters(struct ntfs_volume *vol) * Get folio from page cache, getting it from backing store * if necessary, and increment the use count. */ - folio =3D ntfs_get_locked_folio(mapping, index, max_index, ra); + folio =3D ntfs_get_locked_folio(mapping, index, max_index, &ra); =20 /* Ignore pages which errored synchronously. */ if (IS_ERR(folio)) { @@ -2024,7 +2020,6 @@ s64 get_nr_free_clusters(struct ntfs_volume *vol) else atomic64_set(&vol->free_clusters, nr_free); =20 - kfree(ra); NVolSetFreeClusterKnown(vol); wake_up_all(&vol->free_waitq); ntfs_debug("Exiting."); --=20 2.43.0 From nobody Sun May 24 20:33:33 2026 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) (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 ADED63CE0A8 for ; Thu, 21 May 2026 13:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779368440; cv=none; b=Pfg3FnsSt/H7CmR6tfSmltMTBuM0rt98MWY6/mmF6Lkhp0VoICoa4miAR5iQYQokKdhz8A0ZkIsTk18zxxrtaT4Bak3IMXUXKZp+aQPYrlgxPtXww+T9P5zjd6z3/HWql0k2F1kIS81gqJYSFK3Eygo9275Qmh3SQKIuYGTGp6k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779368440; c=relaxed/simple; bh=/DWc/21g9inXKmvGrguCVoASZnB9td6j3vz+VAB4B/M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LgXSVI6kpG8GhHZE5/GujcuVmdOCJ3yuNp6pF3gIjR3PO+vPsdSc3f/oh1nTRNq93Od3ecyMnK1+mZ/Cm6LkkTbmmgaKgRJ941uNWlpu/HT0up857vM+oxDeKrciBBMA6weiQGzOk4ASnMXKgM6NoShFjCHLCBG6oHDW5SkjBZg= 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=TQClNk0C; arc=none smtp.client-ip=209.85.215.179 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="TQClNk0C" Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-c7979304c0cso529492a12.0 for ; Thu, 21 May 2026 06:00:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779368439; x=1779973239; 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=pO6x8dH77Fth79N5r1T9JUIJlEWo1Lrxw0QlFm833hg=; b=TQClNk0CmoD1dJ3ZD+EktTNkfFCbDcSHom3n3lYSwXV72aXHPJ7HreWUFncTBYk//y 55ZgWT5KUuZq6NKl0rZGOs8OBUBu3zgsdWHNcqsnu0y8EYuDBe7O6SfiaIaJqC/oFk+7 bMmJcOz4pbGwZpJamg47dBjlBF/RDlcyfTGmy+KglmQtQOmXV9PEb5TYwXaaL2/o6Y+Y zvNvGi8IsrLSZw54NrC18e+sYTJ96w07rvxdvI7t45+wjYgYscYUfGX5Hkkff1PfXb06 je0j6oekCWz2P+pRWVL1TWlpztEfRdxfpILLpeVTAkfZj8PXiTJOOWAA3hM68hKuJpM8 RQrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779368439; x=1779973239; 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=pO6x8dH77Fth79N5r1T9JUIJlEWo1Lrxw0QlFm833hg=; b=Cc3mfa/0EZgXJl1RT1Z9Xapj+h3k5NZxxWKU3eDLw1xQeD07OMgI1/njxCFmewOrt8 b8zej9jJhxx7rEpuEI9jfTBjtZRmpJsfO9HStTNBh02HcTuAy0G0396QyKl4zulwvZ1I uZxeVJGjuVRlZmEchMrbyu1d7qDSpbCsfQzlK3PWDkiWm47bWqHUuWle8sq3n9sejOZO Akc1oz8ucuVuUHmydLauCqWTO1MvQZCsQaqBEqlBeYs2nSq0JPFWujZUF6Kuk1U8rgTG 19a6TAJ0FFeSf0RLed3kh8jol9BPDW194+323/Kv5lGZz8QHB29qj8JK1GE6pn7LRSFU J0bg== X-Forwarded-Encrypted: i=1; AFNElJ9QQ6bk09jG7Jpw54clLIkx10Wsf0GcD+jdv5o3P53c3J7xJQGeeviaUCz8551sjea2xP9YJDbRPyJX3Ps=@vger.kernel.org X-Gm-Message-State: AOJu0Yx86rxoI1WDnL9W3IBE3pb8vMqSXZZ0Ho32LH3v3ZdMNS6PlD7S q+yxAU/NX4YFGd+Im+WRJOtvRrAI97gTj0V0oXSwaXxijQrnORp2kb5k X-Gm-Gg: Acq92OGjrjkjMoXhICjf4f9APiWayMLPAdV+dDW0Yxmra07kEqAJnKQ6tySfJc2Xlmq HSWfazgzU9cjGAPFtVh/ruTWx0jgBr9mNM4RxOaluoDAyQMOEhAz0ZpIpY4L90pu3vX5IPewB0N pdqzfcoRB5QeiPoBaEKCs1OuE2DOIzX+Kr4CgeKAT2G4tFTNsgyvxz5pqqXYHy8KZKj1gL2SqIZ h3IbAXWzgAPnrtUr8fRJJM7NGyzeoeM3hZtoubncNEz5FBWzQ9SVwk6mfZRMT2QYZAc5IZ1HhU1 NGGyMyL+JpxZTEcsmxA3MlN7r2bBB25PP2CvWbyKUtxhRfYF+HxHHRvrqYq8y8C+XHb9lshIghy OBp5C1zrjDzysxq2QqsFRDM3pk3ICTkyqt9kIcZZgl4gCZ3bLwNgGlKrWCTVZUZ4pkEkzDgucOZ EPhFriPS3jcdegxQxv6rQyiEA7CB8= X-Received: by 2002:a05:6a20:7484:b0:3a0:b812:3a84 with SMTP id adf61e73a8af0-3b308530a6bmr1862508637.1.1779368439012; Thu, 21 May 2026 06:00:39 -0700 (PDT) Received: from ser8.. ([221.156.231.192]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c851993d8a7sm284340a12.27.2026.05.21.06.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2026 06:00:38 -0700 (PDT) From: DaeMyung Kang To: Namjae Jeon , Hyunchul Lee Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, DaeMyung Kang Subject: [PATCH v3 3/3] ntfs: only alias volume $UpCase to default on exact match Date: Thu, 21 May 2026 22:00:17 +0900 Message-ID: <20260521130017.713848-4-charsyam@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260521130017.713848-1-charsyam@gmail.com> References: <20260520170151.4115308-1-charsyam@gmail.com> <20260521130017.713848-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 --- fs/ntfs/super.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index d2c4fb6ea0d4..876e978370ba 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c @@ -1323,7 +1323,6 @@ static bool load_and_init_upcase(struct ntfs_volume *= vol) u8 *addr; 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. */ @@ -1374,16 +1373,11 @@ static bool load_and_init_upcase(struct ntfs_volume= *vol) 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