Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1968620pxb; Sat, 2 Apr 2022 10:00:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGOKeIyD3ufUtQSgC8toGEjGpWukEAE5ltDcRtNBxPmwIgWE4zPA4G92wgOFG1ANDup+te X-Received: by 2002:a63:9d8f:0:b0:398:dad:c3d8 with SMTP id i137-20020a639d8f000000b003980dadc3d8mr19683982pgd.228.1648918831858; Sat, 02 Apr 2022 10:00:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648918831; cv=none; d=google.com; s=arc-20160816; b=nC8jqSHZS3CEvQxohqyzRR9nKrtRZrv6jzlO5Q/JiNcTBbZk2BCF0nla1F7hIOJYjg +ze8LA4CNXMyM7cPbEUmo5U1UzNeJqNUuxNm0YA4bPaG+ZhB9p5W9Y1imKXv+LAvB1F3 YzBuBkzD1a5TgcFv9IDUjhLh8ALqKwbwtaKkk/bj98vceToskKHI3bkXZKOullmzw/Wg DtxNKdlhMn8p4RZzsP6i5YC2JSwNAIKBKqxYklz9aVW/BDmVTZN9cla2eeWPFEPOzIsN WyXqGxm19pazUCAz09709H79MGe6BKEQdn+Azh/k0FjyMViCW8G4fO0UQHq65ZNuZZlO RAWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=zusP/PTKoKF1xqzsQHGf2GR6QuGA5mAu9XoJETkqlU0=; b=ulRHYh1UmDTI1nz/CCocymbDXIcFMnJsZ9v4t/RRy9lg3oJ61BO94BBtXsWh2Tgna0 je8JKFxzwn3XBHCyhtX8xqThtWx1pYv718KChbalOH5vrJHYSrLOiMzNIUGYnT6HGcuV 5pxwchk2MK/1NL6gaIZpYngRjMG5yghfXqVcP23k26e+BN+yY5uS9WO4yI5vHQv4ebOC Ri6mvxdS4NZiCd+c0ieGdcLTL4B4wWa8S06WqNm7/+OsxxLHrTi8W8TOz7jZnxFTgjzO fGLv3FXHP5nBJ4QpOiSSPi8isvtYrRk20LBCeVmixDJJEqni7pHRtA54GFzC5yiPt0cd 3VDg== 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 c18-20020aa79532000000b004fb3ed18464si4968934pfp.205.2022.04.02.10.00.16; Sat, 02 Apr 2022 10:00:31 -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 S1355801AbiDBNum (ORCPT + 99 others); Sat, 2 Apr 2022 09:50:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355795AbiDBNu1 (ORCPT ); Sat, 2 Apr 2022 09:50:27 -0400 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4D96C315; Sat, 2 Apr 2022 06:48:34 -0700 (PDT) Received: by angie.orcam.me.uk (Postfix, from userid 500) id D5D9392009C; Sat, 2 Apr 2022 15:48:31 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id D308792009B; Sat, 2 Apr 2022 14:48:31 +0100 (BST) Date: Sat, 2 Apr 2022 14:48:31 +0100 (BST) From: "Maciej W. Rozycki" To: yaliang.wang@windriver.com cc: rppt@kernel.org, Thomas Bogendoerfer , huangpei@loongson.cn, Andrew Morton , kumba@gentoo.org, Geert Uytterhoeven , 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() In-Reply-To: <20220310113116.2068859-1-yaliang.wang@windriver.com> Message-ID: References: <20220310113116.2068859-1-yaliang.wang@windriver.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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, 10 Mar 2022, yaliang.wang@windriver.com wrote: > 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 As a critical regression shouldn't this have been marked for backporting to stable branches? Maciej