From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44D32157484 for ; Wed, 15 Jan 2025 17:21:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736961686; cv=none; b=KOMuDujqybKC36TcA44e2HlZ4bZi4vmq3ZDeneuPdKMuxOmOW9bFdsE5gjHsrFrFZje4+5w1PjAJTAHoCXJ91qWCGMW6UXTCkihO3lbgzTaQmFCmJaNSPqUNFvlU5T68l9Kk6Ohtaxbs4nwTbYeMf3UIddCwBLNnbbnK+kXcIA8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736961686; c=relaxed/simple; bh=qv8K6P+rJ3N3NWZzO4UOpR58BJ5OlP70iiFx0t6OsTs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eY45+OEsnH8IhtiEeJqqye9oZ40fSdLnM65zpq7l3mDdWpKlsbKstvgozsEL7Tl0YuD9xoh53C7lYBAgDb6o/Q5qG066m6JOuIToovzvxG8DR6XfNPgbYXpTEeNWgXqBCfg6Iq0HfU0krSyblaMA4JPnADdWxH4aIezygFfPq7Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=hccsjDLT; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hccsjDLT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736961684; 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=n7fD6FZnMW/OK3LA1vYZfY+rnhacvCh2TilJm5lNlJg=; b=hccsjDLTmRjg3mGKUiuFmwXeUMZ7LMZhgSf59fjolI46cvyTMjcUhcNMZStrzpeWBg3bOu aQfzg8/EXrup1oP5hsJ/wbSCr4XRmsSO5qmXRId2b7VSYT/dTqgbiV1B+GQQMtgoYe9p3t zXV7IlH9w0MFkRNRkH5IZmIGHaNoYb4= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-328-LMYoGjJqOgKRxJi3EqAMkw-1; Wed, 15 Jan 2025 12:21:22 -0500 X-MC-Unique: LMYoGjJqOgKRxJi3EqAMkw-1 X-Mimecast-MFC-AGG-ID: LMYoGjJqOgKRxJi3EqAMkw Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-2f5538a2356so88968a91.2 for ; Wed, 15 Jan 2025 09:21:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736961682; x=1737566482; 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=n7fD6FZnMW/OK3LA1vYZfY+rnhacvCh2TilJm5lNlJg=; b=byyuCvOqdmwXl7XLkg4xTnYd0Uigr5thHW+DTt8XMIlfstnNkJxrJV9rwgWJWK1ATq I7sdbYjCUe5bWpxGC2X0KtQgG6HrujpqsBChKftfATcKXZpFDOxlTwpwoSMUbOnXslzn vmPX+a1NX2eTATsTsUZRD+FTDRpbX+M3Ni51Bsc9yaifXWTgT8ncunNThjEi9PGPiWql a5HOwcv3aWeLrreuQbJZM2cq5BHBdnPR4JH3w/vRaP1exHygT4b9pQUru+vjLtJTD6uD 0Aw0qSAocDbRiIrtXE/ktjhvrZHk9qg3CPohfsGXuBVMd4T1Zgcf/DZWy7BbFK+cs3Ye 2QHg== X-Forwarded-Encrypted: i=1; AJvYcCXa5BlDFktDtQ4ufjXAx5ZWxjAVJvRML9cMNrugbMBc4SLgCyRHD91/YugbBv+XWlGNc0/nUQlaIy7k1mk=@vger.kernel.org X-Gm-Message-State: AOJu0YzNdSXYsfjvdHped9hUOZVe51x64yuHX1p/8HdLeGisC1gSPs8K X8NjdURu/tEjOtm1nYOpRPn6Q1eEF1NKUdwETFVdwMFTfN9Ga99IZ5vb4uIp8TYsEnvro2VOyaI DFXu4fbAIJhFR8lIfSJj1nLq8M/D6VIH8Mgjkz514sKxmEZ2kxA6r3JEq7CRl4A== X-Gm-Gg: ASbGncuDqZKWau1yFTH3XjlIrVnpf8w2luGbUUhKqcCp9vILkKHhimL31OhUCXrvdqB n7WvpUJqITZSWh32F/yZfMmCARi2WSk8gEvfRtc6fo8iSyFjgSPyUKleNU+dEKJtvreKHCDDF/T aEmoS0lGJBszrjXctJ7S8BR6Jde6Mg3dlaQ3oWBxGlr4ae4tHG2wyfDwjvcxZsWfe6MJnzpEIjT ModUy/Su7ubpyoVsbv3Q8kLXHSx6lXtcQM0qwPIuZAskZwoxyk2JDN2JzXc0MVkIdaFOX8Q2ZU2 lBDiZ6kfblXggH62tQ== X-Received: by 2002:a05:6a00:914b:b0:72d:35ed:214b with SMTP id d2e1a72fcca58-72d35ed2202mr34314242b3a.24.1736961681602; Wed, 15 Jan 2025 09:21:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSsNepujGNbz1J1IXBjb/0km3pMtHIrAFEFy5rxiY9EIHAZSxb6F0qyHmauJ7UyfeA7MZUmQ== X-Received: by 2002:a05:6a00:914b:b0:72d:35ed:214b with SMTP id d2e1a72fcca58-72d35ed2202mr34314191b3a.24.1736961680947; Wed, 15 Jan 2025 09:21:20 -0800 (PST) Received: from x1n (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d4067f84csm9648975b3a.142.2025.01.15.09.21.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jan 2025 09:21:20 -0800 (PST) Date: Wed, 15 Jan 2025 12:21:15 -0500 From: Peter Xu To: Ryan Roberts Cc: Andrew Morton , Muchun Song , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Shuah Khan , David Hildenbrand , =?utf-8?Q?Miko=C5=82aj?= Lenczewski , Mark Rutland , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v1 1/2] mm: Clear uffd-wp PTE/PMD state on mremap() Message-ID: References: <20250107144755.1871363-1-ryan.roberts@arm.com> <20250107144755.1871363-2-ryan.roberts@arm.com> <26ee9ae0-405f-4085-a864-48d1ee6371f1@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <26ee9ae0-405f-4085-a864-48d1ee6371f1@arm.com> On Wed, Jan 15, 2025 at 04:58:06PM +0000, Ryan Roberts wrote: > Hi Peter, David, Hey, Ryan, > > On 07/01/2025 14:47, Ryan Roberts wrote: > > When mremap()ing a memory region previously registered with userfaultfd > > as write-protected but without UFFD_FEATURE_EVENT_REMAP, an > > inconsistency in flag clearing leads to a mismatch between the vma flags > > (which have uffd-wp cleared) and the pte/pmd flags (which do not have > > uffd-wp cleared). This mismatch causes a subsequent mprotect(PROT_WRITE) > > to trigger a warning in page_table_check_pte_flags() due to setting the > > pte to writable while uffd-wp is still set. > > > > Fix this by always explicitly clearing the uffd-wp pte/pmd flags on any > > such mremap() so that the values are consistent with the existing > > clearing of VM_UFFD_WP. Be careful to clear the logical flag regardless > > of its physical form; a PTE bit, a swap PTE bit, or a PTE marker. Cover > > PTE, huge PMD and hugetlb paths. > > I just noticed that Andrew sent this to Linus and it's now in his tree; I'm > suddenly very nervous that it doesn't have any acks. I don't suppose you would > be able to do a quick review to calm the nerves?? Heh, I fully trusted you, and I appreciated your help too. I'll need to run for 1-2 hours, but I'll read it this afternoon. Side note: no review is as good as tests on reliability POV if that was the concern, but I'll try my best. Thanks, -- Peter Xu