Re: [PATCH net-next v7 2/2] binder: report txn errors via generic netlink

From: Li Li
Date: Mon Nov 04 2024 - 01:26:11 EST


> > +/**
> > + * binder_genl_init() - initialize binder generic netlink
> > + * @family: the generic netlink family
> > + * @name: the binder device name
> > + *
> > + * Registers the binder generic netlink family.
> > + */
> > +int binder_genl_init(struct genl_family *family, const char *name)
> > +{
> > + int ret;
> > +
> > + memcpy(family, &binder_genl_nl_family, sizeof(*family));
> > + strscpy(family->name, name, GENL_NAMSIZ);
>
> You're trying to register multiple families with different names?
> The family defines the language / protocol. If you have multiple
> entities to multiplex you should do that based on attributes inside
> the messages.
>

My initial plan was to use a single "binder" family, which was more
straightforward and cleaner. As Android uses multiple binder contexts
to isolate system framework and vendor domains[1], Grek KH suggested
the netlink messages from different binder contexts should also be
isolated for security reason[2]. Personally I'm fine with either
approach. Please kindly advice which implementation is better.

And I'll fix other issues you mentioned above.

[1]
https://source.android.com/docs/core/architecture/hidl/binder-ipc

[2]
https://lore.kernel.org/lkml/2024081350-establish-direness-38ee@gregkh/

> > + ret = genl_register_family(family);
> > + if (ret) {
> > + pr_err("Failed to register binder genl: %s\n", name);
> > + return ret;
> > + }
> > +
> > + return 0;
> > +}
>