From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 AD75B35C1B7 for ; Sun, 26 Jul 2026 06:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785047118; cv=none; b=Njw1vbu+tWwpT+kAqHpQj6bBztyVv2fZnRXZ266+tXdFHYN5/xTExW9RNQ4bhjxLpERHPBZkJRfR3fUVUXZbAj7QYY/mlzr/Qck4o8+brLyk+FMtiE69aoSX4cngm1ytAwySaLouJyjBZl2dgtUVFIh65rAjMfLMpbUnUrawctQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785047118; c=relaxed/simple; bh=e8mr+b9UCttxj8RlTQotrcq2qgO7pGQftDu5+Avcths=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=mDY8iCUx9WxZ3Ilxic0BH7PyOrguJC96K0M+2s0JsllFQLH68qjtv7JiBx7K/d/iA0s4Gw2eoiT3sexIErj8Kx3O5oK8LiODfnbMaXRu/W/Pah3xbhnJyFFhBhRZZnqlb8K6oZEJ6kCUsji6VEb0eZlbUeAi71Fe17iNb8nZsjk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xbow.com; spf=pass smtp.mailfrom=xbow.com; dkim=pass (2048-bit key) header.d=xbow.com header.i=@xbow.com header.b=UiAqw8wo; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xbow.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xbow.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=xbow.com header.i=@xbow.com header.b="UiAqw8wo" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-84e27035206so1635254b3a.3 for ; Sat, 25 Jul 2026 23:25:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xbow.com; s=google; t=1785047116; x=1785651916; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=tIHL9LfqgPlg0723np5xF3/v3AzqALnVrCAzcfCqCNU=; b=UiAqw8woPubp0TggGEHWMjK9gESI2qNeIeCceiqgI4tv3LJOC2FhlRZU15zbAHI/FL 5zyljdMEHCFjG6kpcINWZ79POoAIhLF5iB9MRJow0QsIiuh3NQiuwoU/NfLx+YRFid8B CspZtWOMZAsgHu0ELgPAUC45KsyiUqFa81rlDtaX+GYOaaUXv58YqJJWZDwqSfS1pFwD D6+3+KskoESOXgEcLOw/BOjzXcTNbGfuCW9SnUwI2jsaKcsAlZ5Buz83t+FMBNjlnYAC 3kfNEfvnUqL2KKKbhCSnsTdcMf0XljcRRk4IPV/9Q8U7xCWghq34ycf2Yyo5uQIny8Vu OTzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785047116; x=1785651916; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=tIHL9LfqgPlg0723np5xF3/v3AzqALnVrCAzcfCqCNU=; b=OxO09jMQSJWLYkA/UlJFSEmqatdzFZntMyM7aeMuwQmE6kwMUD3E+WkYbFFK1xRule UlclvadcvxYrBjBv2MXTmRfSY2dD8tgna959pi5Qe3HF3e0ERRfzbXrA85sG1d82C/66 7nrsShOtbf3mjVSIuEbzWVrvRJlBsRrGTmbj56Syp2jBM/b6JWMUfqohUfNsBoNICK9w ABKpYhzJcpkLLPQSiA7oA2eLsp+DJKV03ZI4ept6nYsoDTNnJa1SvvTgcCoOBIYJBdBT JfTtI73/RYU9o55A8xA10pdrDGR1iAnn3ugd0QbNVO8qa6QaGRKLrPl7hqaevK4xR9Pe hJiw== X-Forwarded-Encrypted: i=1; AHgh+Rp0yBApYPGR5osDyVdB/qgJWjhUvKBXdNuJz9QGq5queskU46fKs7RxGDxATYYywoNsG7f8D0MbyMQU3dQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yzy8orkjJJDsGjW8pudWGpa62jBh7aMtIYkLobLoUOP9+eRUEj4 z4v15xfPYR6G7BR2KRauFqEX8r3AsoDwqqjvng81gbpjPMT46xkpwLObGWM+fm0ZAXM= X-Gm-Gg: AR+sD13pHmR1GDUGkejKoOh6jtGqfRRWyZVhGQ63awHmJ0ulqqEDTVPYHZlA95N01Gj wEkWL6fiN20jZVJPfHs50a6JuX94U2E9sKq5c8BgvXM2vL9Kr70kvA+UKysVWrNinsU8uB8UTgP 20TvVgsgMnCGoD79AQPA9nCDDhY1AnTD66oo70O+LfTD7AbXmF07iIYfMG38xAZr+u09VYz2UOS q3si/WGzjdMOfbtdADn6bnrVfmXzsI75OjTgxPFo/dJjtfs5dbwAuZma4ouR/wcc8reqB3P/hEG 8ffPiLBNQsCc4ASanI1h/+vbDrzhZ2oV1FAZmo18HzIum7vmi1LLrVKHGWPoQl0NOXIudPY35fj wKniAKGVaA9VEnbSlQ8UNKOAe2BOEOIsrCx1laJWAYZXPIucrgr/bizjn5szEK7fWiGJvShVQew AhvyaJBxBENpZGi7jl5sniBrIpK/9v8AC/e9tFKk6jOuDYs/Wm1MoP/R5wM2Ve83ISXICzgLc= X-Received: by 2002:a05:6a00:a207:b0:845:3fea:96c with SMTP id d2e1a72fcca58-84e59435c72mr3295803b3a.21.1785047115931; Sat, 25 Jul 2026 23:25:15 -0700 (PDT) Received: from localhost.localdomain ([125.128.148.126]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84e53253d7dsm1611692b3a.5.2026.07.25.23.25.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 25 Jul 2026 23:25:14 -0700 (PDT) From: Baul Lee To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jack@suse.com, federico.kirschbaum@xbow.com, Baul Lee , stable@vger.kernel.org Subject: [PATCH] udf: fix OOB read for a crafted unallocSpaceEntry Date: Sun, 26 Jul 2026 15:25:09 +0900 Message-ID: <20260726062509.43738-1-baul.lee@xbow.com> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit udf_read_inode() sanity-checks the on-disk allocation-descriptor length before it is used: if (iinfo->i_lenEAttr > bs || iinfo->i_lenAlloc > bs) goto out; /* Now do exact checks */ if (udf_file_entry_alloc_offset(inode) + iinfo->i_lenAlloc > bs) goto out; but the TAG_IDENT_USE branch sets i_lenAlloc from the on-disk lengthAllocDescs and returns before ever reaching them. A USE inode therefore keeps a completely unvalidated le32 there, while i_data is allocated at only bs - sizeof(struct unallocSpaceEntry) bytes. udf_current_aext() computes, in its in-ICB branch, alen = udf_file_entry_alloc_offset(inode) + iinfo->i_lenAlloc; with no clamp and passes alen to udf_get_fileshortad() as maxoffset. That helper only checks (*offset + sizeof(struct short_ad)) > maxoffset, so an inflated i_lenAlloc lets the walk step past the end of i_data and dereference sa->extLength in adjacent slab memory. A Type-1 partition whose unallocSpaceTable extent is non-zero loads the USE table inode at mount and sets UDF_PART_FLAG_UNALLOC_TABLE. An unprivileged statfs(2) then reaches udf_count_free_table() -> udf_next_aext() -> udf_current_aext(), and KASAN reports a slab-out-of-bounds read just past the 472-byte i_data allocation. Apply the same exact check on the USE path, before i_data is allocated and walked. ret is still -EIO there, so the offending inode fails to load. Discovered by XBOW, triaged by Baul Lee Fixes: 23b133bdc452 ("udf: Check length of extended attributes and allocation descriptors") Reported-by: Federico Kirschbaum Reported-by: Baul Lee Cc: stable@vger.kernel.org Signed-off-by: Baul Lee --- fs/udf/inode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/udf/inode.c b/fs/udf/inode.c index c97914aa8d8b..8a0c9ea31a11 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -1475,6 +1475,8 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode) iinfo->i_lenAlloc = le32_to_cpu( ((struct unallocSpaceEntry *)bh->b_data)-> lengthAllocDescs); + if (udf_file_entry_alloc_offset(inode) + iinfo->i_lenAlloc > bs) + goto out; ret = udf_alloc_i_data(inode, bs - sizeof(struct unallocSpaceEntry)); if (ret) -- 2.50.1 (Apple Git-155)