From mboxrd@z Thu Jan 1 00:00:00 1970 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 5CC8AEB64DA for ; Sun, 16 Jul 2023 15:08:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D526C6B0071; Sun, 16 Jul 2023 11:08:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D02636B0074; Sun, 16 Jul 2023 11:08:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF0936B0075; Sun, 16 Jul 2023 11:08:47 -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 B09326B0071 for ; Sun, 16 Jul 2023 11:08:47 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 84326C0205 for ; Sun, 16 Jul 2023 15:08:47 +0000 (UTC) X-FDA: 81017807094.25.FD1AA4F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id BB1E7A001E for ; Sun, 16 Jul 2023 15:08:45 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=IgnfQtPz; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf25.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689520125; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:dkim-signature; bh=71YRJf/232a3syZuKjPIIXvGyTxmi9mrq4kPim5rqDM=; b=knhZa9FNjO1cbSDS2LvuVIZJwZH7QpP76YIXWDBQJJPqrXaukSTq05XKtvlnn+7cRb+1RA KGQ+z/IfLGCiVv8WOTiX0/Gvi/GLdrwBBY48alFrbk4wYXFWeVNV+obDhLTP6GYJ32SXVt 9hw+yTv/O3a9jhzAeg1h2fGXWDArRQI= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=IgnfQtPz; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf25.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689520125; a=rsa-sha256; cv=none; b=OPMBEDHaXIvYfxSA5Py5oAvjaEZjE4riMYnVHuGCa/ocr1fWHv3P/n7QRzogGLSA7WTiIa e+O8O+wtB5w5zdsazADyahB/BznBFg2yDjPl0+wlAlO82atX0ZsYRVQa8wU9ORq92eucAk qQN8dAY5KWltKv7wNUO7khDRoDruDCM= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DFADD60C44; Sun, 16 Jul 2023 15:08:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0AE2C433C7; Sun, 16 Jul 2023 15:08:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1689520124; bh=KTSSKpr8W2AyTags4ZDufRUPc4DzgosKBxp1zr3AJ/4=; h=Subject:To:Cc:From:Date:In-Reply-To:From; b=IgnfQtPz5vUNdpxaA+3IOnxBsf+WIHB1Qj1ku935HjILLHs46CmbN0k9RRBGQ6wju oo6ICFBUc7UYxbulwfJZQ4m9+v0JbOcNg5GqkP1IHoMvs2TtlG50IvvPizgiXMh/3y czFPEALR+hk0J6aAB7CNtoae4Fp/YdtFUOLMEP2w= Subject: Patch "mm/mmap: Fix extra maple tree write" has been added to the 5.4-stable tree To: John.Hsu@mediatek.com,Liam.Howlett@oracle.com,akpm@linux-foundation.org,gregkh@linuxfoundation.org,linux-mm@kvack.org Cc: From: Date: Sun, 16 Jul 2023 17:08:16 +0200 In-Reply-To: <20230706185135.2235532-1-Liam.Howlett@oracle.com> Message-ID: <2023071616-divisibly-abdomen-37a5@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit X-stable: commit X-Patchwork-Hint: ignore X-Rspamd-Queue-Id: BB1E7A001E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: cgz5ag4dxi97qny3g3t19twipu657eft X-HE-Tag: 1689520125-751440 X-HE-Meta: U2FsdGVkX18GC5+wWqlyLHmNE8XiZc9sIJBpE5xkxz5IZ6g7LUl3blebR1QzAJ/7Xq8pBUCulx04gM3dbe3ggbT7n3cQ2HAyTNjCPs8cTuwTrZmTuu9PN2Qc4MB3Tn7xi2QRU0gjoljbU8yNLCxa7W7+YS0cbRUxWcVngbVPDiV/n+8EaQpwQhWVD4E8a/5F67CRIoJs6kgvUXeLECI30z/02ZmIRE44y+4dMzx4iaPkk09Ydl/bxBm5OLlqzX7fNTq6GywGTw+P1Fk8sfybVhKDAMcbJr79IsHuvqbavtQscbQ02uv0I6Pec2saQNzRQ1TW3OqiMoJod+k4gyOpTL1qcJVlHC5PRyaf2wK/sItnBo5FQNo1TIpOmkqIope0ze4ooCnMCW8fiUmOBqAwh4nE1q8iEnA1VD4PCpT9TWKZfYFaUzUjRYo7DTJGV+LUeDAKo7zjGOq26t6f8DC17NEWFktCnE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lLqpTM6ato2CBvIbTuF4SnjG1b54Ya7ZJmsVCOE6HSaJtiWl/p+D4Hxy6hTx2j7h2QpUin+TRLsvr4DKW/VyoWR7n7Yzt4OUJ8JwdFxH1cJLBtUvJcbmHB7iTYVt7I= 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: This is a note to let you know that I've just added the patch titled mm/mmap: Fix extra maple tree write to the 5.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: mm-mmap-fix-extra-maple-tree-write.patch and it can be found in the queue-5.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From Liam.Howlett@oracle.com Sun Jul 16 17:02:51 2023 From: "Liam R. Howlett" Date: Thu, 6 Jul 2023 14:51:35 -0400 Subject: mm/mmap: Fix extra maple tree write To: linux-kernel@vger.kernel.org Cc: Andrew Morton , "Liam R. Howlett" , John Hsu , stable@vger.kernel.org, linux-mm@kvack.org Message-ID: <20230706185135.2235532-1-Liam.Howlett@oracle.com> From: "Liam R. Howlett" based on commit 0503ea8f5ba73eb3ab13a81c1eefbaf51405385a upstream. This was inadvertently fixed during the removal of __vma_adjust(). When __vma_adjust() is adjusting next with a negative value (pushing vma->vm_end lower), there would be two writes to the maple tree. The first write is unnecessary and uses all allocated nodes in the maple state. The second write is necessary but will need to allocate nodes since the first write has used the allocated nodes. This may be a problem as it may not be safe to allocate at this time, such as a low memory situation. Fix the issue by avoiding the first write and only write the adjusted "next" VMA. Reported-by: John Hsu Link: https://lore.kernel.org/lkml/9cb8c599b1d7f9c1c300d1a334d5eb70ec4d7357.camel@mediatek.com/ Cc: stable@vger.kernel.org Cc: linux-mm@kvack.org Signed-off-by: Liam R. Howlett Signed-off-by: Greg Kroah-Hartman --- mm/mmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/mmap.c b/mm/mmap.c index b8af52db3bbe..bb2e0ff0ef61 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -767,7 +767,8 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, } if (end != vma->vm_end) { if (vma->vm_end > end) { - if (!insert || (insert->vm_start != end)) { + if ((vma->vm_end + adjust_next != end) && + (!insert || (insert->vm_start != end))) { vma_mas_szero(&mas, end, vma->vm_end); mas_reset(&mas); VM_WARN_ON(insert && -- 2.39.2 Patches currently in stable-queue which might be from Liam.Howlett@oracle.com are queue-5.4/mm-mmap-fix-extra-maple-tree-write.patch