From mboxrd@z Thu Jan 1 00:00:00 1970 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 3E136C433F5 for ; Mon, 4 Apr 2022 13:38:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 83E386B0072; Mon, 4 Apr 2022 09:38:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7EEA86B0073; Mon, 4 Apr 2022 09:38:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6902D8D0001; Mon, 4 Apr 2022 09:38:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 5C57F6B0072 for ; Mon, 4 Apr 2022 09:38:06 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2D0A8668 for ; Mon, 4 Apr 2022 13:37:56 +0000 (UTC) X-FDA: 79319299752.13.5CC9FDB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 9DA75C002A for ; Mon, 4 Apr 2022 13:37:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649079475; h=from:from: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; bh=jQvLoKlrABbqIctyIUROGClX4i0qGIlwv3fYjTBt7+Y=; b=DRlAkL/n+SvSyk9ognhuRhhackAMO50V3BJ5Hde71bAWPZCPS81Jes5cCddzis5BG/PoVD sDWefSNKnCL5e0ghNY2ECXD1dlrR8Hx8YPuzIo/snTSR25o8S6fpj+1OD+T+qyt3MTHf6l pvzakCc96ZR2x0K5LaQFP9orbU7wdZo= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-658-Mt6wR_r6Pgu3eIv18k6Vqw-1; Mon, 04 Apr 2022 09:37:39 -0400 X-MC-Unique: Mt6wR_r6Pgu3eIv18k6Vqw-1 Received: by mail-wm1-f71.google.com with SMTP id v191-20020a1cacc8000000b0038ce818d2efso3031817wme.1 for ; Mon, 04 Apr 2022 06:37:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=jQvLoKlrABbqIctyIUROGClX4i0qGIlwv3fYjTBt7+Y=; b=XRVTFDHJIeBbEK088XEAoQUblsyKMFktex5AROKOwvBxSZYJC5tHVdAH9ThGWJ6SFT 2YouY9kYYgf3y18XpYs8dMipdCiqFC1sHki/aCpdsTRihxXEjuFX1p7ETp/lEbTihe1W d1+KuDYElVcPw4hJcH0iFgaiK5uxgQcsAFM0xY/AXfjCxAHD3p/qKBg3LBsDb5AuhnSf QlvMyNTCOL6iZ5muFw9zAHk5HrzEeJJ1aeiSX+7Z8LSzuhMWKKJweYYcTE1qIRjaEaXr cM/XjDZgpzNgfrcJQ01Vo3dNIOqFVIIUTmDMEtcUTpADSHL6ZEAKL8Dq99wjRW+6+BBB 8xpA== X-Gm-Message-State: AOAM531/0L2m8pd3NEHoavBKSuR+cGaJf3q5Yb4+lu4KIg5xKs50iH7Q R4BfT56WOxb5jn6SzvIigtYtKkanp7oxxFtexcPO7Aifyp4YvZa9ZBf3T2pMrRiOW8c8JdGU1d6 uyFp4oUYFpJQ= X-Received: by 2002:adf:914f:0:b0:1ed:bb92:d0cc with SMTP id j73-20020adf914f000000b001edbb92d0ccmr17053058wrj.297.1649079458493; Mon, 04 Apr 2022 06:37:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1E8fYvOP0IaOzRyeEC7XVJ6g436XRj+7kMCuM/Z2olmC4aFghSJXcacegyMJ49gpuImGpyQ== X-Received: by 2002:adf:914f:0:b0:1ed:bb92:d0cc with SMTP id j73-20020adf914f000000b001edbb92d0ccmr17053037wrj.297.1649079458195; Mon, 04 Apr 2022 06:37:38 -0700 (PDT) Received: from ?IPV6:2003:cb:c704:4100:c220:ede7:17d4:6ff4? (p200300cbc7044100c220ede717d46ff4.dip0.t-ipconnect.de. [2003:cb:c704:4100:c220:ede7:17d4:6ff4]) by smtp.gmail.com with ESMTPSA id l4-20020a5d5604000000b0020615e8d2b4sm1907903wrv.47.2022.04.04.06.37.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Apr 2022 06:37:37 -0700 (PDT) Message-ID: Date: Mon, 4 Apr 2022 15:37:36 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Subject: Re: [PATCH] mm/swapfile: unuse_pte can map random data if swap read fails To: Miaohe Lin , akpm@linux-foundation.org, Matthew Wilcox Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20220401072926.45051-1-linmiaohe@huawei.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20220401072926.45051-1-linmiaohe@huawei.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Stat-Signature: nb5zcwhffo3yrm8g6hdnfuowj4mcihd4 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="DRlAkL/n"; spf=none (imf10.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 9DA75C002A X-HE-Tag: 1649079475-665785 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: On 01.04.22 09:29, Miaohe Lin wrote: > There is a bug in unuse_pte(): when swap page happens to be unreadable, > page filled with random data is mapped into user address space. The fix > is to check for PageUptodate and fail swapoff in case of error. > > Signed-off-by: Miaohe Lin > --- > mm/swapfile.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 63c61f8b2611..e72a35de7a0f 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -1795,6 +1795,10 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd, > ret = 0; > goto out; > } > + if (unlikely(!PageUptodate(page))) { > + ret = -EIO; > + goto out; > + } Yeah, we have the same handling in do_swap_page(), whereby we send a SIGBUS because we're dealing with an actual access. Interestingly, folio_test_uptodate() states: "Anonymous and CoW folios are always uptodate." @Willy, is that true or is the swapin case not documented there? -- Thanks, David / dhildenb