mirror of
https://github.com/RGBCube/serenity
synced 2025-06-30 10:22:13 +00:00
Kernel: Lock socket mutex across {get,set}sockopt() and SO_ERROR updates
Since a socket can be accessed by multiple threads concurrently, we need to protect shared data behind the socket mutex. There's very likely more places where we need to fix this, the purpose of this patch is to fix a VERIFY() failure in getsockopt() seen on CI.
This commit is contained in:
parent
4e1898df99
commit
a1be135891
4 changed files with 17 additions and 1 deletions
|
@ -505,6 +505,8 @@ ErrorOr<void> IPv4Socket::setsockopt(int level, int option, Userspace<const void
|
|||
if (level != IPPROTO_IP)
|
||||
return Socket::setsockopt(level, option, user_value, user_value_size);
|
||||
|
||||
MutexLocker locker(mutex());
|
||||
|
||||
switch (option) {
|
||||
case IP_TTL: {
|
||||
if (user_value_size < sizeof(int))
|
||||
|
@ -569,6 +571,8 @@ ErrorOr<void> IPv4Socket::getsockopt(OpenFileDescription& description, int level
|
|||
if (level != IPPROTO_IP)
|
||||
return Socket::getsockopt(description, level, option, value, value_size);
|
||||
|
||||
MutexLocker locker(mutex());
|
||||
|
||||
socklen_t size;
|
||||
TRY(copy_from_user(&size, value_size.unsafe_userspace_ptr()));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue