From patchwork Tue Dec 10 08:41:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13901032 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 050C8E77181 for ; Tue, 10 Dec 2024 08:42:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5967E6B013B; Tue, 10 Dec 2024 03:42:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 545BF6B013C; Tue, 10 Dec 2024 03:42:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3BFBB6B013D; Tue, 10 Dec 2024 03:42:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1DCDD6B013B for ; Tue, 10 Dec 2024 03:42:46 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A79EF1C708D for ; Tue, 10 Dec 2024 08:42:45 +0000 (UTC) X-FDA: 82878407808.27.FE6DDF0 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf08.hostedemail.com (Postfix) with ESMTP id 82D31160007 for ; Tue, 10 Dec 2024 08:42:28 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=RbKhL5br; spf=pass (imf08.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733820153; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4zax7EN62Zge5TyiAMCtlwlcwdhFoF4SzkCJ1+TpsME=; b=u1fPWpNal8YeRezrEw3UIRKKhFShje0hqdwryCK+5pGb/i5elGxHEA8YEoEODVLaGHhiRu ApYX+z2F1oLF5KrSHxUVQ0KUS1LSmDMU3tbbH7ihhRvHL8z081KDOfNgj/0MYWejrIkjL/ FIWtefe8ShCdRbpGRd6dgJiWccSYyu4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733820153; a=rsa-sha256; cv=none; b=ORwdv+X9yVH+6Qvj5IoNB0aexiGiMStYKSPPSea/FJD7NDlcWMJ977Q2pP9eMf1gGaG4xt m6Sv8mkDm0JVLUBnKTc+7bXzkXdiYgTUinQz3mODz7HU421dzGmO6ase8HHfoJWiSf5UX0 k8ummEiSV76e+e7orKyCptB7YweDVKg= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=RbKhL5br; spf=pass (imf08.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-725f3594965so1301982b3a.3 for ; Tue, 10 Dec 2024 00:42:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1733820161; x=1734424961; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4zax7EN62Zge5TyiAMCtlwlcwdhFoF4SzkCJ1+TpsME=; b=RbKhL5brbuGAH8A8sKOqcV3IBZ0FKrn9wnntI3mL0xkw0piEOcisX/d7sCjmfSXXLV hie6vtf9Vs5F9xl2BNnsHQ0DRiuHjC3heD5yftYqpSOJk67ScRcW6ud+oMwCF1W2W66i eVTLFMhPC9/GaPFERq49oUJspRhx3b0nuRL8Ru0dmH1GM7zARPcQfWKrIg9ph2q5Zb9E +LdEI/RoPZM2fm9CKdKsJQdWFh/0DeHeptPA6r/Ug0iaYG8EK8pFxI7THpU4s0soT/aE qWjlOr2DxVmcgg96OI8s5RUJ26PVtQZmKDlemrOhomXuHYJ7DQOe5s6uuMuN50q6vmX3 XZTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733820161; x=1734424961; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4zax7EN62Zge5TyiAMCtlwlcwdhFoF4SzkCJ1+TpsME=; b=fsC28SnMi7RkTsWjMOt5A1ppNcltQzXWpc11T4rLeTiQsdE8QTsEKjYWR7KeVvB3SN f+j9v66AH0BRd3AC0jqfGSmbPTEORVrsZAog6OKYnWw6C+uyz20T9qyHCQ+cOvkpLZLT smn1pQN5PMrSADA4nzYjy4wRw07WYejrMHASoj+tSD+mxY/x0n8lZZ6sdSD9UninkrE0 iH6LVnyr4USqRuWkdbwdoDfpyI2vJV9kmGx9Hgn+y+YO3mEMNlUt5n5a8FA9htDmYrDv 8OLvPenV5K7p1lcCCV0MdMEXiuV0Qhf+A33+vhyxJjaVZPPWWE5JNGtREbJf3YG1/ee/ 3S/Q== X-Gm-Message-State: AOJu0Yyai5+O61PHSIAxtSDWMHTzeWrJmPHOUtUlt1s9kKCMborwBTib OUtixO0wj8zrmjpnckbWohfwwl3OvpzvY6ksQpJeaJWe4g6yK6w5rhzP3U/Qf8k= X-Gm-Gg: ASbGncvvP1UUlYMXutUbHSzPy2QBt2h7XYU6DKq+0M5Y91fN/BuvValTyyJSBn1SNbq DR0aISjh3iH6MnP/xDKC4iAQpO3LyZ/L7L1wwcLTcVV5G/yU6HfpSWRAlbfQabS4l8hyaDheuXm W0OyOf1eXw9H/A0GtvNISzMQtGbbObJnkOlbvzdglwWPj4Ry4k2mipKzs+9uXt6p8OMcAYOeP4B 7dc+sV4etAP4LDTrliJhL3/10b6VRD24VU/MhAXA8PEOlt8dBn7HKEQ8x0iVShZM1o+qtIjubk2 lzkGX+cJIe+XcBwRWYw= X-Google-Smtp-Source: AGHT+IH1gRl/JKCwvOjoMJe/2aqSAEex1BHuTnYZJLpcrk9acieiAuFurl5AA3HMy2rCqLHQ4EoUsw== X-Received: by 2002:a05:6a00:4613:b0:725:8c02:8dbc with SMTP id d2e1a72fcca58-725b81b5cf5mr24503375b3a.22.1733820161348; Tue, 10 Dec 2024 00:42:41 -0800 (PST) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.150]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725a29c5ad8sm8859539b3a.8.2024.12.10.00.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2024 00:42:40 -0800 (PST) From: Qi Zheng To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qi Zheng Subject: [PATCH v4 02/11 fix] fix: mm: userfaultfd: recheck dst_pmd entry in move_pages_pte() Date: Tue, 10 Dec 2024 16:41:56 +0800 Message-Id: <20241210084156.89877-1-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <8108c262757fc492626f3a2ffc44b775f2710e16.1733305182.git.zhengqi.arch@bytedance.com> References: <8108c262757fc492626f3a2ffc44b775f2710e16.1733305182.git.zhengqi.arch@bytedance.com> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 82D31160007 X-Stat-Signature: nokq9aw659wo8dyeqftey7wa91kj8x8b X-Rspam-User: X-HE-Tag: 1733820148-306969 X-HE-Meta: U2F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U0Igq7kR2ORmywGbBq7Nx0n2bxV8mZJfEIK1r+TuiEcFoEQ7ktizyUqMox6EAV35b7SIgxn3MAjCbbnUOstFLLwETOJyX4RdNRlhTLPkFWE+/NsrjIfnB3M4weT6+XSMvqip6VTu08tzXVg/l1ZmjlQu/emksPYT4OoVumMcGUn82EJZphc7hhUrqiwv+FKpb8I3n0hlfcdkekPmnYVI2OMZTi5ohxSyEGMbHXmWCcjGiDWJ4RxEDYn3TPvU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.119558, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The following WARN_ON_ONCE()s can also be expected to be triggered, so remove them as well. if (WARN_ON_ONCE(pmd_none(*dst_pmd)) || WARN_ON_ONCE(pmd_none(*src_pmd)) || WARN_ON_ONCE(pmd_trans_huge(*dst_pmd)) || WARN_ON_ONCE(pmd_trans_huge(*src_pmd)) Signed-off-by: Qi Zheng --- mm/userfaultfd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index bc9a66ec6a6e4..4527c385935be 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -1185,8 +1185,8 @@ static int move_pages_pte(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd, } /* Sanity checks before the operation */ - if (WARN_ON_ONCE(pmd_none(*dst_pmd)) || WARN_ON_ONCE(pmd_none(*src_pmd)) || - WARN_ON_ONCE(pmd_trans_huge(*dst_pmd)) || WARN_ON_ONCE(pmd_trans_huge(*src_pmd))) { + if (pmd_none(*dst_pmd) || pmd_none(*src_pmd) || + pmd_trans_huge(*dst_pmd) || pmd_trans_huge(*src_pmd)) { err = -EINVAL; goto out; }