From patchwork Mon Apr 24 15:03:50 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: 55714 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 27E67385701A for ; Mon, 24 Apr 2023 15:04:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 27E67385701A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682348675; bh=rjYCbEoXn21ipCXHjv8lPpUZ/d6Wvb8PR/wQirzfGPk=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ki4ZDDvJQRKZvNdhurJSNIvrqXRsgouHx0hEHuNMmDfOFp6gZQKJqAXhufsEsjFqU as+GFZ9BxEo01bHcgOSjBHHrtutHkBe5zVfreVhVCe6ubaJ6zaIMwNBc2b0lJ4UntA 1n2/OkQ4hRZeI1TO4y776rLfIFHI+2sNT3x2vEAs= 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 E8D663858C2F for ; Mon, 24 Apr 2023 15:04:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E8D663858C2F Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-121-1-0sVZbHMT6c6gkDGr07jQ-1; Mon, 24 Apr 2023 11:03:59 -0400 X-MC-Unique: 1-0sVZbHMT6c6gkDGr07jQ-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-74e1cdf9cbeso1763279485a.0 for ; Mon, 24 Apr 2023 08:03:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682348639; x=1684940639; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rjYCbEoXn21ipCXHjv8lPpUZ/d6Wvb8PR/wQirzfGPk=; b=PfXBXAnsu/Wys2gn/Gu2CTgWNZ1VWom4qKoy8Lz+4hUf3mXsLE+e5x5MRnz7+vcnMW P7t5LvHQCmFoM+Jjnr3ccZ9DjNgD9EX68Bo2HoS4auMBsmhGKdvue1IZiqRkUcK/xKlw l5GcwO0fH1quiHWCCrw/veQEDzRcOWBpcOd79YcrLdXuGv/6yLaamQItuxA4HCXp9m53 SNkXVUqrLoWn7F00IZBG4EzwP8pKm3GbAEt5m9DBN1A9nR0ebiqWmdmifrPRFhMJG10/ 8U3WZXe6S9OBzM+urFYcBmz8b4hmNhdc+a38VbsOaCg3ZAKQ0ggPZRWP1fzzuxBtY6ei k9kQ== X-Gm-Message-State: AAQBX9fUM4ZwRPVyxwhoFPgXdg16FDLnmGIT+1CBpvUou3wtxAiBSI6k 4Yhb0wfL2mN0BD+3wUl3/sVGkn+DCKrkr/NIqPeaU9F6E1dNvzaeihAgZ8GPHaNZtg88dayx5BI dNF/7WIm0ogA7XMIG/b7STYCMaijIzbvT7jJL5ZFLjS7mT9S9L3+pFwNy59INcAQG+PbC5+aTnX drAO2S X-Received: by 2002:a05:622a:196:b0:3ed:6505:bfa9 with SMTP id s22-20020a05622a019600b003ed6505bfa9mr23832272qtw.23.1682348638559; Mon, 24 Apr 2023 08:03:58 -0700 (PDT) X-Google-Smtp-Source: AKy350bNzB9Q3OSbWP7Dm01FhpjgDTNhPLExu82XNz+7wE1M3tAiOZ8/q1WlThF3FQtcy5oYOeNACA== X-Received: by 2002:a05:622a:196:b0:3ed:6505:bfa9 with SMTP id s22-20020a05622a019600b003ed6505bfa9mr23832196qtw.23.1682348638042; Mon, 24 Apr 2023 08:03:58 -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 t15-20020ac8530f000000b003e9c6a4a381sm3683807qtn.54.2023.04.24.08.03.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Apr 2023 08:03:57 -0700 (PDT) To: libc-alpha@sourceware.org Cc: Joe Simmons-Talbott Subject: [PATCH v6 0/3] x86_64: aarch64: Set call number just before syscall Date: Mon, 24 Apr 2023 11:03:50 -0400 Message-Id: <20230424150353.1469397-1-josimmon@redhat.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-6.1 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. 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" 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(-)