From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.54 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795985422; b=J5hGAf+V4eQR6IJBGztWNsPD6pzRiXo5NI5BZDb4Bk2r8iIrhsGCm6suFL/I2CH8Kkk0 /Bda2wA0GbPyWo0Kdy1ddLSGmpb1OUvGb+zwZqTrBn+k5Adl3xCvUNUHqXM4CytvVguJ+ wPhYGZPK9o88OOb+eS8PgIMJxUsWE7dkvRZvzVeg118EgbUplIu/H+2BHKtgySEPmYk8y qmvXYHzpqdbBeX0w2GKf76KxwxPnXIZlnKcUMSMDjV2zr0c0OV1ryhnLbSDxMKOI48XyR UXRH65CsqaPxLF6pxbBLBvA1zPLRnSNU0lP3qAA2XKsh9oSbU5RxEnGyh8/twWsdNQA== 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=5Ri/f2w5i6+R5H82QwFs6WsHRMoH2CjdlRLdWYg2UeKrLRk3FqI3psQMEXzJhAJzorbj TrW+t+bTKy4O3L2UyVXd2UHUOLPuZl/clitjOTQXdULX7Pv9Cd75/dfG6Bam7gf+kWxCb jztIEqGeD0RJ0Zls4onqxh15HlIkl5f1Ro7q96BTW54KvoeL/aJhq7GUj8QW7srzU0meO 21OUE99eZ/dj7ZPhunY/4WKcBG8IXG6fH3/kR4+FDdc3fbzbC7oTTO00kY9kq0Aebr8T8 ioDxJBLwBPAgdQU5VadxHNR+9XKmBDlWv9+lJ3UvIjjZUpgXqh1drdiMQXh3MW9J6IQ== 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.54 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 E9563606A325 for ; Sun, 29 Nov 2026 20:50:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E9563606A325 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-f54.google.com with SMTP id ffacd0b85a97d-4a357b1c649so5555943f8f.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=YnVtnD3ln2kIoayKzDoeqainMYmYgBFBSQCjO0UQrFO9cjAAH+3Au6geJvHtgjw4tx I5V2YvFQdlwooGsHcPnMFSxd+rL8cyOxuyuYS3uj8nN/GsFQs0gs7poPJbIa+vyIu6l3 5v4yAdHL6H4sdocuSCcFj7knLHqmwBDxREBdKuvL3rUoowoRd50slqGaepYmVN9kRF1b sH5ilwleK1rZkEDibSoOPtNVEjPC66ECaHCbIM8MkwCmTUczn7eGWwMgpB+05EEe6o97 oVM12qL4XjvrmSvSnRF+NlSMZk7Q3t8WGIDLbj3yw9mPmCSnChwN+NzUnv7COi8cZZV9 oDNA== X-Forwarded-Encrypted: i=1; AL+hErHuVyCJ0uwMxtZnJqm+5x65MSygKV4nA/G6p3QJAqwswqtj3uM++JaXiAwxRL1yEQZHCQo0jfhjM9/Capw=@vger.kernel.org X-Gm-Message-State: APuU4Z85l3S0SAPfxBWXtvZo38zoW0+cbKqZAMTGILfhwtr9TEl0u62A KVBqRWVYkWDQKWPc4vqFvnB5e2FqDxlsIMwjNh0fYI0Nhj8A7EfOO8et X-Gm-Gg: AZFdTZd9rzCLMrKIDfuWxtToKBOWAjXuOxnxoxJeEc80IuvvDgVp/y7G26OYap5cKhG iPsfDW8BD5zSruDWtkCPn4jU3P+9qWYvfUBITDmFLr/++yRFej5G0GjAzepMlvbSpEIrBPzSEyd lumAv3vgexKsgnneK4ZkRXMGvoukMEd1hOD4x1jRczXnJPaYeWs9qbQzCkmzsrGPKSrNQTauIay RBs1+w/bqf+ReHaJ9TRzEcpbiaqRi353UZ6wBfQ95SQLd9FV2db3pFhD4xSKONWxamwNVoJurjf RMOrGBcZSX/zkXdEFlpdPTsM9vkMn+0axazCVuCv+/qwLoFWYuMb7UeMhd5+KFYcMqITt29T5dD 744Uq1YcSL5DGadCDFFKx0a6E0oPexDg+SVa1Q12gTSBUA0LyXtKdFFD9P8u29LJMT+hJlHdUcA C2gJqrGJs5BiefFMPj909tJDCMxT5X28Mo2IU8hodjdIEbYVRpARifSXAtwI5g0Dig9xx2T/Z7z lzqgxRAm5zM6z+6XksNJRdfAqaoeWk/8j7w19Fm0CJrTHhVGngdywiovqaFEqHVWyUA9D3sbUa/ 3ODK+eNGnAyJBdz5JcEu9/3j 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: linux-kernel@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