Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3036341pxp; Mon, 14 Mar 2022 09:33:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaAX1G0AhxLFycQJd3mo7+P2Pr5j9OlgzjtBjdF2cKLI5lq7h+JB1eeYraZb+gHykZkUcA X-Received: by 2002:a17:902:740a:b0:153:f9b:d8e with SMTP id g10-20020a170902740a00b001530f9b0d8emr24274687pll.76.1647275581830; Mon, 14 Mar 2022 09:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647275581; cv=none; d=google.com; s=arc-20160816; b=PIY8reNwf4+QJ2nhvt9swcPuTLqMq/XjaEGj5yAt0dphLE+yXM3bO8+fU9XSfKl0Sj wD/Wz7G7q515bHvpDkRxfGHSF3sukW1nyav4VDi7xtNbOLSzkff2q8ZKWoJfRjkfEVO/ FFn5tfUqiP+zUd+GC7KxevGkuPlyqEyvuDOSbVdB4YvtMKY0IpQfVI4CMTMn4mC4vlfm KHpaweTciAKQyVVUBuz7NyQmPky7QC3bvHp9KKvpxr0CTznlo3OPVJsBlcqPLe8MQI+i 3v81xjWAc99qimBvFUmOi/3JtOHhUhpwEcPeqRIyAejjG9iZ0EBX8E89YQIA8nz7j92e frHg== 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-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=e6x9W/p+rD5N/9kHq5OfKoHuyo7kcAi6AaFzs8yE62M=; b=SInhENqpDRtc/KdqR4OuhKke+sBN0qX24FM6byMi89uzpCnLUXpMGEGVTFLAkz/NgV v9PZsyFqP4+X7IkhJHnluYN8mbi/aNqvXiGGKulKyXoBcvI473DbTJ5sMgeC9uHHlZjL uaIg0KGfjmz1zrPhvpQr8rCNyq2+QqJX4870XcYSSj6e29oMynu8/dZoFxyK+WZqQ3tu jQL7LVx1wAdhl4ILp7p/AzeKhRZ+XBsjrB9x+axywWiJFijzvCnXDRENCRx+Nhw2C37y gC/HgkuQP+Ax7aTEgEZ0zNQnRSeZqnf2zV1m6KizmZ1maP4xKjxuBJ747wonuh/s9/NX 0/3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x15-20020a170902ec8f00b00151cf0d0d04si17677383plg.185.2022.03.14.09.32.48; Mon, 14 Mar 2022 09:33:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237166AbiCNOyp (ORCPT + 99 others); Mon, 14 Mar 2022 10:54:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233615AbiCNOy0 (ORCPT ); Mon, 14 Mar 2022 10:54:26 -0400 Received: from elvis.franken.de (elvis.franken.de [193.175.24.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3C1FD2610D; Mon, 14 Mar 2022 07:53:16 -0700 (PDT) Received: from uucp (helo=alpha) by elvis.franken.de with local-bsmtp (Exim 3.36 #1) id 1nTm4N-0006nG-01; Mon, 14 Mar 2022 15:53:11 +0100 Received: by alpha.franken.de (Postfix, from userid 1000) id B3FF9C2E31; Mon, 14 Mar 2022 15:51:08 +0100 (CET) Date: Mon, 14 Mar 2022 15:51:08 +0100 From: Thomas Bogendoerfer To: yaliang.wang@windriver.com Cc: rppt@kernel.org, huangpei@loongson.cn, akpm@linux-foundation.org, kumba@gentoo.org, geert@linux-m68k.org, anshuman.khandual@arm.com, penberg@kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] MIPS: pgalloc: fix memory leak caused by pgd_free() Message-ID: <20220314145108.GB13438@alpha.franken.de> References: <20220310113116.2068859-1-yaliang.wang@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220310113116.2068859-1-yaliang.wang@windriver.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_NONE,T_SCC_BODY_TEXT_LINE,T_SPF_HELO_PERMERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 10, 2022 at 07:31:16PM +0800, yaliang.wang@windriver.com wrote: > From: Yaliang Wang > > pgd page is freed by generic implementation pgd_free() since commit > f9cb654cb550 ("asm-generic: pgalloc: provide generic pgd_free()"), > however, there are scenarios that the system uses more than one page as > the pgd table, in such cases the generic implementation pgd_free() won't > be applicable anymore. For example, when PAGE_SIZE_4KB is enabled and > MIPS_VA_BITS_48 is not enabled in a 64bit system, the macro "PGD_ORDER" > will be set as "1", which will cause allocating two pages as the pgd > table. Well, at the same time, the generic implementation pgd_free() > just free one pgd page, which will result in the memory leak. > > The memory leak can be easily detected by executing shell command: > "while true; do ls > /dev/null; grep MemFree /proc/meminfo; done" > > Fixes: f9cb654cb550 ("asm-generic: pgalloc: provide generic pgd_free()") > Signed-off-by: Yaliang Wang > --- > arch/mips/include/asm/pgalloc.h | 6 ++++++ > 1 file changed, 6 insertions(+) applied to mips-next. Thomas. -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]