Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp130767rwb; Thu, 17 Nov 2022 22:06:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf6+4XX/6r3xHhudbqA6x1iPtlTwKxcaKOFOrkWle8ZCnHHyvELhn6jIfdj/AYEjOajOGvZa X-Received: by 2002:a05:6a00:21c2:b0:56b:bba4:650a with SMTP id t2-20020a056a0021c200b0056bbba4650amr6560415pfj.4.1668751573714; Thu, 17 Nov 2022 22:06:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668751573; cv=none; d=google.com; s=arc-20160816; b=DgOIRYgYSgCv42L0mvFFJDBicl/A7SmojGJvkq5jwpUVt9hmv0uqFeWyHBrwYV7HMC CFuylH4OMgY3L9YcRYdy+GpUsb2Bg/sFB49nyHFDxjpTehV1yvzbxNAcZZ6KQunt2UKu qpymSwXsXtYhHvTcpsrfjWjlucFlOr5oCCQl8FrYBlxy30fMvvi3xLGMwplXld20gsGe 60ftwPKDfO3jI/lAtQCRC1pDtI/oCDwbc9gzXfAI/h4Lvb6h2PoUCEuFzy0yZzGw6DZC Lk/NxZ995vaKpGALhck8l0A+drfEoIdReKIx8AcWj5vLt71bhFkY03Fd1eHPac9jJ6Gp zyFQ== 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=tnEO6E1grr6Gr3aJvdASXdNYwfa3vFiu4Cif/7kHt0o=; b=Bo217b8Uw0oo5TbdaELNapt86IElaoi5kQUHPdEFY5tTyFuUiJ0oy8ApG6XJBMcMRL aDqJbxx2UU9E+Q41d5e1JOzZg7Oe3E3UcbMzihTRNZgI1QiK2hqHzNffDxxz1ms4FtfR kWOwJaQdMb/Jo7qfF/Dz5jC/RLd9pSaWGeozzmq2TTXk+y57Tc+3Y8nf9gPBvKyp8xfl OoN3c8cYwVx3urTmn80xLRyPAoRERlrjV2Z0GcjnIjMWk7eXVzAsT64yiCTk9R9qVJ9r dlGtCZeOKSRO5Duf3p+LFEajsPjuhdA/YSC9K/mIZtC1j0Dg9p1Rl7mhudauOINIRzgr my2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=hAXwshqp; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v135-20020a63618d000000b0047008fd7bc4si2936528pgb.413.2022.11.17.22.06.02; Thu, 17 Nov 2022 22:06:13 -0800 (PST) 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=@infradead.org header.s=casper.20170209 header.b=hAXwshqp; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240901AbiKRFab (ORCPT + 90 others); Fri, 18 Nov 2022 00:30:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230004AbiKRFa3 (ORCPT ); Fri, 18 Nov 2022 00:30:29 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7BBF8F3DB; Thu, 17 Nov 2022 21:30:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=tnEO6E1grr6Gr3aJvdASXdNYwfa3vFiu4Cif/7kHt0o=; b=hAXwshqplXRMcXB4Z6fOP1HiPs BT9RjODtqGH3KfgrOf8sLezL1o2s6p15OuZBZgjTca13ohdU9Kj3I9hPfC1XBXCiYTjzchenK5vHU tsLair41qG+krZuXb5RATFOZt0stL42n0ZTVfY++JNWrNtVCYX9OdIfXfXxIbgqUZcdY120BpRJrb XOlJrkq5HWbVjpFzoiYNRvejjAM6hrOFMIjmCd52hrkzBarSajLx65XpC899CIqDqWo0uk69Fti9O eNJUmL84wwKOX/tepHCWMpEGtADQ7KTYjUVSVHKSiLtAds//QSE5KMPvfabP7kq7z9tvfQN6legdU ZSXkXhBg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovtxP-001q6a-HB; Fri, 18 Nov 2022 05:30:31 +0000 Date: Fri, 18 Nov 2022 05:30:31 +0000 From: Matthew Wilcox To: Liu Shixin Cc: Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] fs/buffer: fix a NULL pointer dereference in drop_buffers() Message-ID: References: <20221109095018.4108726-1-liushixin2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221109095018.4108726-1-liushixin2@huawei.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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 Wed, Nov 09, 2022 at 05:50:18PM +0800, Liu Shixin wrote: > syzbot found a null-ptr-deref by KASAN: > > BUG: KASAN: null-ptr-deref in instrument_atomic_read include/linux/instrumented.h:71 [inline] > BUG: KASAN: null-ptr-deref in atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline] > BUG: KASAN: null-ptr-deref in buffer_busy fs/buffer.c:2856 [inline] > BUG: KASAN: null-ptr-deref in drop_buffers+0x61/0x2f0 fs/buffer.c:2868 > Read of size 4 at addr 0000000000000060 by task syz-executor.5/24786 > > CPU: 0 PID: 24786 Comm: syz-executor.5 Not tainted 6.0.0-syzkaller-09589-g55be6084c8e0 #0 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022 > Call Trace: > > __dump_stack lib/dump_stack.c:88 [inline] > dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106 > print_report+0xf1/0x220 mm/kasan/report.c:436 > kasan_report+0xfb/0x130 mm/kasan/report.c:495 > kasan_check_range+0x2a7/0x2e0 mm/kasan/generic.c:189 > instrument_atomic_read include/linux/instrumented.h:71 [inline] > atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline] > buffer_busy fs/buffer.c:2856 [inline] > drop_buffers+0x61/0x2f0 fs/buffer.c:2868 > try_to_free_buffers+0x2b1/0x640 fs/buffer.c:2898 > [...] > > We use folio_has_private() to decide whether call filemap_release_folio(), > which may call try_to_free_buffers() then. folio_has_private() return true > for both PG_private and PG_private_2. We should only call try_to_free_buffers() > for case PG_private. So we should recheck PG_private in try_to_free_buffers(). > > Reported-by: syzbot+fbdb4ec578ebdcfb9ed2@syzkaller.appspotmail.com > Fixes: 266cf658efcf ("FS-Cache: Recruit a page flags for cache management") but this can only happen for a filesystem which uses both bufferheads and PG_private_2. afaik there aren't any of those in the tree. so this bug can't actually happen. if you have your own filesystem that does, you need to submit it.