Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp828121pxu; Thu, 26 Nov 2020 13:08:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZBw43RzpNHd4x+M0d/FJjko0DgSArIOfxi4IJLapkcSvQCGlW+KfOqCXmY8fh5QTjwFR/ X-Received: by 2002:a17:906:d0cd:: with SMTP id bq13mr4269987ejb.372.1606424922534; Thu, 26 Nov 2020 13:08:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424922; cv=none; d=google.com; s=arc-20160816; b=FUFkB23D46+3vTmr33InNhU3hyqZa32JoPfFqldBKabzmNAHv1d6oPN2hIUr+LYfhT C62E/mEZkwei8yh6vZsu1Q3yEhB1X9RaFfUSiSSSjwR1oZ8jB9E7NIP7EUfE1e2RkclR lAx5yGfugY4AAIve8VR5NmX8hxxGglBJfxKw8bw1cCXQ2V8+oYYJEczADmHsmjTF92/Y r6swmJbGaFYQ/6kKnKmNOuOitvhKqqj+Hb3BXAABKMyLs0GaeLE5YDooBxtpV/SlC8xP LuxTKJkfn5QVD1e0OuRgKS/ACMnVzXSDyfsCl9rzB4AbXlgby+uWDv1BtCY2BPfS+ahr nVDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=+DPbCJpxA7cAR73v6lWTkiJY8+EHk7hpjS9ajBQQrvQ=; b=Q8suolNCHp+z27mnWgRO7AvZqaPAIwLZhwzl/xNfBf7HnFXymD7PuPo0k1SNFh8FLd 4CeRjt5uLZtoRD2PWVlcH3Oa86VJoj1ivsh3ab4Yj5kBN7VRPfM9s97IZYREKcwnwc5q oCLfUMtjVEA80X0JCcOdTenlUAICqPC4VXcuykHMfCXIhOoliLqWR7uN77lJHIgKzxV6 rO/8FDSZYHE/jtkmERxpaqGprBk95GqGuv1yPnYlDFYcqL7P2PxMJ0dhCkSDltzkGiAO wLPG1gPvo5d1FnVgajJBXZlniYYv9Tp9ejF5a0Y3PwMMrytZvYdD5kz9eiwsF1giPDCJ 24QQ== 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 x15si3745475edl.520.2020.11.26.13.08.00; Thu, 26 Nov 2020 13:08:42 -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; 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 S1732943AbgKZDFK (ORCPT + 99 others); Wed, 25 Nov 2020 22:05:10 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:7990 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732425AbgKZDFK (ORCPT ); Wed, 25 Nov 2020 22:05:10 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4ChN0N5WKmzhYKZ; Thu, 26 Nov 2020 11:04:52 +0800 (CST) Received: from [10.174.177.149] (10.174.177.149) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Thu, 26 Nov 2020 11:05:04 +0800 Subject: Re: [PATCH] xfs: check the return value of krealloc() in xfs_uuid_mount To: Gao Xiang CC: Eric Sandeen , "Darrick J. Wong" , , References: <20201125065036.154312-1-miaoqinglang@huawei.com> <365b952c-7fea-3bc2-55ea-3f6b1c9f9142@sandeen.net> <9f998a9d-0684-6b45-009e-acf2e0ac4c85@huawei.com> <20201126021622.GA336866@xiangao.remote.csb> From: Qinglang Miao Message-ID: <5d6b6f6f-4bc3-2821-d5b1-569afba0221a@huawei.com> Date: Thu, 26 Nov 2020 11:05:03 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20201126021622.GA336866@xiangao.remote.csb> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.149] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2020/11/26 10:16, Gao Xiang 写道: > 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 ?). 'next time' means next time when I send patches related to memory failure, not on this one. Sorry for making confusing to you. > > 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... Yeah.. I should pay more attension. > > Thanks, > Gao Xiang > Thanks for your advice~ >> >> Thanks for your advice! >> > > . >