]> xenbits.xensource.com Git - unikraft/libs/lwip.git/commit
sockets.c: fix crash when handling invalid/unsupported FDs
authorHugo Lefeuvre <hugo.lefeuvre@manchester.ac.uk>
Fri, 26 Nov 2021 14:23:11 +0000 (15:23 +0100)
committerUnikraft <monkey@unikraft.io>
Mon, 29 Nov 2021 16:28:59 +0000 (16:28 +0000)
commit5f399bbec0bafbf5d5c1d976fc2588a5a7b99651
tree34bd0dec341e672e637590abec2581122722db7a
parent8c17cdb602111ac927608b6b03ec243857a3c673
sockets.c: fix crash when handling invalid/unsupported FDs

aee924b [0] introduce a bug where any return value of sock_net_file_get
that is an error code but *not -EBADF* will return in a crash.

Assume a situation where sock_net_file_get(i) returns an error-encoded
file that is not -EBADF (e.g., -EINVAL): that file will go through the

if (PTR2ERR(file) == -EBADF)

check and pass it, moving on to

if (maxfd < file->sock_fd)

where the error-encoded pointer is dereferenced, resulting in a crash.

[0] https://github.com/hlef/lib-lwip/commit/aee924ba854034f8b085a4298

Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@manchester.ac.uk>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Approved-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #14
sockets.c