Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3025199rwb; Mon, 15 Aug 2022 16:23:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR5/5BAII2gBGxHxUmjh7u1nwSSM+4ldcTTsI5xaA//ajD/oVbPL1/3P6gA2tCrEzclQ+9MO X-Received: by 2002:a05:6402:f25:b0:43d:e499:e32e with SMTP id i37-20020a0564020f2500b0043de499e32emr16184136eda.2.1660605791614; Mon, 15 Aug 2022 16:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605791; cv=none; d=google.com; s=arc-20160816; b=A/cd9LxVgVGMEKFJdHjsHm2B7pPMfVAw9HrAMDIN89YdctrjRR26r9PokMY/cYLeVq K2w8hfFS/dncAah8Qb3yQpUYOIc5eNg7J2pHPtooU6A7lmnmH5qWahriycZo0khMKoIg bH7Sp8JdURQcJPKGZT+IxbTvIJd7Rjhq2FTtxEqHIQvsbHzVunFTTejbOly2VCOG904P Yxxzo7z5uifIkWpIzFGjd6OG4sFy2J+jOtOOGhtgaBXXwsljALCGpli0ICxKICbPpS84 gZz4SDgDoVy/VcTTufit0TtVg5XO7a8qcb6/IscGXO2Ea6EV+kyICm6dN1afEn7g8VR5 YD+g== 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=5pSlcXyG0/jnl6G8eDEtUGfSpqXmzfulfcfONsPy3tQ=; b=uNDxwdR+fL/aveYqb/61Lv7zqbj09IZrNPgMcj9GKCXwhOcgsnZyX86AumDidp9nBB v5/NmyAfZs99gSd8W7oE2GXrhKhamCPmtwC7HdN6zHEjhIULiw16xRsV0bsw4f2JYY+N zkZVozxtFteFEK/AEk8hKT5SIs/B6pFhPa5Wvobfzc3z0yv2njbjSGoU8DCseX8F0HXP eC/cM+9adVhdISMp9NAkyW3Bd51vk0Gxkw2wwyYE6wlsEIQTMM3sqw60I79uHpGXCVL2 xVH0t2MeCaDe6Jg0UuWWT44QJdQDkmTbjcfv87th74XoeMENrLNtQlFyAGxbRwGQiBt1 nfbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mIRUqHJ8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u25-20020a05640207d900b0043dc410c5ddsi8237609edy.484.2022.08.15.16.22.46; Mon, 15 Aug 2022 16:23:11 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mIRUqHJ8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348754AbiHOWZo (ORCPT + 99 others); Mon, 15 Aug 2022 18:25:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350817AbiHOWSi (ORCPT ); Mon, 15 Aug 2022 18:18:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2C6341D1D; Mon, 15 Aug 2022 12:42:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8F6706068D; Mon, 15 Aug 2022 19:42:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 792A1C433C1; Mon, 15 Aug 2022 19:42:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592546; bh=VWGqh+CG2Lil5Z4q1lpCoF7XgqNZB5NgJibu9/AVpOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mIRUqHJ8JfCEViZlOpV0xJqGfHw0SN68XMhN7p4kf/azDrZnGho4ascp/+uzmJDpx b6zxmUN0F7SByWTiFOMixQV1cxjIBxrooTrcPCKBwNHiwnqpArCKPhFDlFZCrLGQvH xJqApFqsVeAROGSsPQhp1Eqp+ZwUFSZABvlrpGzQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaohe Lin , Andrew Morton , Sasha Levin Subject: [PATCH 5.18 0806/1095] mm/mmap.c: fix missing call to vm_unacct_memory in mmap_region Date: Mon, 15 Aug 2022 20:03:25 +0200 Message-Id: <20220815180502.619094244@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,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 From: Miaohe Lin [ Upstream commit 7f82f922319ede486540e8746769865b9508d2c2 ] Since the beginning, charged is set to 0 to avoid calling vm_unacct_memory twice because vm_unacct_memory will be called by above unmap_region. But since commit 4f74d2c8e827 ("vm: remove 'nr_accounted' calculations from the unmap_vmas() interfaces"), unmap_region doesn't call vm_unacct_memory anymore. So charged shouldn't be set to 0 now otherwise the calling to paired vm_unacct_memory will be missed and leads to imbalanced account. Link: https://lkml.kernel.org/r/20220618082027.43391-1-linmiaohe@huawei.com Fixes: 4f74d2c8e827 ("vm: remove 'nr_accounted' calculations from the unmap_vmas() interfaces") Signed-off-by: Miaohe Lin Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- mm/mmap.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/mmap.c b/mm/mmap.c index 313b57d55a63..6d9bfd9c94ca 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1882,7 +1882,6 @@ unsigned long mmap_region(struct file *file, unsigned long addr, /* Undo any partial mapping done by a device driver. */ unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end); - charged = 0; if (vm_flags & VM_SHARED) mapping_unmap_writable(file->f_mapping); free_vma: -- 2.35.1