From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796561083; b=OU8jqirFSLPto41p2mgznUuVwuslPq+I/rlO57AtiF8j7mRfweqY4QD3vqsscBAHWroe 5NhF9YfkVdwj1NoTlJEYLyEtLhtHw9Rr6U8fhQZqTsh4VXamPRSQe9/PZ/3/L9xSRKT1X z9s2x0qGGqS1ijpFbLu57T0HIozFi/qbjqnkShI1UMIPcTyeABVsyfcUmj6DgP351U+Mi AxKrISR3k97ZIJRcr8afvcr6hEPyV/R6oDnz5rSNVKCojU1gPa+3RAmS3XD91aRJcMYwn QcVpSduzQq2mUiyf378Fdg4BjMSJekX9SvRsp9Z89tOhvoxYQ4CMOuxojE/r/oPl/Yg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796561083; 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=sjBGKQ41w9FAGuRNkE8XHHdvHSxz2GUpT1/SqvPWLa8=; b=QVzHnvGZgZXYrwsVIR0JCGg3UjNSX/M4J1bKll7j5+hMLd6kkRPnD8epZPlOKjYbYgiH +7jPjCaWUTa/9hcLBwl7WvsYUp2GnjqHakH9ce6XfwFtKkAVg4nLaqwaRjlXxoNT69AUL cjAxgLfhwe9OLhBVx6/UVtAo0T5eFvvUzEtL+oo8tBneRyrEjARG6+ili1LYbNDGZtUQY NWXuL4PCTC/2PjwBwCgydZla5Fmh9SgUIWNE3JUR6JWFyS0ExH5Z1QqKXO23P0aYivmQv tGFgejagnO8w51Q5odHWv8m+fzC06r32gPuEFDuFm8nZntK0/6qg9IcPP9SbQfdfGFQ== 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=SMmeEX7K; arc=none smtp.remote-ip=74.125.82.172 Received: from mail-dy1-f172.google.com (mail-dy1-f172.google.com [74.125.82.172]) (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 2B4CA606A680 for ; Sun, 6 Dec 2026 12:44:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2B4CA606A680 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=SMmeEX7K Received: by mail-dy1-f172.google.com with SMTP id 5a478bee46e88-386bd881d39so4428879eec.1 for ; Sun, 06 Dec 2026 04:44:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iiitd.ac.in; s=google; t=1796561082; x=1797165882; 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=sjBGKQ41w9FAGuRNkE8XHHdvHSxz2GUpT1/SqvPWLa8=; b=SMmeEX7KXkefcAnpOgUTZ0tyhGTW08dNAoXa3huPa4/GUZdMXt58JGqe9kiuYANPrK nDUTBmIR/mGU/PjxYZuryhd3oNyGndag75geB0SUyrkLoigKHfxV9qf/ycWi6HPkxXHz UGSft++TfP7Qbyp8fvEFSNNF3KYW1b2p8bXig= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796561082; x=1797165882; 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=sjBGKQ41w9FAGuRNkE8XHHdvHSxz2GUpT1/SqvPWLa8=; b=i8da4ER5t5zHei+8livbrQVpFWQbXHzxgAUOynIVI3bi/zFUh8xNH1KYZZBZ7mxPAN y0jumkgVxqs1ws1qbSC8RNwKAvcqha8ugnUK3dHu5lEAd+dUvuVuHN9uLBEpaJMQ8YGS OIcqhW9f259QxFf0jVN2Gao5dukFVatT/FTAk9aEwfeOEmJGWw1eVz75nXdkwCK4YZgZ LyLXm+zvcn33TqLVXcsOTevm55ku6FWPCqifFcR+7A+AdtZCvk2JzIKNT31RNfKQHl+d IKoCFrDxabQryFLNWkL91Qbee8XoerL0QTwlQMN7i7aK/0/PTtUDg4QFw4k7jMYTG5oL DZsQ== X-Forwarded-Encrypted: i=1; AL+hErF46na9mzWNHL6kWtOsKFyeNYGQNvzebkAC7wJUvGzfkCJmsOXsv3HQWEPmjttNYHRz6n+atTpbvD8vaVA=@vger.kernel.org X-Gm-Message-State: AB4q+uFBZzkFsggdg+1NqfUPnNoFpD0Qszw69qENUMoRp1K9gfImyzuY VhaumXd8cZSoVdliGRIpQv2f+aKZZkNw0Lb+cePG53pHX6hp7Y/4jafyTSCrRYgTKrc= X-Gm-Gg: AZFdTZe+yQfxm8vWUeGtBHVTU1XHRl0E+vhIuTp3u8IwVlnxTEsVEbF3S/SyvQ4HInR xW4CPt6IwQ9aUEbMdZc4bFji5lULrW7UvkA1rFkZjwlnHxNpxyswdMjEa1zeW9BWI8BK4/KMCYu 3MmWQvgYWbUntFrRAFmu8gBu+/vTbZcZaM7XaICtA8yJkgvBjdZ/QS3/S2OvOkGn3nrnI3qSWgx 3jC9XpmN+HFac2396CdDZ20zNjwwnBhV5q5EZ385yY8EmnD5FKwvryMzQVTa70+GldQBvmK1VHg AhzWY2yvaw/21kPdGDAWzj//DU6zj7/tQn/l/e87/XWwa7tj9dJf5Vi6WGqf80A14YWWnCQ91MT 2zVjNxjhJ7wYkj9DrDWaMwcMCt+cNEKk1isE7NFq4EQ2kB4jS9oHdm9Sk+nONSgtQxGspGZl/sm rSPMWjVaVXwk6Q4iEYs8XF5TaopqVsOX4b4u/vDBsN99mz6Tkr7pCkI+38BwgFRyt3F97+iPVsi C9LHP7QOYDjPoPL88NNzjE8fzCoGrPoShLLME4WX3q+LuHzg2wcFuYFb82W3KPE4h9BXPrWj5K8 dM9axHgZK7De7HFT9hbmDTHl0z80UWNwAkrZ7516ZYfvqIV4zKtipFz3khAHInlcaOGOVQQsaJZ V8A8mavqX33QCtvUke4A69eLsneWZq7adfQuUuWyFCU4mqeNTfAkB7Joye3C7n1Mv X-Received: by 2002:a05:693c:8843:b0:381:c532:3d88 with SMTP id 5a478bee46e88-3875212ff71mr8582205eec.23.1796561082128; Sun, 06 Dec 2026 04:44:42 -0800 (PST) Received: from iiitd-S2600STB.iiitd.edu.in ([103.25.231.160]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-387521c102esm31305271eec.13.2026.12.06.04.44.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2026 04:44:41 -0800 (PST) From: Piyus Kedia To: Carlos Maiolino , linux-xfs@vger.kernel.org Cc: "Darrick J . Wong" , Dave Chinner , linux-kernel@vger.kernel.org, Kapil Vaswani Subject: [BUG] xfs: inode buffer verifier reads past a buffer shorter than a block Date: Sun, 6 Dec 2026 18:14:36 +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, xfs_inode_buf_verify() counts the inodes in an inode buffer by rounding the buffer's length up to whole filesystem blocks, and checks that many. Log recovery reads inode buffers at the length a log item gives, which can be less than a block, and the verifier then reads inodes past the buffer, 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. fs/xfs/libxfs/xfs_inode_buf.c:52 ni = XFS_BB_TO_FSB(mp, bp->b_length) * mp->m_sb.sb_inopblock; An inode buffer read through the inode geometry is whole blocks, but xlog_recover_inode_ra_pass2() and xlog_recover_inode_commit_pass2() read one at an inode item's ilf_len, which is not checked. 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. With ilf_len 1 on a 1 KiB-block image, readahead verification reads the second inode of a 512-byte buffer: BUG: KASAN: slab-out-of-bounds in xfs_inode_buf_verify+0x13c/0x2f0 Read of size 4 at addr ffff888050551660 by task kworker/1:0/26 Workqueue: xfs-buf/loop0 xfs_buf_ioend_work xfs_inode_buf_verify (fs/xfs/libxfs/xfs_inode_buf.c:59) xfs_buf_ioend (fs/xfs/xfs_buf.c:1141) process_one_work (kernel/workqueue.c:3497) The buggy address is located 96 bytes to the right of allocated 512-byte region (kmalloc-rcl-512, xfs_buf_alloc() from xlog_recover_inode_ra_pass2()) af133e8606d3 ("xfs: verify inode buffers as they are read from disk") brought that count in; the check it replaced in xfs_imap_to_bp() used BBTOB(imap->im_len) >> sb_inodelog. By the source, a buffer item replayed as an inode buffer (XFS_BLFT_DINO_BUF) with a blf_len of less than a block reaches the same verifier; we have not run that. 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 magic, version and di_next_unlinked of the inodes past the buffer, up to the rest of the block. They decide only whether the buffer passes the verifier; in our runs it failed and the mount failed. This one was not hit by the fuzzer: it came up while we checked the inode item's ilf_len, which the fuzzer had not changed. On ksmbd-for-next (d70570cf8003, 2026-12-04), our upstream base, whose fs/xfs is identical to mainline master (9437ee8b6cf6), with KASAN. fs/xfs/libxfs/xfs_inode_buf.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: without the patch KASAN report ilf_len 1 (a 512-byte inode buffer) 2 of 2 with the patch, kasan_multi_shot on: no report, alone in one boot and together with our other log recovery fixes in two more; the verifier checks the one inode the buffer holds, which in our image fails it ("Metadata corruption detected at xfs_inode_buf_verify"), and the mount fails with EUCLEAN. control, the same log written back unchanged: both kernels recover and mount. A patch follows in reply to this mail. It counts the inodes in the buffer's own length, as xfs_imap_to_bp() did before af133e8606d3. xfsprogs shares this file. 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 inode ilf_boffset, and an unchecked dquot qlf_boffset. This came up in the analysis of crashes found by AI-driven fuzzing built on top of syzkaller; the analysis was then checked by hand against the code, and the 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