Message ID | 20231128053202.29007-2-zhangjiachen.jaycee@bytedance.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp3698370vqx; Mon, 27 Nov 2023 21:35:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IE1DcJRZigceY3bIhNYLi+vjeM53gMS2B2RSgrYJlhZxZK3pPrX9ym+B64UUc2L52uYLiqJ X-Received: by 2002:a05:6a20:bca7:b0:18a:d4c3:1350 with SMTP id fx39-20020a056a20bca700b0018ad4c31350mr11873131pzb.44.1701149705863; Mon, 27 Nov 2023 21:35:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701149705; cv=none; d=google.com; s=arc-20160816; b=OFvK3LeN9rvZHgBYlHg6fe8qKwyQw1TH3olVx9H4XLU8OsXIvvDJMUZyXlQZB44h8K GXZF9g6oygvHrbwVc3ueifhFQQeEOW+chkG9KUPrg/OjM8kxPad6Q6VrE5Ny3bTo64/9 B2g4Y3LE3dJSUcrGUWLmUcv4i7Zi6Liy2jayDOugvae20gy7/iT90Vk8dzvE/5eQGPYQ tdwGHvLhzO1cCnNv+yeDrIKHfgNczrzTVnnw5YeHULWH1btnIKmFT1q1N204yUKvhHqP JsZUaAHSGKT+z63t8DvRgVnC9AoSxV9x2FXXqBn22dE1/dFcV7EbHwaCR7lWD8R9ie88 b+5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fxO33hgX7qudIID8yDsz8ucZ3gJV05i7WjPRt4ATm1c=; fh=af6/g7Mw4PWw8c1/IQL1lMUyTpO0lxbaYh3SFBWn9U8=; b=njJwgF26ccGOjDlWlIokDXWLTx9h5KBruVNxKxtoyTx6YHACbgBaMgCKUVepPIG6xK /e7+ZjRvaIok5v2OjRGZcdqnWmscWHUO6gnH3Kw7dkpz3lmFqygxQ6m4lBaavGZnetUL X9jSWVINQzVbILfim88r4l/clipYkoQye+jsdrsodC5IVob0G5NEIqhEP8LS1DEFjmcz cBGOnS+RQM9xWPAdMOOKxJiqxbGkAxz1PU4NiRfzjlLu9Y2eUs+p0ZkEPfNZUbhG3KnW PVfHo/lLbrDKs4CfxT/RQMqmtOlKl9ZipKmTDlNQ7FtkUJtL9D16mLvckXLB3Y8/w8Xv IWzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=bhZA9CJc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id i7-20020a170902c94700b001cfd295e132si3556498pla.441.2023.11.27.21.35.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 21:35:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=bhZA9CJc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 09CDA805FD64; Mon, 27 Nov 2023 21:35:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343574AbjK1Few (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Tue, 28 Nov 2023 00:34:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343552AbjK1Feq (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 28 Nov 2023 00:34:46 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21731E6 for <linux-kernel@vger.kernel.org>; Mon, 27 Nov 2023 21:34:29 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1ce28faa92dso38862925ad.2 for <linux-kernel@vger.kernel.org>; Mon, 27 Nov 2023 21:34:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1701149668; x=1701754468; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fxO33hgX7qudIID8yDsz8ucZ3gJV05i7WjPRt4ATm1c=; b=bhZA9CJchPrKFiQfbQF+NRJRfXVXkcAFEkGxZ7UABAQ1cfDqDCZbSPOzurpSk+scPc hQUC17nOc6sFrkYIFnANlXLljAnqoMLyZ8IsuHhUjz8zPTQaHuKgL6TfsGa948nxoA/s IWgg84LIqYD3zvi9L+9R5nogMayy0c1PwNm2Sbqv1gUDpYi56dUnzwXklqp6iws57fxa pmaFrp/fyFhjuKW5nt1F+GGhGqFA6rAx4hnIcczt1/k9XmUmHlJ3OAFTeQ09QlVailTJ Gp3nZo7d9vmhhUOMLTPHlXkBzagXVGTmutvEPFDycrfxhdBZY2LFOwVklLP0LFDDrY3m pelg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701149668; x=1701754468; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fxO33hgX7qudIID8yDsz8ucZ3gJV05i7WjPRt4ATm1c=; b=UwiULU3yeYzIezEvFVdoAavjK6hBqR7OlJp13jZuNCYYsiafXA0jC6yEvw/vOkvm+b hy4PLxNkJPLL/kAYdFGmXgmmmAEj0or9ddYjLJdCPQ3cJK75FHn1vxRlABOjS9kr2oIE Wb5IrCay2PpbzAxFrBDxg31K65+7aQV/UTDONaJUHftLPiUISbGw3uHtCr9w843qsVd2 MDhh1+1nbDKsQkn7mKOuCc0gPFiO8FrPYdDoTzluzkeLPFM/Uk9TOQQDWNUFpYtwOnFT udroEdlvJE/hz4yJq7m1+gTLqvpzm7ZfJWwUg162kwDawNrM+daBG3K4+UMseXruci86 xIzg== X-Gm-Message-State: AOJu0YyN/eiSBvm+NiQvFAU67Ujiv9yO0JnbitQI8lIfzVmZtMlZ6cll Vvpoyn/ALieCfwq5YyIPkAD7Xw== X-Received: by 2002:a17:902:b401:b0:1cf:9790:f243 with SMTP id x1-20020a170902b40100b001cf9790f243mr12596195plr.61.1701149668646; Mon, 27 Nov 2023 21:34:28 -0800 (PST) Received: from localhost.localdomain ([61.213.176.14]) by smtp.gmail.com with ESMTPSA id u12-20020a17090341cc00b001cfb6bef8fesm5372899ple.186.2023.11.27.21.34.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 21:34:28 -0800 (PST) From: Jiachen Zhang <zhangjiachen.jaycee@bytedance.com> To: Chandan Babu R <chandan.babu@oracle.com>, "Darrick J. Wong" <djwong@kernel.org> Cc: Dave Chinner <dchinner@redhat.com>, Allison Henderson <allison.henderson@oracle.com>, Zhang Tianci <zhangtianci.1997@bytedance.com>, Brian Foster <bfoster@redhat.com>, Ben Myers <bpm@sgi.com>, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, xieyongji@bytedance.com, me@jcix.top, Jiachen Zhang <zhangjiachen.jaycee@bytedance.com> Subject: [PATCH 1/2] xfs: ensure tmp_logflags is initialized in xfs_bmap_del_extent_real Date: Tue, 28 Nov 2023 13:32:01 +0800 Message-Id: <20231128053202.29007-2-zhangjiachen.jaycee@bytedance.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20231128053202.29007-1-zhangjiachen.jaycee@bytedance.com> References: <20231128053202.29007-1-zhangjiachen.jaycee@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 27 Nov 2023 21:35:03 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783784753843633804 X-GMAIL-MSGID: 1783784753843633804 |
Series |
Fixes for ENOSPC xfs_remove
|
|
Commit Message
Jiachen Zhang
Nov. 28, 2023, 5:32 a.m. UTC
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.
Fixes: 1b24b633aafe ("xfs: move some more code into xfs_bmap_del_extent_real")
Signed-off-by: Jiachen Zhang <zhangjiachen.jaycee@bytedance.com>
---
fs/xfs/libxfs/xfs_bmap.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Comments
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 <hch@lst.de> But I wonder if removing the local flags variable and always directly assigning to *logflagsp might be more robust in the long run.
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 <hch@lst.de> > > 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
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index be62acffad6c..7cb395a38507 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -5048,8 +5048,10 @@ xfs_bmap_del_extent_real( if (tp->t_blk_res == 0 && ifp->if_format == XFS_DINODE_FMT_EXTENTS && ifp->if_nextents >= XFS_IFORK_MAXEXT(ip, whichfork) && - del->br_startoff > got.br_startoff && del_endoff < got_endoff) - return -ENOSPC; + del->br_startoff > got.br_startoff && del_endoff < got_endoff) { + error = -ENOSPC; + goto done; + } flags = XFS_ILOG_CORE; if (whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip)) {