Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4481373rdb; Fri, 15 Sep 2023 03:47:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOIeOCjfnvju0E3t55DpDyp4H4wG7Ezlw8EApN3bTv1/fTZ5VUEX+efAu0wYFVqSP/H2Tc X-Received: by 2002:a05:6a20:6a20:b0:12b:fe14:907e with SMTP id p32-20020a056a206a2000b0012bfe14907emr1565239pzk.20.1694774831472; Fri, 15 Sep 2023 03:47:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694774831; cv=none; d=google.com; s=arc-20160816; b=UJsy55yIXPyaiMwoZQWUAqvu9w9RXpnqeFvafLGCjqC4Qk+7VLEAVcjTmaypGMb4ks xMsR4lSpQFnWN2aqKENsI9gIkeITYpPRISn2yiFH/Cift3o/YS3294l5+Ka72MRoS1ke ObbdoRXRPFDMgPox5LygVI1PVwbsPVEchkhFqBkDaNT15q+EozQJPooFLcWcGZfuq4lq 71waSofQSZ/crPfMUs0zjR0rKiMRRJr0rS31XY066bBpKpQfZHcD2zNymR1CIUJoU3At hhhG/7y3u2Qccy7RGqROYnnwWvqYr+/i44ZkfEilJucyKvyOET8jRIfEj7I663xqfrZI 4G0w== 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:dkim-signature; bh=kwWvVl8aOTD5MluoXekdmrqRM+dRNHxbE45XnwaB2gw=; fh=8/oUzX0iC8yQPfNntb0eYWSKSldSlVaTv/n/37u/K2I=; b=TIkMKXAdY1fd3rGfm7dUY7ga4wYEhPcI7dcToNOkSvtIhWv7XQCEioAwDqVJgRbj4S gXmAM4kT1TtErvf7uapE67MSagMfvbDt50IcIvFlFqHdf/aCu7fwTn/ilxqgujo9Xngo 8kD5x4G0f3A1Hquo7jWVnaaR+++WfeKcgbHVf2IbGE+jbKlphFTczOabSSa52f8h/K55 9sTHRxktZ1/HwKjP7VuChl64ZKWEySfml+CbA9DaE/XCAudbcx7FzcWaS3o2kwZefOuN 11QmGiVIwQhNvYV4s0niuGMp34Y4NLjvNICEQL3w0I1yE+uZsZPyJRcBuiaJzaFdOw6W ohaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=C9zntzdF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id t18-20020a17090ad51200b00274aeabd1d8si62637pju.70.2023.09.15.03.47.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 03:47:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=C9zntzdF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 374FA837D492; Thu, 14 Sep 2023 09:51:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233926AbjINQvn (ORCPT + 99 others); Thu, 14 Sep 2023 12:51:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231588AbjINQvm (ORCPT ); Thu, 14 Sep 2023 12:51:42 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9886C1BCB for ; Thu, 14 Sep 2023 09:51:38 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1c337aeefbdso10657255ad.0 for ; Thu, 14 Sep 2023 09:51:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694710298; x=1695315098; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=kwWvVl8aOTD5MluoXekdmrqRM+dRNHxbE45XnwaB2gw=; b=C9zntzdFcoblYjLzyZqQ2T3AWK08feI2T3ILWTxEU1Y1hRewCdrVgsthJ1PEy4aaUq vVFf5NSTTJQ+/utw1HYaYBUFHYGQ9FUJl++YOz83Ao20/TrNqTim/rqGTSUKrA8afp6y h/T8eUpHOwKArCSF7aPgJOhK+fOzWnLjASZQY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694710298; x=1695315098; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=kwWvVl8aOTD5MluoXekdmrqRM+dRNHxbE45XnwaB2gw=; b=ZJ4HShn+0qaQtiZoTAGV3kXfkpEmC1y4YW160OX5SjnKDrt7ggHbxYI4dudKL6rTF0 P4RPJ6IydM+/9bl1J7K9W37xFtnV9Efk59vP5d9M/aAT3DnjUEx7jJ4wocNW2DojwdGI 8J3Edf6IXtlet5DuWg3QjlUQRTm6vvvuvEKPyxiNgH0XOwtcaHQoqS4iVAnTdlLq1gBm /lpluLE7V1A4l8tNIAeC63N1cBRBWez8WXbZ5XfL5iP4+g1YWCKpMysVNLyXMFpn/dGD XVh9uS0lIdtjKsR17FIEklhQHlKaFV9WxXvVNlC7iFvwvCaqq/M4wS6ao6jMh23Bqcw9 8HWQ== X-Gm-Message-State: AOJu0YydrcYnmwTzXAQMivsploOOpJFMnjpCGwfNsLit4XKtGhO7b0Q4 I3d74gaRTVgK1/RvBuI0om/Iyg== X-Received: by 2002:a17:902:650d:b0:1c3:d9ed:d16e with SMTP id b13-20020a170902650d00b001c3d9edd16emr5531650plk.39.1694710298093; Thu, 14 Sep 2023 09:51:38 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id n1-20020a170902d2c100b001c322a41188sm1817053plc.117.2023.09.14.09.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 09:51:37 -0700 (PDT) Date: Thu, 14 Sep 2023 09:51:36 -0700 From: Kees Cook To: Josh Poimboeuf Cc: Randy Dunlap , Stephen Rothwell , Linux Next Mailing List , Linux Kernel Mailing List , Kent Overstreet , Peter Zijlstra Subject: Re: linux-next: Tree for Sep 12 (bcachefs, objtool) Message-ID: <202309140951.F73B5557D6@keescook> References: <20230912152645.0868a96a@canb.auug.org.au> <20230913210829.zkxv6qqlamymhatr@treble> <202309131758.208804F4@keescook> <20230914135144.udwf3lmhh5zael5e@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230914135144.udwf3lmhh5zael5e@treble> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 14 Sep 2023 09:51:45 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email On Thu, Sep 14, 2023 at 03:51:44PM +0200, Josh Poimboeuf wrote: > On Wed, Sep 13, 2023 at 06:01:42PM -0700, Kees Cook wrote: > > > +++ b/fs/bcachefs/buckets.h > > > @@ -180,7 +180,7 @@ static inline u64 bch2_dev_buckets_reserved(struct bch_dev *ca, enum bch_waterma > > > > > > switch (watermark) { > > > case BCH_WATERMARK_NR: > > > - unreachable(); > > > + BUG(); > > > > Linus gets really upset about new BUG() usage (takes out the entire > > system): > > https://docs.kernel.org/process/deprecated.html#bug-and-bug-on > > > > It'd be nicer to actually handle the impossible case. (WARN and return > > 0?) > > Sure, see below. Looks good to me; thanks! -Kees > > BTW, I'm about to go off grid for 1.5 weeks, so there will be no v3 > coming from me anytime soon :-) > > ---8<--- > > From: Josh Poimboeuf > Subject: [PATCH v2] bcachefs: Remove undefined behavior in bch2_dev_buckets_reserved() > > In general it's a good idea to avoid using bare unreachable() because it > introduces undefined behavior in compiled code. In this case it even > confuses GCC into emitting an empty unused > bch2_dev_buckets_reserved.part.0() function. > > Use WARN_ON(1) instead, which is nice and defined. While in theory it > should never trigger, if something were to go awry and the > BCH_WATERMARK_NR case were to actually hit, the failure mode is more > robust. > > Fixes the following warnings: > > vmlinux.o: warning: objtool: bch2_bucket_alloc_trans() falls through to next function bch2_reset_alloc_cursors() > vmlinux.o: warning: objtool: bch2_dev_buckets_reserved.part.0() is missing an ELF size annotation > > Reported-by: Randy Dunlap > Signed-off-by: Josh Poimboeuf > --- > fs/bcachefs/buckets.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/fs/bcachefs/buckets.h b/fs/bcachefs/buckets.h > index f192809f50cf..211f054bf83d 100644 > --- a/fs/bcachefs/buckets.h > +++ b/fs/bcachefs/buckets.h > @@ -180,7 +180,8 @@ static inline u64 bch2_dev_buckets_reserved(struct bch_dev *ca, enum bch_waterma > > switch (watermark) { > case BCH_WATERMARK_NR: > - unreachable(); > + WARN_ON(1); > + break; > case BCH_WATERMARK_stripe: > reserved += ca->mi.nbuckets >> 6; > fallthrough; > -- > 2.41.0 > -- Kees Cook