From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ewsoutbound.kpnmail.nl (ewsoutbound.kpnmail.nl [195.121.94.184]) (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 5DF6B1519B4 for ; Sat, 20 Dec 2025 19:21:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.121.94.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766258465; cv=none; b=DYilAgzhJq0NXNsEkAFH/vZNAqnRhZFog/Vqz3j+0oC5mSuR92cosxaU+oFwiTxncBxgoBT0+GhKrUsXSZ1MOKkTvSfKQCVskK7I1YGB6l8wIyLcDM2gzaEk9xZ36N6lKr0znUAq+ruv4nYytp/RXSVY3C3lXaAYFpTXu+fQq4Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766258465; c=relaxed/simple; bh=dtJfCPdHUZSrGPMxi6ZYyt4iO2zrTqVRZj3Ta+uWrwA=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: MIME-Version:Content-Type; b=ggs3LW+f29qH1zd2BB+XT/g4pRNj1aJGc3FT3IHPoKC76MZcPhxLNE3MW0xDR4LGvMdH8tFjjH2MV73izgYq+rfR9n7doxII5kjzieulesCe6NCwkbPHjt3692pj1rcsqCBP3m6meGevQPLsJk6AIKD69z/4IUKGb5qSnqYd9no= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xs4all.nl; spf=pass smtp.mailfrom=xs4all.nl; dkim=pass (2048-bit key) header.d=xs4all.nl header.i=@xs4all.nl header.b=iFWqNmWN; arc=none smtp.client-ip=195.121.94.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xs4all.nl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xs4all.nl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=xs4all.nl header.i=@xs4all.nl header.b="iFWqNmWN" X-KPN-MessageId: 95622e87-ddd9-11f0-9e68-005056994fde Received: from mta.kpnmail.nl (unknown [10.31.161.189]) by ewsoutbound.so.kpn.org (Halon) with ESMTPS id 95622e87-ddd9-11f0-9e68-005056994fde; Sat, 20 Dec 2025 20:25:03 +0100 (CET) Received: from mtaoutbound.kpnmail.nl (unknown [10.128.135.189]) by mta.kpnmail.nl (Halon) with ESMTP id 0079bdec-ddd9-11f0-b5be-0050569981f5; Sat, 20 Dec 2025 20:20:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=xs4all01; h=content-type:mime-version:subject:message-id:to:from:date; bh=OuJqAxyvu2ChhXaFqXDdBbre/ZMdIQMwq+Xnos/5apI=; b=iFWqNmWN6oTkSqbGhE1bDvLudvJEaPnzrualpXlUrvmz7nv5O49voEUVLtMO2c07S0PJW14uve4wD RV71deSNxKk5FavJ0Fvdi/C1ePtntj5yCTuI0zoNIrISuxDJmqrZcrofi6UnjtxQM0K7Hj8O15Uq/N kUpUVeadE44EppkzTnTFB/h5edcDecpdPNwlvGCKc6u3eZu8tKUapBs5E0W9xoFR3z/oK5z4nTl+zp X+6dLlmHxL9eXBKGFK0zeXsi4O6PN7mQHEKsfm1aAIkoJ5fn8pEEFEkj2LFO7IdyQciKr8QumAhWav aQv2UJSH+J0JEm5CNOA4L+fjuRZ+2sg== X-KPN-MID: 33|mqbpLdo2cvjFxSTH93WWdJcwOW9/SXOMsWDwFRV4QmEAeoI87FIBapRYKiw1xCk kFARsGy1ZWpmMGZlikZYSlDfy/3h8xe3Ankdt45Y1qa8= X-CMASSUN: 33|r5tiO5bp7OKGUdt+H5h83jTxn+Jd8zdOEWpjZVWLamrwH6NUqbh7zdGThAIOQLJ a4wY7Nd0+tQX4Wj4VJnpwVA== X-KPN-VerifiedSender: Yes Received: from cpxoxapps-mh01 (cpxoxapps-mh01.personalcloud.so.kpn.org [10.128.135.207]) by mtaoutbound.kpnmail.nl (Halon) with ESMTPSA id 006ecdbb-ddd9-11f0-94b1-00505699eff2; Sat, 20 Dec 2025 20:20:53 +0100 (CET) Date: Sat, 20 Dec 2025 20:20:53 +0100 (CET) From: Jori Koolstra To: Christian Brauner Cc: Jan Kara , Tetsuo Handa , Mateusz Guzik , Taotao Chen , linux-kernel@vger.kernel.org, skhan@linuxfoundation.org, syzbot+5ad0824204c7bf9b67f2@syzkaller.appspotmail.com Message-ID: <1956578351.2530481.1766258453335@kpc.webmail.kpnmail.nl> In-Reply-To: <3zzv4o6hiluxrxf7nlbcc3fbohtwkwmnxs6aojlgicd5cwctkk@h6nj53uelusk> References: <20251208153947.108343-1-jkoolstra@xs4all.nl> <3zzv4o6hiluxrxf7nlbcc3fbohtwkwmnxs6aojlgicd5cwctkk@h6nj53uelusk> Subject: Re: [PATCH v2] minix: Add required sanity checking to minix_check_superblock() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal Thanks for your time and the review Jan. If someone has time to pull this and https://lkml.org/lkml/2025/12/1/726 in that would be much appreciated, if there is no further critique :) Thanks and happy holidays, Jori. > Op 09-12-2025 09:48 CET schreef Jan Kara : > > > On Mon 08-12-25 16:39:47, Jori Koolstra wrote: > > The fs/minix implementation of the minix filesystem does not currently > > support any other value for s_log_zone_size than 0. This is also the > > only value supported in util-linux; see mkfs.minix.c line 511. In > > addition, this patch adds some sanity checking for the other minix > > superblock fields, and moves the minix_blocks_needed() checks for the > > zmap and imap also to minix_check_super_block(). > > > > This also closes a related syzbot bug report. > > > > Signed-off-by: Jori Koolstra > > Reported-by: syzbot+5ad0824204c7bf9b67f2@syzkaller.appspotmail.com > > Closes: https://syzkaller.appspot.com/bug?extid=5ad0824204c7bf9b67f2 > > Looks good. Feel free to add: > > Reviewed-by: Jan Kara > > Honza > > > --- > > Changes in v2: > > - Moved the minix_blocks_needed() checks for the zmap and imap also > > to minix_check_super_block(). > > --- > > fs/minix/inode.c | 50 ++++++++++++++++++++++++++++-------------------- > > 1 file changed, 29 insertions(+), 21 deletions(-) > > > > diff --git a/fs/minix/inode.c b/fs/minix/inode.c > > index 51ea9bdc813f..c8c6b2135abe 100644 > > --- a/fs/minix/inode.c > > +++ b/fs/minix/inode.c > > @@ -170,10 +170,38 @@ static int minix_reconfigure(struct fs_context *fc) > > static bool minix_check_superblock(struct super_block *sb) > > { > > struct minix_sb_info *sbi = minix_sb(sb); > > + unsigned long block; > > > > - if (sbi->s_imap_blocks == 0 || sbi->s_zmap_blocks == 0) > > + if (sbi->s_log_zone_size != 0) { > > + printk("minix-fs error: zone size must equal block size. " > > + "s_log_zone_size > 0 is not supported.\n"); > > + return false; > > + } > > + > > + if (sbi->s_ninodes < 1 || sbi->s_firstdatazone <= 4 || > > + sbi->s_firstdatazone >= sbi->s_nzones) > > return false; > > > > + /* Apparently minix can create filesystems that allocate more blocks for > > + * the bitmaps than needed. We simply ignore that, but verify it didn't > > + * create one with not enough blocks and bail out if so. > > + */ > > + block = minix_blocks_needed(sbi->s_ninodes, sb->s_blocksize); > > + if (sbi->s_imap_blocks < block) { > > + printk("MINIX-fs: file system does not have enough " > > + "imap blocks allocated. Refusing to mount.\n"); > > + return false; > > + } > > + > > + block = minix_blocks_needed( > > + (sbi->s_nzones - sbi->s_firstdatazone + 1), > > + sb->s_blocksize); > > + if (sbi->s_zmap_blocks < block) { > > + printk("MINIX-fs: file system does not have enough " > > + "zmap blocks allocated. Refusing to mount.\n"); > > + return false; > > + } > > + > > /* > > * s_max_size must not exceed the block mapping limitation. This check > > * is only needed for V1 filesystems, since V2/V3 support an extra level > > @@ -293,26 +321,6 @@ static int minix_fill_super(struct super_block *s, struct fs_context *fc) > > minix_set_bit(0,sbi->s_imap[0]->b_data); > > minix_set_bit(0,sbi->s_zmap[0]->b_data); > > > > - /* Apparently minix can create filesystems that allocate more blocks for > > - * the bitmaps than needed. We simply ignore that, but verify it didn't > > - * create one with not enough blocks and bail out if so. > > - */ > > - block = minix_blocks_needed(sbi->s_ninodes, s->s_blocksize); > > - if (sbi->s_imap_blocks < block) { > > - printk("MINIX-fs: file system does not have enough " > > - "imap blocks allocated. Refusing to mount.\n"); > > - goto out_no_bitmap; > > - } > > - > > - block = minix_blocks_needed( > > - (sbi->s_nzones - sbi->s_firstdatazone + 1), > > - s->s_blocksize); > > - if (sbi->s_zmap_blocks < block) { > > - printk("MINIX-fs: file system does not have enough " > > - "zmap blocks allocated. Refusing to mount.\n"); > > - goto out_no_bitmap; > > - } > > - > > /* set up enough so that it can read an inode */ > > s->s_op = &minix_sops; > > s->s_time_min = 0; > > -- > > 2.51.2 > > > -- > Jan Kara > SUSE Labs, CR