History

bpf, sockmap: fix sock_hash_alloc and reject zero-sized keys

Currently, it is possible to create a sock hash map with key size of 0 and have the kernel return a fd back to user space. This is invalid for hash maps (and kernel also hasn't been tested for zero key size support in general at this point). Thus, reject such configuration.

Daniel Borkmann committed 8 years ago

Commit b845c891 parent 96c26e01 file · +3 −1Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/bpf/sockmap.c+3−1
@@ -2140,7 +2140,9 @@ static struct bpf_map *sock_hash_alloc(union bpf_attr *attr) · 2139 unmodified lines
21402140 return ERR_PTR(-EPERM);
21412141
21422142 /* check sanity of attributes */
2143− if (attr->max_entries == 0 || attr->value_size != 4 ||
2143+ if (attr->max_entries == 0 ||
2144+ attr->key_size == 0 ||
2145+ attr->value_size != 4 ||
21442146 attr->map_flags & ~SOCK_CREATE_FLAG_MASK)
21452147 return ERR_PTR(-EINVAL);
21462148

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