From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 7EF3C29E117 for ; Sun, 7 Jun 2026 05:17:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780809452; cv=none; b=qXSkirtRUa4pHh+duad68s4y9T9sO/39Ay/0RFPhYspMUK6DwWF+IuKtBX0ixVbKm5vboG2iCdatHM0YZByaofCLCz9BoyNeg2qAWOksYCphnrmdDGBVkaR+VtMcUoq47F9L7FFn53PG7AwNugrc0H4dXmoH3QZVthhgmnJ6Y/4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780809452; c=relaxed/simple; bh=j+xZy8gt8DDV+QgucaCN87y/EmcwMb0teW0b/sea2b4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FNqWMXNmQyxta9xWDgvu9wD3eduSwRFtjCQHCKLbzyaZrn0d4M9peR4NfxO4zTT6OG45xqV3aFvzAqcKo9XPd1q3sFrw1T4Es+NoNvs6ew4ra27+VE76MwN7YyN0UhsGSwYJBf4LWOrg5Zu2jXyub9kVQbZrFwnGRGaKOV1I8bI= 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=Bg9c7Ck0; arc=none smtp.client-ip=209.85.216.54 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="Bg9c7Ck0" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-36bc065c298so299951a91.2 for ; Sat, 06 Jun 2026 22:17:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780809451; x=1781414251; 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=s/xh4ji4ljzs7Ld2VhqWZs4IQIsCD/V0jgUFhhnWvko=; b=Bg9c7Ck0L7xjNgIWEDnGguzpc867L2BAS5vr7QEM/Qg7br8Z6+LAlr4mn4jmpOQLQi 3GXNspQcrg4yOyfH/b5R3tDshIsvkszEqsHL+iQkjb+fH07OzMkp7TvBkbS3KmDSDkao JVCqDmDkgQZ0Lbgj98abD3ncD8zeRQ8cTfC3gX4mrrceZ0/vmbTRJ5cjTuSHqx10EGg+ lB5V/bv/dgdf++achcWip4zupIRr9xnMA3nUzQWEaSOyZfPqaKVmqb3TZHWqVOoKj4Ib pOfiOagv4cuLVC4Bdu4AtHN+f8zlGZYBuoSCChleIk4LLVdKiCQSi4ixc+uNC+vp94Yb qr6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780809451; x=1781414251; 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=s/xh4ji4ljzs7Ld2VhqWZs4IQIsCD/V0jgUFhhnWvko=; b=byMlfv09w2gL64/KMdef1zcx/Q3BU26d0H+AjUDgNA9gZFSTMpolqHVV8m3feJ4v/I 7LLqw4FdYZ1r7HvB0jHa/zMMbqAqpO+Qz2Kg1xiEiSlC5y0s45PXtbhV+wTDsP+1Hhy4 gNUd7AGTmpaSiMsKPVl8lRgxZPGzs9l8e+qQuVQGE6Hz6kxAKli4Y/MIydPSFZV9GTBM H8loWhdZvZWuo99LBLQxOd89gUth7OOk6IzdJbti7LUqCl+lDGaa4+U6KZE49rsFmyyZ 78iXEb6cMBHYc+h7moXSKlrFztW2tNy8uB22oyEiOGgG3+5K/DRYLKwL9yXeZI/yo9qV oLbA== X-Forwarded-Encrypted: i=1; AFNElJ9/HmZ/x8mBjPeBnCJJOwMagzekniR/TYXPuLQNZYQF1nciQGVP1nSXlEglSXS1xwIthLvK/JHZEDawzjs=@vger.kernel.org X-Gm-Message-State: AOJu0YzSYS0hUAoBzJK1Cew4/hMJd6EmfkBkTIWUq5oWaKa2dPL+mlzM 3r/Oe33Ynv15NDM1RNK4EYyT3h0oUKTppHS/6rfmEP2JDkxk8Kutzc5UCJC/4g== X-Gm-Gg: Acq92OF4TOnDvBARG9SOsN2ibeJ8XAsaaVH52YPnOeCAMj+8/WZCVp7c/iLadCSoAel EOAdQgviTxwa8Bu/suir2+Ql6V0twQwQZzzzuuLEQloMHuEdBW3UsyBWm1e2I0iAV/19ambqyEt Lzs3wYg7AIcZppyGHFl4tEidDtU8z1XS6R8nn/rRwSqZoXXcOYKsb091Fz9aarsRtJt3jAHvEVZ zKi2vUA8qJ5uU+D3JDgErJtlK52IqO6NyYOVTxWxtA/CzGfi+Rjh1r8AQF54bzBj6u9k6TX/yWw eKkLZpQrjm/uYSGog9XZRcysj00KwCdlf+aYUZWwsURD2ijhs/XCpHlhdpyng7AqMgcBSzCQAU6 LiBjLGe7PRuz7kyABREr2/qjuE+auehBjrlElMaUYIKXGygpnMZ9LMj+SmwNDITBz0UI/Kgwgob cmbZZg5uNY5aRlaPJEKZeBFvJCRIY= X-Received: by 2002:a17:90b:2708:b0:368:f0a:1c49 with SMTP id 98e67ed59e1d1-370ebdfd031mr5330721a91.0.1780809450653; Sat, 06 Jun 2026 22:17:30 -0700 (PDT) Received: from ser8.. ([221.156.231.192]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-842828e5638sm14494648b3a.50.2026.06.06.22.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jun 2026 22:17:30 -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 v5 1/4] ntfs: reject non-resident records for resident-only attributes Date: Sun, 7 Jun 2026 14:17:20 +0900 Message-ID: <20260607051723.1499833-2-charsyam@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260607051723.1499833-1-charsyam@gmail.com> References: <20260607051723.1499833-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 7e293b85ad19..0fb2b6acf8b2 100644 --- a/fs/ntfs/attrib.c +++ b/fs/ntfs/attrib.c @@ -595,6 +595,22 @@ static u32 ntfs_resident_attr_min_value_length(const __le32 type) } } +static bool ntfs_attr_type_must_be_resident(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; @@ -665,7 +681,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_must_be_resident(a->type)) goto corrupt; if (!ntfs_non_resident_attr_value_is_valid(a)) goto corrupt; -- 2.43.0