History

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.

Anjali Kulkarni committed 3 years ago

Commit 2aa1f7a1 parent a4c9a565 files · +100 −35Browse files

Showing the changes to include/uapi (1 of 5 files). Show all

Unified · Split

include/uapi/linux/cn_proc.h+25−18
@@ -30,6 +30,30 @@ enum proc_cn_mcast_op { · 29 unmodified lines
30 PROC_CN_MCAST_IGNORE = 230 PROC_CN_MCAST_IGNORE = 2
31};31};
32 32
33enum proc_cn_event {
34 /* Use successive bits so the enums can be used to record
35 * sets of events as well
36 */
37 PROC_EVENT_NONE = 0x00000000,
38 PROC_EVENT_FORK = 0x00000001,
39 PROC_EVENT_EXEC = 0x00000002,
40 PROC_EVENT_UID = 0x00000004,
41 PROC_EVENT_GID = 0x00000040,
42 PROC_EVENT_SID = 0x00000080,
43 PROC_EVENT_PTRACE = 0x00000100,
44 PROC_EVENT_COMM = 0x00000200,
45 /* "next" should be 0x00000400 */
46 /* "last" is the last process event: exit,
47 * while "next to last" is coredumping event
48 */
49 PROC_EVENT_COREDUMP = 0x40000000,
50 PROC_EVENT_EXIT = 0x80000000
51};
52
53struct proc_input {
54 enum proc_cn_mcast_op mcast_op;
55};
56
33/*57/*
34 * From the user's point of view, the process58 * From the user's point of view, the process
35 * ID is the thread group ID and thread ID is the internal59 * ID is the thread group ID and thread ID is the internal
@@ -44,24 +68,7 @@ enum proc_cn_mcast_op { · 8 unmodified lines
44 */68 */
45 69
46struct proc_event {70struct proc_event {
47 enum what {71 enum proc_cn_event what;
48 /* Use successive bits so the enums can be used to record
49 * sets of events as well
50 */
51 PROC_EVENT_NONE = 0x00000000,
52 PROC_EVENT_FORK = 0x00000001,
53 PROC_EVENT_EXEC = 0x00000002,
54 PROC_EVENT_UID = 0x00000004,
55 PROC_EVENT_GID = 0x00000040,
56 PROC_EVENT_SID = 0x00000080,
57 PROC_EVENT_PTRACE = 0x00000100,
58 PROC_EVENT_COMM = 0x00000200,
59 /* "next" should be 0x00000400 */
60 /* "last" is the last process event: exit,
61 * while "next to last" is coredumping event */
62 PROC_EVENT_COREDUMP = 0x40000000,
63 PROC_EVENT_EXIT = 0x80000000
64 } what;
65 __u32 cpu;72 __u32 cpu;
66 __u64 __attribute__((aligned(8))) timestamp_ns;73 __u64 __attribute__((aligned(8))) timestamp_ns;
67 /* Number of nano seconds since system boot */74 /* Number of nano seconds since system boot */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t