From nobody Fri Dec 19 18:47:49 2025 Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) (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 D9EC81D5CD4 for ; Wed, 13 Aug 2025 07:17:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.181.97.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755069477; cv=none; b=CzM5eFMo5fEEw5PDexG81RMqUQvqDSjaKU7HB1uaqsnRZOMpYY8UO0VIhy1wa9mYeGRzuH0BEDDr1c3p2bo42dSVDjuxG/JgAuDsBOutBBHIBHM8dzemxlmoqW4MA7LNX8AqySCZBTCbj3EhVgviFYBjLcsgg8hYM+Mn47POdWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755069477; c=relaxed/simple; bh=yx5d22O6GS87qKAd0DQ2odvf7pYBa8UK2MQ7XPuXfkM=; h=Message-ID:Date:MIME-Version:To:From:Subject:Content-Type; b=UffIjTKpkU+VuJIkWZKD5ocwuYkXJ/nxwRw5MWwVAGgNZGvUnCVYHTaXJTNHacEd6hrO/GEqcVXEOI+zYpM+/sibe/tpjKVApVOyriBCF3nV6pfuvevwIRaela0UcdmbTfNQ8WzGtRLUL+ZOIsQl0ZRS4woTAUBua3KnG9uynZE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=I-love.SAKURA.ne.jp; spf=pass smtp.mailfrom=I-love.SAKURA.ne.jp; arc=none smtp.client-ip=202.181.97.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=I-love.SAKURA.ne.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=I-love.SAKURA.ne.jp Received: from www262.sakura.ne.jp (localhost [127.0.0.1]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 57D7HhlX016523; Wed, 13 Aug 2025 16:17:43 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from [192.168.1.10] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 57D7HgPg016520 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Wed, 13 Aug 2025 16:17:43 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Message-ID: Date: Wed, 13 Aug 2025 16:17:43 +0900 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Phillip Lougher , Andrew Morton , LKML From: Tetsuo Handa Subject: [PATCH] squashfs: Verify inode mode when loading from disk Content-Transfer-Encoding: quoted-printable X-Anti-Virus-Server: fsav404.rs.sakura.ne.jp X-Virus-Status: clean Content-Type: text/plain; charset="utf-8" The inode mode loaded from corrupted disk might by error contain the file type bits. Since the file type bits are set by squashfs_read_inode() using bitwise OR, the file type bits must not be set by squashfs_new_inode() from squashfs_read_inode(); otherwise, an invalid file type bits later confuses may_open(). Reported-by: syzbot Closes: https://syzkaller.appspot.com/bug?extid=3D895c23f6917da440ed0d Signed-off-by: Tetsuo Handa Reviewed-by: Phillip Lougher --- fs/squashfs/inode.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c index d5918eba27e3..dee8fa016930 100644 --- a/fs/squashfs/inode.c +++ b/fs/squashfs/inode.c @@ -68,6 +68,10 @@ static int squashfs_new_inode(struct super_block *sb, st= ruct inode *inode, inode->i_mode =3D le16_to_cpu(sqsh_ino->mode); inode->i_size =3D 0; =20 + /* File type must not be set at this moment, for it will later be set by = the caller. */ + if (inode->i_mode & S_IFMT) + err =3D -EIO; + return err; } =20 --=20 2.50.1