Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp856916pxb; Thu, 19 Nov 2020 15:58:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyDx/7EbXFXLmcrXtGCJ9d90gaScivOJoW7kJfb36XZNoyGYgsaehuS+HCE3TpEaBE49Ie4 X-Received: by 2002:a17:906:6091:: with SMTP id t17mr1012236ejj.476.1605830302272; Thu, 19 Nov 2020 15:58:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605830302; cv=none; d=google.com; s=arc-20160816; b=xO0tH1JsxHbg36uU/asKCN15YLiqVd3H6pfdC47S2O9DCeN+uWjiDriSbtZtCKwDUE 2Ra0KZ0GALdca5BupHef0ZLF5ivu87EE1PolHeJV6bdDInh+jZQ3mIKrk4bC+RJYyZVw ySOlogIHGwWskS8PUqOctrPlzTksSNonKLXlOZ5gTv0wYjpWvYTKaY6Gbeni0WQndf9G QImBgoog3c/5cowLnKzG3ZpKCGBdiRSfTMpytFDyh1Ed68YtK3oaUlfwcf9coDY0mYAs u72LcFGVHEt9sppxrZkDaPjQXtZqXdcICy3AxUuG8flQqeFKy+eyxny2rpYlQr4YgaZ7 cLzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=LKwvJrSAqDwJVWrXdQ2j2YKSRZdnkIRpsnYMAkNM7Kg=; b=qeotdw/ZlHy/LzMbSiTlCyGeNeSHiZyDu4e8jJ5m9zWf4UmW1i9C1SiC09QNqu+NEk EK/XcUbWEkitk/d0W91jibhiZ87Iq8gGq0okHSZFHfxhs7TXkZ5F2LRk/brFyQ2crubQ ybc131X8olN5escj0BFULodOCnHSgiOfY2LrFwUdILyHgp8/sWk0UnrmmrY3rvnusvBE dvJwSrAfBJpSPELkFGaCjUwWwKcDewbest+ra19gFe9zj/by7mg9hVYEzJU1RJ7RrgA2 zaUHfm5JoDqfcTovveqmdzD1GYHdwiDkddxdwYjRNfHg51iVgJ56Ua18mcicE1raxAnx seOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KkE+4W39; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sa28si721089ejb.734.2020.11.19.15.57.37; Thu, 19 Nov 2020 15:58:22 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=KkE+4W39; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727103AbgKSX4X (ORCPT + 99 others); Thu, 19 Nov 2020 18:56:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727098AbgKSX4X (ORCPT ); Thu, 19 Nov 2020 18:56:23 -0500 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 060EBC0613D4 for ; Thu, 19 Nov 2020 15:56:23 -0800 (PST) Received: by mail-ot1-x342.google.com with SMTP id n11so7130316ota.2 for ; Thu, 19 Nov 2020 15:56:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LKwvJrSAqDwJVWrXdQ2j2YKSRZdnkIRpsnYMAkNM7Kg=; b=KkE+4W39DDOxozFRy6Nk4k+fmZjXCgxFnSeLm1gfEHfIzQnFCfk3WvMIbOa+DGN5xO BQq2UMiKf7RNIhkBO6e7kYyB34mpaqUkISxVM0z5hDWebGDb7P6M7aYB/eu3uTGMN1Fs FyY80PwtOw6/HX90wrCoT0MnoN1fhquvl+xeCpTgxi0gjQUZicneW9S091WX1HUj8TL4 B8giKbSg+pEZFJPhmY9w89aMwcM0iISAjF8ZOZMc4ct8fu+v9mZVqE+VRZtqBy41BLKW vjJJf7EkX/TIAJkJckKzCiIzOAkEmYW1ieRJxp3uCsEzW/0GEl+YIxfkL7wmYL3DDrNI 4CZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LKwvJrSAqDwJVWrXdQ2j2YKSRZdnkIRpsnYMAkNM7Kg=; b=bhBB4ZxBCqqPgxCdb9FtGVXvSnPrg/O9x7Oldi0E84eFwYKjIxjs310q/cyo4zt6vE C4LDrAw2DHkYL4idhUZWHiBIlNqgJrCFzrdzFsON1fU5DN2xlegskbbiyJdKSAWSEVvA 8LHotItZRyXwHbnJnmcrK+UxFeHuNMIwQiz0SR9jCwzN3/uOCwf0rdSjN3sy5ljvUYFI P0xAM1gyrj0RAFxv6NBnCS8UwEjkhgzu3TopOXDyT+WaZDlc9RmwLaP5j6bPDr1vBA/s jZBbCusXzBLjcKA04qxIAwsXm+BXqYTa2wZ/2t5kJSS7acncRIvvqSPz1HD6ZGCmyzyi tSeA== X-Gm-Message-State: AOAM531e4jKcoPYJG02k8RXoYTnFeQvBFI9H7lDsPRzHoNrdjXeRatxy yCjpwoBRQJWA8j88mI9V7nrP0fREJwlhXjUES4IAhVJ1zbw= X-Received: by 2002:a9d:4b81:: with SMTP id k1mr12285314otf.371.1605830182229; Thu, 19 Nov 2020 15:56:22 -0800 (PST) MIME-Version: 1.0 References: <20201111011745.2016-1-sonnysasaka@chromium.org> <20201111011745.2016-7-sonnysasaka@chromium.org> In-Reply-To: From: Luiz Augusto von Dentz Date: Thu, 19 Nov 2020 15:56:11 -0800 Message-ID: Subject: Re: [PATCH BlueZ v2 7/7] battery: Implement Battery Provider API To: Sonny Sasaka Cc: Bastien Nocera , BlueZ , Miao-chen Chou Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Sonny, On Thu, Nov 19, 2020 at 12:15 PM Sonny Sasaka wrote: > > Hi Luiz, > > > On Tue, Nov 17, 2020 at 2:26 PM Luiz Augusto von Dentz > wrote: > > > > Hi Sonny, > > > > On Tue, Nov 17, 2020 at 2:20 PM Sonny Sasaka wrote: > > > > > > Hi Bastien, > > > > > > Thank you for the feedback. Please find my answers below. > > > > > > On Tue, Nov 17, 2020 at 2:51 AM Bastien Nocera wrote: > > > > > > > > Hey Sonny, > > > > > > > > On Tue, 2020-11-10 at 17:17 -0800, Sonny Sasaka wrote: > > > > > This patch implements the BatteryProvider1 and > > > > > BatteryProviderManager1 > > > > > API. This is a means for external clients to feed battery information > > > > > to > > > > > BlueZ if they handle some profile and can decode battery reporting. > > > > > > > > > > The battery information is then exposed externally via the existing > > > > > Battery1 interface. UI components can consume this API to display > > > > > Bluetooth peripherals' battery via a unified BlueZ API. > > > > > > > > Was this patch reviewed for potential security problems? From the top > > > > of my head, the possible problems would be: > > > > - I don't see any filters on which user could register battery > > > > providers, so on a multi user system, you could have a user logged in > > > > via SSH squatting all the battery providers, while the user "at the > > > > console" can't have their own providers. Also, what happens if the user > > > > at the console changes (fast user switching)? > > > > - It looks like battery providers don't check for paired, trusted or > > > > even connected devices, so I would be able to create nearly unbound > > > > number of battery providers depending on how big the cache for "seen" > > > > devices is. > > > For security, the API can be access-limited at D-Bus level using D-Bus > > > configuration files. For example, we can let only trusted UNIX users > > > as the callers for this API. This D-Bus config file would be > > > distribution-specific. In Chrome OS, for example, only the "audio" and > > > "power" users are allowed to call this API. This way we can make sure > > > that the callers do not abuse the API for denial-of-service kind of > > > attack. > > > > I guess there is still some the risk of conflicts even with the use of > > D-Bus policy blocking roge applications, there could still be multiple > > entities providing the battery status from the same source, which is > > why I suggested we couple the Battery1 with the Profile1, so only the > > entity that has registered to handle let say HFP can provide a battery > > status and we automatically deduce the source is from HFP. > > These are two different issues. The issue with bad applications can be > overcome with D-Bus policy. The issue with multiple providers is > inherent: we have to have a duplicate resolution because one device > may report battery from different sources, e.g. via HFP and A2DP at > the same time. The latter case is rare in practice but still possible, > so I propose the simplest duplication resolution which is accept the > first provider registered (of that specific device) and ignore the > rest. > > Coupling Battery1 with Profile1 will limit the flexibility of this > feature. For example, some speakers report battery status via a > separate LE channel (GATT). If we require Battery provider to be also > a registered Profile, we won't be able to support these cases since > GATT clients do not register any profile. Actually it is a good policy to provide GattProfile1 if you are interested in enabling auto-connect, which I suppose most third-party services would like to enable: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt#n367 Note that we are doing to avoid complicate conflict resolution since profiles by design can only be registered once that means Battery sources will also be limited to one per profile, Im fine if you choose not to have this integration in the first version . > > > > > > > > > > > Given that the interface between upower and bluez is supposedly > > > > trusted, it might be good to ensure that there are no fuzzing problems > > > > on the bluez API side that could translate to causing problems in > > > > upower itself. > > > Could you give an example of what potential problems of upower can be > > > caused by communicating with BlueZ through this API? > > > > > > > > > > > I didn't review the code in depth, but, having written this mechanism > > > > for Bluetooth battery reporting, I think that this is the right way to > > > > go to allow daemons like pulseaudio to report battery status. > > > > > > > > Cheers > > > > > > > > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz