Bug 1975576 - Allow ioctls used by WebRTC for interface info in Linux socket process sandbox. a=RyanVM DONTBUILD

Original Revision: https://phabricator.services.mozilla.com/D265735

Differential Revision: https://phabricator.services.mozilla.com/D267151
This commit is contained in:
Jed Davis
2025-10-02 12:09:05 +00:00
committed by rvandermeulen@mozilla.com
parent cd6cafbe76
commit 0242b773ca

View File

@@ -12,6 +12,7 @@
#include <linux/ipc.h>
#include <linux/net.h>
#include <linux/sched.h>
#include <linux/sockios.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
@@ -22,6 +23,8 @@
#include <sys/utsname.h>
#include <time.h>
#include <unistd.h>
// This has to go after <sys/socket.h> for annoying reasons
#include <linux/wireless.h>
#include <algorithm>
#include <utility>
@@ -2231,16 +2234,21 @@ class SocketProcessSandboxPolicy final : public SandboxPolicyCommon {
auto shifted_type = request & kIoctlTypeMask;
// Rust's stdlib seems to use FIOCLEX instead of equivalent fcntls.
return If(request == FIOCLEX, Allow())
return Switch(request)
.Case(FIOCLEX, Allow())
// Rust's stdlib also uses FIONBIO instead of equivalent fcntls.
.ElseIf(request == FIONBIO, Allow())
.Case(FIONBIO, Allow())
// This is used by PR_Available in nsSocketInputStream::Available.
.ElseIf(request == FIONREAD, Allow())
// Allow anything that isn't a tty ioctl (if level < 2)
.ElseIf(
BelowLevel(2) ? shifted_type != kTtyIoctls : BoolConst(false),
Allow())
.Else(SandboxPolicyCommon::EvaluateSyscall(sysno));
.Case(FIONREAD, Allow())
// WebRTC needs interface information (bug 1975576)
.Cases({SIOCGIFNAME, SIOCGIFFLAGS, SIOCETHTOOL, SIOCGIWRATE},
Allow())
.Default(
// Allow anything that isn't a tty ioctl (if level < 2)
If(BelowLevel(2) ? shifted_type != kTtyIoctls
: BoolConst(false),
Allow())
.Else(SandboxPolicyCommon::EvaluateSyscall(sysno)));
}
CASES_FOR_fcntl: {