Re: [PATCH v11 2/2] binder: report txn errors via generic netlink

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 9, 2025 at 4:18 PM Jakub Kicinski <kuba@xxxxxxxxxx> wrote:
>
> On Thu, 9 Jan 2025 23:19:40 +0000 Carlos Llamas wrote:
> > On Thu, Jan 09, 2025 at 12:13:00PM -0800, Jakub Kicinski wrote:
> > > On Thu, 9 Jan 2025 11:48:24 -0800 Li Li wrote:
> > > > Cleaning up in the NETLINK_URELEASE notifier is better since we
> > > > register the process with the netlink socket. I'll change the code
> > > > accordingly.
> > >
> > > Hm. Thought I already told you this. Maybe I'm mixing up submissions.
> > >
> > > Please the unbind callback or possibly the sock priv infra
> > > (genl_sk_priv_get, sock_priv_destroy etc).
> >
> > Sorry, it was me that suggested NETLINK_URELEASE. BTW, I did try those
> > genl_family callbacks first but I couldn't get them to work right away
> > so I moved on. I'll have a closer look now to figure out what I did
> > wrong. Thanks for the suggestion Jakub!
>
> Hm, that's probably because there is no real multicast group here :(
> genl_sk_priv_get() and co. may work better in that case.
> your suggestion of NETLINK_URELEASE may work too, tho, I think it's
> the most error prone

sock_priv_destroy works with genl_sk_priv_get().

But, I have to manually modify the generated netlink header file to satisfy CFI.

-void binder_nl_sock_priv_init(struct my_struct *priv);
-void binder_nl_sock_priv_destroy(struct my_struct *priv);
+void binder_nl_sock_priv_init(void *priv);
+void binder_nl_sock_priv_destroy(void *priv);

The reason is that these 2 callback functions are defined in
include/net/genetlink.h as below
void (*sock_priv_init)(void *priv);
void (*sock_priv_destroy)(void *priv);

Otherwise, kernel panic when CFI is enabled.

CFI failure at genl_sk_priv_get+0x60/0x138 (target:
binder_nl_sock_priv_init+0x0/0x34; expected type: 0x0ef81b7d)

Jakub, we probably need this patch. Please let me know if you have a
better idea. Thanks!

diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index 8155ff6d2a38..84033938a75f 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -2352,8 +2352,8 @@ def print_kernel_family_struct_hdr(family, cw):
     cw.p(f"extern struct genl_family {family.c_name}_nl_family;")
     cw.nl()
     if 'sock-priv' in family.kernel_family:
-        cw.p(f'void
{family.c_name}_nl_sock_priv_init({family.kernel_family["sock-priv"]}
*priv);')
-        cw.p(f'void
{family.c_name}_nl_sock_priv_destroy({family.kernel_family["sock-priv"]}
*priv);')
+        cw.p(f'void {family.c_name}_nl_sock_priv_init(void *priv);')
+        cw.p(f'void {family.c_name}_nl_sock_priv_destroy(void *priv);')
         cw.nl()





[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux