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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D493C43217 for ; Sat, 19 Nov 2022 01:45:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232194AbiKSBpN (ORCPT ); Fri, 18 Nov 2022 20:45:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232340AbiKSBou (ORCPT ); Fri, 18 Nov 2022 20:44:50 -0500 Received: from mail-vs1-xe30.google.com (mail-vs1-xe30.google.com [IPv6:2607:f8b0:4864:20::e30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89C2FBDEF4; Fri, 18 Nov 2022 17:02:23 -0800 (PST) Received: by mail-vs1-xe30.google.com with SMTP id t14so6336922vsr.9; Fri, 18 Nov 2022 17:02:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=rlT2eva1Dr7TgqfsYlKAOHQYOBdy4szmlJCNqoMCyFQ=; b=VOjf5eujWq+PJS0lBZYTm6+xd/PIrorMDmkkZd2vnoRpD7bMImm+QxBfUzg8df58CD HdiUNCD6Wv/nT0Up7oyVv+btfKbd3xEfTbOVRtkaT/2Mc3DdA0SEXH/WCHlsIDCtxyN6 MvOmXtid5yJLdTuqSinNPUl0bjCSuF6es+Spu2SzrlN541I5MtRLjPAY23Apc1p0yLo2 otd6nc+6j7/B9CAZS0DOz+EQVLKQjF9/hbSpgJoBwsm5fy1cuoRl3Ui+U/3TCyFLQFfL ZtGGdfe63mM+vVZA8ft0AV108A5JaXI58VpooQCtPAzLkAbMHxy61Iz3H8wNpIPFLsYP Ml8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rlT2eva1Dr7TgqfsYlKAOHQYOBdy4szmlJCNqoMCyFQ=; b=hV04WhasQzUZCwHbbEqU6fjPqQ+mYO7D1fFO/+IbnPsGQlmhRXbiEvtxvnQjsDViqv KopQvn3yxsVPaESTaeJS8qsFQ3B6fMmisUVhUCDvztEIrKyJu14Nh34odeSt1OIiCCMZ 7RxNyygMOSXadHdEftbRBZsg/vbvm031rLEuHE17jwCs0C33QnuF+42Zpv5Z7BSub0Ns VXRdvCpYzuh5PyUkLMPil547BQzJIvmrLdSZoK04skj6m903QlNdz0Jn6zIBcoZvsde/ ZClDvCowa8RbqYGouc9EkfXmZjSaWjK+DViIaaR7WFxB5cXeMMQx3JyyMDIH+Mplg3NV opzw== X-Gm-Message-State: ANoB5pkR3JUBisnsuM4hpY88hMOF54ERd9GmOIDf9RMc3KVmNixFd+OS aGIv8zA5GhjrpEE6ct0OefwqAx61p+7YxemUjYvzAla5 X-Google-Smtp-Source: AA0mqf7JZLvt89xRFQC5fdCnVMosLV8+a19C4WrKmjhOXDLWFcQN7f4JQk/PbX9heRRrbR1ELCxbXGDIjKudvXoz9WU= X-Received: by 2002:a05:6102:7ab:b0:3ac:f694:b8c4 with SMTP id x11-20020a05610207ab00b003acf694b8c4mr6059445vsg.26.1668819742470; Fri, 18 Nov 2022 17:02:22 -0800 (PST) MIME-Version: 1.0 References: <20221114040441.1649940-1-zhangpeng362@huawei.com> In-Reply-To: From: Ryusuke Konishi Date: Sat, 19 Nov 2022 10:02:05 +0900 Message-ID: Subject: Re: [PATCH] nilfs2: fix NULL pointer dereference in nilfs_palloc_commit_free_entry() To: Peng Zhang Cc: ye.xingchen@zte.com.cn, chi.minghao@zte.com.cn, vishal.moola@gmail.com, linux-nilfs@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+ebe05ee8e98f755f61d0@syzkaller.appspotmail.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 19, 2022 at 9:38 AM Ryusuke Konishi wrote: > On Tue, Nov 15, 2022 at 3:39 AM Ryusuke Konishi wrote: > > On Mon, Nov 14, 2022 at 12:39 PM Peng Zhang wrote: > What was happening here was complicated. > There were two state inconsistencies in DAT: > 1) A virtual block number (vblocknr == 6145) in the report, was used > twice in a btree. > Because of this, nilfs_dat_commit_end() on that address was called twice. > 2) For the virtual block number (vblocknr == 6145), the DAT bitmap > status was free (second anomaly), and nilfs_dat_commit_alloc() was > performed at the same time as the second nilfs_dat_commit_end() above. > > As I mentioned, when nilfs_dat_commit_end() frees a virtual block > number in the bitmap of DAT, nilfs_dat_prepare_end() usually allocates > buffer heads of the bitmap block and the descriptor block, and sets > them to the request struct. But, the above two anomalies overlap, as > you pointed out, de_block is initialized to 0 by > nilfs_dat_prepare_alloc() in the middle of "prepare" and "commit", and I wrote it wrong, this should be ".., de_blocknr is initialized to 0 by nilfs_dat_commit_alloc() ..". Ryusuke Konishi From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ryusuke Konishi Subject: Re: [PATCH] nilfs2: fix NULL pointer dereference in nilfs_palloc_commit_free_entry() Date: Sat, 19 Nov 2022 10:02:05 +0900 Message-ID: References: <20221114040441.1649940-1-zhangpeng362@huawei.com> Mime-Version: 1.0 Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=rlT2eva1Dr7TgqfsYlKAOHQYOBdy4szmlJCNqoMCyFQ=; b=VOjf5eujWq+PJS0lBZYTm6+xd/PIrorMDmkkZd2vnoRpD7bMImm+QxBfUzg8df58CD HdiUNCD6Wv/nT0Up7oyVv+btfKbd3xEfTbOVRtkaT/2Mc3DdA0SEXH/WCHlsIDCtxyN6 MvOmXtid5yJLdTuqSinNPUl0bjCSuF6es+Spu2SzrlN541I5MtRLjPAY23Apc1p0yLo2 otd6nc+6j7/B9CAZS0DOz+EQVLKQjF9/hbSpgJoBwsm5fy1cuoRl3Ui+U/3TCyFLQFfL ZtGGdfe63mM+vVZA8ft0AV108A5JaXI58VpooQCtPAzLkAbMHxy61Iz3H8wNpIPFLsYP Ml8w== In-Reply-To: List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Peng Zhang Cc: ye.xingchen-Th6q7B73Y6EnDS1+zs4M5A@public.gmane.org, chi.minghao-Th6q7B73Y6EnDS1+zs4M5A@public.gmane.org, vishal.moola-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, syzbot+ebe05ee8e98f755f61d0-Pl5Pbv+GP7P466ipTTIvnc23WoclnBCfAL8bYrjMMd8@public.gmane.org On Sat, Nov 19, 2022 at 9:38 AM Ryusuke Konishi wrote: > On Tue, Nov 15, 2022 at 3:39 AM Ryusuke Konishi wrote: > > On Mon, Nov 14, 2022 at 12:39 PM Peng Zhang wrote: > What was happening here was complicated. > There were two state inconsistencies in DAT: > 1) A virtual block number (vblocknr == 6145) in the report, was used > twice in a btree. > Because of this, nilfs_dat_commit_end() on that address was called twice. > 2) For the virtual block number (vblocknr == 6145), the DAT bitmap > status was free (second anomaly), and nilfs_dat_commit_alloc() was > performed at the same time as the second nilfs_dat_commit_end() above. > > As I mentioned, when nilfs_dat_commit_end() frees a virtual block > number in the bitmap of DAT, nilfs_dat_prepare_end() usually allocates > buffer heads of the bitmap block and the descriptor block, and sets > them to the request struct. But, the above two anomalies overlap, as > you pointed out, de_block is initialized to 0 by > nilfs_dat_prepare_alloc() in the middle of "prepare" and "commit", and I wrote it wrong, this should be ".., de_blocknr is initialized to 0 by nilfs_dat_commit_alloc() ..". Ryusuke Konishi