* Re: [PATCH 00/13] sixaxis support
From: Johan Hedberg @ 2013-11-27 9:34 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1385417752-25664-1-git-send-email-szymon.janc@gmail.com>
Hi Szymon,
On Mon, Nov 25, 2013, Szymon Janc wrote:
> Hi All,
>
> This is yet another attempt to get PS3 controller support into BlueZ upstream.
>
> I based my work on Fedora out-of-tree patch (hence copyright info) and tried
> to take into consideration comments from previous upstreaming attempt.
>
> I find sixaxis name short and neat so I sticked with it.
>
> I didn't really like the idea of hardcoding SDP records so I took different
> approach of doing reverse SDP search while cable associated device first
> connects. This is done before authorizing incoming HID connection.
>
> Some functions unavailable to exteral plugins were renamed with btd_ prefix
> (or explicitly marked in bletooth.ver) to export them (patch 1-8).
>
> Patch 9-10 add sixaxis external plugin that depends on udev. This plugin is
> responsible for preparing newly USB connected PS3 sixaxis device and creating
> btd_device with proper PNP information.
>
> Patch 12 adds support for handling first connection of sixaxis device in input
> plugin itself. This is something I would like to get comments and suggestions.
> Currently this is rather sixaxis oriented, but could be made more generic (some
> hooks registration) if desired.
>
> This serie is not implemententing any LED (or other features) setting support.
> I have an impression that those should not be handled by BlueZ but some other
> entity (util tools or driver itself perhabs?) as this is not related to
> transport itself and should be set/used on USB connection as well.
>
> This was tested with Dualshock3 and seems to be working nicely here.
>
> Comments are welcome.
>
> --
> BR
> Szymon Janc
>
> Szymon Janc (13):
> core: Export some symbols from libbluetooth
> Rename adapter_get_device to btd_adapter_get_device
> Rename device_set_temporary to btd_device_set_temporary
> Rename device_set_trusted to btd_device_set_trusted
> Rename device_device_set_name to btd_device_device_set_name
> Rename device_get_uuids to btd_device_get_uuids
> Rename adapter_get_address to btd_adapter_get_address
> Rename adapter_find_device to btd_adapter_find_device
> plugins: Add initial code for sixaxis plugin
> plugins/sixaxis: Add initial code for udev handling
> plugins/sixaxis: Add support for configuring new controllers
> device: Add device_discover_services function
> input: Add support for handling sixaxis devices
>
> Makefile.plugins | 8 ++
> bootstrap-configure | 1 +
> configure.ac | 5 +
> plugins/neard.c | 10 +-
> plugins/sixaxis.c | 286 ++++++++++++++++++++++++++++++++++++++++++
> plugins/wiimote.c | 2 +-
> profiles/audio/avctp.c | 18 +--
> profiles/audio/avdtp.c | 11 +-
> profiles/health/hdp.c | 10 +-
> profiles/health/hdp_util.c | 6 +-
> profiles/input/device.c | 4 +-
> profiles/input/manager.c | 4 +-
> profiles/input/server.c | 104 ++++++++++++++-
> profiles/network/connection.c | 2 +-
> profiles/network/server.c | 4 +-
> profiles/sap/server.c | 3 +-
> src/adapter.c | 74 ++++++-----
> src/adapter.h | 6 +-
> src/attrib-server.c | 6 +-
> src/bluetooth.ver | 2 +
> src/device.c | 70 +++++++----
> src/device.h | 10 +-
> src/profile.c | 14 +--
> 23 files changed, 551 insertions(+), 109 deletions(-)
> create mode 100644 plugins/sixaxis.c
This looked good enough to me, so all patches have been applied. Thanks.
I did apply one small patch on top of this though to make the include
statements consistent with the direction we're trying to push the tree
in.
Johan
^ permalink raw reply
* Re: Crasher during remote initiated pairing
From: Johan Hedberg @ 2013-11-27 9:06 UTC (permalink / raw)
To: Bastien Nocera; +Cc: linux-bluetooth
In-Reply-To: <1385398409.3423.25.camel@nuvo>
Hi Bastien,
On Mon, Nov 25, 2013, Bastien Nocera wrote:
> I have a particularly stubborn device, the TomTom Go Remote that tries
> to connect to my computer as soon as it's turned on, even when I've
> removed the pairing on the computer side.
>
> With GNOME's Bluetooth wizard open, I receive an out of the blue request
> for pairing, I pass it the expected PIN code (0000), I then find that
> the wizard doesn't work as I expected and turn it off. bluetoothd
> promptly crashes:
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007f0cf9ffde24 in agent_auth_cb (agent=<optimized out>, derr=0x7fffab655920, user_data=0x7f0cfb2e0020) at src/adapter.c:4370
> 4370 struct service_auth *auth = adapter->auths->head->data;
> (gdb) p adapter
> $1 = (struct btd_adapter *) 0x7f0cfb2e0020
> (gdb) p adapter->auths
> $2 = (GQueue *) 0x7f0cfb2d1240
> (gdb) p adapter->auths->head
> $3 = 0x0
>
> Some missing NULL checks?
>
> I imagine that this should be reproduceable using simple-agent and
> making it exit after replying to RequestPinCode.
The agent_auth_cb is actually not used for pairing but for
authorization, so whether it's RequestPinCode or RequestPasskey wont
matter for the above backtrace. Anyway, I was never able to reproduce
the exact same issue as you had, but I did find two places needing some
extra checks (one in adapter.c and another in agent.c). So it'd be good
if you could give the latest git a spin and see if you can still
reproduce the crash.
Johan
^ permalink raw reply
* Re: [PATCH 3/6] android/socket: Handle Android events for server socket
From: Johan Hedberg @ 2013-11-27 9:03 UTC (permalink / raw)
To: Andrei Emeltchenko, linux-bluetooth
In-Reply-To: <20131127082942.GD3149@aemeltch-MOBL1>
Hi Andrei,
On Wed, Nov 27, 2013, Andrei Emeltchenko wrote:
> > > I assume this would be primary used to clean up socket structure if
> > > Android decides to stop listen().
> >
> > Which HAL method would "stop listen()" be done with? I don't see such a
> > method in the HAL (please correct me if I'm wrong though). If there's no
> > such method it's not possible to stop the listening socket, and hence
> > you're just adding dead code here.
>
> This is listening on socketpair descriptor, the other end was sent to
> Android framework. So we might get some signal or socket close.
You'll need to explain in more detail how this could happen. We should
already have other places looking for the HAL-side going a way (e.g. if
it crashes) and then calling the necessary cleanup functions.
Johan
^ permalink raw reply
* Re: [PATCH 3/6] android/socket: Handle Android events for server socket
From: Andrei Emeltchenko @ 2013-11-27 8:29 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <20131127082128.GA23732@x220.p-661hnu-f1>
On Wed, Nov 27, 2013 at 10:21:28AM +0200, Johan Hedberg wrote:
> Hi Andrei,
>
> On Wed, Nov 27, 2013, Andrei Emeltchenko wrote:
> > On Tue, Nov 26, 2013 at 05:46:02PM +0200, Johan Hedberg wrote:
> > > Hi Andrei,
> > >
> > > On Tue, Nov 26, 2013, Andrei Emeltchenko wrote:
> > > > Add watch for tracking events from Android framework for server socket.
> > > > ---
> > > > android/socket.c | 27 ++++++++++++++++++++++++++-
> > > > 1 file changed, 26 insertions(+), 1 deletion(-)
> > >
> > > I've applied the first two patches, but wanted to ask about this one:
> > >
> > > > +static gboolean sock_server_stack_event_cb(GIOChannel *io, GIOCondition cond,
> > > > + gpointer data)
> > > > +{
> > > > + struct rfcomm_sock *rfsock = data;
> > > > +
> > > > + DBG("");
> > > > +
> > > > + if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) {
> > > > + error("Socket error: sock %d cond %d",
> > > > + g_io_channel_unix_get_fd(io), cond);
> > > > + cleanup_rfsock(rfsock);
> > > > +
> > > > + return FALSE;
> > > > + }
> > > > +
> > > > + return TRUE;
> > > > +}
> > >
> > > I don't see where (in which patch) you'd add code to handle G_IO_IN on
> > > this socket. Aren't you supposed to read data from this socket and write
> > > it to the RFCOMM one?
> >
> > At this moment I do not know which data might come from this socket. I
> > have debug statement to know that something is coming.
>
> The fact that you're adding G_IO_IN as one of the conditions for the
> callback tells the reader that you're interested in data. Then, when the
> reader looks at the function implementation he thinks "wait a minute, it
> looks like there's a bug here since this is never reading anything". The
> debug statement wont help you since then you'll end up in an endless
> loop if there ever is data (since the data gets never removed from the
> incoming socket buffer). So I'd just remove G_IO_IN from the conditions.
>
OK
> > I assume this would be primary used to clean up socket structure if
> > Android decides to stop listen().
>
> Which HAL method would "stop listen()" be done with? I don't see such a
> method in the HAL (please correct me if I'm wrong though). If there's no
> such method it's not possible to stop the listening socket, and hence
> you're just adding dead code here.
This is listening on socketpair descriptor, the other end was sent to
Android framework. So we might get some signal or socket close.
Best regards
Andrei Emeltchenko
^ permalink raw reply
* Re: [PATCH 3/6] android/socket: Handle Android events for server socket
From: Johan Hedberg @ 2013-11-27 8:21 UTC (permalink / raw)
To: Andrei Emeltchenko, linux-bluetooth
In-Reply-To: <20131127080051.GC3149@aemeltch-MOBL1>
Hi Andrei,
On Wed, Nov 27, 2013, Andrei Emeltchenko wrote:
> On Tue, Nov 26, 2013 at 05:46:02PM +0200, Johan Hedberg wrote:
> > Hi Andrei,
> >
> > On Tue, Nov 26, 2013, Andrei Emeltchenko wrote:
> > > Add watch for tracking events from Android framework for server socket.
> > > ---
> > > android/socket.c | 27 ++++++++++++++++++++++++++-
> > > 1 file changed, 26 insertions(+), 1 deletion(-)
> >
> > I've applied the first two patches, but wanted to ask about this one:
> >
> > > +static gboolean sock_server_stack_event_cb(GIOChannel *io, GIOCondition cond,
> > > + gpointer data)
> > > +{
> > > + struct rfcomm_sock *rfsock = data;
> > > +
> > > + DBG("");
> > > +
> > > + if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) {
> > > + error("Socket error: sock %d cond %d",
> > > + g_io_channel_unix_get_fd(io), cond);
> > > + cleanup_rfsock(rfsock);
> > > +
> > > + return FALSE;
> > > + }
> > > +
> > > + return TRUE;
> > > +}
> >
> > I don't see where (in which patch) you'd add code to handle G_IO_IN on
> > this socket. Aren't you supposed to read data from this socket and write
> > it to the RFCOMM one?
>
> At this moment I do not know which data might come from this socket. I
> have debug statement to know that something is coming.
The fact that you're adding G_IO_IN as one of the conditions for the
callback tells the reader that you're interested in data. Then, when the
reader looks at the function implementation he thinks "wait a minute, it
looks like there's a bug here since this is never reading anything". The
debug statement wont help you since then you'll end up in an endless
loop if there ever is data (since the data gets never removed from the
incoming socket buffer). So I'd just remove G_IO_IN from the conditions.
> I assume this would be primary used to clean up socket structure if
> Android decides to stop listen().
Which HAL method would "stop listen()" be done with? I don't see such a
method in the HAL (please correct me if I'm wrong though). If there's no
such method it's not possible to stop the listening socket, and hence
you're just adding dead code here.
Johan
^ permalink raw reply
* Re: [PATCH 3/6] android/socket: Handle Android events for server socket
From: Andrei Emeltchenko @ 2013-11-27 8:00 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <20131126154602.GB25005@x220.p-661hnu-f1>
Hi Johan,
On Tue, Nov 26, 2013 at 05:46:02PM +0200, Johan Hedberg wrote:
> Hi Andrei,
>
> On Tue, Nov 26, 2013, Andrei Emeltchenko wrote:
> > Add watch for tracking events from Android framework for server socket.
> > ---
> > android/socket.c | 27 ++++++++++++++++++++++++++-
> > 1 file changed, 26 insertions(+), 1 deletion(-)
>
> I've applied the first two patches, but wanted to ask about this one:
>
> > +static gboolean sock_server_stack_event_cb(GIOChannel *io, GIOCondition cond,
> > + gpointer data)
> > +{
> > + struct rfcomm_sock *rfsock = data;
> > +
> > + DBG("");
> > +
> > + if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) {
> > + error("Socket error: sock %d cond %d",
> > + g_io_channel_unix_get_fd(io), cond);
> > + cleanup_rfsock(rfsock);
> > +
> > + return FALSE;
> > + }
> > +
> > + return TRUE;
> > +}
>
> I don't see where (in which patch) you'd add code to handle G_IO_IN on
> this socket. Aren't you supposed to read data from this socket and write
> it to the RFCOMM one?
At this moment I do not know which data might come from this socket. I
have debug statement to know that something is coming.
I assume this would be primary used to clean up socket structure if
Android decides to stop listen().
Best regards
Andrei Emeltchenko
^ permalink raw reply
* Loading ath3k firmware failed
From: AceLan Kao @ 2013-11-27 3:40 UTC (permalink / raw)
To: Marcel Holtmann, Gustavo Padovan, Johan Hedberg, linux-bluetooth,
Chen Chong, Peng Chen
Cc: Anthony Wong, YK
Hi all,
Sorry to spam you guys.
I recently encountered a issue that I can't figure out how to fix it,
so I write to you and hope some of you can give me hints.
The issue is ath3k easily fails to load its firmware when the USB port
is switchable(EHCI -> XHCI).
ath3k: probe of 2-7:1.0 failed with error -110
Sometimes it fails to load the firmware when boot up, sometimes it
fails when resume from S3.
I try to set the D0 register to 0 to force it use EHCI, then it works well.
Disable the USB 3.0 function from BIOS, it also works well.
And another workaround is to delay loading the ath3k module around 30
seconds, it can load the firmware without problems.
It's not only happened on a certain Atheros chip, we've encountered
this issue on many Atheros chips.
To get rid of this issue, please give me some hints, I can help to
verify your ideas.
Best regards,
AceLan Kao.
^ permalink raw reply
* BT Handover Issue
From: Bruno Bruzzano @ 2013-11-26 22:26 UTC (permalink / raw)
To: sameo, linux-bluetooth@vger.kernel.org, linux-nfc
Hi Samuel,
When I try to send the BT Handover Message to pair my smartphone
(Nexus5), I encounter an issue.
My background is bluez upstream, neard upstream.
I did the following steps:
-run bluetooth -ndE
-run neard -nd '*'
-run ./simple-agent (with NoInputNoOutput capability)
-set power and poll the NFC Adapter
-put my device on top of the adapter ( -> neard recognizes the device,
creating the right deviceX interface)
-./test-device push /org/neard/nfc0/device0 Handover bluetooth
The procedure starts, but it stopped itself before to send the message
to the device.
Here, I made a pastebin of neard.
http://pastebin.com/XEqeucER
In addiction, here you can find other 2 pastbins about the messages I
receive when I do the push (typing './test-device push
/org/neard/nfc0/device0 .....')
http://pastebin.com/faai51ed
http://pastebin.com/N0jWnyXG
Another question: do you think it is possibile send the Handover
Message using the MIME type? I mean, typing: ./test-device push
/org/neard/nfc0/device3 MIME raw application/vnd.bluetooth.ep.oob
'lenghtOOB + device mac_address'
Please give me a feedback.
Thanks!
Bruno aka br1_21
^ permalink raw reply
* Re: [PATCH 3/6] android/socket: Handle Android events for server socket
From: Johan Hedberg @ 2013-11-26 15:46 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1385474750-18331-3-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Tue, Nov 26, 2013, Andrei Emeltchenko wrote:
> Add watch for tracking events from Android framework for server socket.
> ---
> android/socket.c | 27 ++++++++++++++++++++++++++-
> 1 file changed, 26 insertions(+), 1 deletion(-)
I've applied the first two patches, but wanted to ask about this one:
> +static gboolean sock_server_stack_event_cb(GIOChannel *io, GIOCondition cond,
> + gpointer data)
> +{
> + struct rfcomm_sock *rfsock = data;
> +
> + DBG("");
> +
> + if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) {
> + error("Socket error: sock %d cond %d",
> + g_io_channel_unix_get_fd(io), cond);
> + cleanup_rfsock(rfsock);
> +
> + return FALSE;
> + }
> +
> + return TRUE;
> +}
I don't see where (in which patch) you'd add code to handle G_IO_IN on
this socket. Aren't you supposed to read data from this socket and write
it to the RFCOMM one?
Johan
^ permalink raw reply
* Re: [PATCH 1/2] android/haltest: trivial: Fix typo channle -> channel
From: Johan Hedberg @ 2013-11-26 15:43 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1385473625-14266-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Tue, Nov 26, 2013, Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> ---
> android/client/if-sock.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Both patches have been applied. Thanks.
Johan
^ permalink raw reply
* [PATCH BlueZ 3/3] core/agent: Set first agent as default
From: Luiz Augusto von Dentz @ 2013-11-26 15:05 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385478310-22520-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This sets the first agent automatically as default so systems with a
single agent should never have to bother with RequestDefaultAgent.
---
src/agent.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/agent.c b/src/agent.c
index 7880ba6..aa8ba33 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -930,6 +930,9 @@ static DBusMessage *register_agent(DBusConnection *conn,
DBG("agent %s", agent->owner);
+ if (g_hash_table_size(agent_list) == 0)
+ set_default_agent(agent);
+
g_hash_table_replace(agent_list, agent->owner, agent);
return dbus_message_new_method_return(msg);
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ 2/3] client: Fix not releasing agent if bluetoothd exit without calling Release
From: Luiz Augusto von Dentz @ 2013-11-26 15:05 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385478310-22520-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If AgentManager1 disappear the agent should auto release itself
otherwise next time AgentManager1 appears bluetoothctl wont register
the agent again.
---
client/agent.c | 26 ++++++++++++++++----------
client/main.c | 5 ++++-
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/client/agent.c b/client/agent.c
index 81526a1..f074d82 100644
--- a/client/agent.c
+++ b/client/agent.c
@@ -156,14 +156,11 @@ dbus_bool_t agent_input(DBusConnection *conn, const char *input)
return TRUE;
}
-static DBusMessage *release_agent(DBusConnection *conn,
- DBusMessage *msg, void *user_data)
+static void agent_release(DBusConnection *conn)
{
agent_registered = FALSE;
agent_capability = NULL;
- rl_printf("Agent released\n");
-
if (pending_message) {
dbus_message_unref(pending_message);
pending_message = NULL;
@@ -172,6 +169,14 @@ static DBusMessage *release_agent(DBusConnection *conn,
agent_release_prompt();
g_dbus_unregister_interface(conn, AGENT_PATH, AGENT_INTERFACE);
+}
+
+static DBusMessage *release_agent(DBusConnection *conn,
+ DBusMessage *msg, void *user_data)
+{
+ rl_printf("Agent released\n");
+
+ agent_release(conn);
return dbus_message_new_method_return(msg);
}
@@ -430,13 +435,8 @@ static void unregister_agent_reply(DBusMessage *message, void *user_data)
dbus_error_init(&error);
if (dbus_set_error_from_message(&error, message) == FALSE) {
- agent_registered = FALSE;
- agent_capability = NULL;
rl_printf("Agent unregistered\n");
-
- if (g_dbus_unregister_interface(conn, AGENT_PATH,
- AGENT_INTERFACE) == FALSE)
- rl_printf("Failed to unregister agent object\n");
+ agent_release(conn);
} else {
rl_printf("Failed to unregister agent: %s\n", error.name);
dbus_error_free(&error);
@@ -450,6 +450,12 @@ void agent_unregister(DBusConnection *conn, GDBusProxy *manager)
return;
}
+ if (!manager) {
+ rl_printf("Agent unregistered\n");
+ agent_release(conn);
+ return;
+ }
+
if (g_dbus_proxy_method_call(manager, "UnregisterAgent",
unregister_agent_setup,
unregister_agent_reply,
diff --git a/client/main.c b/client/main.c
index 5639f0e..fe5f290 100644
--- a/client/main.c
+++ b/client/main.c
@@ -319,8 +319,11 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data)
dev_list = NULL;
}
} else if (!strcmp(interface, "org.bluez.AgentManager1")) {
- if (agent_manager == proxy)
+ if (agent_manager == proxy) {
agent_manager = NULL;
+ if (agent_capability)
+ agent_unregister(dbus_conn, NULL);
+ }
}
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ 1/3] client: Add 'auto' parameter to agent command
From: Luiz Augusto von Dentz @ 2013-11-26 15:05 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds 'auto' parameter to agent command which auto accepts requests
whenever possible.
---
client/agent.c | 14 +++++++++++++-
client/agent.h | 2 +-
client/main.c | 30 ++++++++++++++++++------------
3 files changed, 32 insertions(+), 14 deletions(-)
diff --git a/client/agent.c b/client/agent.c
index 2d9dffd..81526a1 100644
--- a/client/agent.c
+++ b/client/agent.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <readline/readline.h>
#include <gdbus.h>
@@ -40,6 +41,7 @@
static gboolean agent_registered = FALSE;
static const char *agent_capability = NULL;
+static bool agent_auto_accept = false;
static DBusMessage *pending_message = NULL;
static char *agent_saved_prompt = NULL;
static int agent_saved_point = 0;
@@ -259,6 +261,9 @@ static DBusMessage *request_confirmation(DBusConnection *conn,
dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &device,
DBUS_TYPE_UINT32, &passkey, DBUS_TYPE_INVALID);
+ if (agent_auto_accept)
+ return dbus_message_new_method_return(msg);
+
str = g_strdup_printf("Confirm passkey %06u (yes/no): ", passkey);
agent_prompt(str);
g_free(str);
@@ -278,6 +283,9 @@ static DBusMessage *request_authorization(DBusConnection *conn,
dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &device,
DBUS_TYPE_INVALID);
+ if (agent_auto_accept)
+ return dbus_message_new_method_return(msg);
+
agent_prompt("Accept pairing (yes/no): ");
pending_message = dbus_message_ref(msg);
@@ -296,6 +304,9 @@ static DBusMessage *authorize_service(DBusConnection *conn,
dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &device,
DBUS_TYPE_STRING, &uuid, DBUS_TYPE_INVALID);
+ if (agent_auto_accept)
+ return dbus_message_new_method_return(msg);
+
str = g_strdup_printf("Authorize service %s (yes/no): ", uuid);
agent_prompt(str);
g_free(str);
@@ -375,7 +386,7 @@ static void register_agent_reply(DBusMessage *message, void *user_data)
}
void agent_register(DBusConnection *conn, GDBusProxy *manager,
- const char *capability)
+ const char *capability, bool auto_accept)
{
if (agent_registered == TRUE) {
@@ -401,6 +412,7 @@ void agent_register(DBusConnection *conn, GDBusProxy *manager,
}
agent_capability = NULL;
+ agent_auto_accept = auto_accept;
}
static void unregister_agent_setup(DBusMessageIter *iter, void *user_data)
diff --git a/client/agent.h b/client/agent.h
index 0fbe8e5..467afb0 100644
--- a/client/agent.h
+++ b/client/agent.h
@@ -22,7 +22,7 @@
*/
void agent_register(DBusConnection *conn, GDBusProxy *manager,
- const char *capability);
+ const char *capability, bool auto_accept);
void agent_unregister(DBusConnection *conn, GDBusProxy *manager);
void agent_default(DBusConnection *conn, GDBusProxy *manager);
diff --git a/client/main.c b/client/main.c
index ebc85c6..5639f0e 100644
--- a/client/main.c
+++ b/client/main.c
@@ -29,6 +29,7 @@
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <signal.h>
#include <sys/signalfd.h>
@@ -53,13 +54,15 @@ static GMainLoop *main_loop;
static DBusConnection *dbus_conn;
static GDBusProxy *agent_manager;
-static char *auto_register_agent = NULL;
+static char *agent_capability = NULL;
+static bool agent_auto_accept = false;
static GDBusProxy *default_ctrl;
static GList *ctrl_list;
static GList *dev_list;
static const char * const agent_arguments[] = {
+ "auto",
"on",
"off",
"DisplayOnly",
@@ -284,9 +287,10 @@ static void proxy_added(GDBusProxy *proxy, void *user_data)
if (!agent_manager) {
agent_manager = proxy;
- if (auto_register_agent)
+ if (agent_capability)
agent_register(dbus_conn, agent_manager,
- auto_register_agent);
+ agent_capability,
+ agent_auto_accept);
}
}
}
@@ -434,7 +438,8 @@ static gboolean parse_argument_agent(const char *arg, dbus_bool_t *value,
return FALSE;
}
- if (strcmp(arg, "on") == 0 || strcmp(arg, "yes") == 0) {
+ if (strcmp(arg, "on") == 0 || strcmp(arg, "yes") == 0 ||
+ strcmp(arg, "auto") == 0) {
*value = TRUE;
*capability = "";
return TRUE;
@@ -680,17 +685,18 @@ static void cmd_agent(const char *arg)
return;
if (enable == TRUE) {
- g_free(auto_register_agent);
- auto_register_agent = g_strdup(capability);
+ g_free(agent_capability);
+ agent_capability = g_strdup(capability);
+ agent_auto_accept = strcmp(arg, "auto") == 0 ? true : false;
if (agent_manager)
agent_register(dbus_conn, agent_manager,
- auto_register_agent);
+ agent_capability, agent_auto_accept);
else
rl_printf("Agent registration enabled\n");
} else {
- g_free(auto_register_agent);
- auto_register_agent = NULL;
+ g_free(agent_capability);
+ agent_capability = NULL;
if (agent_manager)
agent_unregister(dbus_conn, agent_manager);
@@ -1331,9 +1337,9 @@ static gboolean parse_agent(const char *key, const char *value,
gpointer user_data, GError **error)
{
if (value)
- auto_register_agent = g_strdup(value);
+ agent_capability = g_strdup(value);
else
- auto_register_agent = g_strdup("");
+ agent_capability = g_strdup("");
return TRUE;
}
@@ -1410,7 +1416,7 @@ int main(int argc, char *argv[])
g_list_free_full(ctrl_list, proxy_leak);
g_list_free_full(dev_list, proxy_leak);
- g_free(auto_register_agent);
+ g_free(agent_capability);
return 0;
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH 6/6] android: Do not dereference possible NULL pointer
From: Andrei Emeltchenko @ 2013-11-26 14:05 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385474750-18331-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
eir might be NULL, do not derefernce it in debug and print instead
pointer.
---
android/bluetooth.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index aa684bd..77ce519 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -916,8 +916,8 @@ static void mgmt_device_found_event(uint16_t index, uint16_t length,
flags = btohl(ev->flags);
ba2str(&ev->addr.bdaddr, addr);
- DBG("hci%u addr %s, rssi %d flags 0x%04x eir_len %u eir %u",
- index, addr, ev->rssi, flags, eir_len, *eir);
+ DBG("hci%u addr %s, rssi %d flags 0x%04x eir_len %u eir %p",
+ index, addr, ev->rssi, flags, eir_len, eir);
confirm_name = flags & MGMT_DEV_FOUND_CONFIRM_NAME;
--
1.8.3.2
^ permalink raw reply related
* [PATCH 5/6] android/hal-sock: Check uuid before dereference
From: Andrei Emeltchenko @ 2013-11-26 14:05 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385474750-18331-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
uuid might be NULL and channel might be specified which makes it
valid case for Android. This adds check for uuid and service name.
---
android/hal-sock.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/android/hal-sock.c b/android/hal-sock.c
index e02a49a..f45be30 100644
--- a/android/hal-sock.c
+++ b/android/hal-sock.c
@@ -34,12 +34,17 @@ static bt_status_t sock_listen_rfcomm(const char *service_name,
DBG("");
+ memset(&cmd, 0, sizeof(cmd));
+
cmd.flags = flags;
cmd.type = BTSOCK_RFCOMM;
cmd.channel = chan;
- memcpy(cmd.uuid, uuid, sizeof(cmd.uuid));
- memset(cmd.name, 0, sizeof(cmd.name));
- memcpy(cmd.name, service_name, strlen(service_name));
+
+ if (uuid)
+ memcpy(cmd.uuid, uuid, sizeof(cmd.uuid));
+
+ if (service_name)
+ memcpy(cmd.name, service_name, strlen(service_name));
return hal_ipc_cmd(HAL_SERVICE_ID_SOCK, HAL_OP_SOCK_LISTEN,
sizeof(cmd), &cmd, NULL, NULL, sock);
@@ -90,10 +95,15 @@ static bt_status_t sock_connect(const bt_bdaddr_t *bdaddr, btsock_type_t type,
return BT_STATUS_UNSUPPORTED;
}
+ memset(&cmd, 0, sizeof(cmd));
+
cmd.flags = flags;
cmd.type = type;
cmd.channel = chan;
- memcpy(cmd.uuid, uuid, sizeof(cmd.uuid));
+
+ if (uuid)
+ memcpy(cmd.uuid, uuid, sizeof(cmd.uuid));
+
memcpy(cmd.bdaddr, bdaddr, sizeof(cmd.bdaddr));
return hal_ipc_cmd(HAL_SERVICE_ID_SOCK, HAL_OP_SOCK_CONNECT,
--
1.8.3.2
^ permalink raw reply related
* [PATCH 4/6] android/socket: Check create_rfsock returns valid structure
From: Andrei Emeltchenko @ 2013-11-26 14:05 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385474750-18331-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/socket.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/android/socket.c b/android/socket.c
index c4f14ab..772afaa 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -638,6 +638,11 @@ static void accept_cb(GIOChannel *io, GError *err, gpointer user_data)
sock_acc = g_io_channel_unix_get_fd(io);
rfsock_acc = create_rfsock(sock_acc, &hal_fd);
+ if (!rfsock_acc) {
+ g_io_channel_shutdown(io, TRUE, NULL);
+ return;
+ }
+
connections = g_list_append(connections, rfsock_acc);
DBG("rfsock: fd %d real_sock %d chan %u sock %d",
@@ -898,8 +903,11 @@ static int handle_connect(void *buf)
DBG("");
- android2bdaddr(cmd->bdaddr, &dst);
rfsock = create_rfsock(-1, &hal_fd);
+ if (!rfsock)
+ return -1;
+
+ android2bdaddr(cmd->bdaddr, &dst);
bacpy(&rfsock->dst, &dst);
memset(&uuid, 0, sizeof(uuid));
--
1.8.3.2
^ permalink raw reply related
* [PATCH 3/6] android/socket: Handle Android events for server socket
From: Andrei Emeltchenko @ 2013-11-26 14:05 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385474750-18331-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Add watch for tracking events from Android framework for server socket.
---
android/socket.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/android/socket.c b/android/socket.c
index 20dbc5e..c4f14ab 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -587,6 +587,24 @@ static bool sock_send_accept(struct rfcomm_sock *rfsock, bdaddr_t *bdaddr,
return true;
}
+static gboolean sock_server_stack_event_cb(GIOChannel *io, GIOCondition cond,
+ gpointer data)
+{
+ struct rfcomm_sock *rfsock = data;
+
+ DBG("");
+
+ if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) {
+ error("Socket error: sock %d cond %d",
+ g_io_channel_unix_get_fd(io), cond);
+ cleanup_rfsock(rfsock);
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static void accept_cb(GIOChannel *io, GError *err, gpointer user_data)
{
struct rfcomm_sock *rfsock = user_data;
@@ -656,7 +674,8 @@ static int handle_listen(void *buf)
const struct profile_info *profile;
struct rfcomm_sock *rfsock;
BtIOSecLevel sec_level;
- GIOChannel *io;
+ GIOChannel *io, *io_stack;
+ GIOCondition cond;
GError *err = NULL;
int hal_fd;
int chan;
@@ -701,6 +720,12 @@ static int handle_listen(void *buf)
g_io_channel_set_close_on_unref(io, TRUE);
g_io_channel_unref(io);
+ /* Handle events from Android */
+ cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
+ io_stack = g_io_channel_unix_new(rfsock->fd);
+ g_io_add_watch(io_stack, cond, sock_server_stack_event_cb, rfsock);
+ g_io_channel_unref(io_stack);
+
DBG("real_sock %d fd %d hal_fd %d", rfsock->real_sock, rfsock->fd,
hal_fd);
--
1.8.3.2
^ permalink raw reply related
* [PATCH 2/6] android/socket: Use security level for connect / listen
From: Andrei Emeltchenko @ 2013-11-26 14:05 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385474750-18331-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Use MEDIUM security level for connections without profile and default
sec_level for others. rfsock now has pointer to profile info.
---
android/socket.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/android/socket.c b/android/socket.c
index 184deae..20dbc5e 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -70,6 +70,8 @@ struct rfcomm_sock {
bdaddr_t dst;
uint32_t service_handle;
+
+ const struct profile_info *profile;
};
static struct rfcomm_sock *create_rfsock(int sock, int *hal_fd)
@@ -667,7 +669,7 @@ static int handle_listen(void *buf)
return -1;
else {
chan = cmd->channel;
- sec_level = BT_IO_SEC_LOW;
+ sec_level = BT_IO_SEC_MEDIUM;
}
} else {
chan = profile->channel;
@@ -786,6 +788,7 @@ fail:
static void sdp_search_cb(sdp_list_t *recs, int err, gpointer data)
{
struct rfcomm_sock *rfsock = data;
+ BtIOSecLevel sec_level = BT_IO_SEC_MEDIUM;
GError *gerr = NULL;
sdp_list_t *list;
GIOChannel *io;
@@ -829,11 +832,14 @@ static void sdp_search_cb(sdp_list_t *recs, int err, gpointer data)
DBG("Got RFCOMM channel %d", chan);
+ if (rfsock->profile)
+ sec_level = rfsock->profile->sec_level;
+
io = bt_io_connect(connect_cb, rfsock, NULL, &gerr,
BT_IO_OPT_SOURCE_BDADDR, &adapter_addr,
BT_IO_OPT_DEST_BDADDR, &rfsock->dst,
BT_IO_OPT_CHANNEL, chan,
- BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
+ BT_IO_OPT_SEC_LEVEL, sec_level,
BT_IO_OPT_INVALID);
if (!io) {
error("Failed connect: %s", gerr->message);
@@ -875,6 +881,8 @@ static int handle_connect(void *buf)
uuid.type = SDP_UUID128;
memcpy(&uuid.value.uuid128, cmd->uuid, sizeof(uint128_t));
+ rfsock->profile = get_profile_by_uuid(cmd->uuid);
+
if (bt_search_service(&adapter_addr, &dst, &uuid, sdp_search_cb, rfsock,
NULL) < 0) {
error("Failed to search SDP records");
--
1.8.3.2
^ permalink raw reply related
* [PATCH 1/6] android/socket: Make profile struct const
From: Andrei Emeltchenko @ 2013-11-26 14:05 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
We are not supposed to change profile structure, make it const.
---
android/socket.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/android/socket.c b/android/socket.c
index 83e6996..184deae 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -335,7 +335,7 @@ static sdp_record_t *create_spp_record(uint8_t chan, const char *svc_name)
return record;
}
-static struct profile_info {
+static const struct profile_info {
uint8_t uuid[16];
uint8_t channel;
uint8_t svc_hint;
@@ -381,7 +381,7 @@ static struct profile_info {
},
};
-static uint32_t sdp_service_register(struct profile_info *profile,
+static uint32_t sdp_service_register(const struct profile_info *profile,
const void *svc_name)
{
sdp_record_t *record;
@@ -444,7 +444,7 @@ static int bt_sock_send_fd(int sock_fd, const void *buf, int len, int send_fd)
return ret;
}
-static struct profile_info *get_profile_by_uuid(const uint8_t *uuid)
+static const struct profile_info *get_profile_by_uuid(const uint8_t *uuid)
{
unsigned int i;
@@ -651,7 +651,7 @@ static void accept_cb(GIOChannel *io, GError *err, gpointer user_data)
static int handle_listen(void *buf)
{
struct hal_cmd_sock_listen *cmd = buf;
- struct profile_info *profile;
+ const struct profile_info *profile;
struct rfcomm_sock *rfsock;
BtIOSecLevel sec_level;
GIOChannel *io;
--
1.8.3.2
^ permalink raw reply related
* [PATCH 2/2] android/haltest: Add uuid autocompletions
From: Andrei Emeltchenko @ 2013-11-26 13:47 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385473625-14266-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/client/if-sock.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/android/client/if-sock.c b/android/client/if-sock.c
index 12ac755..5394a5d 100644
--- a/android/client/if-sock.c
+++ b/android/client/if-sock.c
@@ -35,6 +35,10 @@ ENDMAP
static int listen_fd[MAX_LISTEN_FD];
static int listen_fd_count;
+static const char * const uuids[] = {
+ "00001101", "00001105", "0000112f", NULL
+};
+
/*
* This function reads data from file descriptor and
* prints it to the user
@@ -193,6 +197,9 @@ static void listen_c(int argc, const char **argv, enum_func *enum_func,
if (argc == 3) {
*user = TYPE_ENUM(btsock_type_t);
*enum_func = enum_defines;
+ } else if (argc == 5) {
+ *user = (void *) uuids;
+ *enum_func = enum_strings;
}
}
@@ -264,6 +271,9 @@ static void connect_c(int argc, const char **argv, enum_func *enum_func,
} else if (argc == 4) {
*user = TYPE_ENUM(btsock_type_t);
*enum_func = enum_defines;
+ } else if (argc == 5) {
+ *user = (void *) uuids;
+ *enum_func = enum_strings;
}
}
--
1.8.3.2
^ permalink raw reply related
* [PATCH 1/2] android/haltest: trivial: Fix typo channle -> channel
From: Andrei Emeltchenko @ 2013-11-26 13:47 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/client/if-sock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/android/client/if-sock.c b/android/client/if-sock.c
index eef9a76..12ac755 100644
--- a/android/client/if-sock.c
+++ b/android/client/if-sock.c
@@ -328,9 +328,9 @@ static void connect_p(int argc, const char **argv)
/* Methods available in btsock_interface_t */
static struct method methods[] = {
STD_METHODCH(listen,
- "<sock_type> <srvc_name> <uuid> [<channle>] [<flags>]"),
+ "<sock_type> <srvc_name> <uuid> [<channel>] [<flags>]"),
STD_METHODCH(connect,
- "<addr> <sock_type> <uuid> <channle> [<flags>]"),
+ "<addr> <sock_type> <uuid> <channel> [<flags>]"),
END_METHOD
};
--
1.8.3.2
^ permalink raw reply related
* Re: [PATCH v2 00/20] Initial AVDTP for Android
From: Luiz Augusto von Dentz @ 2013-11-26 13:46 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
In-Reply-To: <1385391283-10962-1-git-send-email-luiz.dentz@gmail.com>
Hi,
On Mon, Nov 25, 2013 at 4:54 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> The code is based on the current implementation available in
> profiles/audio/avdtp.{c,h} but it is transport agnostic and does not
> contain any external dependency except glib for IO handling.
>
> Both the signaling and the transport connection has to be handled by
> the upper layer, that is why it is not modified in place to avoid
> breaking current implemention until this work is considered stable.
>
> Two new function are added:
>
> - avdtp_new: Creates AVDTP session and attach signaling transport
> - avdtp_stream_set_transport: Set stream transport
>
> Both receives a fd as parameter so in future it should be possible to
> replace the IO handling.
>
> This set also includes a initial test set based on the current AVDTP
> test specification, once merged more tests will be added as well,
> then the intent is to make this used by audio plugin.
>
> Note: It is possible to track back to the original code by doing:
> git log --follow or git blame -C -C.
>
> v2: Add a separate commit to copy existing AVDTP files
>
> Luiz Augusto von Dentz (20):
> android: Add copy of current AVDTP implemention
> android/AVDTP: Strip dependencies
> unit/AVDTP: Add /TP/SIG/SMG/BV-05-C test
> unit/AVDTP: Add /TP/SIG/SMG/BV-06-C test
> unit/AVDTP: Add /TP/SIG/SMG/BV-07-C test
> unit/AVDTP: Add /TP/SIG/SMG/BV-08-C test
> unit/AVDTP: Add /TP/SIG/SMG/BV-09-C test
> unit/AVDTP: Add /TP/SIG/SMG/BV-10-C test
> unit/AVDTP: Add /TP/SIG/SMG/BV-11-C test
> unit/AVDTP: Add /TP/SIG/SMG/BV-12-C test
> unit/AVDTP: Add /TP/SIG/SMG/BV-15-C test
> unit/AVDTP: Add /TP/SIG/SMG/BV-16-C test
> unit/AVDTP: Add /TP/SIG/SMG/BV-17-C test
> unit/AVDTP: Add /TP/SIG/SMG/BV-18-C test
> unit/AVDTP: Add /TP/SIG/SMG/BV-19-C test
> unit/AVDTP: Add /TP/SIG/SMG/BV-20-C test
> unit/AVDTP: Add /TP/SIG/SMG/BV-21-C test
> unit/AVDTP: Add /TP/SIG/SMG/BV-22-C test
> unit/AVDTP: Add /TP/SIG/SMG/BV-23-C test
> unit/AVDTP: Add /TP/SIG/SMG/BV-24-C test
>
> Makefile.am | 8 +
> android/Makefile.am | 1 +
> android/a2dp.c | 23 +
> android/avdtp.c | 3256 +++++++++++++++++++++++++++++++++++++++++++++++++++
> android/avdtp.h | 275 +++++
> unit/test-avdtp.c | 612 ++++++++++
> 6 files changed, 4175 insertions(+)
> create mode 100644 android/avdtp.c
> create mode 100644 android/avdtp.h
> create mode 100644 unit/test-avdtp.c
>
> --
> 1.8.3.1
This set is now upstream.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: Crasher during remote initiated pairing
From: Johan Hedberg @ 2013-11-26 13:43 UTC (permalink / raw)
To: Bastien Nocera, linux-bluetooth
In-Reply-To: <20131126133427.GA19614@x220.p-661hnu-f1>
Hi Bastien,
On Tue, Nov 26, 2013, Johan Hedberg wrote:
> On Mon, Nov 25, 2013, Bastien Nocera wrote:
> > Heya,
> >
> > I have a particularly stubborn device, the TomTom Go Remote that tries
> > to connect to my computer as soon as it's turned on, even when I've
> > removed the pairing on the computer side.
> >
> > With GNOME's Bluetooth wizard open, I receive an out of the blue request
> > for pairing, I pass it the expected PIN code (0000), I then find that
> > the wizard doesn't work as I expected and turn it off. bluetoothd
> > promptly crashes:
> >
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x00007f0cf9ffde24 in agent_auth_cb (agent=<optimized out>, derr=0x7fffab655920, user_data=0x7f0cfb2e0020) at src/adapter.c:4370
> > 4370 struct service_auth *auth = adapter->auths->head->data;
> > (gdb) p adapter
> > $1 = (struct btd_adapter *) 0x7f0cfb2e0020
> > (gdb) p adapter->auths
> > $2 = (GQueue *) 0x7f0cfb2d1240
> > (gdb) p adapter->auths->head
> > $3 = 0x0
> >
> > Some missing NULL checks?
>
> Not sure. The GQueue internals should not be of our concern, meaning if
> we have a non-NULL GQueue pointer I'd expect it to be safe to call
> g_queue_is_empty on that pointer. I wonder if this is some kind of
> freed memory access or similar. valgrind might show this.
Just ignore the above, I was following the exact line number in the
trace (4370) which landed me in process_auth_queue() instead of
agent_auth_cb(), i.e. I was looking at the wrong piece of code and
making the wrong conclusions.
Johan
^ permalink raw reply
* Re: Crasher during remote initiated pairing
From: Johan Hedberg @ 2013-11-26 13:34 UTC (permalink / raw)
To: Bastien Nocera; +Cc: linux-bluetooth
In-Reply-To: <1385398409.3423.25.camel@nuvo>
Hi Bastien,
On Mon, Nov 25, 2013, Bastien Nocera wrote:
> Heya,
>
> I have a particularly stubborn device, the TomTom Go Remote that tries
> to connect to my computer as soon as it's turned on, even when I've
> removed the pairing on the computer side.
>
> With GNOME's Bluetooth wizard open, I receive an out of the blue request
> for pairing, I pass it the expected PIN code (0000), I then find that
> the wizard doesn't work as I expected and turn it off. bluetoothd
> promptly crashes:
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007f0cf9ffde24 in agent_auth_cb (agent=<optimized out>, derr=0x7fffab655920, user_data=0x7f0cfb2e0020) at src/adapter.c:4370
> 4370 struct service_auth *auth = adapter->auths->head->data;
> (gdb) p adapter
> $1 = (struct btd_adapter *) 0x7f0cfb2e0020
> (gdb) p adapter->auths
> $2 = (GQueue *) 0x7f0cfb2d1240
> (gdb) p adapter->auths->head
> $3 = 0x0
>
> Some missing NULL checks?
Not sure. The GQueue internals should not be of our concern, meaning if
we have a non-NULL GQueue pointer I'd expect it to be safe to call
g_queue_is_empty on that pointer. I wonder if this is some kind of
freed memory access or similar. valgrind might show this.
Johan
^ permalink raw reply
* Re: [PATCH 1/4] android: Add CAP_NET_RAW capability
From: Ravi kumar Veeramally @ 2013-11-26 13:14 UTC (permalink / raw)
To: linux-bluetooth, johan.hedberg
In-Reply-To: <20131125142532.GA26309@x220.p-661hnu-f1>
Hi Johan,
On 25.11.2013 16:25, Johan Hedberg wrote:
> Hi Ravi,
>
> On Mon, Nov 25, 2013, Ravi kumar Veeramally wrote:
>> On 25.11.2013 16:01, Johan Hedberg wrote:
>>> Hi Ravi,
>>>
>>> On Mon, Nov 25, 2013, Ravi kumar Veeramally wrote:
>>>> CAP_NET_RAW capability is required to up the bnep interfaces
>>>> in android environment.
>>>> ---
>>>> android/main.c | 1 +
>>>> 1 file changed, 1 insertion(+)
>>>>
>>>> diff --git a/android/main.c b/android/main.c
>>>> index c9733f3..bfd2a87 100644
>>>> --- a/android/main.c
>>>> +++ b/android/main.c
>>>> @@ -506,6 +506,7 @@ static bool set_capabilities(void)
>>>> header.pid = 0;
>>>> cap.effective = cap.permitted =
>>>> + CAP_TO_MASK(CAP_NET_RAW) |
>>>> CAP_TO_MASK(CAP_NET_ADMIN) |
>>>> CAP_TO_MASK(CAP_NET_BIND_SERVICE);
>>>> cap.inheritable = 0;
>>> Would you then say that commit 9bda7e8c2130de9a3340ebd0e6cc1dedc2eae338
>>> is incorrect? A quick grep doesn't show any instances of checking this
>>> capability in the BNEP code of the kernel. Exactly which system call is
>>> it that needs it?
>> bnep_if_up from profiles/network/common.c
>> ---
>> ifr.ifr_flags |= IFF_UP;
>> ifr.ifr_flags |= IFF_MULTICAST;
>>
>> err = ioctl(sk, SIOCSIFFLAGS, (caddr_t) &ifr);
>> ---
>> requires this capability in android environment only.
>> this code is under android macro.
> So you've verified that under "normal" Linux this ioctl does not require
> the NET_RAW capability?
>
>>> If you answered positively to my first question, please send a patch for
>>> that as well.
>> I didn't understand this, sorry.
> My first question was: "Would you then say that
> commit 9bda7e8c2130de9a3340ebd0e6cc1dedc2eae338 is incorrect?". Do you
> not understand that question or what I asked you to do in case the
> answer is "yes"?
I tried on host with systemd configure options and limiting
capabilities to
only CAP_NET_ADMIN and CAP_NET_BIND_SERVICE. ioctl call for
interface(bnepX)
up works well. Android throws an error("Permission denied").
CAP_NET_RAW is required
for android.
Thanks,
Ravi.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox