From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (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 4190D31E820 for ; Mon, 8 Jun 2026 15:49:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780933771; cv=none; b=jas2KaWazLpuESiWKvh0zb/ox9dZfrKGOZwdPZ0ar4CRnncyy14MIKKdpwiSGNd3WaqK/GOacA0GskBW5UR/n6bcbF5vnZHb411LnkzTvGX9Rwd2XLdOuVpYOHeoKdqznFnmd1QGMYq8sLA8ahIXK9fsaaN8xP63ZUDUFLzwdD4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780933771; c=relaxed/simple; bh=UPloW7wCBJ8A+fJCKHYFghT/wlBntz1WJRmB53j9Ttc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U6kpYRFcZVKGbbM/+iNv48QMjnOixhaLL5xN7wXOb96BLuVnHejuGuGhud9+vAL+gOQrX3fIroYM5zoVaESBpFlHZUqAjcKjCW0L+BgQmuVyW2U9qg1z501+IXYlO+a43kYeykuBUFpLyVoqJQofaEqQYMELLrOl3/IzB9JDHM4= 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=MNEr/74n; arc=none smtp.client-ip=209.85.216.53 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="MNEr/74n" Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-36dccb2c91bso434550a91.0 for ; Mon, 08 Jun 2026 08:49:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780933770; x=1781538570; 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=4AEyICkcxZy1T6IWxG4M+aIj2et6ppgQhv+Dv6SSs9s=; b=MNEr/74n5hjLlgB3wo40ywGOduUmRpxx55GuY9PyBdn7spBCtBNuTYQatwy0wc/QHn 3bbCUM385YcXAmVAh8beXjaCcy1DyjaMcSh01LLQsc38Cas16ChDrWOXggoycTELLVFc B0WK3JAQ1Ak5D5MNjKif28vnjY6M2KYEM6tQzx/2qkw0ZSxI5O9IPQiSJjs42IklY8u1 YtAKjZQpQbDl2e9CVX3ZFexhqwAQBAj+1qa2hSysgfGAVpgoZRptBu4VeR+epndDcMkj IQst2Z4/pgm/llcqEGZ4ooreQLaUFtQ/1aPP85IP+HMSa5d6jOH8XDeY0lOxhbUh+m+J ofOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780933770; x=1781538570; 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=4AEyICkcxZy1T6IWxG4M+aIj2et6ppgQhv+Dv6SSs9s=; b=TtKMtAI+Tq2trrJjZZCHcrP11gb7hfYEUMTxe1BXxpmEbS+wTzD9bhA/2AL9ao79SV km42wFQWX3PWIygUuTfs1Ceer/leiKsANv1lnnVG27mh2Aae8zn4YRr/QsB7avLWSrsj hYmZrxov7Df4Ccxt9l6Agw6gbqf+7TZ0lWRlbeJjLotLY1IRDynqkG4TVbKcBX8uBj0N kpAxd9yZ7DxR9IFrjWW9rNnvxTtTmcIKRLaMzZDfSo5xqi7xcstMe7z+87V+fXw2XU/k i8GuHmBVGldsKPPPWahhhgsANmOUbNsVxHLwJdZBwoxLViZZcXncnXphtPd42nHpE6KA eEVQ== X-Forwarded-Encrypted: i=1; AFNElJ8tahpvq7TphCYMAsG8tWpynY3fhGh9yWI4zBoP03R9I+lUIBIBjc0z8113y0T9M3yxQg9r3ynFP7mKTC4=@vger.kernel.org X-Gm-Message-State: AOJu0Yxw1NknxoK7VbdhZTX4jLgaSOaVwGJpD6T21qaoDpoXZANcUQmR 9syJ0EGZjKs/dsrsOBt8PBlrChq+yOS5ziSOM+itm8bWJgTiGEgiQrIdNYeOKYEP X-Gm-Gg: Acq92OEky95PYzbc2BTUCP847BfrPPcVbsy5zihcRMTH5xhfXAmFIQNW2TqUOXyUHKj uMYv3IlQS+42Z+M5wKArwcrOtKzErYsH2wyR5DKgMsLBbEEVpoOjZy4qQ/y74v34+viH0r3l3On Fc9Zk3mRI5J1j1DxouZI3I6I/OcYayaL1KKiCbqtI1jB1VzBSivmzJPM9oHnPOJbumxIH4Zuqbw UL/oq6iF/3A64r4PBKWiGzhoDdPKDk+yh0RFs0M55M/U7HlojLmgsSas2iceXWxwzuqtE8AcrMl ATHA7g/twK9lfXh5Q2xUqezLp0Khwb9nQm1shrxwkXa9kHvp/nDUA8erkL8hIGWrVJVS8cAT9O7 p6suQAgNZCCTxNM/xH6+5Fo4LdUbPEdVrLLsPi8vyx1MkwvzNelJej0G+2n0kPy3atvb4Qn9vas 9SsiPsYfA+nNpGjXjq0Z+xsjgIAD4= X-Received: by 2002:a17:90b:5190:b0:36b:900a:d298 with SMTP id 98e67ed59e1d1-370ee340826mr7752785a91.1.1780933769563; Mon, 08 Jun 2026 08:49:29 -0700 (PDT) Received: from ser8.. ([221.156.231.192]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c85df0a624fsm15937526a12.18.2026.06.08.08.49.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 08:49:29 -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 v6 1/4] ntfs: reject non-resident records for resident-only attributes Date: Tue, 9 Jun 2026 00:49:14 +0900 Message-ID: <20260608154917.2703739-2-charsyam@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260608154917.2703739-1-charsyam@gmail.com> References: <20260608154917.2703739-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: 8bit The shared lookup-time attribute validator rejects non-resident $FILE_NAME and $VOLUME_NAME records because their formats require resident values and callers handle returned records as resident attributes. Other resident-only attribute types still pass through the generic non-resident mapping-pairs checks. That leaves real resident/non-resident union confusion paths. Inode load looks up $STANDARD_INFORMATION and then reads data.resident.value_offset without checking a->non_resident. ntfs_inode_sync_standard_information() does the same when updating the standard information value. ntfs_write_volume_flags() also looks up $VOLUME_INFORMATION and reads data.resident.value_offset directly. $INDEX_ROOT callers in dir.c and index.c depend on the same lookup contract before consuming the resident index root value. Reject non-resident records for all resident-only attribute types in the shared validator. Keep the existing $FILE_NAME and $VOLUME_NAME behavior, but factor it through a helper and extend it to $STANDARD_INFORMATION, $OBJECT_ID, $VOLUME_INFORMATION, $INDEX_ROOT, and $EA_INFORMATION. For $OBJECT_ID and $EA_INFORMATION this is contract hardening for resident-only formats; this patch only rejects the non-resident form and does not add new resident value validation for those types. Signed-off-by: DaeMyung Kang --- fs/ntfs/attrib.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c index 5e1ad1cd0118..1254fbe7666e 100644 --- a/fs/ntfs/attrib.c +++ b/fs/ntfs/attrib.c @@ -596,6 +596,22 @@ static u32 ntfs_resident_attr_min_value_length(const __le32 type) } } +static bool ntfs_attr_type_is_resident_only(const __le32 type) +{ + switch (type) { + case AT_STANDARD_INFORMATION: + case AT_FILE_NAME: + case AT_OBJECT_ID: + case AT_VOLUME_NAME: + case AT_VOLUME_INFORMATION: + case AT_INDEX_ROOT: + case AT_EA_INFORMATION: + return true; + default: + return false; + } +} + static bool ntfs_file_name_attr_value_is_valid(const u8 *value, const u32 value_length) { const struct file_name_attr *fn; @@ -666,7 +682,7 @@ static bool ntfs_attr_value_is_valid(struct ntfs_volume *vol, u32 min_len; if (a->non_resident) { - if (a->type == AT_FILE_NAME || a->type == AT_VOLUME_NAME) + if (ntfs_attr_type_is_resident_only(a->type)) goto corrupt; if (!ntfs_non_resident_attr_value_is_valid(a)) goto corrupt; -- 2.43.0