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 X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7002C433E2 for ; Wed, 2 Sep 2020 15:32:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 856F5207EA for ; Wed, 2 Sep 2020 15:32:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727024AbgIBPXY (ORCPT ); Wed, 2 Sep 2020 11:23:24 -0400 Received: from mx2.suse.de ([195.135.220.15]:41592 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727821AbgIBPWU (ORCPT ); Wed, 2 Sep 2020 11:22:20 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 44BA3AD4A; Wed, 2 Sep 2020 15:22:02 +0000 (UTC) Date: Wed, 02 Sep 2020 17:22:00 +0200 Message-ID: From: Takashi Iwai To: maz@kernel.org Cc: alsa-devel@alsa-project.org, dan.carpenter@oracle.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, o-takashi@sakamocchi.jp, perex@perex.cz, syzkaller-bugs@googlegroups.com, tiwai@suse.com, viro@zeniv.linux.org.uk Subject: Re: general protection fault in snd_ctl_release In-Reply-To: <000000000000c15ee205ae4f2531@google.com> References: <000000000000c15ee205ae4f2531@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Wed, 02 Sep 2020 08:57:22 +0200, syzbot wrote: > > Hello, > > syzbot found the following issue on: > > HEAD commit: b51594df Merge tag 'docs-5.9-3' of git://git.lwn.net/linux > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=172fea15900000 > kernel config: https://syzkaller.appspot.com/x/.config?x=3c5f6ce8d5b68299 > dashboard link: https://syzkaller.appspot.com/bug?extid=dd94e1d44f61c258d538 > compiler: gcc (GCC) 10.1.0-syz 20200507 > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=179811c1900000 > > The issue was bisected to: > > commit a9ed4a6560b8562b7e2e2bed9527e88001f7b682 > Author: Marc Zyngier > Date: Wed Aug 19 16:12:17 2020 +0000 > > epoll: Keep a reference on files added to the check list Luckily, this one could be easily reproduced locally, and I confirmed that the commit above indeed brought a regression. It seems that the same file gets closed twice after this patch, and KASAN caught the double-free. With the debug patch below, the syz reproducer hits occasionally the first check point; it indicates that we're calling get_file() to the file being deleted. Then fput() will be called again to this file, and it's deleted again in the end. Marc, Al, could you guys check this bug? Thanks! Takashi --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1995,9 +1995,13 @@ static int ep_loop_check_proc(void *priv, void *cookie, int call_nests) * during ep_insert(). */ if (list_empty(&epi->ffd.file->f_tfile_llink)) { + if (!file_count(epi->ffd.file)) { + pr_err("XXX file being deleted\n"); + } else { get_file(epi->ffd.file); list_add(&epi->ffd.file->f_tfile_llink, &tfile_check_list); + } } } } @@ -2205,6 +2209,8 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, error = -ELOOP; if (ep_loop_check(ep, tf.file) != 0) goto error_tgt_fput; + } else if (!file_count(tf.file)) { + pr_err("XXX file being deleted #2\n"); } else { get_file(tf.file); list_add(&tf.file->f_tfile_llink,