Message ID | 20240813-uffd-thp-flip-fix-v2-2-5efa61078a41@google.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 13EC6C52D7C for <linux-mm@archiver.kernel.org>; Tue, 13 Aug 2024 20:25:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81BE76B0089; Tue, 13 Aug 2024 16:25:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A3AD6B008A; Tue, 13 Aug 2024 16:25:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 644686B0092; Tue, 13 Aug 2024 16:25:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3C20C6B0089 for <linux-mm@kvack.org>; Tue, 13 Aug 2024 16:25:47 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E2F36140AA9 for <linux-mm@kvack.org>; Tue, 13 Aug 2024 20:25:46 +0000 (UTC) X-FDA: 82448353092.14.A7162DE Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by imf29.hostedemail.com (Postfix) with ESMTP id E705E120030 for <linux-mm@kvack.org>; Tue, 13 Aug 2024 20:25:44 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ybruSOcF; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf29.hostedemail.com: domain of jannh@google.com designates 209.85.128.51 as permitted sender) smtp.mailfrom=jannh@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723580665; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=C8hC/8u5rHQIE5OTDIzO5nzE5ccZrI6SAOcdv8SAfDg=; b=7mFSu7cgNm1deL9ryMGo076hK3qjJSr6eae+5ZtNOBpXOJVT5EKVrfyP1a6rPgtFqy3Q2y ggxWQ8Q0Vf58H8d0BFT3SBHtE8lW5wiCsGZHwHWXcKDBLaj7XH/euS3dh2jbBD5juJImR4 SjLAUSmY4ROoZwO10uHzo3wbJAKBNF0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723580665; a=rsa-sha256; cv=none; b=fk1/Ef7si7GZsIXcxLFaxXZPsGozytmU9TxUOWS3RGIxjaWC1X/pFXT1jM/JU13sNnlAd/ VU/LO6MOvj0xZdipA1kG0R17JHzrQQnodHDtPCCZwFCJsyYsOsXRRx8Lj/bNTc1VwVnnbR gsoNKQNMe764c98iRzPVMOlIhu0IWqg= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ybruSOcF; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf29.hostedemail.com: domain of jannh@google.com designates 209.85.128.51 as permitted sender) smtp.mailfrom=jannh@google.com Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-428e12f6e56so9935e9.0 for <linux-mm@kvack.org>; Tue, 13 Aug 2024 13:25:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723580743; x=1724185543; darn=kvack.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=C8hC/8u5rHQIE5OTDIzO5nzE5ccZrI6SAOcdv8SAfDg=; b=ybruSOcFqVbLsroOAr1Xl4WOW1ZNhlUkOHnpxcv1T9DVEXr4Y5cVzkb0/p62LuuuSR jTMT8Iaa69fb60ePFR1mP8eMz4IsW0e6oXCnl8ErWMJitonss791IrbkijBjXlsjErdS LWQB56SQn8S8ixapX+ykRnNdvCut6s5GmW8e+bvQEBJSr+nkrgIv5u0l8zPiQmTu26Sj Xt5oFCb1n2+jYFdvZW9v0BaEr3LmLqkViCZ0yfHeAysutBChLhL7AX00R+Z+d2hCSMRW GxGJLCULR+venoWEcD3jE0K1KSB3i5FeaXB23lybqXkyIujrSLUzfIvBVrACB0EuBcuE kIGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723580743; x=1724185543; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C8hC/8u5rHQIE5OTDIzO5nzE5ccZrI6SAOcdv8SAfDg=; b=MwUAh+N5ggqsMeO0AUDpbcp0fWK38VDJkKHf1add0cZ/wWPG/HscEFcJ/fsr1l3t3c 8xzVkj/k2bCSt7CSvAG5PaKRREE8NQLg2ldMSgLbibj4dUFs0LNV41UtVROyHbGxPcIp RB5N96IjeTc8XwIcSPbgBBjh6muut+5IwIUich4aIHDH8usvQho2G5LQe82wuONfrsPK gbvv7BGmNwXJr1WxVqtRnNrAWmOphnEOD6+hug4W1dJoqf1JB55A5ZCCE/SFXR+ens76 QgzjiIYCYd7w8AnuimyeSvxtmVZ6fTPW+Y2mO1RZMmeZeXkMrcd0HfYqOI7SGaFZO8VU uB8Q== X-Gm-Message-State: AOJu0YwaNGOV4WtrizWJlF4UBFtFmrcyfLskQI0PG7QH5ry9erCk7fod foGH6oogMt8WHfeSKOUPtN80Ov69T89SG72tXEAjGOl4d1JU3Rxy8/o9QZPZtWk4dGA4OG7IxyM Wdw== X-Google-Smtp-Source: AGHT+IGLLbA7isZyCSmnyKczKWq9+cyJGJEJpYUawegxPAI3pwvA6i9O/zVRBIs345jqiM6wxH4Ilg== X-Received: by 2002:a05:600c:501f:b0:426:7018:2e2f with SMTP id 5b1f17b1804b1-429dec3d255mr5555e9.5.1723580742844; Tue, 13 Aug 2024 13:25:42 -0700 (PDT) Received: from localhost ([2a00:79e0:9d:4:a608:a4cb:f4c2:6573]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d877f234sm26530545e9.1.2024.08.13.13.25.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 13:25:42 -0700 (PDT) From: Jann Horn <jannh@google.com> Date: Tue, 13 Aug 2024 22:25:22 +0200 Subject: [PATCH v2 2/2] userfaultfd: Don't BUG_ON() if khugepaged yanks our page table MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240813-uffd-thp-flip-fix-v2-2-5efa61078a41@google.com> References: <20240813-uffd-thp-flip-fix-v2-0-5efa61078a41@google.com> In-Reply-To: <20240813-uffd-thp-flip-fix-v2-0-5efa61078a41@google.com> To: Andrew Morton <akpm@linux-foundation.org>, Pavel Emelianov <xemul@virtuozzo.com>, Andrea Arcangeli <aarcange@redhat.com>, Hugh Dickins <hughd@google.com> Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, David Hildenbrand <david@redhat.com>, Qi Zheng <zhengqi.arch@bytedance.com>, Jann Horn <jannh@google.com>, stable@vger.kernel.org X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1723580736; l=1397; i=jannh@google.com; s=20240730; h=from:subject:message-id; bh=tzIAzt339urOnQP09jTAjXTel5g3L+lCAuxLVJJcPg8=; b=U5pU3rpcbs7XfZhd6TtUWxvTgQAQAflkgJ5K+vZYgkKpqqGS3XYHTVRAJkLG94mCVkVX5F7fz XY0Lb4AZrHXC6jrhYrjoIfRyPG3EWQwDdn3PUdv78rzxnTrCvAGxNWq X-Developer-Key: i=jannh@google.com; a=ed25519; pk=AljNtGOzXeF6khBXDJVVvwSEkVDGnnZZYqfWhP1V+C8= X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: E705E120030 X-Stat-Signature: 4naqx84z63hdofy3m819gwjq9w85qyq8 X-Rspam-User: X-HE-Tag: 1723580744-38015 X-HE-Meta: U2FsdGVkX19+zrGXK6vrCL6IpgacjfhdPRZlqakqgS5FDyIOULNJa/fjiwTMut3milwzGfV8REVxGbWCyCI2STT1pBeX1FPzsC66bvhxENReWxPA0AR3KofdQtHs1OFmQMFqcNoLVWowjCsr6HV+hcO7Fxo631NlBumByQqDbMoJZiSVZ/unjI1MV5QGZZAgf6xOq1kj/HbehKYPRlLCQHIl/1fpSwE+2bB65LtDLsof+XJU/fNrQYqe8dZ3d58fznjIiVaZ/cu4xtNTYZ0XSOcceqcatj2P2m1KxpwHuDfkWlb7SZVbEur3X8y4/siPllktvNBbAibuFXrBJdFlcvblCJ+LJVfUAO8zHppq6VFkEzd+5S4HQIOW70ybGmTOEHnQ6Tl2IoAdDeHTXiHRPm4v0XlKMsX/YGtrjnUs4BLxY8qqI+wMqpcuzhI3RG8q3bk5V0zJAEdQ7Kswf69PmnuEiIC+LzseSBUSzthABR9NHY99Mvc65+9Xuo7aP/RCThs9vQUM0rsfXaRax12Oct/51jvvbVFOp0QoG/XFdsIQ3yOlANriUYFsgmbcrD4l78eJUn4X4a5ss4a2kgRWQ4ijT4K6/bScGtklOJvEl90zDhhMm8Or7mi0Y6959kW6mceyUQ8KZxdSX3q0FTz6pEC7x3UIZQ4ERECy68t5hTNQ5nQgmbaeEH53FJ55FZHjWaObumLeEg1PEr/7fmHV9GWknjQvKzRT0aB5U0rGza6+pjjm8CuEewMFpJe+kbHvDyJd1VOa+qabkoaFXViU5JCeFTIaKKWIIs6I0b7H8J7A8BgENVlIxvmqfJqh29W1tweERr4vfWj812raCxDtflq5JZ0RurqH06LDIFurMJq9qikw0RKE8XM8auNCYDGYnUt9KOVQgmwM02H2T4/vby5lwWa7jj7IsEY26TNKUGFFP8Dra6umD6BbrqQGtWUL2x1o1WLQg0i1onKQmWp z6SIOWjn XEqjAnC5DJGSA1xCrRG28gK+/IA7460Ds7gIT4xeBV10sVS1WlW8XFaluVNkqMUN5y8BoCeJk68zjaDfMOrXyOpDfrsgLxaOs/8wI5eYA0wIVbpikwAZnI5SoZb73lrsmhEXsISq7cBjA2LwoALMkE2iitJUCkwwkGf9+P/W5jpVBPXAU/D/cIAPvlzj4IQLqKnW6A5vmchHpV3pJrE5HKxMcPUpB8sez81UBDbfkYW2U0TXKKr8r27TCHJSAqmlrYZv3SkwNWN1c/MEYsumsmMgQwfOZ7/OkcvnbmOd1avtCwUuvbiUqJLbcsIrVUzP7EPW73oE59kAitiODHMoqyUpvKRw1yAyKZt9CQH2+aPERB4ZTcQIZdTmWKmqz6uaQrzYmmaPuAS+h6q0RsyzFnqsXF1/VlkcB4ylCXWrNv0ATvVgNUGPyYglhSD2lBInkRJ7YAS74LiDbt+eQLwkz8mOmVw9E0vm8d0S6kYlIfm8rT78= 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
userfaultfd: fix races around pmd_trans_huge() check
|
expand
|
diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 290b2a0d84ac..acc56c75ba99 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -807,9 +807,10 @@ static __always_inline ssize_t mfill_atomic(struct userfaultfd_ctx *ctx, err = -EFAULT; break; } - - BUG_ON(pmd_none(*dst_pmd)); - BUG_ON(pmd_trans_huge(*dst_pmd)); + /* + * For shmem mappings, khugepaged is allowed to remove page + * tables under us; pte_offset_map_lock() will deal with that. + */ err = mfill_atomic_pte(dst_pmd, dst_vma, dst_addr, src_addr, flags, &folio);