github.com/ttpreport/gvisor-ligolo@v0.0.0-20240123134145-a858404967ba/pkg/sentry/platform/systrap/sysmsg_thread_amd64.go (about)

     1  // Copyright 2021 The gVisor Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package systrap
    16  
    17  import (
    18  	"github.com/ttpreport/gvisor-ligolo/pkg/abi/linux"
    19  	"github.com/ttpreport/gvisor-ligolo/pkg/seccomp"
    20  	"golang.org/x/sys/unix"
    21  )
    22  
    23  func appendSysThreadArchSeccompRules(rules []seccomp.RuleSet) []seccomp.RuleSet {
    24  	return append(rules, []seccomp.RuleSet{
    25  		{
    26  			// Rules for trapping vsyscall access.
    27  			Rules: seccomp.SyscallRules{
    28  				unix.SYS_GETTIMEOFDAY: {},
    29  				unix.SYS_TIME:         {},
    30  				unix.SYS_GETCPU:       {}, // SYS_GETCPU was not defined in package syscall on amd64.
    31  			},
    32  			Action:   linux.SECCOMP_RET_TRAP,
    33  			Vsyscall: true,
    34  		},
    35  		{
    36  			Rules: seccomp.SyscallRules{
    37  				unix.SYS_ARCH_PRCTL: {
    38  					{
    39  						seccomp.EqualTo(linux.ARCH_SET_FS),
    40  						seccomp.MatchAny{},
    41  						seccomp.MatchAny{},
    42  						seccomp.MatchAny{},
    43  						seccomp.MatchAny{},
    44  						seccomp.MatchAny{},
    45  						seccomp.GreaterThan(stubStart), // rip
    46  					},
    47  					{
    48  						seccomp.EqualTo(linux.ARCH_GET_FS),
    49  						seccomp.MatchAny{},
    50  						seccomp.MatchAny{},
    51  						seccomp.MatchAny{},
    52  						seccomp.MatchAny{},
    53  						seccomp.MatchAny{},
    54  						seccomp.GreaterThan(stubStart), // rip
    55  					},
    56  				},
    57  			},
    58  			Action: linux.SECCOMP_RET_ALLOW,
    59  		},
    60  	}...)
    61  }