connector/cn_proc: Add filtering to fix some bugs
authorAnjali Kulkarni <anjali.k.kulkarni@oracle.com>
Wed, 19 Jul 2023 20:18:18 +0000 (13:18 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 23 Jul 2023 10:34:22 +0000 (11:34 +0100)
commit2aa1f7a1f47ce8dac7593af605aaa859b3cf3bb1
tree4bd4ccb2aaec83fa5e3bd30109955b386742c476
parenta4c9a56e6a2cdeeab7caef1f496b7bfefd95b50e
connector/cn_proc: Add filtering to fix some bugs

The current proc connector code has the foll. bugs - if there are more
than one listeners for the proc connector messages, and one of them
deregisters for listening using PROC_CN_MCAST_IGNORE, they will still get
all proc connector messages, as long as there is another listener.

Another issue is if one client calls PROC_CN_MCAST_LISTEN, and another one
calls PROC_CN_MCAST_IGNORE, then both will end up not getting any messages.

This patch adds filtering and drops packet if client has sent
PROC_CN_MCAST_IGNORE. This data is stored in the client socket's
sk_user_data. In addition, we only increment or decrement
proc_event_num_listeners once per client. This fixes the above issues.

cn_release is the release function added for NETLINK_CONNECTOR. It uses
the newly added netlink_release function added to netlink_sock. It will
free sk_user_data.

Signed-off-by: Anjali Kulkarni <anjali.k.kulkarni@oracle.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/connector/cn_proc.c
drivers/connector/connector.c
drivers/w1/w1_netlink.c
include/linux/connector.h
include/uapi/linux/cn_proc.h