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 8EAA2C433EF for ; Tue, 19 Apr 2022 07:39:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 206178D0058; Tue, 19 Apr 2022 03:39:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 18F318D0047; Tue, 19 Apr 2022 03:39:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 008178D0058; Tue, 19 Apr 2022 03:39:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0195.hostedemail.com [216.40.44.195]) by kanga.kvack.org (Postfix) with ESMTP id DE94F8D0047 for ; Tue, 19 Apr 2022 03:39:40 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 6C17DA567B for ; Tue, 19 Apr 2022 07:39:40 +0000 (UTC) X-FDA: 79372828920.28.10B7DB7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id F3BA9140008 for ; Tue, 19 Apr 2022 07:39:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650353979; 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=XOpmuM2i+aI3NSsRRZHn/eWgehmHPwpUAsrONEKKMOs=; b=XRt5+yVdy0i9x4xVTwi6zlWd3kJLM6ZL41ccf0EJDEiwj1YUgqPc4n7lOVhBaT1UQ4k7RT r+F888NUOoVI/T5L2UMOISlTRbvZyR9jHLZoZQoGMAeiwIb9EhMMu54DhTqEOhDQ91sRME CNG64d8qqChjUsQvVBciBpTsED4YldM= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-396-ceQO8otWOHqOboBkImD5ow-1; Tue, 19 Apr 2022 03:39:38 -0400 X-MC-Unique: ceQO8otWOHqOboBkImD5ow-1 Received: by mail-wm1-f72.google.com with SMTP id i184-20020a1c3bc1000000b0038e4c5968b5so929264wma.0 for ; Tue, 19 Apr 2022 00:39:38 -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=XOpmuM2i+aI3NSsRRZHn/eWgehmHPwpUAsrONEKKMOs=; b=eYlFnnJCwI2Ox/sfkXHXVodHnztwpvS0nbLQ+55mIDez0kcOU65bB49wlqJMZDVN19 JHoLYzuqJCzNCYrq4+5xaSU9RU6Ww7ZF72rg3eBjxetwc0DyBoShaqAVlURhzX57wWXv 61nk7ISUbblY6ZjJnv21WT887T3N74wMiQXV5XtzJQQD3d3S7aAV8bqeaIdWViTGXCT/ o1qaK2NjavCwEpdS5Pmo+5YBRtVHNiUzyrxe0gH0umeEP44XsJhjaAVkHM7ghfoQ9McV eR0Tuzvx+QuZwvmriC2U0u2C1oHJX4wukx1euTa0++tUvCexhNU6BfwQXefiomgQUXwV CsAA== X-Gm-Message-State: AOAM533Amyx66+Boxz9HvdkPJayMbBcWeCROgGQTfqhe214SakGuRPDX BdALrGNyZIv0pkROhYf7pH2sMAivZW4zS62OZukgKDvTCdSaXBE1RAsK61FawI05LZUVaCYvCzz E/Y+Gh0452Ic= X-Received: by 2002:a5d:6da9:0:b0:20a:8d08:9977 with SMTP id u9-20020a5d6da9000000b0020a8d089977mr8724763wrs.24.1650353977123; Tue, 19 Apr 2022 00:39:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPnGJoHNCRvBkoifHOOljCQXSGLKIO7XF3Y29udTxBvINx0tU0Slt2gzNuLzPFknUJ1K6L2Q== X-Received: by 2002:a5d:6da9:0:b0:20a:8d08:9977 with SMTP id u9-20020a5d6da9000000b0020a8d089977mr8724729wrs.24.1650353976824; Tue, 19 Apr 2022 00:39:36 -0700 (PDT) Received: from ?IPV6:2003:cb:c704:5d00:d8c2:fbf6:a608:957a? (p200300cbc7045d00d8c2fbf6a608957a.dip0.t-ipconnect.de. [2003:cb:c704:5d00:d8c2:fbf6:a608:957a]) by smtp.gmail.com with ESMTPSA id n68-20020a1c2747000000b0038e6b4d5395sm16241144wmn.16.2022.04.19.00.39.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 Apr 2022 00:39:36 -0700 (PDT) Message-ID: <72cfde7a-61d7-980c-4653-94ae83eb4257@redhat.com> Date: Tue, 19 Apr 2022 09:39:35 +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 v2] mm/swapfile: unuse_pte can map random data if swap read fails To: Miaohe Lin , Alistair Popple Cc: akpm@linux-foundation.org, willy@infradead.org, vbabka@suse.cz, dhowells@redhat.com, neilb@suse.de, surenb@google.com, minchan@kernel.org, peterx@redhat.com, sfr@canb.auug.org.au, rcampbell@nvidia.com, naoya.horiguchi@nec.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20220416030549.60559-1-linmiaohe@huawei.com> <87tuapk9n7.fsf@nvdebian.thelocal> <5a78dd68-343d-ac57-a698-2cfead8ee366@huawei.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <5a78dd68-343d-ac57-a698-2cfead8ee366@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-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: F3BA9140008 X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XRt5+yVd; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf23.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com X-Stat-Signature: sbtrf1mf3r9mumpfdyo5bmj5noepn1az X-HE-Tag: 1650353978-639837 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 19.04.22 09:29, Miaohe Lin wrote: > On 2022/4/19 11:51, Alistair Popple wrote: >> Miaohe Lin writes: >> >>> 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. In case >>> of error, a special swap entry indicating swap read fails is set to the >>> page table. So the swapcache page can be freed and the user won't end up >>> with a permanently mounted swap because a sector is bad. And if the page >>> is accessed later, the user process will be killed so that corrupted data >>> is never consumed. On the other hand, if the page is never accessed, the >>> user won't even notice it. >> >> Hi Miaohe, >>> It seems we're not actually using the pfn that gets stored in the special swap >> entry here. Is my understanding correct? If so I think it would be better to use > > Yes, you're right. The pfn is not used now. What we need here is a special swap entry > to do the right things. I think we can change to store some debugging information instead > of pfn if needed in the future. > >> the new PTE markers Peter introduced[1] rather than adding another swap entry >> type. > > IIUC, we should not reuse that swap entry here. From definition: > > PTE markers > =========== > ... > PTE marker is a new type of swap entry that is ony applicable to file > backed memories like shmem and hugetlbfs. It's used to persist some > pte-level information even if the original present ptes in pgtable are > zapped. > > It's designed for file backed memories while swapin error entry is for anonymous > memories. And there has some differences in processing. So it's not a good idea > to reuse pte markers. Or am I miss something? I tend to agree. As raised in my other reply, maybe we can simply reuse hwpoison entries and update the documentation of them accordingly. -- Thanks, David / dhildenb