Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1460099pxj; Fri, 4 Jun 2021 15:19:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmkb7B6wHhzL0I9e06ZVplLwCplMJbt83V9iVDwfKspw3DcGlFM/e9rJyJWZACjCrHsufH X-Received: by 2002:a05:6402:4313:: with SMTP id m19mr6952528edc.263.1622845175188; Fri, 04 Jun 2021 15:19:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622845175; cv=none; d=google.com; s=arc-20160816; b=oDWZcWzctslU9C6Q6/zsIpoFsi/Wzymv5ZyOT8Oc1lr24eDw0x3UbdaH+SskorKUpS 0AlovJW64nSDjjpynJ8LCBxT6n9DgU2/YSwhg3xK9pqQ5zAY3iPrIfyad4nATmNCcAO8 TmehaBxVoJt9m89xv/aG5YICY3BUsZiTd6GsjfXkCEIANdf7DDEYZTY5Ywwa2c2tIXh9 gLmZXAjLkkEmnx7XZElPXBAqBmf2DY2U4mRR4qQmXhJKhc3LqbaCArzg972UMk6c5JsG 1wUiCI+/Q0DF8+QIL/7tBw+koWuPnlUGkADeNscmiwUoi5y401NQRPe1i9kB706af4cK c5kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:reply-to:dkim-signature; bh=pcYtAUYeodJdboycZjWkgW5N1uQ7326a6fGDGP2wKnI=; b=VCrcFgTkhDUR9n1GYAcxaWoJAOxmrHUJvkIe6p7wHUTu2v2kT853xEoo2n/Eyrwl1l 7/bhG7h0sgVdGUWGH+n9REITrIBI+VvJSifzRGxDbPTir2NXVn8iHZgWNiyTw4ii3+fd +ubf2xZ50HpOXKtPKD9CBAHsOQZWD5UUzKAo1zDJof6p9iMpqt78/xueHxn/BygLeVSK zVVjQsCQqpqlDuO/vOm4Q4QO9CkI4k4UVHHr/FqkxVMODLJr9D4WSeMgIzRjrtTRAJfF JrPlnCJdlFEqrk5WsUE55+C6Dr3FcEpy2ZA+R/XaphcFDZVq65LfNPMcFdAsfeNUay3Q JMIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@systech.com header.s=key header.b=An70fACv; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pj12si5461155ejb.371.2021.06.04.15.18.57; Fri, 04 Jun 2021 15:19:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@systech.com header.s=key header.b=An70fACv; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229982AbhFDWS5 (ORCPT + 99 others); Fri, 4 Jun 2021 18:18:57 -0400 Received: from rcloudmail.hostconnection.net ([38.96.19.98]:60665 "EHLO rcloudmail.hostconnection.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229668AbhFDWS4 (ORCPT ); Fri, 4 Jun 2021 18:18:56 -0400 X-SmarterMail-Authenticated-As: jay.foster@systech.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=systech.com; s=key; h=Content-Language:Content-Transfer-Encoding:Content-Type :In-Reply-To:MIME-Version:User-Agent:Date:Message-ID:Organization :From:References:Cc:To:Subject:Reply-To:Received; bh=pcYtAUYeodJdboycZjWkgW5N1uQ7326a6fGDGP2wKnI=; b=An70fACvnM+kh47+hXwec+wdjn3HIL6pAnRo0tYWq42m7KFQ/bH1YO5vXnn0n7i4o LrYqreGDXyT3PqJWlMl2Rum9kJzO3ejJHYxGJlMsKAXWt0JHLs2H2N8lx4FycU7Lk Rn+RFIdP5h+XjbYo+E4z3qXn7ZOK76bzly1FPuMB4= Received: from [172.16.4.182] (wsip-70-167-11-34.sd.sd.cox.net [70.167.11.34]) by rcloudmail.hostconnection.net with SMTP (version=Tls12 cipher=Aes256 bits=256); Fri, 4 Jun 2021 15:17:01 -0700 Reply-To: jay@systech.com Subject: Re: Bluez Socket File Descriptor Leak To: Luiz Augusto von Dentz Cc: "linux-bluetooth@vger.kernel.org" References: <749228e2-4d49-83ef-06f0-2db0532beb93@systech.com> From: Jay Foster Organization: Systech Corporation Message-ID: <22ada41a-d85b-1cbb-a05c-68bb754edcf0@systech.com> Date: Fri, 4 Jun 2021 15:16:47 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Exim-Id: 22ada41a-d85b-1cbb-a05c-68bb754edcf0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org On 6/4/2021 2:39 PM, Luiz Augusto von Dentz wrote: > Hi Jay, > > On Fri, Jun 4, 2021 at 12:14 PM Jay Foster wrote: >> I am experiencing an odd problem with PAN networking. I have PAN >> networking setup in NAP role. Another machine makes a BNEP connection >> and performs network activity, then disconnects the BNEP connection. >> This repeats periodically. This works just fine, except after a while, >> the BNEP connection fails with the following in the log. >> >> May 4 13:08:02 (none) daemon.debug bluetoothd[1373]: >> profiles/network/server.c:confirm_event() BNEP: incoming connect from >> B8:27:EB:E5:35:9B >> May 4 13:08:03 (none) daemon.err bluetoothd[1373]: Can't add bnep0 to >> the bridge br1: Too many open files(24) >> >> ls /proc/`pidof bluetoothd`/fd shows about 1000 open file descriptors >> (sockets mostly). This looks like some kind of resource (file >> descriptor) leak. >> >> Has anyone experienced this before? I don't know if it is in the >> bluetoothd application or one if the libraries (glib2, dbus) it links >> with. Happens with bluez 5.19 and 5.52. > That looks like the fd are not released (via close) after they are > attached to the bridge, you could in theory increase the number of fd > a process can have in the meantime but we will need to fix this > problem at some point so please have a issue created in github: > > https://github.com/bluez/bluez/ > Using strace attached to bluetoothd during a BNEP disconnect/reconnect sequence, it looks like the socket that the previous BNEP connection was accepted on is not closed.  bluetoothd accepts the new connection on a new socket (fd count goes up by one) but never closes the previous connection socket.  This is unrelated to the bridge.  That just happens to be the first function that tries to create a socket after the fd limit is reached. Increasing the fd limits for the process is not an option (It will eventually fail).  This is on a resource limited embedded system.