Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp653683lqe; Sat, 6 Apr 2024 19:05:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWnpKQIAQkmkbXufE+4yA5wvC6+MGvmbqDWbIu5ripcPXZz2JeHhkL8QAI7FrDMZvRn00GGW0zPJoDg1HhNwQs5Hl6qiofzEHfE0lMn8w== X-Google-Smtp-Source: AGHT+IELsesThlMyZn6GoNjveeL0NrzLi1bh4lNKfo+K1lfe97tHF1LtY2U8/4cAcoaX9ah9nA8W X-Received: by 2002:a05:6870:ec8e:b0:22a:6cbb:be5b with SMTP id eo14-20020a056870ec8e00b0022a6cbbbe5bmr5835008oab.43.1712455532027; Sat, 06 Apr 2024 19:05:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712455532; cv=pass; d=google.com; s=arc-20160816; b=obAOo5WfP6U3i0h8VqT02/KGTXLykLVZoIOjBocZHh6Jya4BfjgLoj13etb7zdC4Cn QnyHustj4XiadpmM3gxgxXhqGsmZrcOBb2yY96WrKtnCb6CI9faCG1dB0J2id8c3RBkO SI99V1IF0/EVreTZgzrTOvu7dOk+PdhZrXlGIuePsHgBpUPrX8CPeVheXA1nmB9MNbp/ o98GuBTx+Bb69mmvDsh9v8JjElmdjKwne/uRJZdShj2ZVv3+8MdV3laCvQyp0kaVaqFG fYCkHEvwnZh+mwmDTMPNs2yB4k0xdawHi9cd4LACSK7vG6i2u+m83rkoall6aNNrlnEE hxCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:date:message-id:from :references:cc:to:subject; bh=pL2zpixevP49m+peDqkdQt9pYHhY9RtZNqmB55x9q5s=; fh=1lGJqjbu60dDj7L5SWjZegHp3glUM6H7ybexcBIJREQ=; b=Ywj37gm/hz50F2/pa3OHXi+u7wrvJ4IhROe6ItnQL9JVKGYRQy2VcJZ8SogRH4EZEe cYPTzMCtfQYc2oRiDaD2++Qvi2kCnNqMDznKE2rPjEt0aztFxAJJ5cgZIDvekpJAJ/vi KePROnGQ42TldTGNxnWoW7BVz6lWQ1+eLhasv+idjjU+DbEAWs0pR5lJTvjn1y/Rl6uE vobuiBA5Lo2RgAERadrm5Kl7dIW7nDQYlsLLhvH4BGSdOC4qB/v6AU/TCH3wW1o4jQ94 6OeUVC3t71Fs1Dl4oDeIbwUDEQvNgsJ/PY6gUl0IzCw9M+fKaeGwcfAGz3+80c6XTSto EyFA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-134128-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134128-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id f25-20020a05620a20d900b0078bc201504csi5333363qka.774.2024.04.06.19.05.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Apr 2024 19:05:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134128-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-134128-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134128-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id BC6BB1C20AE5 for ; Sun, 7 Apr 2024 02:05:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F0191876; Sun, 7 Apr 2024 02:05:23 +0000 (UTC) Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D678B8494; Sun, 7 Apr 2024 02:05:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712455522; cv=none; b=sUH696LyMaykKqrLmmcRx1lcpmXvClv5RAebhkzsBCWymkONkyJCJEM5yWAHOf3z1HrCk+XVv5B2ELGndcOCgBo5fGVimP+SDJR3g82tQgXj+sBeJxVXYrgPZdqor5eas66OI5YMVALEjZ8WQOq3HgCBKx8qRh5jt2hWo6uEiEE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712455522; c=relaxed/simple; bh=q7avWxTZ18Mq6nKKz2xrkTtQwuh0fsXGBm/jnjmYUEk=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=mMbbwQgu7LNH11TeDXASXsHzSzGQJf+JsKIHbLNFnwccNFuHobZS1ZRlikB09NLZYyDYz0NQFSccZwMyBkpOMLJVRa0cyVfWfcSXXBhL8LpBGEawdqe9A0jl2Q8+Efl1rFhwTI6iKR0JrsQNnurkEei49pnfkCZ4XBr7og8OaMo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VBwXg5B76z4f3m73; Sun, 7 Apr 2024 10:05:07 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.75]) by mail.maildlp.com (Postfix) with ESMTP id 3C56E1A0176; Sun, 7 Apr 2024 10:05:16 +0800 (CST) Received: from [10.174.178.129] (unknown [10.174.178.129]) by APP2 (Coremail) with SMTP id Syh0CgCXBQlY_xFmjWn_JQ--.19215S2; Sun, 07 Apr 2024 10:05:14 +0800 (CST) Subject: Re: [syzbot] [nilfs?] KASAN: slab-out-of-bounds Read in wb_writeback To: Jan Kara , Christian Brauner Cc: gregkh@linuxfoundation.org, konishi.ryusuke@gmail.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nilfs@vger.kernel.org, syzkaller-bugs@googlegroups.com, tj@kernel.org, viro@zeniv.linux.org.uk References: <000000000000fd0f2a061506cc93@google.com> <00000000000003b8c406151e0fd1@google.com> <20240403094717.zex45tc2kpkfelny@quack3> <20240405-heilbad-eisbrecher-cd0cbc27f36f@brauner> <20240405132346.bid7gibby3lxxhez@quack3> From: Kemeng Shi Message-ID: <089011b5-63a1-5251-022b-91cf1af95e17@huaweicloud.com> Date: Sun, 7 Apr 2024 10:05:12 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20240405132346.bid7gibby3lxxhez@quack3> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-CM-TRANSID:Syh0CgCXBQlY_xFmjWn_JQ--.19215S2 X-Coremail-Antispam: 1UD129KBjvJXoWxXFy3tw4rWF17ZF4rXF1UWrg_yoW5tF1Upr Z8tFyIkr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ri 05-04-24 13:05:59, Christian Brauner wrote: >> On Wed, Apr 03, 2024 at 11:47:17AM +0200, Jan Kara wrote: >>> On Tue 02-04-24 07:38:25, syzbot wrote: >>>> syzbot has found a reproducer for the following issue on: >>>> >>>> HEAD commit: c0b832517f62 Add linux-next specific files for 20240402 >>>> git tree: linux-next >>>> console+strace: https://syzkaller.appspot.com/x/log.txt?x=14af7dd9180000 >>>> kernel config: https://syzkaller.appspot.com/x/.config?x=afcaf46d374cec8c >>>> dashboard link: https://syzkaller.appspot.com/bug?extid=7b219b86935220db6dd8 >>>> compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40 >>>> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1729f003180000 >>>> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17fa4341180000 >>>> >>>> Downloadable assets: >>>> disk image: https://storage.googleapis.com/syzbot-assets/0d36ec76edc7/disk-c0b83251.raw.xz >>>> vmlinux: https://storage.googleapis.com/syzbot-assets/6f9bb4e37dd0/vmlinux-c0b83251.xz >>>> kernel image: https://storage.googleapis.com/syzbot-assets/2349287b14b7/bzImage-c0b83251.xz >>>> mounted in repro: https://storage.googleapis.com/syzbot-assets/9760c52a227c/mount_0.gz >>>> >>>> IMPORTANT: if you fix the issue, please add the following tag to the commit: >>>> Reported-by: syzbot+7b219b86935220db6dd8@syzkaller.appspotmail.com >>>> >>>> ================================================================== >>>> BUG: KASAN: slab-out-of-bounds in __lock_acquire+0x78/0x1fd0 kernel/locking/lockdep.c:5005 >>>> Read of size 8 at addr ffff888020485fa8 by task kworker/u8:2/35 >>> >>> Looks like the writeback cleanups are causing some use-after-free issues. >>> The code KASAN is complaining about is: >>> >>> /* >>> * Nothing written. Wait for some inode to >>> * become available for writeback. Otherwise >>> * we'll just busyloop. >>> */ >>> trace_writeback_wait(wb, work); >>> inode = wb_inode(wb->b_more_io.prev); >>>>>>>> spin_lock(&inode->i_lock); <<<<<< >>> spin_unlock(&wb->list_lock); >>> /* This function drops i_lock... */ >>> inode_sleep_on_writeback(inode); >>> >>> in wb_writeback(). Now looking at the changes indeed the commit >>> 167d6693deb ("fs/writeback: bail out if there is no more inodes for IO and >>> queued once") is buggy because it will result in trying to fetch 'inode' >>> from empty b_more_io list and thus we'll corrupt memory. I think instead of >>> modifying the condition: >>> >>> if (list_empty(&wb->b_more_io)) { >>> >>> we should do: >>> >>> - if (progress) { >>> + if (progress || !queued) { >>> spin_unlock(&wb->list_lock); >>> continue; >>> } >>> >>> Kemeng? >> >> Fwiw, I observed this on xfstest too the last few days and tracked it >> down to this series. Here's the splat I got in case it helps: > > OK, since this is apparently causing more issues and Kemeng didn't reply > yet, here's a fix in the form of the patch. It has passed some basic > testing. Feel free to fold it into Kemeng's patch so that we don't keep > linux-next broken longer than necessary. Thanks! Sorry for the late reply as I was on vacation these days. Also sorry for the bug introduced. The change looks good to me. Thanks a lot for helping to fix this in time. Kemeng > > Honza >