From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.54 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796560947; b=QXP6wYRiT24xOKhaxiD6ajfRU1XmPoMaLb7fvv8yJEcreVRMYnhplkOCdl4Y9m/qK0df CrQhlWdWB2xspCS9mR7WKCHrYU+L4IUmmw3jHiwAqLAIz5fdzPfjhfoLs8vEW3lq/Osnl auukdvY9raQhohsTSVuEKkM3Ye2Gsa7qm8puxjCeEM7Kf2Lj4nyMXjbzX4XkhQbfjsaNw 41uT8HXL76vmC6l68zGfGpnqlfkL5TRHwf3QSRwrR0N2a5hY/e0aBZBrJGFGHhzbXwob6 Zjgp/+WQKZoCffVHtItbW6UH4k1suIx/5xx5jmawa7utUqn8o2GhrH4gJrRfliBMAxQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796560947; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=8+qnFAdwFisrrqQ/AJvo3dA6huELSK7QwTzIDTGG60s=; b=ayMXcBm5hFpXG+Bm5Z/KoWCEct09wkcync0BaHfgZFJyQo3wSxysvIT7IABp4Bc10+of jqXtzH/7OoYNdPwk4Po+YQaUcyoKJUwIP1zo4DzyTXDTsrjg0FiT+UaBvQY00rbX2Kd87 ZMeqRVG07/nWJaMLLb3wcIZNiiY4jIR7GX2sd0RFJPceSc9F8y1gHqblwviG3EFuEUWxJ BysVBYEgUCjwunqIN3OwYpHUvIJFss0/miPBHNT8DDYGhWopjVpkt+0vsfqVqg2W5ttgW rFghwIgJPqc0mpqU4bpLnVdDHTBnzUqlhws1QW1uYy9Gg/wUYk3WX3j7MMRXPW934hw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=iiitd.ac.in; spf=pass smtp.mailfrom=iiitd.ac.in; dkim=pass header.d=iiitd.ac.in header.i=@iiitd.ac.in header.a=rsa-sha256 header.s=google header.b=ULcl9O1r; arc=none smtp.remote-ip=74.125.82.54 Received: from mail-dl1-f54.google.com (mail-dl1-f54.google.com [74.125.82.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C5B0606A31F for ; Sun, 6 Dec 2026 12:42:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0C5B0606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iiitd.ac.in Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iiitd.ac.in Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=iiitd.ac.in header.i=@iiitd.ac.in header.a=rsa-sha256 header.s=google header.b=ULcl9O1r Received: by mail-dl1-f54.google.com with SMTP id a92af1059eb24-1b546061d58so5611073c88.1 for ; Sun, 06 Dec 2026 04:42:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iiitd.ac.in; s=google; t=1796560946; x=1797165746; 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=8+qnFAdwFisrrqQ/AJvo3dA6huELSK7QwTzIDTGG60s=; b=ULcl9O1rdpqWQj1Z0YWFtNjwtEXd5tFiJDqLSYPBSjfkTSEsxzTfciCtO428m5VptC WMbDF+XtizyNXC0Xfn5FxQ6gjz9oY6eQcc5Pkk+5G/yt4l/TLlLKqariUbMT8xVQp/bt H0VW26lyfkLUYG15wGLVC9L2RKNqty88IjG7A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796560946; x=1797165746; 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=8+qnFAdwFisrrqQ/AJvo3dA6huELSK7QwTzIDTGG60s=; b=RehO60IYvKw+G3be51L5Wwh98mUeNCnwv8oPOGk2p1rQyutLM2Y1NSqej5ib2/TIOY XwfT7BJdXPpeKGdbYw7En0Oh8ws4zR2S+DON1A59WF+sjk/KkKqEYLmiXtpoOzK96/VN ukZ3Oh4ARKvAHYBYnJZC9F1Yajr93hGB6yiKFTPMiDE7V8GpJO7ELcms9CwrYS+zBi39 sQKJBWtj5wJWJxSmOWQEpAqpEA8MKD+PQOUQiids3Ad81Z0QEedeaGaOJB98ArjsAIsL C/MczK2bJnanuLsfZThqpHkPFYaRLPQL1UV8jVoyJF6mNJqW0G4T2CeUGlVUog41kVeG sFgw== X-Forwarded-Encrypted: i=1; AL+hErEdK6mTDVuJByChyHsFWabvGMldyXBbSEmgZe4tNkPTXnR6KanWrtgoaHu0cKuwmV+Uz3oAxfTJKESg4y8=@vger.kernel.org X-Gm-Message-State: AB4q+uFFnh5BBgseYXKqzjqDtHWoyFbBh0Qo9P/4TX+xM7FTJzxqSXgH xWFxDGhd9dLtcjrTpZMjafVJPI6ejMtjOo5yPOeWhLVzuD2vDmCsrXVYNdeACA+iIk1mQ28H6Tn B/GLA3b2BWA== X-Gm-Gg: AZFdTZdIcJ075cjv02S2yNryEhb0OHKsQQx2n1l1l8V8yC/lgYzhRa7duBYjC345vFZ PmnDZvlEm1ILmYfO5K6zCXQrhIDqOz9lIGHDTAF8cadCqp65JLUqh1jcawFBajs3CBS87lBui5M OZ/OUsTPq1Dtz8aWKZaYdyKj28Xkd9LiUmzQNdumniwxo60M5JI2EqSBbILiALQZFUugOoaDIES x+7PMGmkUv7AVfxk2NvM5ReALG9w8ywtFweaFvvey+D7TUttBM2OZiBch2HSI44B9mCFe90NoI1 I43S+NzTtYhxhNoDNiMZ4DmAslhLHgqwMh7EUAhedpw9ybLVTVQpyIcyQ3iELrshvlDlT30+GQi cNm9zTBNtyCpKOujuHcnTHCeugdwXeBkpYd6ChtHWA1cwmpBhsxGWAIrzQxQf8ky6U78c7n2Xj9 0dgY8YzWLiwZ60AJEiwbDe+TtrwJNE/MzvGy7J8fFeIGwHhGs1SIoxLVvg+T/yQ8eFSZLOkm8I6 w0jjWZqlv2+gWT0nRI9nGYgYXzJkQlA0xdVzKv912K/OaIcU2rLlPnagKe1KX+ADa+iF9wN6PGO Y68zO4W59HUCSx+YhGT/ASwOWJHrNeA5P6JVjb2jryhfr+/KymRrP9Px7a5KWXApl31qdPZotiF pbOGntQQMYPwpId9lFTEFca5A2RC4G5eq9ricMg6Y6En2nC8T8BPjBvln+fKrx7ko X-Received: by 2002:a05:7300:d80d:b0:387:5117:e0 with SMTP id 5a478bee46e88-387520d0e37mr7984089eec.7.1796560945933; Sun, 06 Dec 2026 04:42:25 -0800 (PST) Received: from iiitd-S2600STB.iiitd.edu.in ([103.25.231.160]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3875218bc9fsm28905618eec.6.2026.12.06.04.42.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2026 04:42:25 -0800 (PST) From: Piyus Kedia To: Carlos Maiolino , linux-xfs@vger.kernel.org Cc: "Darrick J . Wong" , Aldo Ariel Panzardo , linux-kernel@vger.kernel.org, Kapil Vaswani Subject: [BUG] xfs: inode log item recovery reads fork regions the item does not have Date: Sun, 6 Dec 2026 18:12:20 +0530 Message-Id: X-Mailer: git-send-email 2.34.1 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi, Mounting an XFS image whose log is dirty replays the inode items in the log, and xlog_recover_inode_commit_pass2() takes the inode core and the fork regions from item->ri_buf[] by what ilf_fields says was logged, without checking that the item has that many regions. Our fuzzer found an out-of-bounds read this way, inside mount(2). The code is identical in 7.4-rc5, mainline and xfs/for-next, and the line numbers below hold for all three. xlog_recover_add_to_trans() sizes item->ri_buf[] by the 16-bit size field of the item's first region, here ilf_size (xfs_log_recover.c:2235), and the item is committed with however many regions arrived, ri_cnt <= ri_total; 2094dab19d45 ("xfs: fail recovery on a committed log item with no regions") rejects only ri_cnt == 0. The image below is one filesystem whose dirty log has a field of its inode items changed and the record's CRC recomputed; the same log written back unchanged recovers and mounts on every kernel we ran. xlog_recover_inode_commit_pass2() takes the inode core from ri_buf[1] (:369) and the fork regions from ri_buf[2] and ri_buf[2] or [3], as ilf_fields says (:503, :560); ilf_size and ilf_fields are compared only by ASSERTs. With ilf_size 3 and both a data and an attr fork flag the attr fork region is ri_buf[3], first read by the bound that 9232301894a0 ("xfs: bound inode fork length against the fork size during log recovery") added: fs/xfs/xfs_inode_item_recover.c:522 if ((fields & (XFS_ILOG_ADATA | XFS_ILOG_AEXT)) && item->ri_buf[(fields & XFS_ILOG_DFORK) ? 3 : 2].iov_len > XFS_DFORK_ASIZE(dip, mp)) { BUG: KASAN: slab-out-of-bounds in xlog_recover_inode_commit_pass2+0xb47/0x1720 Read of size 8 at addr ffff88804956c638 by task poc/9458 xlog_recover_inode_commit_pass2 (fs/xfs/xfs_inode_item_recover.c:523) xlog_recover_items_pass2 (fs/xfs/xfs_log_recover.c:2020) ... xfs_log_mount (fs/xfs/xfs_log.c:621) The buggy address is located 8 bytes to the right of allocated 48-byte region (kmalloc-64: ri_buf[] of three entries) and then by the attr fork copy at :560 and :561 (reported next with kasan_multi_shot), which has read it since before git; 9232301894a0 added a read before it rather than the bug. With ilf_size 1 the core pointer itself is read past a one-entry array, at :369, and in our run the pointer read there faulted. Our separate report on logged fork roots in the same function (xfs_bmbt_to_bmdr(), ) is related: the check its patch adds reads ri_buf[2 or 3] as well, and the patch for this report makes sure that entry exists first. Impact - who can trigger it - A crafted XFS image with a dirty log has to be mounted; all of the above happens inside mount(2), before the filesystem can be used. XFS is not FS_USERNS_MOUNT, so mount(2) needs CAP_SYS_ADMIN in the initial user namespace: root, or a service that mounts on a user's behalf. We have not tested whether desktop auto-mounting of removable media mounts such an image. Recovery runs at every mount of a dirty log but -o norecovery (which has to be read-only); a read-only mount (MS_RDONLY) replays the log too (we measured that with a dquot item). The image chooses its own geometry and contents. - What is read: the struct kvec at ri_buf[3], 16 bytes past a 48-byte array. Its length is compared with the attr fork size and then sizes the attr fork copy, from its pointer. Those bytes are the unused tail of a 64-byte kmalloc object, which our kernel zeroes on allocation (init_on_alloc), so the length read was 0, nothing was copied, and the mount succeeded, in our runs and the fuzzer's. Where the tail is not zeroed, those 16 bytes give the length and the source of the copy into the inode's attr fork (by the source); we have not tested that. With ilf_size 1 the array is a 16-byte object and ri_buf[1], the core pointer, is read from past it: a general protection fault in our run. Seen on 7.4.0-rc5 (twice) and REPRODUCED ON UPSTREAM: on ksmbd-for-next (d70570cf8003, 2026-12-04), our upstream base, whose fs/xfs is identical to mainline master (9437ee8b6cf6), with KASAN. fs/xfs/xfs_inode_item_recover.c is also unchanged in mainline c3500c5ef648 (2026-12-04) and in xfs-linux for-next (ab1a77ab136c), where the patch applies as is. Same config and image before and after, the patch the only change; one boot per run, the fuzzer's own program included where it had one: without the patch KASAN report ri_buf[3] (ilf_size 3, data and attr fork) 3 of 3 ri_buf[1] (ilf_size 1) 1 of 1, + fault with the patch, kasan_multi_shot on: no report, alone in two boots that each ran both triggers, and together with our other log recovery fixes in three more (one of them the fuzzer's own programs). Each mount fails with EUCLEAN after an XFS_IS_CORRUPT() report and Bad inode log item, ino 8256: 3 regions, fields 0x83 need 4. Bad inode log item, ino 8262: 1 regions, fields 0x1 need 2. controls, the same logs written back unchanged: both kernels recover and mount. We looked at every other item type's recovery. EFI/EFD, RUI/RUD, CUI/CUD, BUI/BUD, XMI/XMD and ATTRI/ATTRD read only ri_buf[0], after checking its length against the size their format computes, and ATTRI checks the region count per opcode (ad206ae50eca, d72f2084e309); ICREATE range-checks every field. Not covered by this patch, by the source and not run: format regions shorter than the struct read from them (ICREATE reads 28 bytes with no length check, QUOTAOFF its qf_flags), and the inode core region, bounded only from above (:475), which xfs_log_dinode_to_disk() reads to the size its logged di_version implies. We can send patches for those. A patch follows in reply to this mail. Before the buffer is read, it checks that the item has the core and one region for each fork ilf_fields names; the mount then fails with EUCLEAN and the corruption report. We are reporting four related log recovery bugs separately, each with its own patch: buffer items whose dirty bitmap outruns their regions, an unchecked inode ilf_boffset, an unchecked dquot qlf_boffset, and the inode buffer verifier's inode count. This was found by AI-driven fuzzing built on top of syzkaller; its analysis was then checked by hand against the code, and every access above was reproduced. The reproducer is one program that carries its filesystem image, and we are happy to send it on request. Kapil Vaswani Piyus Kedia