From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 934E6385843E for ; Tue, 30 May 2023 10:13:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 934E6385843E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685441625; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fIOn7a96bivznlb7+WhiwYvkirWiCJhxE8hBRZiLilg=; b=P40ZYh7dPU3h7hieZyroj82lnJoYibUcGutV2PBsq7I/f0WlwruRq2tKH1uqBN6R6h6JZ/ LkpDfeLR4a9FHljyAY0ssy6lJyz6/905Glu0Mu37lY1vIT3VZOsl497RkV4HhsMotK+G6F Rw23nlPMB+DPZoqctLbmCU4hWu2MpFA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-558-FOH-LP1kMtqvVmdKEMJ2wQ-1; Tue, 30 May 2023 06:13:42 -0400 X-MC-Unique: FOH-LP1kMtqvVmdKEMJ2wQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E8DBA3C13509; Tue, 30 May 2023 10:13:41 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E0A83202696C; Tue, 30 May 2023 10:13:40 +0000 (UTC) From: Florian Weimer To: Noah Goldstein Cc: Joe Simmons-Talbott , Noah Goldstein via Libc-alpha Subject: Re: [PATCH v6 1/3] x86_64: Set the syscall register right before doing the syscall. References: <20230424150353.1469397-1-josimmon@redhat.com> <20230424150353.1469397-2-josimmon@redhat.com> <20230525180743.GN176347@oak> <877csvk1zt.fsf@oldenburg.str.redhat.com> <20230526125947.GP176347@oak> Date: Tue, 30 May 2023 12:13:39 +0200 In-Reply-To: (Noah Goldstein's message of "Fri, 26 May 2023 14:18:14 -0700") Message-ID: <87sfbeunxo.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,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 List-Id: * Noah Goldstein: > On Fri, May 26, 2023 at 5:59=E2=80=AFAM Joe Simmons-Talbott wrote: >> >> On Fri, May 26, 2023 at 09:04:06AM +0200, Florian Weimer wrote: >> > * Noah Goldstein via Libc-alpha: >> > >> > > I'm minorly opposed to this patch. Even if GLIBC guarantees all >> > > syscalls will set the number the instruction before, that's no guara= ntee >> > > for the entire program. Furthermore in the event of: >> > > `movl $VAL, %eax; syscall` >> > > It's still not safe to *always* assume that `VAL` correspond to the >> > > syscall number as a jump (direct or indirect) could still go between >> > > the instructions (i.e there is no guarantee in the assembly that the >> > > `mov` dominates the `syscall). >> > > So at the end of the day, we are bloating the library without, AFAIC= T, >> > > providing any real guarantee. Maybe I'm missing something? >> > >> > Joe, is there a size change to libc.so.6 as the result of this change? >> >> No, the size is the same with and with out this patchset on x86_64. >> > There aren't many syscalls so it's only a minor cost (hence the only > minor opposition), but I don't see the value this provides given that it > still won't be safe to assume the syscall number is always set the > instruction beforehand for any robust purpose. So it still feels like > why take any cost at all? I think there is any run-time cost at all, only the increased source complexity. It's much easier to change glibc than to add full register tracking to a the static analysis tool that discovers system calls in the disassembly. Thanks, Florian