Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2640144rdh; Sun, 26 Nov 2023 13:55:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IEXUFg2WDlz3UVkY8+vSPYqy6Zn640eUHhXRRsiyfqDLPHZYmztLfoUtKToX8qgw6sr3vQs X-Received: by 2002:a05:6808:202a:b0:3b8:42f2:408e with SMTP id q42-20020a056808202a00b003b842f2408emr13688541oiw.42.1701035735057; Sun, 26 Nov 2023 13:55:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701035735; cv=none; d=google.com; s=arc-20160816; b=rHLIjnA6EGN4BOYmomegSedpYe+lEXRB/vbEqqzd7HKOPjhqQerEbYYeVvQZOZn/LV gmny0gBEks3+1SG0Hy2k0S27fV9cGcq051qCyxBfJk6GArjFX5KIOSEfE4DYcvOFfJDX B4mSQ7kAxgNT3mBhlgxRQyt9XAJtP8O/jgI3MlCan+E69YwsZiUcbE9o9OTCaPGb2iw+ rbEHFqM0klZIFFE0fb8M9cwYbMs5eV5SocjgOjEmmOqHrTMb3rFdI0gUz6EqC7pq9+g7 y1HJDLcNvq0iV6wjmsx4vt3NQYVS50mjXVoz0GSf3XlMS3kv6fIQCGjL9FgHZtjMgKg+ K03Q== 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=UbvJtYTtIvQRI2d4NOXWwsD4H2hzcPgDD+3up9r2zCY=; fh=bhmp2n4ADK+kAnQWewShtxLKlFeifPDlipoWi/pkghA=; b=fTOpAxPCyKntjWBdPkOAZPNCXACchU12wvNuUEQkJUiKD/LFABY2gD6Sd9qtaXWJVR r7uabvXR//6caVlegOztExtqHrhcrWleS3rxm1xH6Pxv9g12lsrlwA/xOMcOmVBu7K21 cZbuqj89d08q3L+BftjnR77oMk7aV3F5XNjtTim8FmRQh3db4QX6FnbR7OKTg5cwrxAU TKlGQJen8G8It1drq89zuXz0iidzJ95UA5vfVAMP2lAyK27fuqStqZF+MqZqcuTD2D7q 4tomr7W/WjIyXy0nrnwgxqVM7MlUSGzHBumviWrEpn0hRF6rKQhnfdVTQcl6l8PWZGFP kT9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TE7icV5j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id 206-20020a6300d7000000b005b92edaa151si8395356pga.739.2023.11.26.13.55.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Nov 2023 13:55:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TE7icV5j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 708CA806116B; Sun, 26 Nov 2023 13:55:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229502AbjKZVzT (ORCPT + 99 others); Sun, 26 Nov 2023 16:55:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbjKZVzS (ORCPT ); Sun, 26 Nov 2023 16:55:18 -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 9F4EB101 for ; Sun, 26 Nov 2023 13:55:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701035723; 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: in-reply-to:in-reply-to:references:references; bh=UbvJtYTtIvQRI2d4NOXWwsD4H2hzcPgDD+3up9r2zCY=; b=TE7icV5jhWPIELcobs6ZjMyvUvyxdE12xLLke6EzhssNSj9FafsOg/wGb2BRiDwtzku4o4 dMDrEeD5+a95yv8jWY3IAaP8W28xcr7ZQzQwnU5EZ+3LE/FG1CoSD60oAeDWAvRmxfmji8 LyWv8g0sm07zIwG+dR26Ydhbi9+3Rfw= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-328-YqaFML-jMe6aX38p6asZ7w-1; Sun, 26 Nov 2023 16:55:22 -0500 X-MC-Unique: YqaFML-jMe6aX38p6asZ7w-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-67a06b43afcso10573546d6.1 for ; Sun, 26 Nov 2023 13:55:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701035722; x=1701640522; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=UbvJtYTtIvQRI2d4NOXWwsD4H2hzcPgDD+3up9r2zCY=; b=qVnwc7tMSnJU5I13Pi6DUEKWeGejdxSJY5AJmwEl3A15hSfJw4tU6ye3ab16jlwXFq Ba4uVc1qDStLuJJthSNBfHo7+uKTY6/mQ/UPZNDgs/reXKioBieTrxnS7hHrAWXfxE3e 5QdgZUxYsap3GPLz++Eg9XvI8IFYmZTvD5RomOifYPKbtMxNmF+EPahHp/RDoJomV3Po LbKFdL06A782uYspDtBodzfxWdtpzgvh9pa6KZlzHf7KfDhpxMhQCphoOQLJHkfXefNu dtMoE+iVdXsBDuQtasYXbh5KaoIJ6WKOsCGivLMPoW1ME+cdCBopMc6iKv9HgRgWfjqO Bj8Q== X-Gm-Message-State: AOJu0Yy/IN0zXVghMDNph+UR18rCw4VmfrueJJrqbXmMYYi6Po9xyLE7 AzB0qZXyhOu1geJn46yL3KFPj+HMi8UJilGK6jPrVDApoXsXzQw5UtL83CoFe5Uka7B81KtEVqG wp5lCHkMK4fQXRNzFk0CpH8wp X-Received: by 2002:a05:6214:1399:b0:678:35a9:c363 with SMTP id pp25-20020a056214139900b0067835a9c363mr10204052qvb.4.1701035721817; Sun, 26 Nov 2023 13:55:21 -0800 (PST) X-Received: by 2002:a05:6214:1399:b0:678:35a9:c363 with SMTP id pp25-20020a056214139900b0067835a9c363mr10204039qvb.4.1701035721527; Sun, 26 Nov 2023 13:55:21 -0800 (PST) Received: from x1n (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id a13-20020a0cb34d000000b00677adcfd261sm893391qvf.89.2023.11.26.13.55.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Nov 2023 13:55:20 -0800 (PST) Date: Sun, 26 Nov 2023 16:55:19 -0500 From: Peter Xu To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dan Williams , Mel Gorman , Matthew Wilcox , "Aneesh Kumar K . V" , Christoph Hellwig Subject: Re: [PATCH] mm/gup: Fix follow_devmap_p[mu]d() on page==NULL handling Message-ID: References: <20231123180222.1048297-1-peterx@redhat.com> <20231124112059.3519d6fdfe71f846f8bf726f@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231124112059.3519d6fdfe71f846f8bf726f@linux-foundation.org> X-Spam-Status: No, score=0.6 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Sun, 26 Nov 2023 13:55:32 -0800 (PST) On Fri, Nov 24, 2023 at 11:20:59AM -0800, Andrew Morton wrote: > On Thu, 23 Nov 2023 13:02:22 -0500 Peter Xu wrote: > > > This is a bug found not by any report but only by code observations. > > > > When GUP sees a devpmd/devpud and if page==NULL is returned, it means a > > fault is probably required. Here falling through when page==NULL can cause > > unexpected behavior. > > > > Well this is worrisome. We aren't able to construct a test case to > demonstrate this bug? Why is that? Is it perhaps just dead code? IIUC it's not dead code. Take the example of follow_devmap_pmd(), it can return page==NULL at least when seeing write bit missing: if (flags & FOLL_WRITE && !pmd_write(*pmd)) return NULL; AFAICT it can happen if someone does "echo 4 > /proc/$PID/clear_refs" when the mm contains the devmap pmd. Same to pud. It'll be nice if someone that works with dax would like to verify it. In my series (refactor hugetlb gup, part 2) IIUC some hugetlb selftest can start to trigger this path, but I'll need to check. So far it's dax-only. Thanks, -- Peter Xu