From patchwork Mon Apr 17 15:34:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Simmons-Talbott X-Patchwork-Id: 55690 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 841CA385702E for ; Mon, 17 Apr 2023 15:35:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 841CA385702E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681745740; bh=MwcD193AcdeH28RnfG8/+PwU3qhp4fzUCzlYUx7GRP0=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=l8L/8X1tUJI/q3qTOCrSCEOOcxTKZjqzj81zx+jZ1YWC7pzx1ddpn5HIuQ5W6tG9o +BjBPgecFlYJC5WqbZt3n8vSIfju2jWi+03pCh0G2tY2tTT/MIpgaY5M4VuWed+MXR +k5z2rDMDxywhNxBTQi5zUd4UlBF+y2TjvCv1TmQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 15EF83858C50 for ; Mon, 17 Apr 2023 15:35:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 15EF83858C50 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-563-Yy7H5zKgPIKlYXRxvQVGlg-1; Mon, 17 Apr 2023 11:35:07 -0400 X-MC-Unique: Yy7H5zKgPIKlYXRxvQVGlg-1 Received: by mail-qk1-f199.google.com with SMTP id r22-20020a37a816000000b0074abffe8a68so6746246qke.5 for ; Mon, 17 Apr 2023 08:35:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681745706; x=1684337706; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MwcD193AcdeH28RnfG8/+PwU3qhp4fzUCzlYUx7GRP0=; b=SJbiLbN8Urft8vViEgKL2ddERrVOpnRfnoT/Dz9jOE1HnQS08LddUu7hp8E/63MQbI SV6UnLmllNJB1W7UoGuYT9ytO92KG9clwFzyPlOTBLll+IxWLYJzJF9YMbMdKTns4Oex prIIYGUElYFsm9O/NQh8IQHHzkeKELjeI8EfYnHi2QHbTZEpwEBnN2jVsM23P1xPdbro jkeITk1sb4dVpX/iPjetOaONYV4xgMNfN90kbyuv5Eta+NoIrkf3Xr+4X+9xaomLC45b 4lnu/6ALZYgw06hZRjk1MvIedO3o+J3MAP94ye1gcBzBFssTlFsJLVc5IMgVbV3vk/Cu uv+Q== X-Gm-Message-State: AAQBX9dz1HKzfPglBbGSMrHGLX4OlPUTVFPSiAodi9zD3cSwnA+a1KIN HvacW4fGk1nkdn1bbg555DyN2HKxWRIrFiBeE4E2Cl/cmTxOQdzP58y71iUnQ1lY1xNQOlfVXcu 0PnNLTuNYNQFUxNlWVofPiJhMYIRjOeoxiv8SoP85j7frdf2wHPuS2FWs++2TyDv0MEZea9kVmG MDKXbj X-Received: by 2002:ac8:59d5:0:b0:3e6:38b6:88f5 with SMTP id f21-20020ac859d5000000b003e638b688f5mr22219041qtf.25.1681745706536; Mon, 17 Apr 2023 08:35:06 -0700 (PDT) X-Google-Smtp-Source: AKy350YXCRLZzbDMV+ovjoHPFxLZxItC++yjJwpzLZsKMhA1i0CIYLzP2xY4ZV4cmC28GiJJN97wfw== X-Received: by 2002:ac8:59d5:0:b0:3e6:38b6:88f5 with SMTP id f21-20020ac859d5000000b003e638b688f5mr22219009qtf.25.1681745706121; Mon, 17 Apr 2023 08:35:06 -0700 (PDT) Received: from oak.redhat.com (c-71-206-142-238.hsd1.va.comcast.net. [71.206.142.238]) by smtp.gmail.com with ESMTPSA id f20-20020a05620a20d400b0074d3233487dsm1577107qka.114.2023.04.17.08.35.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08:35:05 -0700 (PDT) To: libc-alpha@sourceware.org Cc: Joe Simmons-Talbott Subject: [PATCH v3 0/2] x86_64: aarch64: Set call number just before syscall Date: Mon, 17 Apr 2023 11:34:49 -0400 Message-Id: <20230417153451.1450817-1-josimmon@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230411133004.2268170-1-josimmon@redhat.com> References: <20230411133004.2268170-1-josimmon@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Joe Simmons-Talbott via Libc-alpha From: Joe Simmons-Talbott Reply-To: Joe Simmons-Talbott Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 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. 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 (2): x86_64: Set the syscall register right before doing the syscall. aarch64: Set the syscall register right before doing the syscall. sysdeps/unix/sysv/linux/aarch64/sysdep.h | 20 +++++++++++--- sysdeps/unix/sysv/linux/x86_64/sysdep.h | 33 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-)