Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp158209pxu; Tue, 24 Nov 2020 22:49:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3qJbAR3I+6TSQG8Ae24HU8++fjxFs4EA/z7FNP6c2Wi+aYavaXcGMVNA/daChxQCVHxU+ X-Received: by 2002:a17:906:6713:: with SMTP id a19mr1982423ejp.468.1606286957787; Tue, 24 Nov 2020 22:49:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606286957; cv=none; d=google.com; s=arc-20160816; b=WTUqmuI3VWJIiFpWoVEHvi0IDgAegSraK7VuIEK+QsS51FUlUimTtKyPy6DXa1o/0u wm5yBGXdCI0NCLa4dRc0L/QCEmI1qEv5LbeYK/ZJgv+Rrxyih7AGGxT3luPRwYCsahAk 4KFSm5Hz4fMBdG+ybNqOzsx2NUNxCBm1ZoFwF30uI6gCXdTrJ8q/vU3qdcJgrq8GFbbT WGviv2rx6KT1gOHEdJ84PRhGnAfKGlYH06290qvxfPsTpa5xZuFeehqZmsUMKjoHq740 7DKyeStC0b4ldX6tjzu5lZE92vY8x9z+q7kh1YKWs0gbP/rsAt6NJYBjVHYkUfDT1l82 XeRg== 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 :message-id:date:subject:cc:to:from; bh=pqZkkKO/UWhP+ZZG5n786EQKMxPXj2d6+yi3tmBll9c=; b=TmCbi/mRr0ofyXfNkYZo3aE9CTKZYHpOBdVk7TLCPjVGXptbEV3kLEzwNXi84ivhHZ pfMB2bC84F0IIWFCn53Nlp6e0rXLvd0hy2jPBa0RTFDIblmU+yoOwpgG/UWBxDA/uQT+ r6dLpd5qasQi1gxEQBFHSZANgJSU5FJpzxUZqP0IYM3Dpv2uqAUct0i8cEMcC+c23Br7 19P3jPl/HMCWpOC8JohiKj/NGOENcpn15r1dAmwSlbogA5WuxcvfK790iq9kmC1xHRMO B7Z+ICZUL/UNtU9fsuClcYF2pDULLYPHew3k23tYWXko+TCa9e41+yIHXSuN/qVkdjXi DuTQ== 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 k8si710493ejr.717.2020.11.24.22.48.55; Tue, 24 Nov 2020 22:49:17 -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 S1726935AbgKYGqZ (ORCPT + 99 others); Wed, 25 Nov 2020 01:46:25 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:7678 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726760AbgKYGqY (ORCPT ); Wed, 25 Nov 2020 01:46:24 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Cgry20BZ6z15L7C; Wed, 25 Nov 2020 14:46:02 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Wed, 25 Nov 2020 14:46:13 +0800 From: Qinglang Miao To: "Darrick J. Wong" , CC: , Qinglang Miao Subject: [PATCH] xfs: check the return value of krealloc() in xfs_uuid_mount Date: Wed, 25 Nov 2020 14:50:36 +0800 Message-ID: <20201125065036.154312-1-miaoqinglang@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org krealloc() may fail to expand the memory space. Add sanity checks to it, and WARN() if that really happened. 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; + xfs_uuid_table = if_xfs_uuid_table; hole = xfs_uuid_table_size++; } xfs_uuid_table[hole] = *uuid; -- 2.23.0