From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-112.freemail.mail.aliyun.com (out30-112.freemail.mail.aliyun.com [115.124.30.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B111C38C423 for ; Mon, 4 May 2026 10:28:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.112 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777890512; cv=none; b=jcQiiUHDIjF0mQN/KtL5t+bWFSBN32Za/jys767zHQ5p3JCWuQMqheur6KjP8tZXkifDgmYVwKxg5DrdRH5+r6aeNvIlpAjlpGsoGw0iCJq7gE6BR/jcVVat+s7sY1g/xRFMT+QWWz3mRRZb456s4/turNu5R/7vdcil8atZF6M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777890512; c=relaxed/simple; bh=l0u+qIbMG4K3gGG4R1IQyfVCAKBiFcgivd12uIl/stQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=fDsujxn3OAfZDDM6eiDJW5NKECfCTPenbOrdjtUnsQCoESMzOzhlrcAhCUJGbG7WCzpWF4hRJo0EDVB5hCYFjbhQZJXj0q33oAtu1WiV0x24d0dBbNFcuKqF/LSsZQCAxibzqRVwIumuUPiYeergv6MgF/ak7NYZdJAOu+QemR0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=GQXY4v5U; arc=none smtp.client-ip=115.124.30.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="GQXY4v5U" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1777890501; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=WnrwbVqsOYhf12NlUY/G8R9GdmmzIFV33O/wNPiZVKY=; b=GQXY4v5UxLDeR8tpus8UjaTJwjAAXd+1adpgCe936t6fr1jJFIJlXR04IJJxZOIgwL6CW7p3femVBVr/jzmvQ+KNkOW03DwGQtICnDhbcBN/YzniSnVz5hqTOar1/cPZwplIucpfSpSl2tVbkmuiv8eLHl0TxG2uG5SteVt2VIQ= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R821e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037026112;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0X2Aqmdj_1777890494; Received: from 30.69.177.140(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0X2Aqmdj_1777890494 cluster:ay36) by smtp.aliyun-inc.com; Mon, 04 May 2026 18:28:20 +0800 Message-ID: <4895cf47-70e2-45ec-a7d1-3a762d09c515@linux.alibaba.com> Date: Mon, 4 May 2026 12:28:13 +0200 Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 5.10.y] erofs: fix the out-of-bounds nameoff handling for trailing dirents To: Sasha Levin , stable@vger.kernel.org Cc: Yuhao Jiang , Junrui Luo , Chao Yu References: <2026050132-spender-underfoot-6d7b@gregkh> <20260501191150.3973995-1-sashal@kernel.org> From: Gao Xiang In-Reply-To: <20260501191150.3973995-1-sashal@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2026/5/2 03:11, Sasha Levin wrote: > From: Gao Xiang > > [ Upstream commit d18a3b5d337fa412a38e776e6b4b857a58836575 ] > > Currently we already have boundary-checks for nameoffs, but the trailing > dirents are special since the namelens are calculated with strnlen() > with unchecked nameoffs. > > If a crafted EROFS has a trailing dirent with nameoff >= maxsize, > maxsize - nameoff can underflow, causing strnlen() to read past the > directory block. > > nameoff0 should also be verified to be a multiple of > `sizeof(struct erofs_dirent)` as well [1]. > > [1] https://sashiko.dev/#/patchset/20260416063511.3173774-1-hsiangkao%40linux.alibaba.com > > Fixes: 3aa8ec716e52 ("staging: erofs: add directory operations") > Fixes: 33bac912840f ("staging: erofs: keep corrupted fs from crashing kernel in erofs_readdir()") > Reported-by: Yuhao Jiang > Reported-by: Junrui Luo > Closes: https://lore.kernel.org/r/A0FD7E0F-7558-49B0-8BC8-EB1ECDB2479A@outlook.com > Cc: stable@vger.kernel.org > Signed-off-by: Gao Xiang > Reviewed-by: Chao Yu > [ replaced upstream `bsz` with `PAGE_SIZE` and `sizeof(*de)` with `sizeof(struct erofs_dirent)` ] > Signed-off-by: Sasha Levin Looks good to me. Thanks, Gao Xiang