Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3966769rdh; Tue, 28 Nov 2023 08:19:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGos0ttfzGtzvxFjqC/HO4BjvlFgWmj5vrG+J27JkOHGsZV3prb5r3Ta+9f/Qv1Ama3Lve3 X-Received: by 2002:a05:6a20:144a:b0:18c:548d:3d1a with SMTP id a10-20020a056a20144a00b0018c548d3d1amr11625387pzi.58.1701188362055; Tue, 28 Nov 2023 08:19:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701188362; cv=none; d=google.com; s=arc-20160816; b=0FWJGAlSRxjAS3mJO4IkX2l4m7T3Y8ZvYGto+DN9xwmySYspyOw6rkSbfKvNQFbimE 3esJrofLJcGopNhGHCTIhTD8ZEvZjnNrQP//UoT6jTLJmg20lEptaOEpTeSvYlABc6Ep brSJEuTxdGX4PkPfhKeDs9DwxVo/ga6IwT8JGW6AA4cAaFkbmoQ/jSS/gUMO8E1b4F/m z8FLUhdQYqfp1kl4+w20JaUPc1YRfT9MFIJ+clV/Qcyfio7YK13zlRqgmzQ9FFS7liMU RXypvNasQRx5mZCnQwUCcDNRB+gS3ynds0MC6uHTs1qvkiTQ8VEzn3S9sC8PCC+PNknr n8bg== 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=tZwSAIyQrAzu91RRXSwgXdxuvczlOyGyM1zoHPOX+0w=; fh=oV5n5GtI+knooR4xfd78+WT0v8c/95xmOc9/mGiVZRQ=; b=l3Tb1rKKArJKu5xS9ksApWDEFTW6Q5LJebp2c3737l7uLy7wKK4jAGV1+BMCBlfCJf WTXqh47flhR7R5w8vak1eE+SCrYlNS93vW2hU/0h9Z/dtN8xzkeTpI0rCKQRt91Dx6sn v5HsNNG/cAgf1dMOcHcqEvjlaYqmwb8aOeFtLMKvUkAiXzF8CyqHHV24VOuMRmARf+dc g6epXqPlJHrcg5DP0YksvZsAb3UWIJGnqQJpAQc5pGLQuo/ijqbVpdvpk9xT1QT87XTJ HWds71mplP8xapc9hquMFYysIQPWLDLxP/6oiPN7luc30Kohh6j79NuWeaDXDmgqQApi ukqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PAYeXIcJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id j15-20020a056a00130f00b006cbae9e5105si12402262pfu.113.2023.11.28.08.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 08:19:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PAYeXIcJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 9E7E78054BE9; Tue, 28 Nov 2023 08:19:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229938AbjK1QTC (ORCPT + 99 others); Tue, 28 Nov 2023 11:19:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232094AbjK1QTA (ORCPT ); Tue, 28 Nov 2023 11:19:00 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2326FD66 for ; Tue, 28 Nov 2023 08:19:07 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79CD0C433C7; Tue, 28 Nov 2023 16:19:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701188346; bh=0Ag4qaJaVJYeZsmD/Ziq5NjmMiyUyZLsJEveoMz3LW4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PAYeXIcJISUhsgXkvRPJciIHAtJiy3JURj2WtelWdRE52/+33R7yA289mOzSTFPpQ rwvSp+PNfOUOBQH1Ul7Wq1jJD8+OUCi5IgdB99002hA2VEMI461EJ2V1gIkysFpu7N RN3Cf+ilnB3KDSbC3/FaJDuxPCLYlXHUqx26VNbazKoqVS66CESKEjBCMq9aE6UcyS jnrgswmoFSERvHBfI0edS+Js8eB/OusESfzc2lAjul9+/Vs2DD0TrnfSTAUaVMWRlr mKuXnagpjChGo5xeaRCgDhalBQ+0P1TRId5VxBUD9yZLQTTYvJfZ8lRIYJIrVLVAzO wQFQHbq2qH0ng== Date: Tue, 28 Nov 2023 08:19:05 -0800 From: "Darrick J. Wong" To: Christoph Hellwig Cc: Jiachen Zhang , Chandan Babu R , Dave Chinner , Allison Henderson , Zhang Tianci , Brian Foster , Ben Myers , linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, xieyongji@bytedance.com, me@jcix.top Subject: Re: [PATCH 1/2] xfs: ensure tmp_logflags is initialized in xfs_bmap_del_extent_real Message-ID: <20231128161905.GT2766956@frogsfrogsfrogs> References: <20231128053202.29007-1-zhangjiachen.jaycee@bytedance.com> <20231128053202.29007-2-zhangjiachen.jaycee@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email 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 (howler.vger.email [0.0.0.0]); Tue, 28 Nov 2023 08:19:19 -0800 (PST) On Tue, Nov 28, 2023 at 12:19:23AM -0800, Christoph Hellwig wrote: > On Tue, Nov 28, 2023 at 01:32:01PM +0800, Jiachen Zhang wrote: > > In the case of returning -ENOSPC, ensure tmp_logflags is initialized by 0. > > Otherwise the caller __xfs_bunmapi will set uninitialized illegal > > tmp_logflags value into xfs log, which might cause unpredictable error > > in the log recovery procedure. > > This looks good: > > Reviewed-by: Christoph Hellwig > > But I wonder if removing the local flags variable and always directly > assigning to *logflagsp might be more robust in the long run. Yes, I think it's better to eliminate opportunities for subtle logic bombs by not open-coding variable aliasing. Perhaps this function should set *logflagsp = 0 at the start of the function so that we don't have to deal with uninitialized outparams, especially since the caller uses it even on an error return. --D