Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp735813pxb; Mon, 25 Oct 2021 17:46:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwl/cCLNcuT4pFz7GBs5zKc6o6t5cvC92/fOFOqPqMBN86tp/UKDmSyDm1uDgSjBnOyCMUj X-Received: by 2002:a05:6402:150f:: with SMTP id f15mr31173225edw.224.1635209205562; Mon, 25 Oct 2021 17:46:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635209205; cv=none; d=google.com; s=arc-20160816; b=k0aeljzUc2AarWpCV9Jn+6oBRDsv+JUmF+iBOpExUKrpzaE+cBpOPfbNm4IOg39vOM AY/pKpEB7uPW10BFbFh10IdAydNBcA+E6mwDnD5m/ScQwgSOjD2KUhl5Jsv1LpwwCiFh Ftp2CnoHJtJp/M5yYFhOaX1ogbblob1DeEa6KSPJ2kpN9bh0SKWU9S+cVDYNkQ4dQyE2 JRNpDSK/Lbrk2dCCcNxiSppRA7p2LV6QvBufEORUH+fCAZRul2EpoJIwH4vfHdeASV0q zUPv4J2jHwxuLHqipe/fu698jILkMjWL+llRfQhg23MSHDgtlbDGni958jSTZzIbjqqk WPlg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Nq8Fc3vmdb9EWIj4oW7leHv7g1m+HflJZFmkvzemkUk=; b=X196Q6UZwR1nVBFjblUunCxRIjkvQtlu3K/+eHvbERbMXzGKyEjKo+bB7ARUtVV4+u zd3fQDhwFCFSIshufAGDFcDf+EotZITON/iziNpMfjXK5mld5M5AXsN5J+khr6DHkUrA MqxetnrUw+ZTVm9X5gVuZf3lSdzxJz9LSj6oTCZP/xSQAC8/Bck8BELQiKbSVMESyaB6 ANjtuHM3XXPK/ga5vvj4XjOMHUsLLcL4cYnlKbv8C4hVR0lUYhfr9FRvwDhPxAvOsh9L ybbNUQY8Ibvni1OcPCGNo9rCBw7FszKN697qD/RdeWfSI7zFv+OV7Ws6fqKOmpS4UNI6 r72w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=P+J90Xw2; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fy1si26278866ejc.23.2021.10.25.17.46.19; Mon, 25 Oct 2021 17:46:45 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=P+J90Xw2; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238473AbhJYT52 (ORCPT + 99 others); Mon, 25 Oct 2021 15:57:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:41342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237890AbhJYTwr (ORCPT ); Mon, 25 Oct 2021 15:52:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D9ABC611BF; Mon, 25 Oct 2021 19:43:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635191038; bh=BQ8ZYP4aWA9VG3npybEInN6U77EyNl67sqo4g6hVSTs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P+J90Xw2KOMr7cV8wV4oSOy4aStCDRqZAxSnXr2+rUO8eInCrZ0UXFp0Frqb3rqi4 V1ZjJkWp9EW1JRaznWxGWi8asAZ6WBASOy7eutwyG0tU58Xkus54492B/98bchW3LP iED/T/fIe2gCj06IIUTu8RxI9jjbvJo699+kmA3w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaohe Lin , Vlastimil Babka , Andrey Konovalov , Andrey Ryabinin , Bharata B Rao , Christoph Lameter , David Rientjes , Faiyaz Mohammed , Joonsoo Kim , Kees Cook , Pekka Enberg , Roman Gushchin , Andrew Morton , Linus Torvalds Subject: [PATCH 5.14 101/169] mm, slub: fix potential memoryleak in kmem_cache_open() Date: Mon, 25 Oct 2021 21:14:42 +0200 Message-Id: <20211025191030.687668019@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211025191017.756020307@linuxfoundation.org> References: <20211025191017.756020307@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miaohe Lin commit 9037c57681d25e4dcc442d940d6dbe24dd31f461 upstream. In error path, the random_seq of slub cache might be leaked. Fix this by using __kmem_cache_release() to release all the relevant resources. Link: https://lkml.kernel.org/r/20210916123920.48704-4-linmiaohe@huawei.com Fixes: 210e7a43fa90 ("mm: SLUB freelist randomization") Signed-off-by: Miaohe Lin Reviewed-by: Vlastimil Babka Cc: Andrey Konovalov Cc: Andrey Ryabinin Cc: Bharata B Rao Cc: Christoph Lameter Cc: David Rientjes Cc: Faiyaz Mohammed Cc: Greg Kroah-Hartman Cc: Joonsoo Kim Cc: Kees Cook Cc: Pekka Enberg Cc: Roman Gushchin Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/slub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/slub.c +++ b/mm/slub.c @@ -3935,8 +3935,8 @@ static int kmem_cache_open(struct kmem_c if (alloc_kmem_cache_cpus(s)) return 0; - free_kmem_cache_nodes(s); error: + __kmem_cache_release(s); return -EINVAL; }