Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp594905rdb; Fri, 17 Nov 2023 07:28:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IEyWPINHuffeKKG+13AQnq8EylCpSIMnsgYkXYgOAWOl2S4bSQyBTtKdHF1HihNywEyJ105 X-Received: by 2002:a05:6808:1288:b0:3a7:2524:6d3b with SMTP id a8-20020a056808128800b003a725246d3bmr25999379oiw.12.1700234904840; Fri, 17 Nov 2023 07:28:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700234904; cv=none; d=google.com; s=arc-20160816; b=LgEIxkQPUTiTXUJm5R3DgvD2tG3BtF8qYJZBUVpyavvvCpK2Qy9AN1JLjl7AW2NKGK PXRPqT6VHU07oteHTywg1cHCKwkKukYKct8yEbazW+Z6Om9C8b3CSWguvXJVyoBM0fOU xdHsoFpD2L0fwTxWnm+68nJsa73qD4DLuPqiAqWFw8y/xe9vNMbuh8TVbunjFU57040W ULwI7wlRMS2TFC/kp3kpJRo7w6b2Oac4jCYtvP/nOetqDD6Fl9CbKghnufbSeXHJRj9S WoG5XF4n3s9egloPH7Y55Y7ADCNmDQjVdJUEgpBKAHmP0u9A2j4Io9aH/iGMlsT2eGID nLrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=WmKxE7AQnOU7KXybCy/9YJt3zqy4mGTqUK/bK6QTE/Y=; fh=tniM3AJjDq1GaZ+JDdtlUrNX66JFwQN7UnMG22bs4HM=; b=zj2yhyNEMvsRCZ2lYbAzvLQFUW29tfXRu98LmGi8Z8kQHQ8B07RZsXxhB4Oy4O8nQW efTlNmPf93XeB1bcxN5RYtomW2k0A7IsECs9jbpcTZ/p6e5Mmr5cFVenedrmYV1ah2wa 9i6/ddRmMeqwHfChhi9LCWN2JTZRCGSUCvrLm1oiWFnZfJYsJo11WZx3u7YLsDaYocKL C0TNwd3TipfikWaNQN521peRZ7OSLulAhICZ5Icmzb1Q3qep/ha1h7ZI9IBq2Lpmrf/y uZSboy54BxUgmeFZSR40NmRiDu0NpgU/0C0vVVpXNkZnMqFCVTJlrxXE6ikBYA5GUK0K 8uwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Sy1HeT2+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id by11-20020a056a02058b00b005b64e8336dfsi2116570pgb.604.2023.11.17.07.28.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 07:28:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Sy1HeT2+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 469FD8062AF0; Fri, 17 Nov 2023 07:28:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232348AbjKQP2A (ORCPT + 99 others); Fri, 17 Nov 2023 10:28:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231690AbjKQP16 (ORCPT ); Fri, 17 Nov 2023 10:27:58 -0500 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B68B8D57 for ; Fri, 17 Nov 2023 07:27:53 -0800 (PST) Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2c6efcef4eeso27822971fa.1 for ; Fri, 17 Nov 2023 07:27:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700234872; x=1700839672; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=WmKxE7AQnOU7KXybCy/9YJt3zqy4mGTqUK/bK6QTE/Y=; b=Sy1HeT2+lere+WaserZQqgfPsp2arXPABSErGOGacUMPwh2N2bf0t86G99iumfkJPE 89RyxdkeVMeDEyZy8+OpCrJNwjo0tW5cXzv8at1pEjATGGwLW7ddcQo6oosIu9SkMEI6 TI3OlT///ymb6ilohWCQSbGkS2X6rpFCfm4WH+usvSRHY1JWjYKfsL60k2kqYlNn+IIK 3JWxLbUuEWwQQVeW1t485wIQ8ow73MaI+H2Bju1Y1KAUyNO4CzWh49SPqEaDMedYr8Uv dRtsSXJXfSNOclKQX0UEpVzJUadKM30GP2Ry9Upk5diu7V1GRx3DkGamAWLln1FtZxKw 8k6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700234872; x=1700839672; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WmKxE7AQnOU7KXybCy/9YJt3zqy4mGTqUK/bK6QTE/Y=; b=rl2jR6G4oZsccZA9vwiCc/753S8/E05YOYQ+fYICrluNLPYPW3RRpIS6PfdgJgIQ0h c+6X81PR1uhU/Fp6fIl+EojNGk0zmQGD2WuUaz1eAaIhugUi5kGBDHFQKlYHLI6Fo7q6 3Nmjl9jLFNqwiUOn9Sag9sHRRRF6YfarzdRMExCxr+s3Dju/iKnyoMdWn4PQm3mRecQ5 RAN+XjHMlyQaehSW9dZ59YenWKxB/KMkThLGKQNM/XyP/FIVMCJiBoBu31WienaBlE+0 QcMJJ8ZuavjUzbCRVLK+SBp8ypnbYiNfUpJhAmftDFkhk0hU5Ur/G308Q85n5wbcGlNd VEMQ== X-Gm-Message-State: AOJu0Yzi0pYhlYn/sZ4pMVO9YQYtruC8aNg23cUghTh6Cr4Xz6H9wdBm oikSdZZb7exItTd8aBUM4Io2F3INqK1F8Y6iPng= X-Received: by 2002:a05:651c:b28:b0:2c8:6f66:27a7 with SMTP id b40-20020a05651c0b2800b002c86f6627a7mr1323835ljr.23.1700234871330; Fri, 17 Nov 2023 07:27:51 -0800 (PST) MIME-Version: 1.0 References: <20231116201547.536857-1-peterx@redhat.com> <20231116201547.536857-3-peterx@redhat.com> In-Reply-To: <20231116201547.536857-3-peterx@redhat.com> From: Andrei Vagin Date: Fri, 17 Nov 2023 07:27:40 -0800 Message-ID: Subject: Re: [PATCH 2/3] mm/pagemap: Fix wr-protect even if PM_SCAN_WP_MATCHING not set To: Peter Xu Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Muhammad Usama Anjum , Andrew Morton , David Hildenbrand , syzbot+7ca4b2719dc742b8d0a4@syzkaller.appspotmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Fri, 17 Nov 2023 07:28:22 -0800 (PST) On Thu, Nov 16, 2023 at 12:15=E2=80=AFPM Peter Xu wrote= : > > The new pagemap ioctl contains a fast path for wr-protections without > looking into category masks. It forgets to check PM_SCAN_WP_MATCHING > before applying the wr-protections. It can cause, e.g., pte markers > installed on archs that do not even support uffd wr-protect. > > WARNING: CPU: 0 PID: 5059 at mm/memory.c:1520 zap_pte_range mm/memory.c:1= 520 [inline] > > Fixes: 12f6b01a0bcb ("fs/proc/task_mmu: add fast paths to get/clear PAGE_= IS_WRITTEN flag") > Reported-by: syzbot+7ca4b2719dc742b8d0a4@syzkaller.appspotmail.com > Signed-off-by: Peter Xu Reviewed-by: Andrei Vagin > --- > fs/proc/task_mmu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c > index e91085d79926..d19924bf0a39 100644 > --- a/fs/proc/task_mmu.c > +++ b/fs/proc/task_mmu.c > @@ -2171,7 +2171,7 @@ static int pagemap_scan_pmd_entry(pmd_t *pmd, unsig= ned long start, > return 0; > } > > - if (!p->vec_out) { > + if ((p->arg.flags & PM_SCAN_WP_MATCHING) && !p->vec_out) { > /* Fast path for performing exclusive WP */ > for (addr =3D start; addr !=3D end; pte++, addr +=3D PAGE= _SIZE) { > if (pte_uffd_wp(ptep_get(pte))) > -- > 2.41.0 >