Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3230863rwb; Mon, 15 Aug 2022 21:47:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR7HBRzB88/AxwyPHo9T1i76grB98ljyQLvgBYxfOkbUwkz7yFYT8mcrb8djEIokrcHilvd4 X-Received: by 2002:a17:90b:48c3:b0:1fa:7ade:384a with SMTP id li3-20020a17090b48c300b001fa7ade384amr8799400pjb.106.1660625254628; Mon, 15 Aug 2022 21:47:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660625254; cv=none; d=google.com; s=arc-20160816; b=mLhd/8Irlgot/FNjTL5Qo1EMN7ZLNPXH0/TF0+LdTa0e+aTWG6aPuSwmuAJ++zsXHD OsDbUMpOvLp/grvJXRbccvCTm29MRNGQuP3FtXkTVdIIr3tjPitqdua1KgwxLVu791z7 LtwRQ+cNgh1ULQiEQm8P7cbAtlb35PsutgJ4yWwQfFUb7YkZ3Ch09Z9UvQM4WmkNsDBU dAIz3ynNg8lXLF9iJZaEvadSmWPFuFFRY8YtZOPVxJVGHBhzZi+kyBzSFIA+Uie/6cgj yvH5OL0SnsKiINnitDlyzDSM1qCkRMy857EOyDvYxTYAGfdbSyfNSuKufX4EBPSfuamH yGJQ== 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=Y/Yahl6SzLKA0v0/MfG26ioGn/47QgTmW0xyZne88wQ=; b=ZL+Kd6mwl+kc5KvKicsboBy1CJ6drwfO4tDQ+HlRlrnFjihwfdJE0FXSp9HInxxawR +cJl+ueEIcKZNJPvAkrGE75p86JB4IlTXaih+E06Xrh9CK/KZtgu5GKSj2/nu96O37cX JQusHZXkjThfSx1PgN1l/zu66/VlNTPKIPucwgRSXbfy1T8fR9XsWxti+fqtPVW+GgiK HuPxJiOhhqghOEA5HluCY7o6beBTLJguwdUuMU9f0CuCndKlJvrfPTQLvxyBXnClVfQK 2GHuv56xUfj6AnuMF2+IUfGh0em4QTzESVMcdXvZpPx6GWR018izxW3rpw8Tb+TFeSMF ToGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bbWX2fu0; 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 i12-20020a63540c000000b0040c3a6764b6si1184736pgb.203.2022.08.15.21.47.19; Mon, 15 Aug 2022 21:47:34 -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=bbWX2fu0; 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 S232585AbiHPEpl (ORCPT + 99 others); Tue, 16 Aug 2022 00:45:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231343AbiHPEmA (ORCPT ); Tue, 16 Aug 2022 00:42:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15B7AAB4ED; Mon, 15 Aug 2022 13:36:49 -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 A323E611D6; Mon, 15 Aug 2022 20:36:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D536C433D6; Mon, 15 Aug 2022 20:36:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660595808; bh=NJNHvyU6mSG0RyKd01r4Te1bG8tFBEb8/NemvxO5O3Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bbWX2fu0DgG7ZF7Dilkux8hCLANnFGBUTd2EaLoXzKXeJTMZ2VJJghVMigvRcHXFB 01QWVjdjm8dh6ORY6awRInjd3gtAi1lKuz0jLyWom9q6Cv2Ysf7+obZsSJPafP1NeA qCQ+Sa8nzITs4LOBAUSESQKjQAeB7jgO/lwgMDoc= 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.19 0864/1157] mm/mmap.c: fix missing call to vm_unacct_memory in mmap_region Date: Mon, 15 Aug 2022 20:03:40 +0200 Message-Id: <20220815180514.031777622@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 61e6135c54ef..7c59ec73acc3 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1894,7 +1894,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