Message ID | 20250307122737.10400-1-apanov@astralinux.ru (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 9D324C282DE for <linux-mm@archiver.kernel.org>; Fri, 7 Mar 2025 12:28:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D2DF2280002; Fri, 7 Mar 2025 07:28:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CDEE4280001; Fri, 7 Mar 2025 07:28:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA766280002; Fri, 7 Mar 2025 07:28:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9CF86280001 for <linux-mm@kvack.org>; Fri, 7 Mar 2025 07:28:08 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 776C9B72A2 for <linux-mm@kvack.org>; Fri, 7 Mar 2025 12:28:09 +0000 (UTC) X-FDA: 83194682298.24.D623A3E Received: from mail-gw01.astralinux.ru (mail-gw01.astralinux.ru [37.230.196.243]) by imf29.hostedemail.com (Postfix) with ESMTP id 2FD05120006 for <linux-mm@kvack.org>; Fri, 7 Mar 2025 12:28:05 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf29.hostedemail.com: domain of apanov@astralinux.ru designates 37.230.196.243 as permitted sender) smtp.mailfrom=apanov@astralinux.ru ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741350487; 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; bh=9TQIjiZixNsffIzHTBi1F39+C4RNuiJrcqddd5wfdzE=; b=Jpo9FJTgMxqoOTnx8Js/u8CD+QWoEDkRM+cjBrXB0ol1L8GitVTyOEGMcNhY1uZIAf+1Cw KKnVG5ChBN5Wm22dvUjj8S6BuChvfTdRvZpyBviHduaE6L23/J9/hBmQvUE50sgXJFT7lj psYgjn/Mod4afWjGm8ETRtZ5fZKw60Q= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf29.hostedemail.com: domain of apanov@astralinux.ru designates 37.230.196.243 as permitted sender) smtp.mailfrom=apanov@astralinux.ru ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741350487; a=rsa-sha256; cv=none; b=Ih9qEhowoZeJjMjFKNvO8fT1VELpj0MG3S5mOh9KY0FMt3z2vhvVRpMQrm/CItgbB4T86I uxxE+dhwjUagZPLxOJpxTu5U057jycn7NQGxtl6XoLZLb0rPi870BcKwgZbcrdfnUIwGes JH+aHETBcyHB30kG+VkQts4eYOconRY= Received: from gca-sc-a-srv-ksmg01.astralinux.ru (localhost [127.0.0.1]) by mail-gw01.astralinux.ru (Postfix) with ESMTP id 3533924CBE; Fri, 7 Mar 2025 15:28:03 +0300 (MSK) Received: from new-mail.astralinux.ru (gca-yc-ruca-srv-mail03.astralinux.ru [10.177.185.108]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail-gw01.astralinux.ru (Postfix) with ESMTPS; Fri, 7 Mar 2025 15:27:58 +0300 (MSK) Received: from rbta-msk-lt-156703.astralinux.ru (unknown [10.177.20.114]) by new-mail.astralinux.ru (Postfix) with ESMTPA id 4Z8QY70nWqz1gywd; Fri, 7 Mar 2025 15:27:54 +0300 (MSK) From: Alexey Panov <apanov@astralinux.ru> To: stable@vger.kernel.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Andrew Morton <akpm@linux-foundation.org> Cc: Alexey Panov <apanov@astralinux.ru>, Christoph Lameter <cl@linux.com>, "Liam R. Howlett" <Liam.Howlett@Oracle.com>, David Hildenbrand <david@redhat.com>, Sasha Levin <sashal@kernel.org>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH v2 6.6] mm/mempolicy: fix unbalanced unlock in backported VMA check Date: Fri, 7 Mar 2025 15:27:37 +0300 Message-Id: <20250307122737.10400-1-apanov@astralinux.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Envelope-From: apanov@astralinux.ru X-KSMG-AntiSpam-Info: LuaCore: 51 0.3.51 68896fb0083a027476849bf400a331a2d5d94398, {Tracking_internal2}, {Tracking_from_domain_doesnt_match_to}, d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2;new-mail.astralinux.ru:7.1.1;astralinux.ru:7.1.1, FromAlignment: s X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiSpam-Lua-Profiles: 191572 [Mar 07 2025] X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Version: 6.1.1.11 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2025/03/07 09:54:00 #27658601 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: NotDetected X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 X-Stat-Signature: 9uzn9g3xdftpechoh434omh9diebtjd5 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 2FD05120006 X-Rspam-User: X-HE-Tag: 1741350485-448699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7ZpcVeI5W8yzO3Sm+01/Wh4WvI8QaGp7aEBRJd5WNqUq/SZhZ9yF5HlOcRbXL1UoRTWdoAttovejX5Bn2LV52Z14VluNT+mcIJgP4M6RXkbHzyvs1FJLpApTJLfYMTnfnMkNQyVN7W9VdwFkUjstQzLTLrxeaJsu6gSljOFhHtN23m+JgQNQj5IG3fkvDsaTyqpa96cKyIkxv/q+K7ztW+/Nc6yrmDI= 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
[v2,6.6] mm/mempolicy: fix unbalanced unlock in backported VMA check
|
expand
|
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 94c74c594d10..d2855507d2e9 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1070,11 +1070,10 @@ static long migrate_to_node(struct mm_struct *mm, int source, int dest, node_set(source, nmask); VM_BUG_ON(!(flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL))); + vma = find_vma(mm, 0); - if (unlikely(!vma)) { - mmap_read_unlock(mm); + if (unlikely(!vma)) return 0; - } /* * This does not migrate the range, but isolates all pages that
No upstream commit exists for this commit. The issue was introduced with backporting upstream commit 091c1dd2d4df ("mm/mempolicy: fix migrate_to_node() assuming there is at least one VMA in a MM"). The backport incorrectly added unlock logic to a path where mmap_lock was provided by external context in do_migrate_pages(), creating lock imbalance when no VMAs are found. This fixes the report: WARNING: bad unlock balance detected! 6.6.79 #1 Not tainted ------------------------------------- repro/9655 is trying to release lock (&mm->mmap_lock) at: [<ffffffff81daa36f>] mmap_read_unlock include/linux/mmap_lock.h:173 [inline] [<ffffffff81daa36f>] do_migrate_pages+0x59f/0x700 mm/mempolicy.c:1196 but there are no more locks to release! other info that might help us debug this: no locks held by repro/9655. stack backtrace: CPU: 1 PID: 9655 Comm: a Not tainted 6.6.79 #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd5/0x1b0 lib/dump_stack.c:106 __lock_release kernel/locking/lockdep.c:5431 [inline] lock_release+0x4b1/0x680 kernel/locking/lockdep.c:5774 up_read+0x12/0x20 kernel/locking/rwsem.c:1615 mmap_read_unlock include/linux/mmap_lock.h:173 [inline] do_migrate_pages+0x59f/0x700 mm/mempolicy.c:1196 kernel_migrate_pages+0x59b/0x780 mm/mempolicy.c:1665 __do_sys_migrate_pages mm/mempolicy.c:1684 [inline] __se_sys_migrate_pages mm/mempolicy.c:1680 [inline] __x64_sys_migrate_pages+0x92/0xf0 mm/mempolicy.c:1680 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x34/0xb0 arch/x86/entry/common.c:81 entry_SYSCALL_64_after_hwframe+0x68/0xd2 Found by Linux Verification Center (linuxtesting.org) with Syzkaller. Fixes: a13b2b9b0b0b ("mm/mempolicy: fix migrate_to_node() assuming there is at least one VMA in a MM") Signed-off-by: Alexey Panov <apanov@astralinux.ru> --- v2: Clarify mmap_lock context in commit description. Fix braces for a single statement block. Add empty line after VM_BUG_ON to look more consistent with upstream. mm/mempolicy.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)