If we trap syscalls by default, we must not manually set any filters to trap anything, since it will fail causing us to crash. But also, there are some things we must allow unconditionally even when trapping by default, for the broker to work. sigreturn, obviously, and brk.
Created attachment 249275 [details] [Linux] Seccomp Filters: Set appropriate filters when trapping by default
I think it would be nicer to use RELEASE_ASSERT_NOT_REACHED() rather than CRASH() here (note they are synonyms), but the existing code uses CRASH() so I picked that for consistency.
Comment on attachment 249275 [details] [Linux] Seccomp Filters: Set appropriate filters when trapping by default View in context: https://bugs.webkit.org/attachment.cgi?id=249275&action=review > Source/WebKit2/Shared/linux/SeccompFilters/SeccompFilters.cpp:105 > + Action result = static_cast<Action>(value); Is converting to Action here required?
(In reply to comment #3) > > Source/WebKit2/Shared/linux/SeccompFilters/SeccompFilters.cpp:105 > > + Action result = static_cast<Action>(value); > > Is converting to Action here required? Thanks. Yes: ../../Source/WebKit2/Shared/linux/SeccompFilters/SeccompFilters.cpp:105:12: error: cannot initialize a variable of type 'WebKit::SeccompFilters::Action' with an lvalue of type 'uint32_t' (aka 'unsigned int') Action result = value; ^ ~~~~~
Committed r187455: <http://trac.webkit.org/changeset/187455>
(In reply to comment #4) > (In reply to comment #3) > > > Source/WebKit2/Shared/linux/SeccompFilters/SeccompFilters.cpp:105 > > > + Action result = static_cast<Action>(value); > > > > Is converting to Action here required? > > Thanks. Yes: > > ../../Source/WebKit2/Shared/linux/SeccompFilters/SeccompFilters.cpp:105:12: > error: cannot initialize a variable of type 'WebKit::SeccompFilters::Action' > with an lvalue of type 'uint32_t' (aka 'unsigned int') > Action result = value; > ^ ~~~~~ What I meant was using the uint32_t variable directly in the switch conditional. At the second passing, I now see you have to return an Action value, so you'd have to cast it to the Action type in the return statement at the latest.