Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp221622pxu; Wed, 25 Nov 2020 18:19:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzP8J5o8qMOfRGU+e1Fyu0czsOIAO34qQaNu40JEJIMqoMXl9jSeE+13sIRtAV/2N27N6UJ X-Received: by 2002:aa7:db8a:: with SMTP id u10mr561254edt.204.1606357170898; Wed, 25 Nov 2020 18:19:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606357170; cv=none; d=google.com; s=arc-20160816; b=dqYKRlSQJQESo0byU0ihNyXAsooH4MRJ5bZSQvZTj+iXYkVZHGs/FVSdo12jYsEUm4 kZhqPRRMOu9Z+ZZIB3y/ivEEyjKb0oUy01qN7MelkqVqo2WPQ69A6IiNTOtuD6qUPSzQ N3vkf4nECdj4SBO6SmvZ6tfr4CnTQPBm/kc4BMDi7KbrE9SzD3JmThTivh1g23tpMG7G jXk+KB8jxHLOyuxCv+m2oLzX3eADvbhAjWgPNx7ncEYn2Kg0/S3s5GV2zgeyHTSlIoP1 1VqxAxCSyYXV59F4fplu8sYQU//zXFl2tmMXQUwVOpg9Wj7Js9lVldvyS/4IzP2dKsmr LOHg== 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:message-id:subject:cc :to:from:date:dkim-signature; bh=uguMoFH+kwrpviQ3187PbbsfntNX+68NnH8KwBZPA9I=; b=jh01p29qxBMWbigSIwM7XnYa8M2LC70KEr6b+sZM7GLvd1Y8O9CYisuqdBMQ2uVwmQ a5ZB/JnmaAMSYDnu1io0B9/npVASkwqvSwKZ1ekxlB+8srtamSyWofTTVF6hocMx7Ojy RzhXSckZeo/YALR2Wk0O8crMXWypBXK9plxQTPZjlUAou35bFNJeUIP7fJelhdDrWfdC ZxhZA77e7CxTCcNwe4n6KKFdtNdnbrYePakD9lec+eIZoQMAQmai86AVDlSPUv1vXSFN p6Rf1iAMvKcnL7pLRY8W7qMyzIm3RCA/ZwRqrZGjD/u6VO/D3mlb7lxsYl015apUI5Wz LkHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DaluCAcm; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j21si1685835edj.288.2020.11.25.18.19.08; Wed, 25 Nov 2020 18:19:30 -0800 (PST) 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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DaluCAcm; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732106AbgKZCQj (ORCPT + 99 others); Wed, 25 Nov 2020 21:16:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34278 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732838AbgKZCQi (ORCPT ); Wed, 25 Nov 2020 21:16:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606356997; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uguMoFH+kwrpviQ3187PbbsfntNX+68NnH8KwBZPA9I=; b=DaluCAcmzwXfh3VmwEHiepXsIWYAbkkgpyk4pgSLgRN2akmRmof3D4KOJY57WUL2MeL5Tn pLsDXffNdzJMgwwEsiKHMUBzM/VvtB8Y+VZrzyr+h64IL2xVgE/y6AdQoLi78fvoY1X3aY SY+KbF5hR91XYrmxK9Jh3u293s+hfxM= Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-51-4kQbGLZdNMqha_ITMWpRBA-1; Wed, 25 Nov 2020 21:16:34 -0500 X-MC-Unique: 4kQbGLZdNMqha_ITMWpRBA-1 Received: by mail-pf1-f197.google.com with SMTP id 185so483290pfw.18 for ; Wed, 25 Nov 2020 18:16:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=uguMoFH+kwrpviQ3187PbbsfntNX+68NnH8KwBZPA9I=; b=uV4NbZc3IsmkyMyv6ctlexx7CIt1r4shHj+qPfGYRArFbDkTso2lRRXB1opYt4Ccka b0fSaghCGxVyw5NqrdEVNdU17Nx1hyi00ddVQhgUTmZYSwE5e9VUzZ3wOYBO5jhGZ6zG LyCSjUj1SZkFdDRve8Mho9gkCuK72yUY3qERUgGHKmNZqL0Ag4g5Yof5USyFS3x2/EgU mdn9uTm+vYdYmXBeQZTucEM+SK4NFRUVqKZsHbnt2cN7hcMWwRakodBNSCNSV3zAVyQs dC5LHJU59O+QV5BSnftBodHpM4ybKwTXqOYtxwbYZEL2WAOglcT00aKa2zXRE771rI/V TW7g== X-Gm-Message-State: AOAM533OObwce07yEth5Nstcb3NYJJbGTD7WMaOlbyachgds3vJNz6ln iTaK6rQ/WPrkWfeXXptR9inrA93J8QYEj9B7ikcwTNSIlx7amzEsV1bx4vNGSoN9tPujtOIN+8P wrvA4hcQvddZ7U3ezlYG6Furb X-Received: by 2002:a17:902:7b97:b029:d8:e703:1367 with SMTP id w23-20020a1709027b97b02900d8e7031367mr833157pll.11.1606356993748; Wed, 25 Nov 2020 18:16:33 -0800 (PST) X-Received: by 2002:a17:902:7b97:b029:d8:e703:1367 with SMTP id w23-20020a1709027b97b02900d8e7031367mr833143pll.11.1606356993480; Wed, 25 Nov 2020 18:16:33 -0800 (PST) Received: from xiangao.remote.csb ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id y25sm3004714pfn.44.2020.11.25.18.16.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 18:16:33 -0800 (PST) Date: Thu, 26 Nov 2020 10:16:22 +0800 From: Gao Xiang To: Qinglang Miao Cc: Eric Sandeen , "Darrick J. Wong" , linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] xfs: check the return value of krealloc() in xfs_uuid_mount Message-ID: <20201126021622.GA336866@xiangao.remote.csb> References: <20201125065036.154312-1-miaoqinglang@huawei.com> <365b952c-7fea-3bc2-55ea-3f6b1c9f9142@sandeen.net> <9f998a9d-0684-6b45-009e-acf2e0ac4c85@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9f998a9d-0684-6b45-009e-acf2e0ac4c85@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Qinglang, On Thu, Nov 26, 2020 at 09:21:11AM +0800, Qinglang Miao wrote: > > > 在 2020/11/25 23:55, Eric Sandeen 写道: > > On 11/25/20 12:50 AM, Qinglang Miao wrote: > > > krealloc() may fail to expand the memory space. > > > > Even with __GFP_NOFAIL? > > > > * ``GFP_KERNEL | __GFP_NOFAIL`` - overrides the default allocator behavior > > and all allocation requests will loop endlessly until they succeed. > > This might be really dangerous especially for larger orders. > > > > > Add sanity checks to it, > > > and WARN() if that really happened. > > > > As aside, there is no WARN added in this patch for a memory failure. > > > > > Fixes: 771915c4f688 ("xfs: remove kmem_realloc()") > > > Reported-by: Hulk Robot > > > Signed-off-by: Qinglang Miao > > > --- > > > fs/xfs/xfs_mount.c | 6 +++++- > > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > > > diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c > > > index 150ee5cb8..c07f48c32 100644 > > > --- a/fs/xfs/xfs_mount.c > > > +++ b/fs/xfs/xfs_mount.c > > > @@ -80,9 +80,13 @@ xfs_uuid_mount( > > > } > > > if (hole < 0) { > > > - xfs_uuid_table = krealloc(xfs_uuid_table, > > > + uuid_t *if_xfs_uuid_table; > > > + if_xfs_uuid_table = krealloc(xfs_uuid_table, > > > (xfs_uuid_table_size + 1) * sizeof(*xfs_uuid_table), > > > GFP_KERNEL | __GFP_NOFAIL); > > > + if (!if_xfs_uuid_table) > > > + goto out_duplicate; > > > > And this would emit "Filesystem has duplicate UUID" which is not correct. > > > > But anyway, the __GFP_NOFAIL in the call makes this all moot AFAICT. > > > > -Eric > Hi Eric, > > Sorry for neglecting __GFP_NOFAIL symbol, and I would add a WARN in memory > failure next time. Sorry about my limited knowledge, but why it needs a WARN here since I think it will never fail if __GFP_NOFAIL is added (no ?). I'm not sure if Hulk CI is completely broken or not on this, also if such CI can now generate trivial patch (?) since the subject, commit message and even the variable name is quite similiar to https://lore.kernel.org/linux-xfs/20201124104531.561-2-thunder.leizhen@huawei.com in a day. And it'd be better to look into the code before sending patches... Thanks, Gao Xiang > > Thanks for your advice! >