Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4282524rdb; Thu, 14 Sep 2023 18:46:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxJvWavcyfoCBCp4NiVHNZDHpZDd3VAl7gZp6IG0AyWSb+hDYLV39O/9K8M18aqvyF0e24 X-Received: by 2002:a17:902:e5d2:b0:1be:ffaf:d72a with SMTP id u18-20020a170902e5d200b001beffafd72amr271713plf.60.1694742413820; Thu, 14 Sep 2023 18:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694742413; cv=none; d=google.com; s=arc-20160816; b=wfKQHgcL834gOW8do7QOk/ZjUBKTh6G7sb8OQFT5DmD7GDccPPil1jvAx6XvUJGz3E oKlhv38QpQn2uCKotAM5z0i7RiJUvnQ1YQhgZQdBQbFwLjm1Xf7RWcHpV1UqwxqeEf7T 0ikAUICpfK2z0pmJXvagWdMjn13MPjgv7h61XylyC0K7nMH9M+QmTDzShixufHysXFrR BXx3h4aotUohyyBK/1wEY2fiOyPwRxPN7R5vlUpYYUwd1+MGAMra5Qj5o6BFZw4JXFIa hNFLF2eSWQ54+YgVwRBRcK/HAqyIAdKTLmExgiouKzKwMzQJYPDDlHkQSJy+DmW6lbWJ ihSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=7/m3bz/FMIYfip9hzUryY5fsZo8BtjCMUb7iqvvNxc8=; fh=b45Y9Om8ubzFsmXI0rvnkwF1PdvSdF88x674WoRVCe8=; b=fSn4mdNl44fCmHoR6HB9zi9mxBStznLGxfao3wrl5sGcb1elELQxM0idK7oAC8LF3/ ekTPq8QTfCD9PHUEjo8EXQBGRCzjgkZm7c3FLuRb35/AzHPhMwrGgkObrCD+hgdd2KU7 SKs7RVFiulqMQSUlaBceq6w9n+JoBAqMPjRKMCav6pEw0H2ioBx1uVB1Fg03Mex0pwck is1IHJpo9Mk7M+8XX/92jUMGV9n8SzSy3VuPqM8GnbebrwBT8nq0Pa83WHo/vcDmaSPT hD8WlgVa5YpeRVpsxLcTfTKMrNMEWqNRH56nb1hzPTL7V5CMbHoj3R/k3ejEDMMK9Yx4 6Png== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=KBQHYU+O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id s5-20020a170902ea0500b001bdc78deb5csi2701507plg.398.2023.09.14.18.46.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 18:46:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=KBQHYU+O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id DA59583730A7; Thu, 14 Sep 2023 12:09:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240663AbjINTJN (ORCPT + 99 others); Thu, 14 Sep 2023 15:09:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230311AbjINTJN (ORCPT ); Thu, 14 Sep 2023 15:09:13 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDD3D1FC7 for ; Thu, 14 Sep 2023 12:09:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=7/m3bz/FMIYfip9hzUryY5fsZo8BtjCMUb7iqvvNxc8=; b=KBQHYU+OC2p0pEcUvBBR0Be/w3 g5TVCjkKEIo7PSyc6KjLHHhobgiWZGpRszgsixVRz3zDMHXAKV/mS7d+r1zhcXJ9tZe+uHIZkPhQQ d79lQHtWTNXPq03Mzly1jE08YbUvHNIdlCpSXW7YefWSf7FUfAJlhPUE5ywPX9XLa+CkYcLoAhLLQ 9nznEIOxVBg5MHP/zQ7eezP0NgPoypT91tJ1RvbOx+4zFvl+KLI7fgLtoxOwp+BOKU/SEfb+gBKnx jxA7Y8l4ORamvaeN2oP5IGzMFtTBu6oLKjHGju9pdfpr1JxSHssXh68Q5y9OjaeFEfoy9CR1wzR5p DCqOIWsw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qgri3-004eEd-Ck; Thu, 14 Sep 2023 19:09:03 +0000 Date: Thu, 14 Sep 2023 20:09:03 +0100 From: Matthew Wilcox To: Suren Baghdasaryan Cc: syzbot , akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [mm?] kernel BUG in vma_replace_policy Message-ID: References: <000000000000f392a60604a65085@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 14 Sep 2023 12:09:15 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email On Thu, Sep 14, 2023 at 06:20:56PM +0000, Suren Baghdasaryan wrote: > I think I found the problem and the explanation is much simpler. While > walking the page range, queue_folios_pte_range() encounters an > unmovable page and queue_folios_pte_range() returns 1. That causes a > break from the loop inside walk_page_range() and no more VMAs get > locked. After that the loop calling mbind_range() walks over all VMAs, > even the ones which were skipped by queue_folios_pte_range() and that > causes this BUG assertion. > > Thinking what's the right way to handle this situation (what's the > expected behavior here)... > I think the safest way would be to modify walk_page_range() and make > it continue calling process_vma_walk_lock() for all VMAs in the range > even when __walk_page_range() returns a positive err. Any objection or > alternative suggestions? So we only return 1 here if MPOL_MF_MOVE* & MPOL_MF_STRICT were specified. That means we're going to return an error, no matter what, and there's no point in calling mbind_range(). Right? +++ b/mm/mempolicy.c @@ -1334,6 +1334,8 @@ static long do_mbind(unsigned long start, unsigned long len, ret = queue_pages_range(mm, start, end, nmask, flags | MPOL_MF_INVERT, &pagelist, true); + if (ret == 1) + ret = -EIO; if (ret < 0) { err = ret; goto up_out; (I don't really understand this code, so it can't be this simple, can it? Why don't we just return -EIO from queue_folios_pte_range() if this is the right answer?)