From nobody Sun May 24 21:37:39 2026 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (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 35A2B381B17 for ; Thu, 21 May 2026 10:18:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779358685; cv=none; b=CV8Jzm5iqscLLPPLXVYGSneL2rtMDlxB7SjVRjrBE9QhWxBTKq8kQmqNkTb4tVWEWu2hJbditqyFFZMourZM65xQrscSrKFQIwvNaPZtI+X8pbT9aQnJkVxsPVqfcieNgP7bJjlIVBmIkLaJ8o5G7uNUvZXiEa4cmrw0P+189SI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779358685; c=relaxed/simple; bh=akiy8XbXXAmzoEjb5CTW4EvpRBclQq/yv9STTM4bqds=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RbsiqOw1oCN7P+GiLc/CJAqcPEYLEKOVIVRFaGWIVylYXyHnV2pJJl5Jk6BA5m9m6KbjYRG/mxCnmmuJcFT05q+JHv+fOoCLwsN90VDsD+dZVDzQLUA55ZJmgEYzzxrGDekcEFkwHU2xGfUrFyl5kaQIhRlh920lMZ5ZwUsdv3k= 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=lzCu3+JE; arc=none smtp.client-ip=209.85.215.171 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="lzCu3+JE" Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-c7979304c0cso512583a12.0 for ; Thu, 21 May 2026 03:18:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779358682; x=1779963482; 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=lzCu3+JEmYIJuXmYNrlgWNXDnyWv7mYFeSpjEAEaVIUajPG/Xvenn3MfIvHlFu1i5y zgJWOrG0Ax6RxGrIPg2/5bhu4+POJSKgxH2/Ixhg+8l5A3GQ1fsgCw/rP60Tr74YYkm2 feL+Gl1M8EOPTSmpzLEYlTr+piPNIjSx85UdabxCIo9yAehgrthyj3dUW6V2i3HTdHtv EuxyPTVhL4g2zn+8wVpevk3Sv0VjZVpb5V8sM9T7E9A8oUYkTPqbBIwuA8rhnuZwJid2 +prhOZJ4ip9So3IXktzo5yGjuvxqc5uGqUMFlYO9piF+JAVJFE/EwNBUUx7V11QzJFaA 2+6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779358682; x=1779963482; 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=ZcgoyaZrF6FmpSQaLPp5WgSnQ+ti9zzsW5Z6/5GLE1Uok3UBlMaEWQnhWw37yknZ0O iKUM/BgAzCp8nl6sVLihU3PUK4m4AuAEGT48umLwdhSvuG48cgh2fGJCA4//Go5rQfzX gP5Nu7JVkAGRvXuC8G7LBx4GIHWRmx/3S7NoZnjO4wlWYSlgo/eUHF+P+80ggVZ8LlpI s3o+RB8fgRKK/bLVu8uZCtrMJM2PRmbBp606WlhmgW4B+u2GQo2lh2qHwqZRBmDkBDfV 3N3F7V1axtcDTPM6EoS5VAVY3XfN4gnxOPFIqOlluk8iG60VIms6g6DEP/WUHKgxpvNV xzPg== X-Forwarded-Encrypted: i=1; AFNElJ/1t4fAoxHd+9zQHnnR9eBGPZbLaYjUGqsMypeLfwGqEFmZLwOiSX70zOVlhc+rxtybgXbN2vmk2E5Xe/Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5jlrD32keTZFPcF5k36Gl0H0kopyQVutoQDG260C7xEc92Kgp 4VRsGA/HsG1moeZQ1rsylZqfhycGXQEaEdPpnZpTm8LNqRfBgYUFvpVa X-Gm-Gg: Acq92OFBqYOIWtW/71+hkzGAlu5Dipg2GF4hzkXxRgAZHD7sfoCnVnX78bqkkIMnqvm 2lElMCRSe5Y0PmFQevA0dhiw6q4mkL0rLcXld46Jq1m5AA0VvQJ5pfnzQnA9sMeVxSdFM0YA0tb 05G8/2R+XU5NdrqY4u6NhMyuC1pL1G+2aRwaNFBM14hi3WkQXbQB/R8P1BAwPkqzpLpmnQyqjRX PdC7EeRKi/EOUm8KqFID53qF+ZkjX5wG8AGbKCUi2bA2OYg1UW7/dzubxajIdExgrMLmp+BSxxn leOgOYudIinB11pbie1AQti81mE0zzCiQCeIZ6mB82xknhMoiAxBDU4XNnJiiiZOsFuudwjZCUy Go18iXCJCtiQWT4vwdrSVs6f4VnN08uWcj6R1seUiz44DOK8sxGWskxRx1BnPEZUDJ1voonqee1 2xSlM3Zz0prKex/wVfWzBydqeu6Bo= X-Received: by 2002:a05:6a00:114a:b0:82f:6cd5:f6ff with SMTP id d2e1a72fcca58-8414ae99c52mr1240092b3a.7.1779358681555; Thu, 21 May 2026 03:18:01 -0700 (PDT) Received: from ser8.. ([221.156.231.192]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84154e1fc86sm1197799b3a.44.2026.05.21.03.18.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2026 03:18:01 -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 v2 1/3] ntfs: free volume-wide resources on fill_super failure Date: Thu, 21 May 2026 19:17:49 +0900 Message-ID: <20260521101751.591345-2-charsyam@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260521101751.591345-1-charsyam@gmail.com> References: <20260520170151.4115308-1-charsyam@gmail.com> <20260521101751.591345-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 21:37:39 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 A573839A054 for ; Thu, 21 May 2026 10:18:06 +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=1779358688; cv=none; b=hdk833jUDpKbf28a9DsikmIGcgC/uuHqv7r3ecNzh/VZPkDwHSaBRWZht2v0cQiDhTlLvO8YG/vr+D6EKHuWL8K+BWB8zOfF9fP75obHf3eQhJ8TINHQ23cakGyI5oKKaKhwY7ohT6GD6g0oW8dgMDAFoUpoe1WdZdZx4RMsAs8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779358688; c=relaxed/simple; bh=9Pe8+ZjrYRQJiOIU8K7FPoyUGDQ+DlBlLp/jlo74mZE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QspsTagbHzNzstw+8BwDk6kho1BttHgbPrgub6wAxof7IDAGiIwz0uAfCapdyKF+PnmSqrkkLRBNSzAWGj0luHKJhQc7vmJG0CxxJUydMMSI0bDkdG/I35IDqCRLsXgj7o+0h48EkpTCRZvOenn19FjOBfZzyQcBPqP8k9SnFjQ= 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=cn5AIKGC; 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="cn5AIKGC" Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-c802196bd32so515706a12.1 for ; Thu, 21 May 2026 03:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779358685; x=1779963485; 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=bN7pEF/YCMte4OiPfGkGfT7emXc7eO02yqJ1xiQvVVg=; b=cn5AIKGCnmgM0s8SyGdeicPRNc+09cNXplKa5TsNPAK2LhDa6F22nJKaFGcAHCsbNR ncuVlPtAD7F2V4B++I5vxKBtHv6iqNkYATqPdGwnPfFVVETs3JBM/U+VPkIJCjR5hWIZ LrkDCYlkT1idv7EJ6ErmOPizALx9S2IPOLJ3iTVSZNC26YZ7FN/LvWaRYC+XRfkHgHe+ 2LwP2J5ksMo+DpOB2VULDuq4bp+lyXShUsC1J0cGWsYV1H4yzCW5vryJWjTRFhW9e0QL gSixvLkUMB0yvZHjP4JsrjFYshOiVk7k4xtUdHwgCMoYVAylqibWW7U7520U3avv7RWx uq+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779358685; x=1779963485; 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=bN7pEF/YCMte4OiPfGkGfT7emXc7eO02yqJ1xiQvVVg=; b=Ngl3VlmhgqRFBRvMXlgf4joF3GaL8oK7d/EDYD0G43b3QH7FQgdqD3CCtK/k7LRoDU KjVZaOQFfgzfXYpOkxDOhTWhV8QNJ+Jr9dItolxJo7niDKL79pK1nWG/ApM5AN2d59LG LEnj+SIBfXC6+u+xH2RtsCl/gDqenXwxlLMxDfI/H2Oh/SJAXFniqefsydYew4MBOlN1 ewE8U8OVW0f8prnnitGZEMxB6hRTegD4RFq/zO7+p4lxuBFOi9BiueRnjIn0p1uWirvL TV/vjT+/iWrZNqH8jTtxce27gewcxc+MT9O2lTRDVDWEixmGAcEQjo2UAi6LrR7Jj0re Z3MA== X-Forwarded-Encrypted: i=1; AFNElJ9YB0weubHJw0T6W52HXTS6WpZ9y67uxyFrYNAK3QH83fa5G7JclK474zCt0DGXWk1zr9NJLp460HLCqAI=@vger.kernel.org X-Gm-Message-State: AOJu0YwHwuRs4gO3QMnfl4xCrLoY5UL0R6kOo3pv1DKgyBOmo+SOJ5vv CpO1Z1KhkCXDrX+qLme31cyJmPTetHV4X3/ZCJr99KHbbj1DO+3K1Ydf X-Gm-Gg: Acq92OHWhTzNpiNnK4h4e8iSnRe2SFbkHAsHdal9kJbOacGeKFprrcp7ZfSduRvdovZ SLPKce9J2xj5kAbWiyxMBSIJ9ess5/hbzqKMQIGhs9oXIZ3t1fb8QcJMN6A3/fcpFAUZoueVYVB pXVFsXsH64f+tPGlukVezom1fIN36mjvIRfrso16ftAx1McribwEBolochdViS+1zXT3T0f8oUI 6FyT5PVwqh9jqBsfj1TQqPsdgwDBZv22cPLjTBcHgvFiExk40/vGXJueliSBjlsLZlNsdkXztkE GfnZw1pXVZNvxVHlLIjN+14ivn+MiXk/4hFKzJCpdpjYXDhJXIxwCRBoGfPIzta0vlkXnku/a89 T9L9lqVcFvfDjvTxYKQPIh/DT511Oz7TleckYX4R1g6L8JBlzXypP7cuTUMMoHmibQgVXDq5LVS L2gGN2KS+g7kc+yqdOOAfuEZ/Hw+M= X-Received: by 2002:a05:6a00:997:b0:82f:6a82:4231 with SMTP id d2e1a72fcca58-8414ac846bfmr1346412b3a.1.1779358685366; Thu, 21 May 2026 03:18:05 -0700 (PDT) Received: from ser8.. ([221.156.231.192]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84154e1fc86sm1197799b3a.44.2026.05.21.03.18.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2026 03:18:04 -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 v2 2/3] ntfs: avoid heap allocation for free-cluster readahead state Date: Thu, 21 May 2026 19:17:50 +0900 Message-ID: <20260521101751.591345-3-charsyam@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260521101751.591345-1-charsyam@gmail.com> References: <20260520170151.4115308-1-charsyam@gmail.com> <20260521101751.591345-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..14fd244f29fe 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 {}; =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 21:37:39 2026 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 0E9D439E6C6 for ; Thu, 21 May 2026 10:18:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779358690; cv=none; b=W0ktcGbl+pAHezelZ6esVbsBauTWqGgE9KiFpAAjUSS2g2YAvNCzrDfGiBdPCXhFbllxJYErou1LImxULpAcqXqFOJs1Il2YpwMMIVviN3YYVydfEt7E5FOgwidg1ToLa2IRXC42N3w8SqrongoysXu4Vccnrf0IGi0vweIT6fs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779358690; c=relaxed/simple; bh=vwsQZ2R3eKTkCSRO/SpyoNW9ls59kUMMez9Nn4L1k78=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jtbUqALbqDUPGsJK0lJrVpPabG6bDECvtcdwVvqJgXaPNuNiZKK5ZhoNGoADuqyWW9B0I53uS84UNBYxlZNKxwn+EFF1azXvdBQ7I6vSyIMGSXqqaWyVUJOAA65NLemp+t6BDhpjz9CUrdOhxYoTg7XwMl4rtPGZGhun2TlWBF4= 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=VsUX/LBz; arc=none smtp.client-ip=209.85.216.49 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="VsUX/LBz" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-365de41f8a1so710990a91.2 for ; Thu, 21 May 2026 03:18:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779358688; x=1779963488; 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=7FhPZ6mwbYBBt75MdFT5zKA1xzkMlLRUIuzLsq8lvBg=; b=VsUX/LBzf33hxA1eD+3CfsxDMlLPBta2y2MpVfH0AOBMGCe5DZV6SV+N73JmY9/WHL gl+ZJaLC4wYG3cl2UnyuMed2L5uuNS3/Ork/G/pEKKYN6nzodSbWKtSdx2j4Y08jMgiW HuirzGp0SLHbvRCCx3ePO0KHy6wEQhPPIHHW7ZdsVqYqclMleKAz15H6i8soW65zjaFL A2ChrJ4E7UJmd/CA9BRbTRjarjlmYV80GePYmOqOk6gZ7pprHaArQTmyaIlsG5ImdvZs M2n/mLb16+nCIavCSDe7BWSMs1yrkmXpV/IFf/KCH8Px1w3wUCBC4iRxk+1I8kyap5nF 56Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779358688; x=1779963488; 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=7FhPZ6mwbYBBt75MdFT5zKA1xzkMlLRUIuzLsq8lvBg=; b=CaVNGVBzUM4lErNxc/i2g8iV+v4iAzzkd+H0P6kHeKgIW1sI3ZPz8KZ4BVMn+p4EQ1 fcPHyXlV3r1KcDiOhfSswWBwXUnyYh5Y/1QULvrGvJ1eVkE572HTJrMmJzs9IsvNIOhj xhUVZKoBIFWsFda7aESKasjKAsPdvLrjqyZ72SzDnfAr7CDAJnofFrZ3ZvUJgvrIKAaq lYGq7Q9HaBW1ZF1EInXJN+KN4MvOwaC1mnOCtpwPVTVaenVIsds+nFXkGIjzsxOLSV69 Ly7P1sysFE92LLe3JMZiWmqabrgAcg86nKrOZ/xs8iD0F6NsMEEp3lsy+sZMPWo96Pj1 B/0A== X-Forwarded-Encrypted: i=1; AFNElJ9WpQnBupIKWOa9a9CAskG8bD9907fJOi0kgAhq8Y2FwTPq40m0/s/7ouMcY3ZsK1R7iuCQkqWGR6WcXfg=@vger.kernel.org X-Gm-Message-State: AOJu0YwdakXMoPIcLYilAt0Fx+aN9sGBJdUqMEg0l3NiIsyYa4ASkYGq JHML5uJrZdzOjjp0PL5tt6EIzdbFWhpXrzVjAGyNRL2TJXHDaISDXPJM X-Gm-Gg: Acq92OEwxy0V8c+EqOWR9tG55ZOosuMi0u31ZVSLabhvHzPCMRDgwnRCyVpN3x/JVt4 fA/k9FOsgi9OPpkW/QXRLDoKWDFMlNUKIJ5D3KRQDzM8BPwGYrTl/zyEnNW41dmay3wTtLkoJXR L9wBs4WhB4yFa/9zhnP/XE73L7T9VSKvVMi8SuOIdz9PlcMFVeWFWec68NqA78bfDaUPZeIZIvG tX0eptCL6UeO6DgZcZIeh2n+Jp+AdctcvSIggSonRzWAlJnqHWJfHSHwwpV8UhMu2zbQhyw/a62 R25c3yEEXyBWoluDp9HbNYDcClffJKfEktOnRe+4LausPkOB9WKyYArmqysg6z1xu7pau36Akz6 QVr64STEHupnv3Uf1bezUI/Vg4ir1w6NPOT8sRyzs1ys0PcdY0mcu2ySClgKRTcg6TmprRgal6v RaoS3BZrQsSU4bz6fy X-Received: by 2002:a05:6a20:9f08:b0:39c:68ed:9a39 with SMTP id adf61e73a8af0-3b308791329mr1429889637.6.1779358688285; Thu, 21 May 2026 03:18:08 -0700 (PDT) Received: from ser8.. ([221.156.231.192]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84154e1fc86sm1197799b3a.44.2026.05.21.03.18.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2026 03:18:07 -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 v2 3/3] ntfs: only alias volume $UpCase to default on exact match Date: Thu, 21 May 2026 19:17:51 +0900 Message-ID: <20260521101751.591345-4-charsyam@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260521101751.591345-1-charsyam@gmail.com> References: <20260520170151.4115308-1-charsyam@gmail.com> <20260521101751.591345-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 14fd244f29fe..971c2822f5e3 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