From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.173 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796560991; b=czJwktg3Dm5pGqlcjE/5zXtg8+KuzSb90e4YXX27Zt9liVrj59AO+4MTCf/oXtDZ7pQU lMcQ5O8opdhppyPrlY069/Y2odZsZIFeHWV60saaEVFpXm4TC5EFDREmtaCK2ynWx8D4R mfS1N+GkmtDN4F1JyeLqeKG1imGtpMWqh0zF0FDS4tXmGCVbylTljgt6ZWufHlCelbV+6 bJS7VTb9ygX49CXsi8T/SEu1RPdvP3KkZxTZ8BYGC88yKs/QwdTR9CxwBwYnpdlE8LLsg 0S7MLFlet/mNeWAbfAI/LiZe80DszHb3ZZJhVsDWs2AS7RsgCafMnveuP5temRdPUJA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796560991; 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=NalABPHx/HhRpOJ4AH35vk3/6xQnFE6ZsZzfQllDm8s=; b=3pNG8vHm/nSe2K8Lz77o7PXopy/09fKk3Uz15mkXqvm7pp5Id5FqMIYi0CeDiOWGkjt6 Kb3XXS9INLh6OY9cG4c9T2u/4FuhJq8pQPN3Z0kmF97PXjwV4icpaR0jTry/18cSF0hcj s3sGB56SxyZ9chWrF6H2Z02iAtBdQm0iaOZdFJR67e94Zi2RaHODW0OSK8mJS7ijhUfej BsP4MJe0PPKt7l4EUjkenKh7//0Yp9cm4EkXoKYZp2slJr/o0TMcQFtj/bSz0yoF9zHd+ hRJu1D5Bmy9oKPL61olWYUZlC9Kze8Yuz7xMCzyrdvwr3e9H/z7+ZL/k+NBBid0pN3Q== 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=EXlCld4e; arc=none smtp.remote-ip=74.125.82.173 Received: from mail-dy1-f173.google.com (mail-dy1-f173.google.com [74.125.82.173]) (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 8E353606A321 for ; Sun, 6 Dec 2026 12:43:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8E353606A321 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=EXlCld4e Received: by mail-dy1-f173.google.com with SMTP id 5a478bee46e88-387504e1934so2576826eec.1 for ; Sun, 06 Dec 2026 04:43:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iiitd.ac.in; s=google; t=1796560991; x=1797165791; 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=NalABPHx/HhRpOJ4AH35vk3/6xQnFE6ZsZzfQllDm8s=; b=EXlCld4eb9xSgOlrtjhzlZIzWcbjOh0hvaazb1tKgzoK+kwNXxs7Hc44vxVQ7qqvQC Fssu6ridK2DIzTWkatqJuQQ2zV/YsxD8pv7N8wRjX4VQcVbBKXuiAa+uCxMgOnaCxGp/ CXvQS02pwMJktLVH7zJ9wKDpXaeEb4TTLlnpA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796560991; x=1797165791; 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=NalABPHx/HhRpOJ4AH35vk3/6xQnFE6ZsZzfQllDm8s=; b=DbN42IZ8V/mG+6DcSt0LF+XXevmluvzW/ebtROWEFpZUSi/GcfQ51f5M8XrYEomgur f66u0sFhV5soP+9oMtGnWp9JdaUKGGJ6aow/Ci9OUM6t8hWjtxtK6Wxo3dof3FigZ+JX 1itrvBSjnHAJfFTn9usMQ+0OKPcil6Z+h7xqM79AbeMQV5jFsQfz+u6sNMH31CoccfhB SF3QENxw/guzHvUAXOBVoJsB3m1RoNn6VBADvxE5bO8ag3bBGjM0+bcBsYCxn78jaGi5 JyPAt6eFun/tRCZs0f7EV6uQmgzBbYHs+vHbBVm1SO/A7XWwUd5afYx1YYS6NuonQpj9 wJlQ== X-Forwarded-Encrypted: i=1; AL+hErGWAqhmxWfPPxrOhCFEQhNHKHU4MMG9hRsCSCYhTbFLgpZwybmhkVVylkIlfWBTzO+Um5yE/aywPA4z2wo=@vger.kernel.org X-Gm-Message-State: AB4q+uFRJ/j3V4vXeZRVhguCRBGyV0qVLKqOshgM+UcdXdVt3zvjz6zV vDtkkR+MPtu9kMzlgfedivTMw2tUVtRf2c0y/uX8leatof8KGBjHLBCD+wzgO3cMtWs= X-Gm-Gg: AZFdTZdB+Mg1rU1zQN+9n9+bulFP4buwBKvk6hCXcAcQyvjUlBmIFOveZ+RBKXhIxux iodkXsceWl1dC3gs6Q7MJkEq+6iTrkLaYcftww9DSVjIbBoW7o0SgToUpmAimHUPaZUXFn4BcKC D7IlLAutErZhYdfte+mZ+YZBAMUg1q7s+pAaro7fIqBjDt3i9MFvtYKSTC604DmD0tH+FdegbnZ DA6KY2odEDWu8eypfg9CaI961rHn+wCelSwn5kaglej21OYibYMHMV8qU8vml9ehAonCApqnj6z gkH0oSEY7wmbHzHwtK6mWMLtiyYfFyE0tQ0Hzg5F5uTJPNRCA+cs6oigvuo3Djm7Z0vgGQPzlhV /MC7rocBVGP5QmmDXnZSw/0LdjvBSHLOSGMTkDxU6cvTOwB/YFaTbg1lg5zzr28POquzTmMIpTh vkfZopS88aBR/PEWTRkIKFXE+rRn9TU3lTQb3lIiZk1lCaoMX6pGakVxT+Yj2k6xciWV2AxVMeh ++ut/luUBnrilHb+QnWdyZl1vlPnd2RaP3pjMlHlD7Kf5hvaefEuE0kGsJGKLBjjk6naE1zA9OR Yh2pC5yVMBjoqo4SZ7OXAVUHezbjVcWfAMQZtgFItpMrEE7HmMtTf3DOIWvr6n/TbJgFFCYEsA0 NWYMbql7ebT5Vi8BtcEWbPzomvFzaF1C2ihHqcf1zWJa+bdwkwK8c+mG4QPKkAxtr X-Received: by 2002:a05:693c:884d:b0:384:2662:a7fe with SMTP id 5a478bee46e88-38751fbf97fmr7523581eec.1.1796560990647; Sun, 06 Dec 2026 04:43:10 -0800 (PST) Received: from iiitd-S2600STB.iiitd.edu.in ([103.25.231.160]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3875218c6a6sm31204652eec.5.2026.12.06.04.43.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2026 04:43:10 -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 and writes at an unchecked ilf_boffset Date: Sun, 6 Dec 2026 18:13:05 +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() finds the inode at the item's ilf_boffset in the buffer it reads for it, without checking the offset against that buffer. Our fuzzer found an out-of-bounds read this way, inside mount(2); with the inode magic placed where the read lands, the recovered inode is written past the buffer, which we measured. The code is identical in 7.4-rc5, mainline and xfs/for-next, and the line numbers below hold for all three. fs/xfs/xfs_inode_item_recover.c:351 error = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len, 0, &bp, &xfs_inode_buf_ops); ... dip = xfs_buf_offset(bp, in_f->ilf_boffset); ... if (XFS_IS_CORRUPT(mp, !xfs_verify_magic16(bp, dip->di_magic))) { ilf_boffset, an int32_t, is not checked against the buffer, so di_magic is read wherever it points. 9232301894a0 ("xfs: bound inode fork length against the fork size during log recovery") bounded the logged forks by the fork sizes of the inode found there; where the inode is found is not bounded. The image below is one filesystem whose dirty log has fields 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. An inode item read as a 1 KiB buffer (ilf_len 2) with ilf_boffset 1024: BUG: KASAN: slab-out-of-bounds in xlog_recover_inode_commit_pass2+0x298/0x1720 Read of size 2 at addr ffff888050380c00 by task poc/9458 xlog_recover_inode_commit_pass2 (fs/xfs/xfs_inode_item_recover.c:362) xlog_recover_items_pass2 (fs/xfs/xfs_log_recover.c:2020) xlog_recover_commit_trans (fs/xfs/xfs_log_recover.c:2089) ... xfs_log_mount (fs/xfs/xfs_log.c:621) The buggy address is located 0 bytes to the right of allocated 1024-byte region (kmalloc-rcl-1k, the inode buffer) (The fuzzer's ilf_boffset of 65536 in a 16 KiB buffer reads 48 KiB past it: KASAN called that use-after-free in both of its runs; in ours it did so once, and once the read hit memory KASAN did not object to, the magic check failed and so did the mount.) If di_magic matches, the recovered inode is written there: with ilf_boffset 1022 and "IN" in the last two bytes of the 1 KiB buffer, the magic check passes, :394 reads di_version past the buffer, and xfs_log_dinode_to_disk() (:177 on) stores the core past it: BUG: KASAN: slab-out-of-bounds in xfs_log_dinode_to_disk+0x55/0x6a0 Write of size 2 at addr ffff8880258cb400 by task poc/9448 xfs_log_dinode_to_disk (fs/xfs/xfs_inode_item_recover.c:177) xlog_recover_inode_commit_pass2 (fs/xfs/xfs_inode_item_recover.c:495) The buggy address is located 0 bytes to the right of allocated 1024-byte region (kmalloc-rcl-1k, the inode buffer) followed by stores at 2, 3, 4, 6 and 10 bytes past it and more that the console dropped; KASAN's stack depot then warned about its own corrupted metadata (lib/stackdepot.c:506), and the mount failed with EUCLEAN when the recovered inode was verified. 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: di_magic at dip, anywhere within +-2 GiB of the buffer. If it reads "IN", the recovered inode core (176 bytes), its forks and its CRC are stored there. Measured: stores 0 to 10 bytes past a 1 KiB buffer and more, from an image that put the magic in the buffer's last two bytes. - The writes land in whatever follows the buffer, here a 1 KiB kmalloc object and its KASAN metadata (the stack depot warned that it was corrupted). We have not looked at what such writes could be made to do on a kernel without KASAN. 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 ilf_boffset 1024 in a 1 KiB buffer 2 of 2 ilf_boffset 65536 in a 16 KiB buffer 1 of 2 ilf_boffset 1022, magic planted, multi_shot the writes above with the patch, kasan_multi_shot on: no report, alone in two boots that each ran the three 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 one of Bad inode log item, ino 8256: offset 1024 in 1024-byte buffer. Bad inode log item, ino 8256: offset 65536 in 16384-byte buffer. Bad inode log item, ino 8256: offset 1022 in 1024-byte buffer. controls, the same logs written back unchanged: both kernels recover and mount. ilf_len is not checked either. The patch compares ilf_boffset with the buffer actually read, so it holds whatever ilf_len is; a buffer shorter than a block reaches the inode buffer verifier first, which has its own over-read, reported separately. A patch follows in reply to this mail. After the buffer is read, it checks that the whole inode at ilf_boffset lies inside the buffer; 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, inode items whose fork regions are missing, an unchecked dquot qlf_boffset, and the inode buffer verifier's inode count. Our report on logged fork roots () changes the same function; the two patches apply in either order. 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