linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ] profile: Fail RegisterProfile if UUID already exists
@ 2021-06-11  2:07 João Paulo Rechi Vita
  2021-06-11  2:43 ` [BlueZ] " bluez.test.bot
  2021-06-29 23:46 ` [PATCH BlueZ] " João Paulo Rechi Vita
  0 siblings, 2 replies; 5+ messages in thread
From: João Paulo Rechi Vita @ 2021-06-11  2:07 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: jprvita, jprvita, linux

From: João Paulo Rechi Vita <jprvita@gmail.com>

If a process tries to register a profile implementation that is already
registered, RegisterProfile should fail.

This should help address issues when two instances of PulseAudio are
running at the same time, and the second instance tries to register an
audio profile implementation that has already been registered by the
first instance. Two situations where this may happen is when more than
one user is logged in, or during the transition between the GDM session
and the user session, when PulseAudio gets started on the new session
before the old session has been fully terminated.

https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/303
https://gitlab.gnome.org/GNOME/gdm/-/issues/486
---
 src/profile.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/profile.c b/src/profile.c
index 5e460b639..60d17b6ae 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -749,6 +749,30 @@ void btd_profile_foreach(void (*func)(struct btd_profile *p, void *data),
 	}
 }
 
+static struct btd_profile *btd_profile_find_uuid(const char *uuid)
+{
+	GSList *l, *next;
+
+	for (l = profiles; l != NULL; l = next) {
+		struct btd_profile *p = l->data;
+
+		if (!g_strcmp0(p->local_uuid, uuid))
+			return p;
+		next = g_slist_next(l);
+	}
+
+	for (l = ext_profiles; l != NULL; l = next) {
+		struct ext_profile *ext = l->data;
+		struct btd_profile *p = &ext->p;
+
+		if (!g_strcmp0(p->local_uuid, uuid))
+			return p;
+		next = g_slist_next(l);
+	}
+
+	return NULL;
+}
+
 int btd_profile_register(struct btd_profile *profile)
 {
 	profiles = g_slist_append(profiles, profile);
@@ -2441,6 +2465,12 @@ static DBusMessage *register_profile(DBusConnection *conn,
 	dbus_message_iter_get_basic(&args, &uuid);
 	dbus_message_iter_next(&args);
 
+	if (btd_profile_find_uuid(uuid)) {
+		warn("%s tried to register %s which is already registered",
+								sender, uuid);
+		return btd_error_not_permitted(msg, "UUID already registered");
+	}
+
 	if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_ARRAY)
 		return btd_error_invalid_args(msg);
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [BlueZ] profile: Fail RegisterProfile if UUID already exists
  2021-06-11  2:07 [PATCH BlueZ] profile: Fail RegisterProfile if UUID already exists João Paulo Rechi Vita
@ 2021-06-11  2:43 ` bluez.test.bot
  2021-06-29 23:46 ` [PATCH BlueZ] " João Paulo Rechi Vita
  1 sibling, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2021-06-11  2:43 UTC (permalink / raw)
  To: linux-bluetooth, jprvita

[-- Attachment #1: Type: text/plain, Size: 1953 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=498503

---Test result---

Test Summary:
CheckPatch                    PASS      0.61 seconds
GitLint                       PASS      0.12 seconds
Prep - Setup ELL              PASS      46.43 seconds
Build - Prep                  PASS      0.14 seconds
Build - Configure             PASS      8.27 seconds
Build - Make                  PASS      204.57 seconds
Make Check                    PASS      9.18 seconds
Make Distcheck                PASS      233.55 seconds
Build w/ext ELL - Configure   PASS      8.01 seconds
Build w/ext ELL - Make        PASS      186.29 seconds

Details
##############################
Test: CheckPatch - PASS
Desc: Run checkpatch.pl script with rule in .checkpatch.conf

##############################
Test: GitLint - PASS
Desc: Run gitlint with rule in .gitlint

##############################
Test: Prep - Setup ELL - PASS
Desc: Clone, build, and install ELL

##############################
Test: Build - Prep - PASS
Desc: Prepare environment for build

##############################
Test: Build - Configure - PASS
Desc: Configure the BlueZ source tree

##############################
Test: Build - Make - PASS
Desc: Build the BlueZ source tree

##############################
Test: Make Check - PASS
Desc: Run 'make check'

##############################
Test: Make Distcheck - PASS
Desc: Run distcheck to check the distribution

##############################
Test: Build w/ext ELL - Configure - PASS
Desc: Configure BlueZ source with '--enable-external-ell' configuration

##############################
Test: Build w/ext ELL - Make - PASS
Desc: Build BlueZ source with '--enable-external-ell' configuration



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH BlueZ] profile: Fail RegisterProfile if UUID already exists
  2021-06-11  2:07 [PATCH BlueZ] profile: Fail RegisterProfile if UUID already exists João Paulo Rechi Vita
  2021-06-11  2:43 ` [BlueZ] " bluez.test.bot
@ 2021-06-29 23:46 ` João Paulo Rechi Vita
  2021-07-01 22:50   ` Luiz Augusto von Dentz
  1 sibling, 1 reply; 5+ messages in thread
From: João Paulo Rechi Vita @ 2021-06-29 23:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: João Paulo Rechi Vita, linux

On Thu, Jun 10, 2021 at 7:07 PM João Paulo Rechi Vita <jprvita@gmail.com> wrote:
>
> From: João Paulo Rechi Vita <jprvita@gmail.com>
>
> If a process tries to register a profile implementation that is already
> registered, RegisterProfile should fail.
>
> This should help address issues when two instances of PulseAudio are
> running at the same time, and the second instance tries to register an
> audio profile implementation that has already been registered by the
> first instance. Two situations where this may happen is when more than
> one user is logged in, or during the transition between the GDM session
> and the user session, when PulseAudio gets started on the new session
> before the old session has been fully terminated.
>
> https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/303
> https://gitlab.gnome.org/GNOME/gdm/-/issues/486

Any feedback on these changes?  I have
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/593
on the PulseAudio side, and we have been shipping these changes on
Endless OS to address the case where PulseAudio gets started on the
user session before PulseAudio on the GDM session has finished.

Thanks,

João Paulo.

> ---
>  src/profile.c | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
>
> diff --git a/src/profile.c b/src/profile.c
> index 5e460b639..60d17b6ae 100644
> --- a/src/profile.c
> +++ b/src/profile.c
> @@ -749,6 +749,30 @@ void btd_profile_foreach(void (*func)(struct btd_profile *p, void *data),
>         }
>  }
>
> +static struct btd_profile *btd_profile_find_uuid(const char *uuid)
> +{
> +       GSList *l, *next;
> +
> +       for (l = profiles; l != NULL; l = next) {
> +               struct btd_profile *p = l->data;
> +
> +               if (!g_strcmp0(p->local_uuid, uuid))
> +                       return p;
> +               next = g_slist_next(l);
> +       }
> +
> +       for (l = ext_profiles; l != NULL; l = next) {
> +               struct ext_profile *ext = l->data;
> +               struct btd_profile *p = &ext->p;
> +
> +               if (!g_strcmp0(p->local_uuid, uuid))
> +                       return p;
> +               next = g_slist_next(l);
> +       }
> +
> +       return NULL;
> +}
> +
>  int btd_profile_register(struct btd_profile *profile)
>  {
>         profiles = g_slist_append(profiles, profile);
> @@ -2441,6 +2465,12 @@ static DBusMessage *register_profile(DBusConnection *conn,
>         dbus_message_iter_get_basic(&args, &uuid);
>         dbus_message_iter_next(&args);
>
> +       if (btd_profile_find_uuid(uuid)) {
> +               warn("%s tried to register %s which is already registered",
> +                                                               sender, uuid);
> +               return btd_error_not_permitted(msg, "UUID already registered");
> +       }
> +
>         if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_ARRAY)
>                 return btd_error_invalid_args(msg);
>
> --
> 2.20.1
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH BlueZ] profile: Fail RegisterProfile if UUID already exists
  2021-06-29 23:46 ` [PATCH BlueZ] " João Paulo Rechi Vita
@ 2021-07-01 22:50   ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2021-07-01 22:50 UTC (permalink / raw)
  To: João Paulo Rechi Vita
  Cc: linux-bluetooth, João Paulo Rechi Vita, linux

Hi João,

On Tue, Jun 29, 2021 at 4:52 PM João Paulo Rechi Vita <jprvita@gmail.com> wrote:
>
> On Thu, Jun 10, 2021 at 7:07 PM João Paulo Rechi Vita <jprvita@gmail.com> wrote:
> >
> > From: João Paulo Rechi Vita <jprvita@gmail.com>
> >
> > If a process tries to register a profile implementation that is already
> > registered, RegisterProfile should fail.
> >
> > This should help address issues when two instances of PulseAudio are
> > running at the same time, and the second instance tries to register an
> > audio profile implementation that has already been registered by the
> > first instance. Two situations where this may happen is when more than
> > one user is logged in, or during the transition between the GDM session
> > and the user session, when PulseAudio gets started on the new session
> > before the old session has been fully terminated.
> >
> > https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/303
> > https://gitlab.gnome.org/GNOME/gdm/-/issues/486
>
> Any feedback on these changes?  I have
> https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/593
> on the PulseAudio side, and we have been shipping these changes on
> Endless OS to address the case where PulseAudio gets started on the
> user session before PulseAudio on the GDM session has finished.
>
> Thanks,
>
> João Paulo.
>
> > ---
> >  src/profile.c | 30 ++++++++++++++++++++++++++++++
> >  1 file changed, 30 insertions(+)
> >
> > diff --git a/src/profile.c b/src/profile.c
> > index 5e460b639..60d17b6ae 100644
> > --- a/src/profile.c
> > +++ b/src/profile.c
> > @@ -749,6 +749,30 @@ void btd_profile_foreach(void (*func)(struct btd_profile *p, void *data),
> >         }
> >  }
> >
> > +static struct btd_profile *btd_profile_find_uuid(const char *uuid)
> > +{
> > +       GSList *l, *next;
> > +
> > +       for (l = profiles; l != NULL; l = next) {
> > +               struct btd_profile *p = l->data;
> > +
> > +               if (!g_strcmp0(p->local_uuid, uuid))
> > +                       return p;
> > +               next = g_slist_next(l);
> > +       }
> > +
> > +       for (l = ext_profiles; l != NULL; l = next) {
> > +               struct ext_profile *ext = l->data;
> > +               struct btd_profile *p = &ext->p;
> > +
> > +               if (!g_strcmp0(p->local_uuid, uuid))
> > +                       return p;
> > +               next = g_slist_next(l);
> > +       }
> > +
> > +       return NULL;
> > +}
> > +
> >  int btd_profile_register(struct btd_profile *profile)
> >  {
> >         profiles = g_slist_append(profiles, profile);
> > @@ -2441,6 +2465,12 @@ static DBusMessage *register_profile(DBusConnection *conn,
> >         dbus_message_iter_get_basic(&args, &uuid);
> >         dbus_message_iter_next(&args);
> >
> > +       if (btd_profile_find_uuid(uuid)) {
> > +               warn("%s tried to register %s which is already registered",
> > +                                                               sender, uuid);
> > +               return btd_error_not_permitted(msg, "UUID already registered");
> > +       }
> > +
> >         if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_ARRAY)
> >                 return btd_error_invalid_args(msg);
> >
> > --
> > 2.20.1
> >

Applied, thanks.

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH BlueZ] profile: Fail RegisterProfile if UUID already exists
@ 2021-06-11  2:06 João Paulo Rechi Vita
  0 siblings, 0 replies; 5+ messages in thread
