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 0E182C43219 for ; Thu, 24 Nov 2022 11:19:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230021AbiKXLTk (ORCPT ); Thu, 24 Nov 2022 06:19:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbiKXLTh (ORCPT ); Thu, 24 Nov 2022 06:19:37 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C42F627B3C; Thu, 24 Nov 2022 03:19:36 -0800 (PST) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NHwQf3D89zqSgZ; Thu, 24 Nov 2022 19:15:38 +0800 (CST) Received: from kwepemm600001.china.huawei.com (7.193.23.3) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 24 Nov 2022 19:19:34 +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.2375.31; Thu, 24 Nov 2022 19:19:33 +0800 Message-ID: <4d464258-de80-7d9c-bb8d-363d743396e7@huawei.com> Date: Thu, 24 Nov 2022 19:19:32 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH net] net/9p: Fix a potential socket leak in p9_socket_open To: CC: , , , , , , , , , , References: <20221124081005.66579-1-wanghai38@huawei.com> From: "wanghai (M)" In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.176.245] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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 在 2022/11/24 17:15, asmadeus@codewreck.org 写道: > Wang Hai wrote on Thu, Nov 24, 2022 at 04:10:05PM +0800: >> Both p9_fd_create_tcp() and p9_fd_create_unix() will call >> p9_socket_open(). If the creation of p9_trans_fd fails, >> p9_fd_create_tcp() and p9_fd_create_unix() will return an >> error directly instead of releasing the cscoket, which will > (typo, socket or csocket -- I'll fix this on applying) Hi, Dominique. Thanks for reviewing. Here is a typo, it should be csocket. >> result in a socket leak. >> >> This patch adds sock_release() to fix the leak issue. > Thanks, it looks good to me. > A bit confusing that sock_alloc_files() calls sock_release() itself on > failure, but that means this one's safe at least... Yes, this mechanism was introduced by commit 8e1611e23579 ("make sock_alloc_file() do sock_release() on failures") > >> Fixes: 6b18662e239a ("9p connect fixes") > (the leak was present before that commit so I guess that's not really > correct -- but it might help figure out up to which point stable folks > will be able to backport so I guess it's useful either way) Yes, there was already a leak before this patch, and this patch also introduces a leak -- Wang Hai