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 3C8772DF153 for ; Sat, 17 Jan 2026 19:51:59 +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=1768679523; cv=none; b=c8jbh1xq6BfNrY8MEH1yr9aELJCQjmdtj+DB1Qr2mIsD3+bkGsH1c2srIGxQlGlje9QqrzTUflAJp7rh10clSdU8Nj1Py9cC+E0JyKpIVu1rlchHeFk+YHD1Oa1/kxOZCdfjtu9JsibV67Oo5DeqODdeR2aUt9yik4JYALu9kqs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768679523; c=relaxed/simple; bh=lcX6Yj0aycHiGSgp7iGzuY3J3lBOW2WmWtfDAwJkJUk=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: MIME-Version:Content-Type; b=KYvn5J4r54IMyCuvtuGhi5aAJZM4rTSJudXMd/M906Rbqt6ZHC5cnYL3/PP8gI19kd54vnWeTbemo95uTamrs1KB98/q6xcBNFo6Es/aQzztZAnDfo9Qk0/aWQ1IqK75Z3Vx3Di5L5BbFrXdz0lJSbhYIwCK3VIuut97kwjIfpY= 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=MUCoNUGR; 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="MUCoNUGR" X-KPN-MessageId: d1e164bc-f3dd-11f0-af3f-005056994fde Received: from mta.kpnmail.nl (unknown [10.31.161.190]) by ewsoutbound.so.kpn.org (Halon) with ESMTPS id d1e164bc-f3dd-11f0-af3f-005056994fde; Sat, 17 Jan 2026 20:50:48 +0100 (CET) Received: from mtaoutbound.kpnmail.nl (unknown [10.128.135.190]) by mta.kpnmail.nl (Halon) with ESMTP id d276943e-f3dd-11f0-99c2-0050569977a2; Sat, 17 Jan 2026 20:50:49 +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=jiTQsrqSWFRVkOqPUBtB14O1d7gc5deMsQjYquByljA=; b=MUCoNUGRET3wtfkCMobkFLkFgo/m5/AoT17fCC8cCSEF8NUlXj2NsKTIZtIXHVTHPP7pXOLU0KpcV 8LH9QpntRjklmdSfWC/YS+AL9AqDQ/jSvdpjyfVZJtmarGGlzbSa1Il6BemNuGYZ1IVbhTkus+CwLb DE6d1MiCEwarOpedkLE6LinzfKNX6Tzivo8AmSrg4llX0KdBStZ8jrHlcXIxZbTSn9vugPbmsWD5pd 5+JJ64kv9T6Jb5zCXzz1gTdAFrz8T2fKZ12iLyZGHhsr87pFTU8ccH4rgthWxDqVJrs/wckx/vv8S6 ptXHmwKiq+7ZrIz2SOlJMQcvj3Vn/zg== X-KPN-MID: 33|t9VK1kLznDqPDAg1ECPfbosgZZT9LNutoVILMVASKSG4qIsBauZNCHWC9nUmPZK VUMwsbSWJthKU+8d8sV/Ak5aMiJmUNbYJMnKZqj4VvWY= X-CMASSUN: 33|EVv01zTm3/wcJ2yy7PO77qEqcUT9Hal5faREpyjQuRmw/0ZR6ctrdq1n3MMGHQv w64V0cxy/vhqiEO5FIiMI2A== X-KPN-VerifiedSender: Yes Received: from cpxoxapps-mh04 (cpxoxapps-mh04.personalcloud.so.kpn.org [10.128.135.210]) by mtaoutbound.kpnmail.nl (Halon) with ESMTPSA id d2707eac-f3dd-11f0-b8d7-005056995d6c; Sat, 17 Jan 2026 20:50:49 +0100 (CET) Date: Sat, 17 Jan 2026 20:50:49 +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: <16607624.1776549.1768679449235@kpc.webmail.kpnmail.nl> In-Reply-To: <3zzv4o6hiluxrxf7nlbcc3fbohtwkwmnxs6aojlgicd5cwctkk@h6nj53uelusk> References: <20251208153947.108343-1-jkoolstra@xs4all.nl> <3zzv4o6hiluxrxf7nlbcc3fbohtwkwmnxs6aojlgicd5cwctkk@h6nj53uelusk> Subject: [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 Hello Christian, If you have time I would greatly appreciate if you can apply this minix patch reviewed by Jan Kara (and my other minix patch that is also still outstanding). I would normally not be in a hurry, but it has been outstanding for over a month and I need to get two more patches upstream to graduate the LFX Linux Kernel Mentorship program, and I am already overdue. So it would really help me out if you could take a look. Thanks, Jori. PS. Saw you will speak on VFS at FOSDEM this year. Hope to see you there. > 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