Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2061162pxb; Fri, 5 Mar 2021 06:34:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1cCya1EWjzzmx7GqeG+Z+c5KIJ03ZWZvcgFKam3EHehy2AeUX6pB9eEJo68bAijg2xUbE X-Received: by 2002:a17:907:3e8c:: with SMTP id hs12mr2474037ejc.105.1614954854734; Fri, 05 Mar 2021 06:34:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614954854; cv=none; d=google.com; s=arc-20160816; b=HrPoYW8pf4TdidSzX+pzW4MU5Gbo1h9osJcWm46ly/0Jy5F3gezTewayidTzPhwGEB d7Apw6V7S1rvHfTVkkYRKpSVwT9jNbXPeq/Jt3QIClwDe/lDjLkM1NI7+GJ4GmbiVpo0 y3xaAG/G45f5m3ASa7SV5wKDht2XUkdUfsTDGHkSLjqyUNzdt34FdAjMmsA3VEeKTEkh tqbI2+BbJxnxzdG4gqBLhug9wiI4T/vtBeijR0d++fDVhwqtygS7z7jQT1mMUYxqj34J /7QHM5mOkoVRs7oKVbc6J/Ep4LMyZkFsFqgWmJECP1dMa2FYVfYtTJeRTM2hxZuVf8I1 B3fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=otwQ1Bg3fR/eZErmKdKMHZgjV63eif97Spd5e/R29oU=; b=XfSxBbc36Zb7+glI/DT4RjJY7SYZlCp9ZkonPO8/LIiW8Vc7PHpXSL3pwBQCFuvblU UmffehbhULHLeni3DA3DmT46KoWvzqQtB+523VqcUVbrouFifJoE3R5XZrewGWq+/rjI x4+EOM7xkmfpc+RMFSsSzODEE/VvSikqTIzR+dWdeZ+DkvpJ5h9vQD0eaRsveG4HIMkB 4rFDDxzY8fOP4cPBzKtq/eJHSIUF5gVwak7564a+0CQAEckVl2/Z6IMNTPnsxqpJ3MRm cqyzUaPo3CfnxEQMoPZ4RfQ3cf8SOPkA36Adv6cJEzU5Pty1kWHVr8KeBkR6Adstzae6 gS0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b4si1596778edn.586.2021.03.05.06.33.50; Fri, 05 Mar 2021 06:34:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230289AbhCEOdH (ORCPT + 99 others); Fri, 5 Mar 2021 09:33:07 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:46413 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230177AbhCEOcr (ORCPT ); Fri, 5 Mar 2021 09:32:47 -0500 Received: from cwcc.thunk.org (pool-72-74-133-215.bstnma.fios.verizon.net [72.74.133.215]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 125EWewb023284 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 5 Mar 2021 09:32:41 -0500 Received: by cwcc.thunk.org (Postfix, from userid 15806) id 4EEE515C3A88; Fri, 5 Mar 2021 09:32:40 -0500 (EST) Date: Fri, 5 Mar 2021 09:32:40 -0500 From: "Theodore Ts'o" To: Sabyrzhan Tasbolatov Cc: jack@suse.cz, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+a8b4b0c60155e87e9484@syzkaller.appspotmail.com Subject: Re: [PATCH v2] fs/ext4: fix integer overflow in s_log_groups_per_flex Message-ID: References: <20210223170118.GD30433@quack2.suse.cz> <20210224095800.3350002-1-snovitoll@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210224095800.3350002-1-snovitoll@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed, Feb 24, 2021 at 03:58:00PM +0600, Sabyrzhan Tasbolatov wrote: > syzbot found UBSAN: shift-out-of-bounds in ext4_mb_init [1], when > 1 << sbi->s_es->s_log_groups_per_flex is bigger than UINT_MAX, > where sbi->s_mb_prefetch is unsigned integer type. > > 32 is the maximum allowed power of s_log_groups_per_flex. Following if > check will also trigger UBSAN shift-out-of-bound: > > if (1 << sbi->s_es->s_log_groups_per_flex >= UINT_MAX) { > > So I'm checking it against the raw number, perhaps there is another way > to calculate UINT_MAX max power. Also use min_t as to make sure it's > uint type. > > [1] UBSAN: shift-out-of-bounds in fs/ext4/mballoc.c:2713:24 > shift exponent 60 is too large for 32-bit type 'int' > Call Trace: > __dump_stack lib/dump_stack.c:79 [inline] > dump_stack+0x137/0x1be lib/dump_stack.c:120 > ubsan_epilogue lib/ubsan.c:148 [inline] > __ubsan_handle_shift_out_of_bounds+0x432/0x4d0 lib/ubsan.c:395 > ext4_mb_init_backend fs/ext4/mballoc.c:2713 [inline] > ext4_mb_init+0x19bc/0x19f0 fs/ext4/mballoc.c:2898 > ext4_fill_super+0xc2ec/0xfbe0 fs/ext4/super.c:4983 > > Reported-by: syzbot+a8b4b0c60155e87e9484@syzkaller.appspotmail.com > Signed-off-by: Sabyrzhan Tasbolatov Applied, thanks. - Ted