Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp160004rdb; Thu, 16 Nov 2023 15:10:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IF07fzSVF0z9XCQfJbGaqKfvl+x585Td+ymeBjw5KuvnH8uPMt6R2S5Mdi/P9xR2ZLVNTWB X-Received: by 2002:a17:903:48f:b0:1ce:171d:27a5 with SMTP id jj15-20020a170903048f00b001ce171d27a5mr9360051plb.27.1700176237098; Thu, 16 Nov 2023 15:10:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700176237; cv=none; d=google.com; s=arc-20160816; b=Xm1JdTg5DMGIF2m+Up5POIOJlLE6pVIAAVAFjtS9YbG7Zisef6ZozT6XNWqsQD0zpd s2nf5mnT0tPX+e3crkNo9AodiaSi+yc6pUoU/pCUw99QJpYf23XWytd6hq2z8+s4JbzX 6UiaY/tTOduozpXwSxS99IipkQhX4VNjsO6+pq8+Oap2htsFNhpBEOmqaBQ1dKIdwcQq vsN6pHkzUoYLr/YGF9QX7xSuNO3jUsQBEpjRCE3yAD7GsFyGUaLKkzXgG+9Yg2q7tjgU Da9WlNhS1GvbwQU2Z5HJCnmg2WAPzr6D0MNhma3pfsmVgFZ1+hxiZfLGx2DL6focy8/Q tykw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:autocrypt:from:references:cc:to:content-language :subject:user-agent:mime-version:date:message-id:dkim-signature; bh=+MKeibb6KnKnaA+iE0iv1obj46zXM3TXwKHeMWH8DpE=; fh=k0Y8CaVQ5olSXV/CixUMeXbyxdZpOVo9DHwSYxWIshE=; b=IvIf/lHBLlI8mMBLk0LB/UYH6w3B4ChWiHFVpeBKwMPTxljaMJzkIsz+jXJRN9YkG2 Vz0poNgF1hJ/5uSeCDLaqDo3/A/MX5EhPvncAgIEzqqxJIQl7EF38Anp6Ve0P+Sejbc7 BZqsuxjwmVhYjy6C6LF1fYi8MRLw+mlr0QZZYrePVNXJ6TJCRl58A1y0iix8CbhAvh08 ybNisuYr4gkYoDHbxyYhJ4IeXG0dNw4a50tYKLIi5xwPWfBNQWa5YAsXwuMytOzAesSl ZyRTw+enn52ItdPFvJzlamkVGT6MHtRxywnp36pjGr0N9A/WsUvLnaziJXmismrX1zKT BG+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FxRr1p9k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id bd9-20020a170902830900b001bbf293f45esi374900plb.625.2023.11.16.15.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 15:10:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FxRr1p9k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B6AD581E648F; Thu, 16 Nov 2023 15:10:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229745AbjKPXKZ (ORCPT + 99 others); Thu, 16 Nov 2023 18:10:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbjKPXKY (ORCPT ); Thu, 16 Nov 2023 18:10:24 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98C60D4A for ; Thu, 16 Nov 2023 15:10:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700176220; h=from:from: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:references:autocrypt:autocrypt; bh=+MKeibb6KnKnaA+iE0iv1obj46zXM3TXwKHeMWH8DpE=; b=FxRr1p9kBQD8SqJSQQtJ11OPPTF0QnHJhqJ9rPBpjNATk0PmUKiFO3CowVmFe9ZopQY4fH 7LhNfSwbd2WnJLaT4xgkUzOrBfgeogL6iaV6YKr5LoOaKFh7+RlESPpgkXlIgbwWQVmFyb KJ4Ak1ZNYbwoGwdS/RP2y2d+Ukas5Mg= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-346-ng2OKuG0NnKrvZdyJ8yCAw-1; Thu, 16 Nov 2023 18:10:19 -0500 X-MC-Unique: ng2OKuG0NnKrvZdyJ8yCAw-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4084001846eso8814065e9.1 for ; Thu, 16 Nov 2023 15:10:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700176218; x=1700781018; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+MKeibb6KnKnaA+iE0iv1obj46zXM3TXwKHeMWH8DpE=; b=YU5OQSfc3r/xf9Pg8sgl0AwZfgdv5uHzESS1T05ObXlhg4nW0ER8bzBlk4Mw3K5NXP 6Sg9Bb0eYVuqRr8brlaQblKSTAaFhrCpfjZAx4X7iYre8nq9sPbbht7Q95b01Y2F6wNc RFhhqGZ8n6OVr17PX1Svh26ebSo/wp4JkeZYJXXF3P2WZoxVyo1VJY6akgQBytFqpUr7 xsiB2weSH3N2lFZDrWj95pOQosChIazmbdJKfMjPGrR3UYk2FOUp1VF7dJETAY3dJQ7b XJreYlP6d+rhdF51zdUCU9p8JmXrhHyYld1vRTXADOJhbDURovyNguV++t8cJd2CCNId Kpnw== X-Gm-Message-State: AOJu0YyD+1daycy/+zLS3ma+sQqxDHMmp8V7+7tcdip7nLn65jiLhfGQ sbX17LizjqLaEWiJgtytUnOn4IOttlcpIXAtF5sK0r9MWqGpJeKtT94TunF6FRd/g1taS5oL3iD aNQaJ56yKrMf0GXaYGuqUG7Pb X-Received: by 2002:a5d:64cd:0:b0:32d:8830:ee2 with SMTP id f13-20020a5d64cd000000b0032d88300ee2mr16315194wri.43.1700176218356; Thu, 16 Nov 2023 15:10:18 -0800 (PST) X-Received: by 2002:a5d:64cd:0:b0:32d:8830:ee2 with SMTP id f13-20020a5d64cd000000b0032d88300ee2mr16315180wri.43.1700176217987; Thu, 16 Nov 2023 15:10:17 -0800 (PST) Received: from ?IPV6:2003:cb:c714:e000:d929:2324:97c7:112c? (p200300cbc714e000d929232497c7112c.dip0.t-ipconnect.de. [2003:cb:c714:e000:d929:2324:97c7:112c]) by smtp.gmail.com with ESMTPSA id d5-20020adfef85000000b0032fb46812c2sm573718wro.12.2023.11.16.15.10.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Nov 2023 15:10:17 -0800 (PST) Message-ID: Date: Fri, 17 Nov 2023 00:10:16 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/3] mm/pagemap: Fix ioctl(PAGEMAP_SCAN) on vma check Content-Language: en-US To: Peter Xu , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Muhammad Usama Anjum , Andrew Morton , Andrei Vagin , syzbot+e94c5aaf7890901ebf9b@syzkaller.appspotmail.com References: <20231116201547.536857-1-peterx@redhat.com> <20231116201547.536857-2-peterx@redhat.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/ztJIQqsE5LsUomE//bLwzj9IVsaQpKDqW6TAPjcdBDPLHvriq7kGjt WhVhdl0qEYB8lkBEU7V2Yb+SYhmhpDrti9Fq1EsmhiHSkxJcGREoMK/63r9WLZYI3+4W2rAc UucZa4OT27U5ZISjNg3Ev0rxU5UH2/pT4wJCfxwocmqaRr6UYmrtZmND89X0KigoFD/XSeVv jwBRNjPAubK9/k5NoRrYqztM9W6sJqrH8+UWZ1Idd/DdmogJh0gNC0+N42Za9yBRURfIdKSb B3JfpUqcWwE7vUaYrHG1nw54pLUoPG6sAA7Mehl3nd4pZUALHwARAQABzSREYXZpZCBIaWxk ZW5icmFuZCA8ZGF2aWRAcmVkaGF0LmNvbT7CwZgEEwEIAEICGwMGCwkIBwMCBhUIAgkKCwQW AgMBAh4BAheA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FrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <20231116201547.536857-2-peterx@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Thu, 16 Nov 2023 15:10:35 -0800 (PST) On 16.11.23 21:15, Peter Xu wrote: > The new ioctl(PAGEMAP_SCAN) relies on vma wr-protect capability provided by > userfault, however in the vma test it didn't explicitly require the vma to > have wr-protect function enabled, even if PM_SCAN_WP_MATCHING flag is set. > > It means the pagemap code can now apply uffd-wp bit to a page in the vma > even if not registered to userfaultfd at all. > > Then in whatever way as long as the pte got written and page fault > resolved, we'll apply the write bit even if uffd-wp bit is set. We'll see > a pte that has both UFFD_WP and WRITE bit set. Anything later that looks > up the pte for uffd-wp bit will trigger the warning: > > WARNING: CPU: 1 PID: 5071 at arch/x86/include/asm/pgtable.h:403 pte_uffd_wp arch/x86/include/asm/pgtable.h:403 [inline] > > Fix it by doing proper check over the vma attributes when > PM_SCAN_WP_MATCHING is specified. > > Fixes: 52526ca7fdb9 ("fs/proc/task_mmu: implement IOCTL to get and optionally clear info about PTEs") > Reported-by: syzbot+e94c5aaf7890901ebf9b@syzkaller.appspotmail.com > Signed-off-by: Peter Xu > --- Reviewed-by: David Hildenbrand -- Cheers, David / dhildenb