Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3802136pxf; Mon, 29 Mar 2021 11:50:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyUtRkcvpbO9OPIUsl7Z+Tp/QkdqQkgYlyuTiyWaewq3R47UpSw2KL7e7yY+LTiv5jnf2Z X-Received: by 2002:a50:9ea4:: with SMTP id a33mr30689901edf.295.1617043825710; Mon, 29 Mar 2021 11:50:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617043825; cv=none; d=google.com; s=arc-20160816; b=iqRuPs0qrcHXJ1G97OOpd24aNxex/2QUt6TvPk0A1SdnfjakCxCVM2hr5RbgTxxqvM whds++2gtSewMeW6EBtkK169B+klw2HJ7EahXwswOQxqMo6/TE1UrgGCYPhhfk4I6+4b v4gEUhvKRNl65/tMvoF8KHIQS/Dr6CFXIPlvtrtUJBfBckvo8g7PXukQIUmmLbWvaBQu B0qa6Tz1TjH2yqXJSiM6avggg21CPS/eINwylljMkQj3lrCPOfTLJ0dvDJ18ceoiHN78 k1d45fzc0lVPiQcEaZ2VHJWPq+2qLUk6hRS6l4mO0w7BQ+/5S/u11D7E/DvZKhI6/lpb nE7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:mail-followup-to :reply-to:message-id:subject:cc:to:from:date; bh=1lw4eegOxY2Bkjam906sxccb6wXgIosqVGerp1CNkqE=; b=WRdYSfDwnEyWdvyHVyIs4Qh1vgnBiCJQ6Etmterwqps4/uhpEB4eZnEllK8jm2zb7W PxkqJNfz0H8jOi8VuoYQbPKtCessGNP8bU4/YFVQLgHKy69uvaGf4xJk1Di3GUV35Zlo XQKVgN6G1Cd8BhpizSCyhflfp9aEkPBBofx2+H0jXyXgnjT5O9tik4BtdRLlD5E+1JTo DAw4DYwwDF7Dh2F6aQp0Q1a6pQcfV3obpP5koJPm9kSJ44OsVjZKmNsyy4I4w+ckPz0+ B9tmPl7ASQBv1GAP4sEngAJsyYVrlLFW/5iIsjMpc2ISjMM/7v7cOcOUnpm11dHHt/9O 4P8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 b24si8551596edt.285.2021.03.29.11.50.02; Mon, 29 Mar 2021 11:50:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231219AbhC2Squ (ORCPT + 99 others); Mon, 29 Mar 2021 14:46:50 -0400 Received: from mx2.suse.de ([195.135.220.15]:45346 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231509AbhC2Sqk (ORCPT ); Mon, 29 Mar 2021 14:46:40 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 9B397AFF5; Mon, 29 Mar 2021 18:46:39 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 7A276DA842; Mon, 29 Mar 2021 20:44:31 +0200 (CEST) Date: Mon, 29 Mar 2021 20:44:31 +0200 From: David Sterba To: Arnd Bergmann Cc: Chris Mason , Josef Bacik , David Sterba , Anand Jain , Naohiro Aota , Arnd Bergmann , David Sterba , Nikolay Borisov , Johannes Thumshirn , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] [v2] btrfs: zoned: bail out in btrfs_alloc_chunk for bad input Message-ID: <20210329184431.GT7604@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Arnd Bergmann , Chris Mason , Josef Bacik , David Sterba , Anand Jain , Naohiro Aota , Arnd Bergmann , Nikolay Borisov , Johannes Thumshirn , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210323143128.1476527-1-arnd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210323143128.1476527-1-arnd@kernel.org> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 23, 2021 at 03:31:19PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann > > gcc complains that the ctl->max_chunk_size member might be used > uninitialized when none of the three conditions for initializing it in > init_alloc_chunk_ctl_policy_zoned() are true: > > In function ‘init_alloc_chunk_ctl_policy_zoned’, > inlined from ‘init_alloc_chunk_ctl’ at fs/btrfs/volumes.c:5023:3, > inlined from ‘btrfs_alloc_chunk’ at fs/btrfs/volumes.c:5340:2: > include/linux/compiler-gcc.h:48:45: error: ‘ctl.max_chunk_size’ may be used uninitialized [-Werror=maybe-uninitialized] > 4998 | ctl->max_chunk_size = min(limit, ctl->max_chunk_size); > | ^~~ > fs/btrfs/volumes.c: In function ‘btrfs_alloc_chunk’: > fs/btrfs/volumes.c:5316:32: note: ‘ctl’ declared here > 5316 | struct alloc_chunk_ctl ctl; > | ^~~ > > If we ever get into this condition, something is seriously > wrong, so the same logic as in init_alloc_chunk_ctl_policy_regular() > and a few other places should be applied. This avoids both further > data corruption, and the compile-time warning. > > Fixes: 1cd6121f2a38 ("btrfs: zoned: implement zoned chunk allocator") > Link: https://lore.kernel.org/lkml/20210323132343.GF7604@twin.jikos.cz/ > Suggested-by: David Sterba > Signed-off-by: Arnd Bergmann Added to misc-next, thanks.