[v6,0/3] x86_64: aarch64: Set call number just before syscall

Message ID 20230424150353.1469397-1-josimmon@redhat.com
Headers
Series x86_64: aarch64: Set call number just before syscall |

Message

Joe Simmons-Talbott April 24, 2023, 3:03 p.m. UTC
  To make binary call tree analysis easier place the syscall number into
the register just before the syscall is made.  Only do this if the
syscall number is a constant integer.

Compiler optimizations can place quite a few instructions between the
setting of the syscall number and the syscall instruction.  During call
tree analysis the number of instructions between the two can lead to
more difficulty for both tools and humans in properly identifying the
syscall number.  Having the syscall number set in the prior instruction
to the syscall instruction makes this task easier and less error prone.
Being able to reliably identify syscalls made by a given API will make
it easier to understand and verify the safety and security of glibc.

Tested on x86_64 and aarch64.

Chnages to v5:
  * aarch64: Remove '\n\t' from asm.
  * x86_64: Remove unused macros.

Changes to v4:
  * aarch64: Move generated comment.  Remove unused macros from earlier
  version.

  * Added patch
    - nptl: Convert indirect syscall numbers to compile time numeric
      values.

Changes to v3:
  * x86_64: Combine two inline asms into one.
    - Suggested by "H.J. Lu" <hjl.tools@gmail.com>

Changes to v2:
  * Add a more detailed commit message.
  
Changes to v1:
  * aarch64: Combine two inline asms into one.  Avoid loading name twice.

Joe Simmons-Talbott (3):
  x86_64: Set the syscall register right before doing the syscall.
  aarch64: Set the syscall register right before doing the syscall.
  nptl: Use direct syscall numbers in setxid

 nptl/nptl_setxid.c                       | 136 ++++++++++++++++++++++-
 sysdeps/unix/sysv/linux/aarch64/sysdep.h |  29 +++--
 sysdeps/unix/sysv/linux/x86_64/sysdep.h  |  24 ++--
 3 files changed, 164 insertions(+), 25 deletions(-)
  

Comments

Joe Simmons-Talbott May 8, 2023, 2:13 p.m. UTC | #1
Is there anything further I need to do to get this patchset reviewed?

Thanks,
Joe
On Mon, Apr 24, 2023 at 11:03:50AM -0400, Joe Simmons-Talbott wrote:
> To make binary call tree analysis easier place the syscall number into
> the register just before the syscall is made.  Only do this if the
> syscall number is a constant integer.
> 
> Compiler optimizations can place quite a few instructions between the
> setting of the syscall number and the syscall instruction.  During call
> tree analysis the number of instructions between the two can lead to
> more difficulty for both tools and humans in properly identifying the
> syscall number.  Having the syscall number set in the prior instruction
> to the syscall instruction makes this task easier and less error prone.
> Being able to reliably identify syscalls made by a given API will make
> it easier to understand and verify the safety and security of glibc.
> 
> Tested on x86_64 and aarch64.
> 
> Chnages to v5:
>   * aarch64: Remove '\n\t' from asm.
>   * x86_64: Remove unused macros.
> 
> Changes to v4:
>   * aarch64: Move generated comment.  Remove unused macros from earlier
>   version.
> 
>   * Added patch
>     - nptl: Convert indirect syscall numbers to compile time numeric
>       values.
> 
> Changes to v3:
>   * x86_64: Combine two inline asms into one.
>     - Suggested by "H.J. Lu" <hjl.tools@gmail.com>
> 
> Changes to v2:
>   * Add a more detailed commit message.
>   
> Changes to v1:
>   * aarch64: Combine two inline asms into one.  Avoid loading name twice.
> 
> Joe Simmons-Talbott (3):
>   x86_64: Set the syscall register right before doing the syscall.
>   aarch64: Set the syscall register right before doing the syscall.
>   nptl: Use direct syscall numbers in setxid
> 
>  nptl/nptl_setxid.c                       | 136 ++++++++++++++++++++++-
>  sysdeps/unix/sysv/linux/aarch64/sysdep.h |  29 +++--
>  sysdeps/unix/sysv/linux/x86_64/sysdep.h  |  24 ++--
>  3 files changed, 164 insertions(+), 25 deletions(-)
> 
> -- 
> 2.39.2
>