From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795900784; b=LrQxhDHqJDHH/XtSZ8CrBIQ5u1bSl4E5his9htw7Vc7wmFx/u8iUU43uS6Cn8OV0x8AR p25Q/PpYOM84WtrTeD6exJUeQ8+Q875KEFGjC8SK/PsJU+6nUfs73VeRD/NY0VXTr+Kya pabmohvqSgvcxrxo3bNEwBYkwTQWlBz5VZZkXNUPE9Sq6adMi7skvIRVGam+dbkJ5+dMM JMmGCL4pXyc/jwNeySG16A0LuAhnzg+75ihgxtWS2hVIU6fdiVvLUiU8rX+KoKEjpW/7H e6psWrze9POl0t7rRtQfg3wX4GGGhoKXdiavlYRslS4NNiLNT3D8bREcaqd0lMk1dAg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795900784; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: 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=PMInubs8mhBDoxjwSqJppu1ONr2tTRnB/HMAf4ie+0c=; b=hY+dfplppZ2xFmz0Bzlnzm4vw9yHeGhRWBAeh3/nMGIYxExDb3pKkab4DzcvZVEn8VP1 XyKrRIGgeFRf30iTd/OP6iHqjCXgzpSwAXLk7C5UZMFN0Pu1qR5kirGjuqdBO4tK9+ffa +smHO4WXlGfeihb3EdQZMzbfK3phFNB36n/n1PvzGQy7C9O0J6w2mE+fSTDVP9VUpVRzR +DgaBG2nO0B2mR3kqtmhRyIGM//B22RCUeY/Mv6lGCoJVmPSFXvfpaIzb1wbMMCkDOMMz AznlEa0QKE221nwAYxsi2nUBJgrm0wLGyqqpDBv6SX+WYbZA2n+MIz83gunJd82JrtA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=vmOgCRbD; arc=none smtp.remote-ip=209.85.210.46 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (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 26ECD606A33E for ; Sat, 28 Nov 2026 21:19:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 26ECD606A33E 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.a=rsa-sha256 header.s=20260707 header.b=vmOgCRbD Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-843b6f8e2c7so8650996a34.1 for ; Sat, 28 Nov 2026 13:19:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795900783; x=1796505583; 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=PMInubs8mhBDoxjwSqJppu1ONr2tTRnB/HMAf4ie+0c=; b=vmOgCRbD462/9tWOayaTQWIydft120MLC9iMXpLRsFAWROqsmXD/KQ060HmsGDkAa4 558qYX5rKYNvy+2j0TjCJt2buZdBpSJB9CkQ+wDQXaBBsrKkTwmx2fG2i6P/od9+DviA uEpOdV5PCGaX1LY5LOftBa3JHUQ+e9fOtSOqqOwwplKKI4FSG4fjcRo84hfwWGJtD3ay elaaGy8xNKv7HqZ5zZvWowgbN8/ggIFNgZZZPRSKr6NbQpEQ6UEYjE7kCIrf88ot/DQ8 DJAqk7jMGr8uBFqwoIlee625IC8gLoQc5hKmGmBKOjrHY6yubQ9k86gDRO5QEWVvYI7i 4M4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795900783; x=1796505583; 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=PMInubs8mhBDoxjwSqJppu1ONr2tTRnB/HMAf4ie+0c=; b=a8ZalQ9rsfPtYM1HIsh+6WFSHfQcOl3S1g6k2cWbZ2yGZj6sPDAECJP5OvIjyNr2eC ZEpVANW03dEkzO/L9cy5hG/4Qkp1hHbgiOLh2uoDgDzvsJX800EmjfZFLw0EFl7D/XOZ L+Ou86l8NlvHqQYH0b2JuOE48b19lFqwadltYNT1q9CUZtcpOFAMKnRyhrX6JvziVvt5 NDeoimpc+iVKWtux1uwgN+rjB86geKeX3kWEavOIVBX/rLDg0ZuFOZoF/gzVwh2Zy7t7 YCmkZolT5P/K6uY3zsM4D7nZsqoZip8kEHQukwpVVTXBzr1QRtLUQ8/qHHvLW2OKuwlE XqLw== X-Gm-Message-State: APuU4Z/vsaWsd3OP9ewBSLhwFdiqKYyE82KFmbWdAtSgL46IaQ6bqFpw ICbejJSDt6DKU31l5bVurTzHraGGCwjk1khzfsswNSO5IJCyAXLI+TzD X-Gm-Gg: AZFdTZfiuHBSJKr1etV6xjCXS0gIkp7f5EalW/UiHc5QfDmABWZTKLCofqWLFRmoag3 S8H/G2OFhVXmPZZUvEw9STJPITEyd5af5UJ+ucyrSLklD2EIEgUslKctf5jsCInkMdZw4OBt0G0 vFvUdzfGXZXOdJ6CgrHPq2FEFTe0p37Fdaa2Ixm6Yoe4aS9qnZJHNpaF1OAIVTWKJOPc4WVxuF9 iG440YgJ3jQD5oKv3K2sAheME56Hu3FGazqGPtm937sK0Njg/JtkIC2XqeQGHG2C5sbHYpuR9e+ 6zdKDQcdHvNGTWeZEktNyCzIih8zxUFwNPZvAWlXo1Ro7VsGZJaJ/tkr72Qbo3KxPKE4uUIAagX D7KtIHXn2Jc84HI3gP3cuL3F7k0pCcxlmECC4L+QfxPM+8nfhO4gyNKVNN2kASQ8DH5gZA3lDvG dPvFRtrBS1yvqZnoFyyjafrQikYoqWNSbft3kLxfZHhOCbXKAz5lAfeyTNqzbW0dGpB139I9RqM YBXu4M29/LGP92jVEuY6Xdrkf6n3zvQ6gmgc37mkwZa1/IsQ8jabJG1InTuwFlS157Q/pMJbmXb R13gGIyTgrH+RSLNRwNKp9SLt14dw1klWfnCIL9rDsHsm8ZyqeQ17vJ8pBJ3Hx/7iRgGaXHoKwx AysbQ0cMX6QoZd43fYcOJJZXWGF+79hBtSCZjBSmrnl09hyI= X-Received: by 2002:a05:6808:4fe7:b0:4f6:5279:5c75 with SMTP id 5614622812f47-57a0a50337emr33902817b6e.28.1795900783049; Sat, 28 Nov 2026 13:19:43 -0800 (PST) Received: from Wes-PC.localdomain (108-212-132-20.lightspeed.irvnca.sbcglobal.net. [108.212.132.20]) by smtp.gmail.com with ESMTPSA id 5614622812f47-57a3485a164sm20219780b6e.10.2026.11.28.13.19.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Nov 2026 13:19:42 -0800 (PST) From: Wesley Atwell To: Andrew Morton , Phillip Lougher Cc: linux-kernel@vger.kernel.org, Wesley Atwell Subject: [PATCH] squashfs: return directory read errors to readdir callers Date: Sat, 28 Nov 2026 14:19:23 -0700 Message-ID: X-Mailer: git-send-email 2.56.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 squashfs_readdir() logs a directory metadata read failure but returns 0. VFS then reports end of directory to userspace, so a scanner or backup can accept an incomplete tree as complete. On an unmodified mm-nonmm-unstable kernel, a QEMU guest mounted a valid, default-compressed SquashFS image with 3,000 nonempty files. A 4 KiB device-mapper error range inside the directory table made Fedora GNU find exit successfully after only 163 files and GNU tar exit successfully with only 164 archive entries. Healthy scans found all 3,000 files. Traced getdents64 returned a partial listing and then EOF. The injected EIO models unreadable local storage; it is not a claim of a physical-media incident. Follow squashfs_lookup() by setting EIO for invalid directory metadata, preserving negative metadata-read errors, and returning the result through the existing cleanup path. With the same fault, getdents64 now reports EIO after the partial listing, GNU find exits 1, and GNU tar exits 2 with an I/O error. Healthy scans remain complete. BusyBox find and tar still ignore the later readdir error, so this change does not correct those applets' exit status. OpenAI Codex identified the dropped read error, drafted the fix and changelog, and prepared the QEMU directory scans. GNU find and tar reported EIO with the fix under the injected metadata read fault. Healthy scans still found all 3,000 files. Signed-off-by: Wesley Atwell --- fs/squashfs/dir.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/fs/squashfs/dir.c b/fs/squashfs/dir.c index 54d228e06283..3555637a014a 100644 --- a/fs/squashfs/dir.c +++ b/fs/squashfs/dir.c @@ -180,7 +180,7 @@ static int squashfs_readdir(struct file *file, struct dir_context *ctx) block = squashfs_dir_start(squashfs_i(inode)->start, msblk); if (block < 0) - goto failed_read; + goto data_error; dire = kmalloc(sizeof(*dire) + SQUASHFS_NAME_LEN + 1, GFP_KERNEL); if (dire == NULL) { @@ -200,7 +200,7 @@ static int squashfs_readdir(struct file *file, struct dir_context *ctx) * Read directory header */ if (!squashfs_dir_space(inode, length, sizeof(dirh))) - goto failed_read; + goto data_error; err = squashfs_read_metadata(inode->i_sb, &dirh, &block, &offset, sizeof(dirh)); @@ -212,14 +212,14 @@ static int squashfs_readdir(struct file *file, struct dir_context *ctx) dir_count = le32_to_cpu(dirh.count) + 1; if (dir_count > SQUASHFS_DIR_COUNT) - goto failed_read; + goto data_error; while (dir_count--) { /* * Read directory entry. */ if (!squashfs_dir_space(inode, length, sizeof(*dire))) - goto failed_read; + goto data_error; err = squashfs_read_metadata(inode->i_sb, dire, &block, &offset, sizeof(*dire)); @@ -231,10 +231,10 @@ static int squashfs_readdir(struct file *file, struct dir_context *ctx) /* size should never be larger than SQUASHFS_DISK_NAME_LEN */ if (size > SQUASHFS_DISK_NAME_LEN) - goto failed_read; + goto data_error; if (!squashfs_dir_space(inode, length, ++ size)) - goto failed_read; + goto data_error; err = squashfs_read_metadata(inode->i_sb, dire->name, &block, &offset, size); @@ -252,7 +252,7 @@ static int squashfs_readdir(struct file *file, struct dir_context *ctx) type = le16_to_cpu(dire->type); if (type > SQUASHFS_MAX_DIR_TYPE) - goto failed_read; + goto data_error; if (!dir_emit(ctx, dire->name, size, inode_number, @@ -267,11 +267,14 @@ static int squashfs_readdir(struct file *file, struct dir_context *ctx) kfree(dire); return 0; +data_error: + err = -EIO; + failed_read: ERROR("Unable to read directory [%llx:%x]\n", squashfs_i(inode)->start, squashfs_i(inode)->offset); kfree(dire); - return 0; + return err; } base-commit: 941b98138a3df2127ebb5d187bb8f04858f9ed1b