From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76F713BF68D for ; Tue, 18 Aug 2026 09:08:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787044096; cv=none; b=qRm6MUDD3KYt6eM6o77OT7O7Mql10pDnM0BKQnjLY8S/a7qH/t1emlPZUI1T1529c9S0/rkrZEaPawj0P5/j+59198XRbzmeurAlc7q1D7agUovEpCSbYdjyBY+hMo5+sRaxAsfsTm3afWlNYIqDvdGSnEes/HU4oZvyT029pS0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787044096; c=relaxed/simple; bh=gPYh50i/Cwvm1cCcuqRrbhZHsHe0xF51YbcdkDGRDL0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Z7zxwH2vFcdBPZLlVydMUCAo+ofyhwy/uPm3PyNIxwBmLdUMdRvKtO9Y1z5i3brk6eNkP5WXEkgbqyKmlRqUKsDF0GMFh4o41emdYAEHcMo2gEGdkEk+pIDM94vvzEaAvkOA5cOze7FHKA+MjZdCA1xBI9YbGk8PeZdglbPbJH8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MCkC3mv+; arc=none smtp.client-ip=209.85.215.179 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.b="MCkC3mv+" Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-cbe6295f05bso555066a12.1 for ; Tue, 18 Aug 2026 02:08:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787044095; x=1787648895; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=eH2+LAOZDihNr0Vw33UUIwKMjBqap0RbvpO51o4UzTc=; b=MCkC3mv+lMHJeeDmoaUV88Cuj7H6dzyWW0fgkDpHcshq0l1Ga/WnjGAn0Sr6EaC9pk TzLhmaO1TIzg9VX4wgdZuQk6mnXCHhRd2KueNJALiCOlzTHpopAOkhqFX6LnxW2d/bZo 2jTBD5mK7zgBoviCyVxvI7j1vM8dPjQFXcxpvL+i3SPfUGWakYUzyWWdR75FDDesZN3t yRdPZ1vaV4KD7DC5nT4D6kGBHuKaUhPO5qmPw5nzkyVKg16CNfK0mXZplO5pICBszFbT UjjjhJto+0IOu+ddrmiXS1dQe19G8uSHuj41ZehzDbbE7JpisQIW8AVfqKYKg7GVkwnz zmBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787044095; x=1787648895; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=eH2+LAOZDihNr0Vw33UUIwKMjBqap0RbvpO51o4UzTc=; b=BTWyqib/byioiX/9QrIaI9WrlI6k4hIl8kFa+0O3/A1pWA3wI7yezWEqMJjWXta9Q7 ZQVdbIMgql/tPMGR6A3FOio6rFY1OBVMegjUVYVZEu5lsmGhUyEnafYojZYOaL63swRu /c7OTE+XyNmha2ObtoTiOyD06nG+ngmQwEBc7r3XL2ybdTSDVVLE5Tuz/J/gMqivI/qa +6JeCT2OXerGHdA15bLf6IBxrPIConmr1mEz2KbwjXM0T3DelvH73yIjW5hPyU0Ti8Hp XCJnUxNJ8x/YrJnQ+dklB1KJ22K5aYomUwOFuFuCkMc9s79+yCBLrcWaGZmKMFJ9xe2F Fr5w== X-Forwarded-Encrypted: i=1; AHgh+RoT1erC8AWmNodQUDtRrsSSNMUxeB/x+Au3o2zG5Qplj+ddQ/J7TWfNP7oWPewHN02AAcpcN8una83zZBI=@vger.kernel.org X-Gm-Message-State: AOJu0YzU0AL1cbMkcy7gRgUkrRrG+jyaf9nupaXcpYGc3NATl3rOMmXx cwZn7+vbySz5Y9j9st41KJijDV5/4Jd7ZjtFJTdC7Bm5cOenM2iEHql1 X-Gm-Gg: AR+sD13/y7XfoHRAeTyKZfeH2fBt8XH2dmi/oepaGGq28s+y7nQ/0uBEdZH6CDsDElo rIUzBt+bi8P9na05EvZXeh7zR07wkKS11YppcGBFvXy2MqY9WrlKvQ+QZXbTV3rRPap2O4F1pUB +qxIRLahq/LLIOrn6MgyG2AtanRsmgh/xiXsJ+MRL+yYRHeXMnT+Uy3BGBTn1LLC7D9y5qqFart C/3i7PnEefmrel32DOTqLMrpGl6nY+Aw3GrZBJoyNzaEvVg1sWfr76929G7+V8P71WXGguuCVUf zKqa2F3Ls6hp99dfWmS0WwJAt1MO8iXnHGo4w3seHcStAXG1BBiSEIpBiKKgwXn5et6exn7wJ3S fA83G1ZXqXecJeeqqMH1I56/YenIZEvIrRfvdDMyYzY6cAhWlDEbzFkFyD5emaCrO7XumWiqnoW yBgw7mWxjqEje21/ZezGRUTYpiHyozxTmD+MkBlbgXCo9wugV7aOE9v/MmGjPaPu4QdayKDju70 slbrHl2xb8VfmDGIEVa1jQ+cbdn6VZKRJw= X-Received: by 2002:a17:90b:3e87:b0:38e:7f22:f674 with SMTP id 98e67ed59e1d1-395638e58abmr3372749a91.11.1787044094652; Tue, 18 Aug 2026 02:08:14 -0700 (PDT) Received: from KASONG-MC4 ([43.132.141.21]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39531fba7e8sm7803783a91.11.2026.08.18.02.08.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2026 02:08:14 -0700 (PDT) Date: Tue, 18 Aug 2026 17:08:06 +0800 From: Kairui Song To: Breno Leitao Cc: Andrew Morton , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , Youngjun Park , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jann Horn , Pedro Falcato , Hugh Dickins , Baolin Wang , Peter Xu , Johannes Weiner , Yosry Ahmed , Chengming Zhou , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH v2 2/3] mm, swap: distinguish a malformed swap entry from a dying device Message-ID: References: <20260813-swap-v2-0-4a625ccabdae@debian.org> <20260813-swap-v2-2-4a625ccabdae@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260813-swap-v2-2-4a625ccabdae@debian.org> On Thu, Aug 13, 2026 at 03:02:21AM +0800, Breno Leitao wrote: > get_swap_device() returns NULL for two different things: an entry whose > type names no swap device or whose offset is past the end of one, and a > device that swapoff is taking away. The first never becomes valid, the > second does, and callers cannot tell them apart. > > Return ERR_PTR(-EIO) for the two malformed cases and keep NULL for > swapoff. copy_nonpresent_pte() already reports -EIO for the same > corruption on the fork path. > > Callers bail out on failure either way, so switch them to > IS_ERR_OR_NULL() and clear si where the cleanup path would otherwise > put an ERR_PTR. No functional change. > > Signed-off-by: Breno Leitao > --- > mm/memory.c | 6 ++++-- > mm/mincore.c | 2 +- > mm/shmem.c | 2 +- > mm/swap_state.c | 4 ++-- > mm/swapfile.c | 14 +++++++++----- > mm/userfaultfd.c | 3 ++- > mm/zswap.c | 2 +- > 7 files changed, 20 insertions(+), 13 deletions(-) > Looks good, thanks! Acked-by: Kairui Song