[systemd-devel] [PATCH v2 0/7] kdbus: improve user domain accounting

Kay Sievers kay at vrfy.org
Thu Jul 31 08:35:41 PDT 2014


On Wed, Jul 30, 2014 at 10:11 PM, Djalal Harouni <tixxdz at opendz.org> wrote:
> This is series v2 of:
> http://lists.freedesktop.org/archives/systemd-devel/2014-July/021526.html
>
> This series improves user domain accounting and fixes some bugs.
>
> It should go on top of the "kdbus: allow multiple policies" series:
> http://lists.freedesktop.org/archives/systemd-devel/2014-July/021514.html
>
> The v2 fixes the race previously discussed but not fixed in v1 and which
> was inherited from kdbus_domain_user_find_or_new().
>
> If kdbus_domain_user_find_or_new() is called with same parameters and
> if we do not find a previously linked domain user, then we release the
> domain lock, and both threads will race to assign a different ID for the
> same uid, thus, invalidating the users array. We fix this in this series
> by using a new kdbus_domain_user_account() function which takes the same
> domain lock to perform both find a previously domain user or create and
> link a new one.
>
> Summary:
> Patches 1, 2 and 3 are preparation patches to improve the code.

In the future, please do not split up patches which just add or remove
dead code. Just add the code with the patch that uses it. Larger
patches are just as readable as several smaller ones which are just
artificially split up.

> Patch 4 fixes kdbus_domain_user_find_or_new(), callers assume that
> kdbus_domain_user_find_or_new() will fail only with -ENOMEM, but it
> may fail with -ESHUTDOWN, so adapt the code to return the appropriate
> errors and fix all callers. This patch also fixes the discussed race in
> kdbus_domain_user_find_or_new().
>
> Patch 5 improves the bus user quota and reduces the number of domain
> locks that might be taken in that path.
> Currently kdbus_bus_new() execution path might take the domain lock 3 or
> 4 times, reduce this to max 1 or 2 times. The domain is the upper layer,
> reducing the locks should reduce some overheads.
>
> Patch 6 fixes a user quota accounting corruption.
>
> Patch 7 kill dead code.

I have applied all 7. Thanks for doing this.

Kay


More information about the systemd-devel mailing list