From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795985422; b=Sc6mQfcFh/g019SVMIdD+Y5gJrV+uc1ljpeECLnLmvetGNiiGrjnUzU5wISGqaaoCTX/ Q7q7HZHO06bNhoi0s51gclM/O9QoRcBmOW3hfIQ/YShXZisoYBbZ9rZ0NWsuEDacjkP8A o3UBQCY0fUF6InRGrtGs6S6JeprDeqAbL8bSy1Pc4r/+rhS+igw/Bq7oiHeuxA8PcPQBZ VM7ZM3xFDinOvPmtaaMXStTVtDyMS8exANf0dTFggp7hw0I9jGW5EvrQgRquV6nVPAQJz M/wBevRETM/QqMG83qQp35HOi/5Fpkf2M6/26iHyv35LmwuYoy/ENwlRmoIleBOwDBQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795985422; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=rIVFcBVWHzmBKjJmlHw4Xft9KMriatAB3nThKox5rgQ=; b=LrkuZ62v8qBx3QWVX00ooh7waQad8nwJ28CJs8oGfzbcbS2uGiPdYKhU8wdgad6cdFnt J0MznIDfHLUSASwwm4IrwbeFLexxXTW8xfdvvi3vqTKakboONK3Z/qwEQpBUHytaR7oWU hxl9Jq5ghyoGJIkwwx/3phzqt93rq1/o0h9PjZREl4C1iUmsKPJcycPINQSBu81cCDJvx XySodOBjqQT3wr6W24sE0FKx2S25MuIrKF8Z33yfQpLjB7wFJvagoHdq7DPSAFnNoTPBI btBVNTopK3yVbGULAiTu707VcmRrK15V1O5wHJEt6OD6l4BQAymTiM0u9E9/PdsAqcQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=uJ9+3eRX; arc=none smtp.remote-ip=209.85.221.48 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0013F606A32A for ; Sun, 29 Nov 2026 20:50:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0013F606A32A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=uJ9+3eRX Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-4a357b1c649so5555926f8f.3 for ; Sun, 29 Nov 2026 12:50:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795985420; x=1796590220; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=rIVFcBVWHzmBKjJmlHw4Xft9KMriatAB3nThKox5rgQ=; b=uJ9+3eRXt4kl9TZanm5Wo8mxHJ3jaFKyxZAlJukZDjxzeMyeJL0h7AI/4kZ4Ku2K3M ezAarllmhoKtsskwzQuSrX6zgEKYGHPb34dREdL1RfoDWJOnhwoyM4oEDSgSIpna2R2Y JVCGxgbJTp1xyhWWl10D17xYVDXYL30xL4+BrhoLBLHbpQfa/lhOvN+SFYsYEY+PgLZI W2EwrkIs9NM3c9hvrrg7aMsBBgqoyOYVWwybo/ObalhW2p+dfgASVB5b2fP7wd+bQIG7 woDSryaYPxzRws91qPd6ACrDcK5dc1fcDC980BEhhX66F68vDHXqtI81MaElUH8UCXzd jiZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795985420; x=1796590220; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=rIVFcBVWHzmBKjJmlHw4Xft9KMriatAB3nThKox5rgQ=; b=MqyZmumZPL87DkjC6tnBBIvJg+KIo7hwbPGcfN3LBNw78LSie+D8dJ2vnURu4NUKul X+j6m9vpnHTYuSGExO8iEsDQgjbtAeR864A5fOCGyNBBKrywIzrs2mkZaeC42ikly11m qo1UWDVPLQ4p5QJfEQbmfSDxO7u09yw+pDPN5p93556LPcAAEojYqvZw7nSc+1E2GHZy mEz9dQgvJTvQz9sH0GDl0X6AJdfn0t+q/FvBbqrueErUEsbGdCOovK9btFXSjzNev2oi lWKiAsuxkAWMWjbHRFHgqDmPDNHq2VlotWM0P1iarVBNl9O1juFTQuvyZo6KeSFJOyWe VUrw== X-Forwarded-Encrypted: i=1; AL+hErFObx5JbrN5u8ELZV8GIN8kHSUutQ7ney8ox5dkXDUiwRIDkbfgjBqji4g9LFc8YiFex1FUiV8=@vger.kernel.org X-Gm-Message-State: APuU4Z+bVa8FJ5z/hPExBf6qVP1VfHaFj0ogFVhPdZCv3AdL4guq1uKK h6kr3dzKwVGTe4zqDkJAu54/LmzqbEB1npCNJBpnUEXg46qzytOulhM7 X-Gm-Gg: AZFdTZeF1t8sfwU5WFrPBj/sId1jXKdjzZd2ySDT1T/EsxS4OsCNOOusG4Ei8Bppgc8 LEEI5KfdY43S95YCOsXvLIG6fRGK5V8gYsIb5y4jH3oHpYOqkwR67DsOiUEdL6dq1Mrti/3EOi2 Ey8PEHt1iAUR9AWRxx0ndZcpBptTZu/j/nM12gOwaFB7GoyHDAKT24wT7ju6e9At6LObRdFv1cp z21yqKzniGgQNZ6EoG+WUBPjgICqTcCOvf8AEAHPywt2YMxAEbfn9Fcy+Hlsm9rjz8Ds9xZZrJ6 nor10NdToSOCsuX7YF7/L2fTlmTbiRzwuofMle3e4kxKBMv5/O1asYuRM2oBfbhni7fRW7Sikvs GEaaWw86rsAwWpwbKra0x7OYB9Qt481NQCCKmxwVlP89jav3GPvMCoqpuBc+YpuqA/jQKfwzgRQ ZkJxLIz9dp1u+YTcKuETLeolVg0FBE/ZYqpWg5v7yu1FuvGx3f8GC2GCK6ulPUnW42QNw3iB4cY iA8VuJCB/EIQv5xn90oBt9INlHR/IQGJMohiLXVWVo7ZpLlOa54pZQvRJFs9ew5J86LyBzdVDcO 2fpRfyUj0o1FRfR+CcerS8IX X-Received: by 2002:a5d:5e02:0:b0:493:1004:96f7 with SMTP id ffacd0b85a97d-4abb4c7aa66mr50775423f8f.54.1795985420122; Sun, 29 Nov 2026 12:50:20 -0800 (PST) Received: from [192.168.1.22] ([83.231.69.9]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6a67fe48sm55034956f8f.23.2026.11.29.12.50.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 Nov 2026 12:50:18 -0800 (PST) Message-ID: <766c753b-0fe1-4bb6-81c3-0601e59177ea@gmail.com> Date: Sun, 29 Nov 2026 21:50:14 +0100 X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 17/32] mm/memory: drop the swap device ref before do_wp_page() To: "David Hildenbrand (Arm)" , Hugh Dickins , Baolin Wang , Andrew Morton , Mike Rapoport , Peter Xu , Michal Hocko , Kiryl Shutsemau , Manfred Spraul , Davidlohr Bueso , Cyrill Gorcunov , Zi Yan , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Lorenzo Stoakes , Rik van Riel , Vlastimil Babka , Harry Yoo , Jann Horn , Yang Shi , Zach O'Keefe , Song Liu , David Stevens , Kefeng Wang , Alex Williamson , Suren Baghdasaryan , Dave Jiang , Matthew Wilcox , Miaohe Lin , David Rientjes , Shakeel Butt , Jan Kara , Mel Gorman , Jason Gunthorpe , John Hubbard , Gerd Hoffmann , Vivek Kasireddy , Dave Airlie , Matthew Brost , Joshua Hahn , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Hagen Paul Pfeifer , James Bottomley , Felix Kuehling , Alex Sierra , Balbir Singh , Kairui Song , Qi Zheng , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Oscar Salvador , Muchun Song , Dan Williams , Rakie Kim , Hao Li , Christoph Lameter , Roman Gushchin , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt , Alexei Starovoitov , Xu Xin , Chengming Zhou , Shivank Garg Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cxl@vger.kernel.org, linux-rt-devel@lists.linux.dev, SJ Park , Chris Mason , stable@vger.kernel.org References: <20261129-fixes_core_3-v1-0-f66094116801@kernel.org> <20261129-fixes_core_3-v1-17-f66094116801@kernel.org> Content-Language: en-US From: "Jose A. Perez de Azpillaga" In-Reply-To: <20261129-fixes_core_3-v1-17-f66094116801@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 11/29/26 11:06 AM, David Hildenbrand (Arm) wrote: > From: Chris Mason > > swapoff kills si->users and waits for the last put_swap_device() with > wait_for_completion(). do_swap_page() currently holds its reference to the > swap device until it returns to the caller. If it ends up calling into > do_wp_page() and triggers uffd-wp, we will sleep in handle_userfault() > until the user space handler has processed the event and woken up the > thread: > > do_swap_page() swapoff > ============== ======= > get_swap_device() > set_ptes() > folio_unlock() > do_wp_page() > handle_userfault() > schedule() > try_to_unuse() returns 0 > percpu_ref_kill(&p->users) > wait_for_completion(&p->comp) > put_swap_device() > > Consequently, swapoff hangs until the user space handler resolves the > fault. > > Let's fix it by dropping the swap device reference before calling > do_wp_page(). > > This has medium urgency, as an unprivileged process can make swapoff hang > for as long as it likes, using a UFFD_USER_MODE_ONLY userfaultfd. > > Fixes: 2799e77529c2 ("swap: fix do_swap_page() race with swapoff") > Cc: stable@vger.kernel.org > Signed-off-by: Chris Mason > [ david: minor code cleanups, adjust comment and description ] > Signed-off-by: David Hildenbrand (Arm) LGTM: Reviewed-by: Jose A. Perez de Azpillaga -- cheers, jose a. p-a