Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1840850lqg; Mon, 4 Mar 2024 05:41:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXV6Y1r1CoWHUXNoT8FX8vQJRIS5pALS/Q1YfI25jck0enke9Yqkubj5l68z+A7J05lDt/+xHLdtZUsmXre+EHYSvorPZ5wbTWRkQTpqA== X-Google-Smtp-Source: AGHT+IG6NeUoThxGvGA/EtZJkwsTAJGW2JhyHPbqgHfX40OK8vM+jOJWEq0rMF9Fyyl2zxc4P0Ct X-Received: by 2002:a05:6a21:9994:b0:1a0:e463:fcad with SMTP id ve20-20020a056a21999400b001a0e463fcadmr13725819pzb.2.1709559698116; Mon, 04 Mar 2024 05:41:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709559698; cv=pass; d=google.com; s=arc-20160816; b=FYtx10KKFIqDcZ+oAa0o5f4O+98B5snXy66q4L6HBxI3yB9FDtGJ6Q6xPx9YB7IDAh sC94QkkPtw66Tq5uEv7PKOEz2Id0SdVglBDmUpc3GRAGxnEpe5UHeFmHdAcCT90VODnu tq5F8DeWkNX6KA3mi7tn9YXHE6pDNfbUXo5YWN8AxOBvHTFkmAp8TvlQ6BWlnxRGVP6S 7IglPbR5uGepFAeQ7hRW1b+xIhOLXhXqUzUwhNtUDGeB2xXOck+O8cOh3nl397wSilsR Se0BWmJDWHj5OgrrhAz1zMwIR9q0RRDAdNQGOF+vbDvWz8MyPlOTFvg4X933PtzBd7PY 7RJQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=T+Hy1/2zdRakb8Z6eO02TTXRcgHK7cmE+Yagp8YwNAY=; fh=Zf19Wf16qe3DaZp7ziUgtf4gjvn4LSGfkRSvlLaND+Q=; b=odTtIV/0Q+aVgs+ff324Wf6up8b3Xqis9qg8IaNuAu+s+EwbMzW32aO3o1278gskB/ /WIbBXa89xCUjiGu6tlMk81TBwGF0US27Y6Z2TLG+KUw4TztftwlhRQBCEDpGYTYatpP ZBkbuXM3R4NlwOhw0B7GbZLJ8BT/ViMoujqEbpXCqDPf3hJOryS3wezUH/24n+bCy1ro LPrPVGx/Sg/eTlShVOE44F5g6YiOjmObv9Mm4CbV9bcVZ0FoIJoYVNMArMd1PSS7LdE3 bDM2mukIZKbX0suFfjsrah3rXOtqG9qxVPotDs1M2X3OlwA9ayP7+vgmLpDTigLmqEhz S5tQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-90660-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90660-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g5-20020a636b05000000b005dcd29510e5si8268472pgc.349.2024.03.04.05.41.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 05:41:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90660-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-90660-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90660-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A178E28A383 for ; Mon, 4 Mar 2024 13:34:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6002E3FB22; Mon, 4 Mar 2024 13:33:18 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 C62143FB07; Mon, 4 Mar 2024 13:33:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709559197; cv=none; b=POM1bgKQoYWUekHjaK78nbrVJmeFJVQVP2FrU82ZP4fGZ0pLNh6O2HeP7KyEQkrh1Ajp2XrNkAl3ElxkDqodhQXhLT7PAcaFd/x7j+D+H1itgEPfxhLNr3qbwIxdYzcWc5/2NwIvVS3Lxhopo0gDOKHk2/QE0TtidMMAQurpbM8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709559197; c=relaxed/simple; bh=p3LIkl9rC/cvDmNDiTkY3DxMJpyCd0pKeUzStd2zvqE=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=P4MNNgKRl1J5jjeF3ZVSlazGcKMgqkkVOq2X6I2j5GhfvDzfV4Gjk4ONrRXJyjiuwvRiGeE0deCeEhA1zaSI978w3387yjZHXIl8A0Y3+JpgOxHyon7xo/WQ0srEO/R5pOlwbaVCyp9q76ca5hiPdLdjYp1lo9QdVuXJneCRQcs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TpKMX0RY4z2BfBT; Mon, 4 Mar 2024 21:30:48 +0800 (CST) Received: from kwepemm600012.china.huawei.com (unknown [7.193.23.74]) by mail.maildlp.com (Postfix) with ESMTPS id 865B4140118; Mon, 4 Mar 2024 21:33:07 +0800 (CST) Received: from [10.174.178.220] (10.174.178.220) by kwepemm600012.china.huawei.com (7.193.23.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 4 Mar 2024 21:33:06 +0800 Message-ID: Date: Mon, 4 Mar 2024 21:33:05 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] RDMA/restrack: Fix potential invalid address access Content-Language: en-US To: Leon Romanovsky CC: Jason Gunthorpe , , References: <20240301095514.3598280-1-haowenchao2@huawei.com> <20240303125737.GB112581@unreal> <20240304073548.GA13620@unreal> From: Wenchao Hao In-Reply-To: <20240304073548.GA13620@unreal> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600012.china.huawei.com (7.193.23.74) On 2024/3/4 15:35, Leon Romanovsky wrote: > On Mon, Mar 04, 2024 at 11:21:19AM +0800, Wenchao Hao wrote: >> On 2024/3/3 20:57, Leon Romanovsky wrote: >>> On Fri, Mar 01, 2024 at 05:55:15PM +0800, Wenchao Hao wrote: >>>> struct rdma_restrack_entry's kern_name was set to KBUILD_MODNAME >>>> in ib_create_cq(), while if the module exited but forgot del this >>>> rdma_restrack_entry, it would cause a invalid address access in >>>> rdma_restrack_clean() when print the owner of this rdma_restrack_entry. >>> >>> How is it possible to exit owner module without cleaning the resources? >>> >> >> I meet this issue with one of our product who develop their owner kernel >> modules based on ib_core, and there are terrible logic with the exit >> code which cause resource leak. >> >> Of curse it's bug of module who did not clear resource when exit, but >> I think ib_core should avoid accessing memory of other modules directly >> to provides better stability. >> >> What's more, from the context of rdma_restrack_clean() when print >> "restack: %s %s object allocated by %s is not freed ...", it seems >> designed for the above scene where client has bug to alerts there >> are resource leak, so we should not panic on this log print. > > Can you please share the kernel panic? > Sorry, there is no stack or panic info recorded. This is because another issue of "printk". It seems printk would cause a deadlock when printk access invalid address with our kernel. Actually, I found this issue with ftrace/kprobe but not printk, that's why it takes me a long time to address it. BTW, I am not developer of rdma, after found the issue, I think it's better to enhance, so send this patch, and the patch has been tested with the origin scene. > Thanks