From: João Paulo Rechi Vita @ 2021-06-11  2:06 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: jprvita, jprvita

From: João Paulo Rechi Vita <jprvita@gmail.com>

If a process tries to register a profile implementation that is already
registered, RegisterProfile should fail.

This should help address issues when two instances of PulseAudio are
running at the same time, and the second instance tries to register an
audio profile implementation that has already been registered by the
first instance. Two situations where this may happen is when more than
one user is logged in, or during the transition between the GDM session
and the user session, when PulseAudio gets started on the new session
before the old session has been fully terminated.

https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/303
https://gitlab.gnome.org/GNOME/gdm/-/issues/486
---
 src/profile.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/profile.c b/src/profile.c
index 5e460b639..60d17b6ae 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -749,6 +749,30 @@ void btd_profile_foreach(void (*func)(struct btd_profile *p, void *data),
 	}
 }
 
+static struct btd_profile *btd_profile_find_uuid(const char *uuid)
+{
+	GSList *l, *next;
+
+	for (l = profiles; l != NULL; l = next) {
+		struct btd_profile *p = l->data;
+
+		if (!g_strcmp0(p->local_uuid, uuid))
+			return p;
+		next = g_slist_next(l);
+	}
+
+	for (l = ext_profiles; l != NULL; l = next) {
+		struct ext_profile *ext = l->data;
+		struct btd_profile *p = &ext->p;
+
+		if (!g_strcmp0(p->local_uuid, uuid))
+			return p;
+		next = g_slist_next(l);
+	}
+
+	return NULL;
+}
+
 int btd_profile_register(struct btd_profile *profile)
 {
 	profiles = g_slist_append(profiles, profile);
@@ -2441,6 +2465,12 @@ static DBusMessage *register_profile(DBusConnection *conn,
 	dbus_message_iter_get_basic(&args, &uuid);
 	dbus_message_iter_next(&args);
 
+	if (btd_profile_find_uuid(uuid)) {
+		warn("%s tried to register %s which is already registered",
+								sender, uuid);
+		return btd_error_not_permitted(msg, "UUID already registered");
+	}
+
 	if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_ARRAY)
 		return btd_error_invalid_args(msg);
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-07-01 22:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-11  2:07 [PATCH BlueZ] profile: Fail RegisterProfile if UUID already exists João Paulo Rechi Vita
2021-06-11  2:43 ` [BlueZ] " bluez.test.bot
2021-06-29 23:46 ` [PATCH BlueZ] " João Paulo Rechi Vita
2021-07-01 22:50   ` Luiz Augusto von Dentz
  -- strict thread matches above, loose matches on Subject: below --
2021-06-11  2:06 João Paulo Rechi Vita

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).