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 B089CC433FE for ; Thu, 10 Nov 2022 20:28:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C8396B0074; Thu, 10 Nov 2022 15:28:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4778D6B0075; Thu, 10 Nov 2022 15:28:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33EF48E0001; Thu, 10 Nov 2022 15:28:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 21B166B0074 for ; Thu, 10 Nov 2022 15:28:36 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E5964406F1 for ; Thu, 10 Nov 2022 20:28:35 +0000 (UTC) X-FDA: 80118670590.07.FCAAB08 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 8F9C140005 for ; Thu, 10 Nov 2022 20:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668112114; 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=s3qJXkjwOhbGiwzYiY8uWUuyvmMsTBnM2XzNPe9LD9s=; b=AFu1fihkMf4yAkIY7TX22vzAQeuKR7aUoMOIM9pzFEM13Xvk2q3QZRe+eTtRgtIR6xtuPJ twKMb3OMQ3Aan8unZNR0/j+9djDYy4TeJ4YgAn8cwWkVGu87KpEOJ0MGOLutcexpXzbRVH m7nWmyIV22nDRN7oTtxMiX2IQKt5SZI= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-607-gw9lSO4OMOqoKeil-l2HHg-1; Thu, 10 Nov 2022 15:28:33 -0500 X-MC-Unique: gw9lSO4OMOqoKeil-l2HHg-1 Received: by mail-qt1-f198.google.com with SMTP id i13-20020ac8764d000000b003a4ec8693dcso2238617qtr.14 for ; Thu, 10 Nov 2022 12:28:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=s3qJXkjwOhbGiwzYiY8uWUuyvmMsTBnM2XzNPe9LD9s=; b=SdEPtQFxnGM6zHMy7vMrItlIouYSMAbKXIDYM3YGTrBj2OmBLmoiTDq7KsN3W1VGmZ CNTRveQEh3bbzCiHkLZcEy3MMEzfXCV6nQBzNem/WEIjmYmq5coPmPvtveJBbhuiWNHz UORZsPecQbGGRvNZZpRxvFE7qfr85VkkCCWY40XP52byth+cc02ebYh4CFHGhkMi2e76 I7RrqbQM51n51uFjpCCVkA2TZWDr+N6aDvDIquq9KSLrTb2pLRSDomQU4V+CLOf8WUTS uxTVD/EyjYugDmCygy89YZWXXKwTkx3fwpDkiW+Fj/UXHSDnd0pifKDfDz2eaEDT5Gcz FtSQ== X-Gm-Message-State: ACrzQf3+u7ePEIJBjYIXrbSEa3FiFdL0J33wX3Kjhm0OUKP11/XSrp/b ug2f609b3fLQiMT+Ae4bUzZHC01IZSS6mUC0v7mocvCv+PPh/xAc6ajCed2nBQwOLi5jreIdWTf FbuhUxFKwqbc= X-Received: by 2002:a37:8246:0:b0:6f9:bc42:699a with SMTP id e67-20020a378246000000b006f9bc42699amr1741833qkd.496.1668112112502; Thu, 10 Nov 2022 12:28:32 -0800 (PST) X-Google-Smtp-Source: AMsMyM6U7SlZJzxRPAjnUqO/P0jD8kNSK5YAVkzCKarP217RdqceVGneo5WmOtTIZWolo1PJX/v1Lg== X-Received: by 2002:a37:8246:0:b0:6f9:bc42:699a with SMTP id e67-20020a378246000000b006f9bc42699amr1741822qkd.496.1668112112298; Thu, 10 Nov 2022 12:28:32 -0800 (PST) Received: from x1n (bras-base-aurron9127w-grc-46-70-31-27-79.dsl.bell.ca. [70.31.27.79]) by smtp.gmail.com with ESMTPSA id y201-20020a3764d2000000b006fa7b5ea2d1sm138582qkb.125.2022.11.10.12.28.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 12:28:31 -0800 (PST) Date: Thu, 10 Nov 2022 15:28:30 -0500 From: Peter Xu To: Nadav Amit Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Rapoport , Andrew Morton , Axel Rasmussen , Andrea Arcangeli , Ives van Hoorne Subject: Re: [PATCH 2/2] mm/uffd: Sanity check write bit for uffd-wp protected ptes Message-ID: References: <20221110151702.1478763-1-peterx@redhat.com> <20221110151702.1478763-3-peterx@redhat.com> <58FFF1A3-DC37-4D9F-ABF0-3C5DA519BFFB@gmail.com> MIME-Version: 1.0 In-Reply-To: <58FFF1A3-DC37-4D9F-ABF0-3C5DA519BFFB@gmail.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668112115; a=rsa-sha256; cv=none; b=Ps+5YnKXntsvdQWuHjAAjiVsnyaLNEkP1UyMMKkvUS199tS/A4lyghKvagln+jB2RCQ5sl noVykh0XzxQsNwL2w4YXbe2qOKinyMvc99c3GOLMVWD3i1EdMFj4y0BrJwt8fz8D8e2ATx vlRBB0H+r3y1pptcniWNXWcnPpu7h6E= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AFu1fihk; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668112115; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=s3qJXkjwOhbGiwzYiY8uWUuyvmMsTBnM2XzNPe9LD9s=; b=Cu6aWhbJzO9ZtKngJnMqb54DpmEnIMS2KvsWbuWL8Aj+snoN0fLTQS3mt7A49guEi5v75O NaLkPh2OIosZ2rDDTUtxNh2pZjl8o+G7SoWF72HZudIh0F3K/xGk+fRAWjpQOsOVFD2Cd3 T0TN+wDgBqrSSzx64gTi/+P2ViUQUOU= Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AFu1fihk; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com X-Rspam-User: X-Stat-Signature: q1p8ha98p8zhrp198crrru95tke3joze X-Rspamd-Queue-Id: 8F9C140005 X-Rspamd-Server: rspam05 X-HE-Tag: 1668112115-622545 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 Thu, Nov 10, 2022 at 10:43:25AM -0800, Nadav Amit wrote: > On Nov 10, 2022, at 7:17 AM, Peter Xu wrote: > > > +#ifdef CONFIG_DEBUG_VM > > + /* > > + * Having write bit for wr-protect-marked present ptes is fatal, > > + * because it means the uffd-wp bit will be ignored and write will > > + * just go through. > > + * > > + * Use any chance of pgtable walking to verify this (e.g., when > > + * page swapped out or being migrated for all purposes). It means > > + * something is already wrong. Tell the admin even before the > > + * process crashes. We also nail it with wrong pgtable setup. > > + */ > > + WARN_ON_ONCE(wp && pte_write(pte)); > > How about VM_WARN_ON_ONCE() and no ifdef? Oops.. Will quickly respin, thanks. -- Peter Xu