(root)/
strace-6.5/
src/
linux/
x86_64/
arch_get_personality.c
       1  /*
       2   * Copyright (c) 2010-2021 The strace developers.
       3   * All rights reserved.
       4   *
       5   * SPDX-License-Identifier: LGPL-2.1-or-later
       6   */
       7  
       8  int
       9  get_personality_from_syscall_info(const struct_ptrace_syscall_info *sci)
      10  {
      11  	unsigned int pers = sci->arch == AUDIT_ARCH_I386;
      12  
      13  #ifndef X32
      14  	switch(sci->op) {
      15  		case PTRACE_SYSCALL_INFO_ENTRY:
      16  		case PTRACE_SYSCALL_INFO_SECCOMP:
      17  			break;
      18  		default:
      19  			return -1;
      20  	}
      21  
      22  	kernel_ulong_t scno = sci->entry.nr;
      23  
      24  	if (pers == 0 && (scno & __X32_SYSCALL_BIT)) {
      25  		/*
      26  		 * Syscall number -1 requires special treatment:
      27  		 * it might be a side effect of SECCOMP_RET_ERRNO
      28  		 * filtering that sets orig_rax to -1
      29  		 * in some versions of linux kernel.
      30  		 * If that is the case, then
      31  		 * __X32_SYSCALL_BIT logic does not apply.
      32  		 */
      33  		if (scno != (kernel_ulong_t) -1)
      34  			pers = 2;
      35  	}
      36  #endif /* !X32 */
      37  
      38  	return pers;
      39  }