Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5801052iob; Tue, 10 May 2022 04:07:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjEjtkIDmPasH2BKNn6EkL2k1gE/2XQbkdXCO73VSUQ44KOv3zpvNbWRFEjlZ37BUg4oVk X-Received: by 2002:a05:6638:3714:b0:32b:7ffa:bcde with SMTP id k20-20020a056638371400b0032b7ffabcdemr9883835jav.58.1652180876792; Tue, 10 May 2022 04:07:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652180876; cv=none; d=google.com; s=arc-20160816; b=LsU06RalOXtRxa7s7uV7T/TzxaNUnQGNFSNi1xLleZU8BmsfrFtNIEhUKaO074wVQo 88S5TNFZt0QycD/kKsZJO556wW89QTbEmEz4PcUiJ2A0pE+DEfJ5nphxpoGfayGzmIEH 19YH7r4r7wQMptMzwKZ/pmcnnu9pVSnU+DupgLWIrisJoggeoyUD74+xwvrK6PNe/VbZ +n+VGAqSYvTiF+peqJqpbwde7OrBVXJRd7EGSyUJmAKiN9nC8kXQhcEd3xC4I0VT8AcO WcRjTXVqslHPHT02K3usYZJy7tSPtGMZD2g7GOl+F/1EFvaTYCbSpCXBj8TGjpBKe/Cv N6ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=5UpTOEzEig6oOd0slseO1etKaFSjApv+QY6Ez4ZD8lw=; b=ASo+sfpDDU92wF6npVM3iQfIkPfQAabxiy89VJhkm6QHi9mhE/kouY+25wzM13tIOI Vb5Zapgusu81j+NFxwrI0PA6u+/tQ2AjIIK514uzWDe3BVO5jGPYslyYvf/ESzNwnVTP pe5DIuZlzzNFQjbiENT6+YxufAmZYt97AlddFJdlo/b4Cn6V3QquaFyCg09DTWbOuy0Q 5q5opUPWwoF1DIG5MLhUnY/OOXGUrAdQBMTahGkOt/Be9aFOTmLImx0qhqn7Gaa3rRPt +HPOe6zIhJ4phh9K9JpPmkt7p9OkSnHi/DMH6DjsMCVPNeRRLvUnHUv300D7R6UreLiE hL+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i10-20020a056e021b0a00b002cf3e43dd4asi12492154ilv.106.2022.05.10.04.07.43; Tue, 10 May 2022 04:07:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241645AbiEJHe6 (ORCPT + 99 others); Tue, 10 May 2022 03:34:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237654AbiEJHCF (ORCPT ); Tue, 10 May 2022 03:02:05 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 654F67485B for ; Mon, 9 May 2022 23:58:08 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Ky84M29fVzhZ3M; Tue, 10 May 2022 14:57:39 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 10 May 2022 14:58:05 +0800 Subject: Re: [PATCH v3 1/3] mm/swapfile: unuse_pte can map random data if swap read fails To: =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= CC: "akpm@linux-foundation.org" , "willy@infradead.org" , "vbabka@suse.cz" , "dhowells@redhat.com" , "neilb@suse.de" , "david@redhat.com" , "apopple@nvidia.com" , "surenb@google.com" , "minchan@kernel.org" , "peterx@redhat.com" , "sfr@canb.auug.org.au" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" References: <20220424091105.48374-1-linmiaohe@huawei.com> <20220424091105.48374-2-linmiaohe@huawei.com> <20220510061712.GA162496@hori.linux.bs1.fc.nec.co.jp> From: Miaohe Lin Message-ID: <2a95aebe-3a00-4699-12d4-fc5d934dde2c@huawei.com> Date: Tue, 10 May 2022 14:58:05 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20220510061712.GA162496@hori.linux.bs1.fc.nec.co.jp> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/5/10 14:17, HORIGUCHI NAOYA(堀口 直也) wrote: > On Sun, Apr 24, 2022 at 05:11:03PM +0800, 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. 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. >> >> Signed-off-by: Miaohe Lin >> Acked-by: David Hildenbrand > > When I reproduced the issue (generated read error with dm-dust), I saw > infinite loop in the while loop in shmem_unuse_inode() (and this happens > even with this patch). I confirmed that shmem_swapin_page() returns -EIO, > but shmem_unuse_swap_entries() does not return the error to the callers, > so the while loop in shmem_unuse_inode() seems not break. > Many thanks for your report! I didn't test the shmem case because I saw -EIO is returned. So I just focus on the normal page case. Sorry about it. :( > So maybe you need more code around shmem_unuse_inode() to handle the error? I will try to reproduce it and come up a fixup patch asap! And if you like, you can kindly solve this issue too. ;) Thanks a lot! > > Thanks, > Naoya Horiguchi >