From nobody Thu Apr 2 14:08:20 2026 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) (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 080E92EB10 for ; Sat, 28 Mar 2026 15:00:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774710049; cv=none; b=WIbbfpda0V7138bf9HzLxD8wmE4+bhZYaAbhIBpfIjvHqt25TEnt1tpGLoo+iOosCVJvBy2rJDltPIDPwXjYAmJRFGrsHxEUVmOWbOgDqyP5nxue6Y/4TFHOg56uvFg4xuPPLt2umpKhNm2BoqWeLgDawA/bPT5qfnBp4PFBmjA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774710049; c=relaxed/simple; bh=8ZVqhZ/N1PdMAWTWRuymqWQ5zXGNYBpTlwAycXGZ7jQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=tk5cm2IsdLYudWObNbkVzZ4yBSzAEaDRDvTyTFBdpOB1aFQpxjjfe/OGx1bow5dNsgo7Kp3aPHPayjHSt7Vy6ChbUTq0gHmi6ESgJ5qw30OAhC63hM745VpFOrHojWIDI9cVATKjuLVDbHWFGY+EpaaiKn5Rn+d8Ft4M6QAOIh0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kbuL8wGv; arc=none smtp.client-ip=209.85.215.177 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.b="kbuL8wGv" Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-c2af7d09533so2388369a12.1 for ; Sat, 28 Mar 2026 08:00:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774710047; x=1775314847; 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; bh=qUWulkuc6nwiMpNnsS5d9tfMi0kH9Q6gq1CmIp5Vans=; b=kbuL8wGv6tOTfB6Mm+UCbmak+ITUN0T9IoThMlQrYgX5/7R8YxKr8jq24lKBpUdBYx MPcAisMb2Uobm7QuR4PBwrM1tkXMd9R2/BUHoadOuJ6fq5HtG8tk08cj4InCx/EPn6X0 jypmyvwvhJhvCgRtDyG/BfdIkLZL3uszZFsh87EgG723raA1/4RsBARL/0tXVieTv062 cFJBHIA7d4ZpjPFMgsuJM5Xip132ikyGgFgIamIkyBM1MItOirTcwFa0nzAzb4HOOCTN LJf/ov307sQWLONcKcwGtshk8cOlMB784VqF6/6b9VViv7uhQmXAwqeW7tS3csgpNeM1 YQVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774710047; x=1775314847; 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; bh=qUWulkuc6nwiMpNnsS5d9tfMi0kH9Q6gq1CmIp5Vans=; b=naVhu7ocsp3tkBWmEBVt2eTbNBT5HJ3rVS6jZiEYZHWuylV/EfRKzUDReqdd0deM7F 6/HwZXvdTPQPaceFS58PpZi1iP0xQ8LnDMQdD++kqK3o3mP5/V9Lv/iCkTPnTmqHZEnT Go4JZt12cc+zPbsSJ5a2jNKqN+cp7PBGVsGr1oK3VRPIr33WIXcyQxcU9RplP7WIa1Vz wr/9ka93tiUARk27yN6FeST2JgNRTr9dZdeAe/oXmcRsqTuW4PqlfXPYj8hhGglTW2ja EvRg82gVItGXFFfDvy9vzp69BcQfAdO1KH6Sn1XxNTVEZJE+J19jdkbzDiV+LB8jz0YL DLXg== X-Forwarded-Encrypted: i=1; AJvYcCUJg5j0LWaDsPhRv0lYA5G3rDq+cGVSNH22XIEoiTBViHU6PIUS2Zg/jcD5g5KF+iBUHIPGf1jf70XlUN0=@vger.kernel.org X-Gm-Message-State: AOJu0Ywc7lFaVp00iYtWWvAry9oSmPHMhxisdnQq4qJA8jjapmPrGtym jf9pPPYHYkOhsgVopJynReUvkEKjV47+jsoMJ/8kArP3sW8/LX+L04lybHiEkA== X-Gm-Gg: ATEYQzyRayopd+pYjmX814sF7h2qpv8bm94rCmnHBxCjl3LUTt2ePWxMpzHFy9nqbCP 5cvgYCCHPNOJpxUg4JPodMvVwV4Yw9lkeM5NAd/qmlOjJ7UQrzfiOHGYBS10UmsQEiPfeZ7sfqm jtf9u613+TRy7YgbqKw5i5PPZhojCui5awT4Kugs8neM7u392/bhwxP1+aMGU7LWMyZvsN21W39 OQsXpSwqFORXC2Nige1JxVJE3jh8kuH0FnMsC2TG5n1VqZZipcCO8cCSnQoqHNxHNJvjHkfJGtJ b3ZnmH+CxkDZrtgEZNhCBgUltoz/3zH+nXBYGfP32zfy1AsJpTqTcy85vRH809qM4kjRdqoBjg+ P3LQAgeh6TER5cCU31Bigyc/cGinXe+05DQANnLtQoa7eDhVglhZRdQoYvdP5kxq5XEQsWdaPNq z2WaxHRyiuJUAu7xlg3WcZiJQSlxeWYERjIYFcTqf2IqSvpvqtrVJOiOO7Tv8Kp3P/chcM+uSST iJE7QJDHUaGSD0mBg== X-Received: by 2002:a05:6a20:a12b:b0:398:9466:2eef with SMTP id adf61e73a8af0-39c87812061mr7154979637.12.1774710046987; Sat, 28 Mar 2026 08:00:46 -0700 (PDT) Received: from deepanshu-kernel-hacker.. ([2405:201:682f:389d:7beb:e3a8:8b1a:3a0d]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82ca85fc6e9sm2653328b3a.46.2026.03.28.08.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Mar 2026 08:00:46 -0700 (PDT) From: Deepanshu Kartikey To: tytso@mit.edu, adilger.kernel@dilger.ca Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, Deepanshu Kartikey , stable@vger.kernel.org, syzbot+fb32afec111a7d61b939@syzkaller.appspotmail.com Subject: [PATCH v2] ext4: fix bounds check in check_xattrs() to prevent out-of-bounds access Date: Sat, 28 Mar 2026 20:30:38 +0530 Message-ID: <20260328150038.349497-1-kartikey406@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The bounds check for the next xattr entry in check_xattrs() uses (void *)next >=3D end, which allows next to point within sizeof(u32) bytes of end. On the next loop iteration, IS_LAST_ENTRY() reads 4 bytes via *(__u32 *)(entry), which can overrun the valid xattr region. For example, if next lands at end - 1, the check passes since next < end, but IS_LAST_ENTRY() reads 4 bytes starting at end - 1, accessing 3 bytes beyond the valid region. Fix this by changing the check to (void *)next + sizeof(u32) > end, ensuring there is always enough space for the IS_LAST_ENTRY() read on the subsequent iteration. Fixes: 3478c83cf26b ("ext4: improve xattr consistency checking and error re= porting") Cc: stable@vger.kernel.org Reported-by: syzbot+fb32afec111a7d61b939@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3Dfb32afec111a7d61b939 Link: https://lore.kernel.org/all/20260224231429.31361-1-kartikey406@gmail.= com/T/ [v1] Signed-off-by: Deepanshu Kartikey --- v2: Move the fix to check_xattrs() as suggested by Ted Ts'o, instead of adding a check in ext4_xattr_ibody_get(). --- fs/ext4/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 7bf9ba19a89d..c6205b405efe 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -226,7 +226,7 @@ check_xattrs(struct inode *inode, struct buffer_head *b= h, /* Find the end of the names list */ while (!IS_LAST_ENTRY(e)) { struct ext4_xattr_entry *next =3D EXT4_XATTR_NEXT(e); - if ((void *)next >=3D end) { + if ((void *)next + sizeof(u32) > end) { err_str =3D "e_name out of bounds"; goto errout; } --=20 2.43.0