Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1486168pxb; Fri, 22 Oct 2021 01:45:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/x9mBa368qXe6JcumVE/BfN3MCz0GKSJc848qjrkGUb5Y45BxPk53+uVxOICavArXfOMU X-Received: by 2002:a63:6ac2:: with SMTP id f185mr8435496pgc.326.1634892339663; Fri, 22 Oct 2021 01:45:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634892339; cv=none; d=google.com; s=arc-20160816; b=LuVuxx5ms/t9QsAbiQXftSHdnkDuwS5EetxSY4utPGrJpFx9XNOEHE21TOQlBImlvs L173wnRgaFchsArjINX7hek2l/uMNCJOmr4QizQilxrYKpXFSQnbsDz1yhuNCXtRmayQ oBVi9skBfTQB14FZGcDUeH50zROd1/dez6CBN3171NgH60RKaseBo4spn9tUGJfQqj4q oFw8jO/azaIkcm3z/v968PLQalWfPepdwSoHEMn2GCJWmcfxIm2DLrZOqWrYaVwb3TKM MT4Yo+ZBKhRtroPYn6tTM3btuj0c9xQzET36C0glbppBsIVIn3hLPx99EX5bCQ17ZjHy vUGQ== 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 :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=sHOSMNO8j3YiXML43KzmNnqpDEdV+wajvX13HkouC4w=; b=REUqo8VPF3pPvah7JYmiEDShKwSrs4h56aa9stAUItrUDiyADkHnRmW1DVV7GgVbPp yIACUAVlhAO/I91ZnBTF8WxNOR3Tibarxb34k3lmcdY4O+QuMSeKzRIGbKrMnIcpMU3P AkkGQgtfc24pgB0aLnNTeEUNHmZGONG2e1ZySgC8Tuc0/ImSlytx/Lsfg4Y4fFLiTaIs iJFCyTP2rbCoUsSbycvyJLa/VCBNR3mW0nVhRjuOaWSPAAD2W1JaGarIi8YQoaO622NA iIImGX71zwJX7vDJnkplO5s4lwtPEgZCdX8fRXkSw5m3lUJeNNkN0GsVidkOM6fSaOFn oiOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k5si10083752pls.135.2021.10.22.01.45.26; Fri, 22 Oct 2021 01:45:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232331AbhJVIqk (ORCPT + 99 others); Fri, 22 Oct 2021 04:46:40 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:29926 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231991AbhJVIqk (ORCPT ); Fri, 22 Oct 2021 04:46:40 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4HbHpT6WhGzbnNZ; Fri, 22 Oct 2021 16:39:45 +0800 (CST) Received: from kwepemm600001.china.huawei.com (7.193.23.3) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Fri, 22 Oct 2021 16:44:20 +0800 Received: from [10.174.176.245] (10.174.176.245) by kwepemm600001.china.huawei.com (7.193.23.3) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Fri, 22 Oct 2021 16:44:19 +0800 Subject: Re: [PATCH] Bluetooth: cmtp: fix possible panic when cmtp_init_sockets() fails To: Marcel Holtmann CC: Karsten Keil , Johan Hedberg , Luiz Augusto von Dentz , "David S. Miller" , Jakub Kicinski , Thadeu Lima de Souza Cascardo , "open list:NETWORKING [GENERAL]" , , References: <20211022034417.766659-1-wanghai38@huawei.com> <9D8B1F5B-8EFE-40CB-BC85-F6EC3483CC61@holtmann.org> From: "wanghai (M)" Message-ID: Date: Fri, 22 Oct 2021 16:43:59 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <9D8B1F5B-8EFE-40CB-BC85-F6EC3483CC61@holtmann.org> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.176.245] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600001.china.huawei.com (7.193.23.3) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ?? 2021/10/22 12:48, Marcel Holtmann ะด??: > Hi Wang, > >> I got a kernel BUG report when doing fault injection test: >> >> ------------[ cut here ]------------ >> kernel BUG at lib/list_debug.c:45! >> ... >> RIP: 0010:__list_del_entry_valid.cold+0x12/0x4d >> ... >> Call Trace: >> proto_unregister+0x83/0x220 >> cmtp_cleanup_sockets+0x37/0x40 [cmtp] >> cmtp_exit+0xe/0x1f [cmtp] >> do_syscall_64+0x35/0xb0 >> entry_SYSCALL_64_after_hwframe+0x44/0xae >> >> If cmtp_init_sockets() in cmtp_init() fails, cmtp_init() still returns >> success. This will cause a kernel bug when accessing uncreated ctmp >> related data when the module exits. >> >> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") >> Reported-by: Hulk Robot >> Signed-off-by: Wang Hai >> --- >> net/bluetooth/cmtp/core.c | 6 ++++-- >> 1 file changed, 4 insertions(+), 2 deletions(-) >> >> diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c >> index 0a2d78e811cf..ccf48f50afdf 100644 >> --- a/net/bluetooth/cmtp/core.c >> +++ b/net/bluetooth/cmtp/core.c >> @@ -499,11 +499,13 @@ int cmtp_get_conninfo(struct cmtp_conninfo *ci) >> >> static int __init cmtp_init(void) >> { >> + int err; >> + >> BT_INFO("CMTP (CAPI Emulation) ver %s", VERSION); >> >> - cmtp_init_sockets(); >> + err = cmtp_init_sockets(); >> >> - return 0; >> + return err; >> } > just do return cmtp_init_sockets(); > > Regards > > Marcel Ok, I will send v2 > . > -- Wang Hai