From patchwork Wed Aug 30 00:43:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Yznaga X-Patchwork-Id: 13369869 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A75F6C83F12 for ; Wed, 30 Aug 2023 00:44:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 017988E003A; Tue, 29 Aug 2023 20:44:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F0A218E000B; Tue, 29 Aug 2023 20:44:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD2338E003A; Tue, 29 Aug 2023 20:44:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CDCF98E000B for ; Tue, 29 Aug 2023 20:44:05 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A9B94160298 for ; Wed, 30 Aug 2023 00:44:05 +0000 (UTC) X-FDA: 81178924050.04.9AF72A4 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf18.hostedemail.com (Postfix) with ESMTP id 7FBD21C0008 for ; Wed, 30 Aug 2023 00:44:03 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=v54ZhtI1; dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf18.hostedemail.com: domain of anthony.yznaga@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=anthony.yznaga@oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693356243; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=JJx+iBCNiI2MMh8+aO3HVA8Wi5bYTILzpsCDdfw3eNM=; b=zK8ZATZ3eSJyBlv/QJkkjhBCTPekE7Ruz1AloRbF6WzC5ZbrfrfPBBPCLDeHYZzokEK6EX eZtHngLQwBK6y38esY0L9nOpS6VgMXWcCmlheCrAQqh2yRvW/z5Gu2iISh7Jhqp9vaEvC/ ZimHan2wvQwqHDlUY3zeCC8l+aDLRGA= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=v54ZhtI1; dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf18.hostedemail.com: domain of anthony.yznaga@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=anthony.yznaga@oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693356243; a=rsa-sha256; cv=none; b=EmgIq3wDIYsBlxcEKcmLIVtGet946Wbow6Cpx+QObYFJxn3TD5hiKDYY/Ha/3aJxrdRQfq CakgNbcUxoz4gVn45TtAF5MQhtk5s7jHvcz6Xz6qp9J1bJz7/klGJNwFjQoh8bixnEYwoS ElEtiDQlSIs6v+ppvaGHNpzIST0YP68= Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37TNeQog005072; Wed, 30 Aug 2023 00:43:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2023-03-30; bh=JJx+iBCNiI2MMh8+aO3HVA8Wi5bYTILzpsCDdfw3eNM=; b=v54ZhtI1evVq3FAVNushrhnL0Kw3dOcyPaJItg6u5o6ffWqQnk10PW58fVncxwS4aVBQ GKORPZ6z8Vq9jAYXmhEAJVaDw4CFn3GoASyX2R3eugyyr59FVNIClctwv95bzZRKdHEv FIW82SlcLFI2kGmyMgXb0tkVDP5hH6IuLIe0qyL2hnFMWd1+go8k8z2M7k+uf6B96fOc oVcdSsJHjL5OumQkcSnPUz3BXZZZaMN+kYMjwYxe04awaJHWS+K3VKdwKEJ034cwHosj jL2xxDxZxtGOUdKpx7asfOOuLpc03K4a4QNJvQx6p93VlhP0sxl26nABInaPwDz1aDju lg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3sq9j4eaxb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Aug 2023 00:43:53 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 37TMmBZO000607; Wed, 30 Aug 2023 00:43:52 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3sr6gbw64y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Aug 2023 00:43:52 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 37U0hpHt005857; Wed, 30 Aug 2023 00:43:51 GMT Received: from localhost.us.oracle.com (dhcp-10-65-180-98.vpn.oracle.com [10.65.180.98]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3sr6gbw5wk-1; Wed, 30 Aug 2023 00:43:51 +0000 From: Anthony Yznaga To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, Liam.Howlett@Oracle.com, willy@infradead.org Subject: [PATCH] mm: fix unaccount of memory on vma_link() failure Date: Tue, 29 Aug 2023 17:43:24 -0700 Message-Id: <20230830004324.16101-1-anthony.yznaga@oracle.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-29_16,2023-08-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 adultscore=0 bulkscore=0 spamscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308300005 X-Proofpoint-GUID: uqvqKtp2XM9GWbbfUHyH-pA6raDy475s X-Proofpoint-ORIG-GUID: uqvqKtp2XM9GWbbfUHyH-pA6raDy475s X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 7FBD21C0008 X-Stat-Signature: zytonpermje8mt48md9xzaadt33t6pre X-HE-Tag: 1693356243-37378 X-HE-Meta: U2FsdGVkX1/QKqNuAIuOXicHDfYc5zj/Pc8urR1UbHHVRI4FGyURSgwHHdS3DT4mZwbdlLALpCkMppcBI6xrcxkJk0KQmzVgygXqQ+N267H/YpiflZm/IPvhdzzpZpnw53yFFYTaNfEuLerDH0VAJP1V4+yZeBSSR/5rpbuj9KqWTVLvURhXFcSLGSj0qD62mNGxN8OPALiDv8I0tP32tWa9pW2eharCkmfv0wYBcJ0pzYAV/Tfy7YUNmUiBAUg7JCXKVLZmCPfd3uDDDYYiRm2JIYewSmRRe2PHXF+KnxbCsLxYUPOSx2Z8MHE6Xjun1npsCNXH5xMS6+6ykzDD26mb/rSsA50n+k8INk2dmCmOnktXQVY62F7c05dItMqNJiypSX2dnqbyx37Jqa5RqRqTh5/GIyJOhsMlCS1tdcvXnYs6tP7kF3CGarPsWdI3//QHccPgufkiWYWmk8D1Dq12HSId+KF6eamOyf4AGPA8SKllr6Zguz5ER54TiFPbHNJ7/x5v9P8hjsPR/Y8pQUR4cwZn2JHymoGjz6/PD8PPhRHlpCr8HiPshPkrrzJ/NZPIBt3KREAIaM97c/rsld/JhhSv+lhhLCxCbriG8yG2cubABvJdJ5uDU8CL50fHYd2LcVF4uHAvWBIfRB8kfb7NcBYIaQMfsdvx6f/Y5rFe1zEgF73t/uLNJ1tz54kndb61zNI5VycaaFp6Cooejaj5dup/MXDF5aW0xtqmbz+73yldQfz1dYSRw5M/Ae/fICxWCYOd2/LHqR6TmEPhCQXiw93gbuWu2tkJF06f98fscJug4gCS369RwlndpKRT/iVfsz7IDY07OsHKigBhqOD6N+0rJ2b/F9yJWLSLVNP4pvSxRIdjHRI4p/bbShIhwqV75DYx1hv/3vdeykZJJriTJZFZl0ynxNuyBvbEW2rKmBBleDXAi23OQwagyavo3cmlUSmDIhoMxoRpPn1 p3gRCcZ2 H8j0vmx4L+wzzGaFfm+s9PN5UPAkcaZvxBJfzPoMDHqbqDDqmASY+NbrY2ZoEtbbWGi9pPxk9a+ha+DBcynjYqrZXH4QOp2H9YZzGDA3cSQBLqBJHke70OKqOHvtILI8UG2dNDO8yz6PaeEtj4OBKxLJZKC3dbaM8dTABRJQSrQWgn2UN11ZRxARAM6iVzeaT7Rtw+ANz9wjfEEWIKf2FVCb5KaQvoymOWaYDwR8+WyrxNfOuvT4WKHHL2IGCU9Wt4qKP7owjj+RUUnsa6c2dcUoZ0ZEjRFSb2a1qdcUuEFtwOgOTJLqFtbofaYwAdQU9d1zZVWx8us6XiuJhlJYyDd130Ri24UwIaFUO74bjIGBF7PM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Fix insert_vm_struct() so that only accounted memory is unaccounted if vma_link() fails. Fixes: d4af56c5c7c6 ("mm: start tracking VMAs with maple tree") Signed-off-by: Anthony Yznaga Reviewed-by: Liam R. Howlett --- mm/mmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/mmap.c b/mm/mmap.c index 514ced13c65c..f8c084017757 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -3278,7 +3278,8 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma) } if (vma_link(mm, vma)) { - vm_unacct_memory(charged); + if (vma->vm_flags & VM_ACCOUNT) + vm_unacct_memory(charged); return -ENOMEM; }