Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp977371pxp; Wed, 16 Mar 2022 23:14:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy19HP3AmLn5C0q/JSAa1pQ5NdKYN7/eRuiNv9PWtcSpRSvg/98oKcD3llI14Ak2B/CR0g2 X-Received: by 2002:a63:7b1d:0:b0:380:fcc9:93ca with SMTP id w29-20020a637b1d000000b00380fcc993camr2483885pgc.202.1647497674262; Wed, 16 Mar 2022 23:14:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647497674; cv=none; d=google.com; s=arc-20160816; b=rlP+TENb4z+/I9EMMDw2+TNu4RU4vmOtq4QbmIfkaBoN3+pT0TvOat+ipqm9GEa5dQ xx9pch49mCkU0gRFCMMHQAx9F2fywQ/tMJ22D/Ehh0Vb7lImXQY0eCEnHWy6VDpkiA/Y 5Ua6Ca03YfDnoEti5hyNXQNyvpIH11WAXU4es+wemSq+Q/GokID555urcuhcxSP3PQU1 KBh2O7GRIPTHCNup8VD/OdaepHygeT33Hk5kPUs9U8meIqwU7TlqRyyXvx27+cR8v/h7 GMPFLCCLbHIRuROUdcqiUzlHee6gcSxUh/hkGehJSg1/l7aWrU0REur9b7NCLnXSq1Sk vf1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=Q+oG0q/OqpLeOMe0H9+8fCVYgPq3RWnQ9esOTCEo9I4=; b=fqzW6ymXN1uUhx3N64oy84ymLc1FtJFPr4FceT8T0pjMQC7duWOpYYon+xdQ2sEV5W 8Lqy4DLOvrlNRM9gzv4xHPPbI7E0YFc5LgETcMd7HRVacz8YgYiMyT7aDDayyQedvO2w XWRjyuzdJXCWslPXj5z5Up9ELtxdfYOScEEwVNRusChCrWrMpvm7PUtuGYSuJH+tIL9Y ID/umdo5Az1lqXzk/3Y2U1nEjUtaL8vCudc3tA3CIQFdo8cvmyjnzP7cGcbFOgFVgDAT Ralwd/tP7w/KdCDnWXuerj3l299/srDqAn0Yq4U8QCEGTlBDm4aGDQTIG4a4vP6lQP8/ mKbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="GmrNy/EK"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k3-20020a17090a404300b001bf3623d4f5si6628299pjg.50.2022.03.16.23.14.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 23:14:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="GmrNy/EK"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 071C91F83EE; Wed, 16 Mar 2022 21:57:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347192AbiCOKoR (ORCPT + 99 others); Tue, 15 Mar 2022 06:44:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347191AbiCOKoP (ORCPT ); Tue, 15 Mar 2022 06:44:15 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3D9862D2 for ; Tue, 15 Mar 2022 03:43:03 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id s8so18940746pfk.12 for ; Tue, 15 Mar 2022 03:43:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:to:cc:references :from:in-reply-to:content-transfer-encoding; bh=Q+oG0q/OqpLeOMe0H9+8fCVYgPq3RWnQ9esOTCEo9I4=; b=GmrNy/EK2El8Qw8A/91ozUTgFaBURa6uPzKvvy0YkvcyJS3P+iOJjGwbO4eG7Ctpri JWWHthx/4feeSYD+uhkMt+t13hDbnibm4lQo6cAYmEgOFi5B7Jsm04536KqB+JnBhimX S3ntghb/gA2uWNhPzbiuCl5wcK+SxR8ffu0egGVvPtdx6yUdq3UcxMwTy6U+j1j21K6f 4XGvSC4iLgDV/cYn6W8yZKRh0aiZDJ0BrPLkDXtwkySV0B68UPhGGmRuXinE1UUiUj4k DbhIJHIovavmuCt0eSWgLp+tnqeJvuZ+OubQHOzWPM+gByqQfOM2JbfHUl+Wj6X05ZHn Uvvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :to:cc:references:from:in-reply-to:content-transfer-encoding; bh=Q+oG0q/OqpLeOMe0H9+8fCVYgPq3RWnQ9esOTCEo9I4=; b=3NBBshwlAsQvTJZLVpD3WkvVYYy/o3CzF++p8QKsBDAGNoce6Is7wPMmvp26Xh4huS zUDF3eNINgsQMF4jDwdOMhXFy1PPcV5qeNYaIEngXr8Jb25GPxRkxDo8f9O9K9BisrKN iMI+1ibkERtvwP/EiG03P3x47TNfcuJKdc33n6EhAd+JAeDlG0pHV4ZsYtjCthJyZoqh F/e+HiTxwxKuN6zDBRF4ysoJ16Yr+ctOIOqqPOUtk0TFoxLrTBXIoaMQuHycRvy07rw1 C5OjfdM36RJ0hj4O/p4cH6vI/gAFJczremTCFX+P9YBl+F6RIeFO4+0l5u6s8JXgyvJH Ir5w== X-Gm-Message-State: AOAM530pYAwqJWZ8ho+H2B9T8J1sq8FBfxFov/L43A3cqfZ38RAckaaQ Vxux3ZVBi01wV2WT8iWPzpI= X-Received: by 2002:a63:7158:0:b0:37d:f96f:3c78 with SMTP id b24-20020a637158000000b0037df96f3c78mr23048426pgn.378.1647340983404; Tue, 15 Mar 2022 03:43:03 -0700 (PDT) Received: from [127.0.0.1] ([103.97.175.139]) by smtp.gmail.com with ESMTPSA id j14-20020a056a00174e00b004f776098715sm19768027pfc.68.2022.03.15.03.43.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Mar 2022 03:43:03 -0700 (PDT) Message-ID: Date: Tue, 15 Mar 2022 18:43:01 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH] fs: erofs: remember if kobject_init_and_add was done To: Dongliang Mu , Gao Xiang , Chao Yu Cc: syzkaller , linux-erofs@lists.ozlabs.org, Dongliang Mu , linux-kernel@vger.kernel.org References: <20220315075152.63789-1-dzm91@hust.edu.cn> From: Huang Jianan In-Reply-To: <20220315075152.63789-1-dzm91@hust.edu.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 在 2022/3/15 15:51, Dongliang Mu 写道: > From: Dongliang Mu > > Syzkaller hit 'WARNING: kobject bug in erofs_unregister_sysfs'. This bug > is triggered by injecting fault in kobject_init_and_add of > erofs_unregister_sysfs. > > Fix this by remembering if kobject_init_and_add is successful. > > Note that I've tested the patch and the crash does not occur any more. > > Reported-by: syzkaller > Signed-off-by: Dongliang Mu > --- > fs/erofs/internal.h | 1 + > fs/erofs/sysfs.c | 9 ++++++--- > 2 files changed, 7 insertions(+), 3 deletions(-) > > diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h > index 5aa2cf2c2f80..9e20665e3f68 100644 > --- a/fs/erofs/internal.h > +++ b/fs/erofs/internal.h > @@ -144,6 +144,7 @@ struct erofs_sb_info { > u32 feature_incompat; > > /* sysfs support */ > + bool s_sysfs_inited; Hi Dongliang, How about using sbi->s_kobj.state_in_sysfs to avoid adding a extra member in sbi ? Thanks, Jianan > struct kobject s_kobj; /* /sys/fs/erofs/ */ > struct completion s_kobj_unregister; > }; > diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c > index dac252bc9228..2b48a4df19b4 100644 > --- a/fs/erofs/sysfs.c > +++ b/fs/erofs/sysfs.c > @@ -209,6 +209,7 @@ int erofs_register_sysfs(struct super_block *sb) > "%s", sb->s_id); > if (err) > goto put_sb_kobj; > + sbi->s_sysfs_inited = true; > return 0; > > put_sb_kobj: > @@ -221,9 +222,11 @@ void erofs_unregister_sysfs(struct super_block *sb) > { > struct erofs_sb_info *sbi = EROFS_SB(sb); > > - kobject_del(&sbi->s_kobj); > - kobject_put(&sbi->s_kobj); > - wait_for_completion(&sbi->s_kobj_unregister); > + if (sbi->s_sysfs_inited) { > + kobject_del(&sbi->s_kobj); > + kobject_put(&sbi->s_kobj); > + wait_for_completion(&sbi->s_kobj_unregister); > + } > } > > int __init erofs_init_sysfs(void)