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 123ABC433F5 for ; Mon, 21 Mar 2022 11:01:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1ADEC6B0072; Mon, 21 Mar 2022 07:01:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 15E2F6B0073; Mon, 21 Mar 2022 07:01:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F40D06B0074; Mon, 21 Mar 2022 07:01:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0109.hostedemail.com [216.40.44.109]) by kanga.kvack.org (Postfix) with ESMTP id E642E6B0072 for ; Mon, 21 Mar 2022 07:01:48 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 9DF189F5E7 for ; Mon, 21 Mar 2022 11:01:48 +0000 (UTC) X-FDA: 79268103096.23.C36EAFE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 6416818000A for ; Mon, 21 Mar 2022 11:01:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647860506; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=71QPtwQWP7irJw6pdvQh6v8H9j0P/xaK2PjPht9nnok=; b=XQnmjuIElddd4C6guRilrNqQbHYhsZEmlRMEfs9bkwzTikRYQuhzkLmE+bO10aZ6wDDiSN z1Bs3jS0C/65W9P1q0xQDS2bTng+8HTMG6pvKq9zpjyVpRG4oUPDsXcZxclD/00U9hq18u NvKcOxLLMi/zMb61JW3nJAfvK4y4Bwk= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-641-oJWrJZbZOZKbx4G-bC_MjQ-1; Mon, 21 Mar 2022 07:01:44 -0400 X-MC-Unique: oJWrJZbZOZKbx4G-bC_MjQ-1 Received: by mail-ed1-f69.google.com with SMTP id x5-20020a50ba85000000b00418e8ce90ffso8153122ede.14 for ; Mon, 21 Mar 2022 04:01:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=71QPtwQWP7irJw6pdvQh6v8H9j0P/xaK2PjPht9nnok=; b=qBLrUIW+oCQy4QRnHM+K78eYS2rXK14KZ1Y1jFRjpmtUD8z81R4p09YLuSPdELwYx8 sI4VkEAHq6Zy/a2UuKGN7mQwMN766M3bAhaLkcYzkOdJdlD6EEblXM2Ewrrutu6CK77z NbSzfowY8CnIq3tze7EwjdJTIKjKbVOddXE/WtwcunazFs9ddUIPPlph6XssmZTzAiyv nMsfP8jwE/DyB9d5pkYAplD3qNXEBFiPih6mu35ry4sb8+8Qtv3SCCsbOuVsQwsz1/XS LqFk0aqZdOxoatuK5ZOCdIwM7lHo75XbBh+FcyU8XBFVNJIykAJk7TWfXJRXjV6P2vsu QaRA== X-Gm-Message-State: AOAM532xDzLysGGFp1Ncsk65Inhl6I4Hi9alxVtHM9UkvvbNTrh6vwjc WB/wwL2JpN2d74ff7BBfcajbrX4CHrj+PnaXSPUuHreKc8EXqT9qjEagyNWsWdaX8txnP9Tyqq0 3I3iLXs9HW2Q= X-Received: by 2002:a17:907:7254:b0:6db:ad8f:27b4 with SMTP id ds20-20020a170907725400b006dbad8f27b4mr20312107ejc.599.1647860502546; Mon, 21 Mar 2022 04:01:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw10B4UloyTBi1a7t4NLKKvwYaVeL4Lf9on50mGbJUjofJKCu/uM89wiMqWJDmBuZn+jijjIg== X-Received: by 2002:a17:907:7254:b0:6db:ad8f:27b4 with SMTP id ds20-20020a170907725400b006dbad8f27b4mr20312076ejc.599.1647860502271; Mon, 21 Mar 2022 04:01:42 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:63a7:c72e:ea0e:6045? ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.googlemail.com with ESMTPSA id e28-20020a170906649c00b006df6dfeb557sm6869828ejm.49.2022.03.21.04.01.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Mar 2022 04:01:41 -0700 (PDT) Message-ID: <33b6fb1d-b35c-faab-4737-01427c48d09d@redhat.com> Date: Mon, 21 Mar 2022 12:01:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [syzbot] WARNING in kvm_mmu_notifier_invalidate_range_start (2) To: syzbot , david@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, maciej.szmigiero@oracle.com, seanjc@google.com, syzkaller-bugs@googlegroups.com, vkuznets@redhat.com, wanpengli@tencent.com, will@kernel.org, Linux-MM , Andrew Morton References: <000000000000b6df0f05dab7e92c@google.com> From: Paolo Bonzini In-Reply-To: <000000000000b6df0f05dab7e92c@google.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 6416818000A X-Stat-Signature: mmoapyznd3m1hfp3q9ez7pcmx4xz9o43 X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XQnmjuIE; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf06.hostedemail.com: domain of pbonzini@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=pbonzini@redhat.com X-Rspamd-Server: rspam02 X-HE-Tag: 1647860507-132736 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: On 3/21/22 11:25, syzbot wrote: > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12a2d0a9700000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13d34fd9700000 > > The issue was bisected to: > > commit ed922739c9199bf515a3e7fec3e319ce1edeef2a > Author: Maciej S. Szmigiero > Date: Mon Dec 6 19:54:28 2021 +0000 > > KVM: Use interval tree to do fast hva lookup in memslots > > bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=142aa59d700000 > final oops: https://syzkaller.appspot.com/x/report.txt?x=162aa59d700000 > console output: https://syzkaller.appspot.com/x/log.txt?x=122aa59d700000 It bisects here just because the patch introduces the warning; the issue is a mmu_notifier_invalidate_range_start with an empty range. The offending system call mremap(&(0x7f000000d000/0x2000)=nil, 0xfffffffffffffe74, 0x1000, 0x3, &(0x7f0000007000/0x1000)=nil) really means old_len == 0 (it's page-aligned at the beginning of sys_mremap), and flags includes MREMAP_FIXED so it goes down to mremap_to and from there to move_page_tables. No function on this path attempts to special case old_len == 0, the immediate fix would be diff --git a/mm/mremap.c b/mm/mremap.c index 002eec83e91e..0e175aef536e 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -486,6 +486,9 @@ unsigned long move_page_tables(struct vm_area_struct pmd_t *old_pmd, *new_pmd; pud_t *old_pud, *new_pud; + if (!len) + return 0; + old_end = old_addr + len; flush_cache_range(vma, old_addr, old_end); but there are several other ways to fix this elsewhere in the call chain: - check for old_len == 0 somewhere in mremap_to - skip the call in __mmu_notifier_invalidate_range_start and __mmu_notifier_invalidate_range_end, if people agree not to play whack-a-mole with the callers of mmu_notifier_invalidate_range_*. - remove the warning in KVM Thanks, Paolo