MCPcopy Create free account
hub / github.com/bsauce/kernel-exploit-factory / genlmsg_alloc

Function genlmsg_alloc

CVE-2022-2639/exploit.c:92–126  ·  view source on GitHub ↗

genlmsg_alloc() —— alloc a buffer with len (genlmsg)

Source from the content-addressed store, hash-verified

90}
91// genlmsg_alloc() —— alloc a buffer with len (genlmsg)
92void *genlmsg_alloc(int *size) {
93 unsigned char *buf;
94 int len;
95
96 /*
97 * attribute len
98 * attr len = (nla_hdr + pad) + (payload(user data) + pad)
99 */
100 len = nla_total_size(*size);
101 /*
102 * family msg len,
103 * but actually we have NOT custom family header
104 * family msg len = family_hdr + payload(attribute)
105 */
106 len += 0;
107 /*
108 * generic netlink msg len
109 * genlmsg len = (genlhdr + pad) + payload(family msg)
110 */
111 len += GENL_HDRLEN;
112 /*
113 * netlink msg len
114 * nlmsg len = (nlmsghdr + pad) + (payload(genlmsg) + pad)
115 */
116 len = NLMSG_SPACE(len);
117
118 buf = malloc(len);
119 if (!buf)
120 return NULL;
121
122 memset(buf, 0, len);
123 *size = len;
124
125 return buf;
126}
127
128void genlmsg_free(void *buf) {
129 if (buf) {

Callers 3

genlmsg_sendFunction · 0.85
genlmsg_get_family_idFunction · 0.85
ovsmsg_sendFunction · 0.85

Calls 1

nla_total_sizeFunction · 0.85

Tested by

no test coverage detected