Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4025181imw; Thu, 7 Jul 2022 11:22:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tCQitVwsuGKY9otR9GVroFDfZrVunIQDTRBgWXhaT8b8yk/MgY9Q4xdlSvKa19vlXAg9Px X-Received: by 2002:a05:6a00:2407:b0:528:5bbc:aa0d with SMTP id z7-20020a056a00240700b005285bbcaa0dmr26897349pfh.40.1657218142705; Thu, 07 Jul 2022 11:22:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657218142; cv=none; d=google.com; s=arc-20160816; b=FY3PBeXdvzdR31L/5gtYqnNuvs5VcBCspLMPNJ+u1mz+cMLfYKqsxiRSm6BkunqZqR +rNxjvCm5qpL4mMapZqBEMZLr8KOQ/OGluJQNbCbLWim8spglKDX9dT9B5tJmNbA3x9X ZlGewNFReXcYLnHF1oY0gjqTgKYVotqNeWhFLIIqrQYtHtg58I+RrC6gs9oF8Y8YhD4Q 3943fXZ+zgoVM3nHnhGQNNzs1NhLPPRDuQfWZVxyXN3qT5qCC7lSDgWj/eTCBkE4QX5l Yk0x7nAgZh0i9w3A9eQvBNJXibdsBHwUVqINQSo/ySDFakh9o+fhkxmj5RCQnyTj9jqf X+vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=7o6mNBZ85nAUFmywrjMn8kqNBLc5THwMJH5HxcZz3kM=; b=UtATlsj29OOCFphSCov1LGRHJM63qJT9OuYrTeArXCMBrRotNFWszG/SoVJRDQ1Ahm OeFFOxQLvV8MefDyKgI2dwLJv21C8wbO/Iv9ZxC9iMAFKhgjGGCCdGTM2tEAP3g2hBok GEw06tzQVkozdlJwIFEsx4kTuLupZQ99qFmavhu/KMvLo8gvX779hXNB8figRJ+Of7oP VVN9Ym2hqO7pwmVOcI1rnbLcgIXqJARIH+EuiqH7OdiATyig3S0OSUoL/DmmmaWcBwYI D2WsNKFX18j4qvaL94TAB0F1KJ7YkKfsQ48qv7CzCbAPIWdLTSuz/lzKtx9yTZiR5S/f /Gpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2A5xUmgM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j6-20020a63fc06000000b004128ea1a97dsi10268662pgi.399.2022.07.07.11.22.08; Thu, 07 Jul 2022 11:22:22 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2A5xUmgM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236053AbiGGSEM (ORCPT + 99 others); Thu, 7 Jul 2022 14:04:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236048AbiGGSEK (ORCPT ); Thu, 7 Jul 2022 14:04:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A59CF13F42; Thu, 7 Jul 2022 11:04:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 67487B82299; Thu, 7 Jul 2022 18:04:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB409C3411E; Thu, 7 Jul 2022 18:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657217047; bh=SGueRWIyzVyPJjQ6UwiSli1wQJuF/A3j5F+SxexRI4M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=2A5xUmgMvNbXPxl0c/R7AwoUOgkkfPPoho0gVa7Al9D4+G4UxVZ5/2GaxeK2Nu180 KsO0n28XxX7SeLQoxzWNZZUdolFCkDjEusGD0JasBw9Bh2c7UMe//TBl2oVGuIP/iy qPRtKS17zKmhXLOdy7QwHCSF1pSAyPDZUbffqPKY= Date: Thu, 7 Jul 2022 20:04:04 +0200 From: Greg Kroah-Hartman To: Matthew Wilcox Cc: Liu Shixin , Andrew Morton , Jan Kara , William Kucharski , Christoph Hellwig , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH 5.15 v4] mm/filemap: fix UAF in find_lock_entries Message-ID: References: <20220707020938.2122198-1-liushixin2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Thu, Jul 07, 2022 at 04:09:29AM +0100, Matthew Wilcox wrote: > On Thu, Jul 07, 2022 at 10:09:38AM +0800, Liu Shixin wrote: > > Release refcount after xas_set to fix UAF which may cause panic like this: > > > > page:ffffea000491fa40 refcount:1 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x1247e9 > > head:ffffea000491fa00 order:3 compound_mapcount:0 compound_pincount:0 > > memcg:ffff888104f91091 > > flags: 0x2fffff80010200(slab|head|node=0|zone=2|lastcpupid=0x1fffff) > > ... > > page dumped because: VM_BUG_ON_PAGE(PageTail(page)) > > ------------[ cut here ]------------ > > kernel BUG at include/linux/page-flags.h:632! > > invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN > > CPU: 1 PID: 7642 Comm: sh Not tainted 5.15.51-dirty #26 > > ... > > Call Trace: > > > > __invalidate_mapping_pages+0xe7/0x540 > > drop_pagecache_sb+0x159/0x320 > > iterate_supers+0x120/0x240 > > drop_caches_sysctl_handler+0xaa/0xe0 > > proc_sys_call_handler+0x2b4/0x480 > > new_sync_write+0x3d6/0x5c0 > > vfs_write+0x446/0x7a0 > > ksys_write+0x105/0x210 > > do_syscall_64+0x35/0x80 > > entry_SYSCALL_64_after_hwframe+0x44/0xae > > RIP: 0033:0x7f52b5733130 > > ... > > > > This problem has been fixed on mainline by patch 6b24ca4a1a8d ("mm: Use > > multi-index entries in the page cache") since it deletes the related code. > > > > Fixes: 5c211ba29deb ("mm: add and use find_lock_entries") > > Signed-off-by: Liu Shixin > > Acked-by: Matthew Wilcox (Oracle) Now queued up, thanks. greg k-h