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 [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 9CB2B3850433 for ; Thu, 14 Jan 2021 14:38:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9CB2B3850433 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-86-9qKmukeJNhGp9iK4JR5MDg-1; Thu, 14 Jan 2021 09:38:37 -0500 X-MC-Unique: 9qKmukeJNhGp9iK4JR5MDg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9087C80A5C6; Thu, 14 Jan 2021 14:38:36 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-114-66.ams2.redhat.com [10.36.114.66]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D5EB5614FD; Thu, 14 Jan 2021 14:38:35 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella via Libc-alpha Subject: Re: Should legacy fstat (via __fxstat) and fstat@GLIBC_2.33 call the same syscall? References: <87pn27ranx.fsf@oldenburg2.str.redhat.com> <442773f2-7744-aa65-e162-0805a9184811@linaro.org> Date: Thu, 14 Jan 2021 15:38:33 +0100 In-Reply-To: <442773f2-7744-aa65-e162-0805a9184811@linaro.org> (Adhemerval Zanella via Libc-alpha's message of "Thu, 14 Jan 2021 09:29:26 -0300") Message-ID: <877dofr3bq.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Thu, 14 Jan 2021 14:38:43 -0000 * Adhemerval Zanella via Libc-alpha: > On 14/01/2021 09:00, Florian Weimer via Libc-alpha wrote: >> Currently, __fxstat may get mapped to the fstat system call, while fstat >> goes to fstatat. This makes sandboxing issues less obvious to debug: >> >> >> >> Should we change this before the release? And if yes, in what >> direction? > > Implementing fstat/lstat/stat through fstatat does really simplify > the code at *lot* for some architectures. And on others and on some > ABI (32-bit with 64-bit time_t), it would require to use the same > syscall anyway (statx). > > I don't really see any gain in adding back this complexity back on > stat calls, specially with y2038 support requirement. But we currently have this code for the x*stat interfaces. For example, in sysdeps/unix/sysv/linux/xstat.c: __xstat (int vers, const char *name, struct stat *buf) { switch (vers) { case _STAT_VER_KERNEL: { # if STAT_IS_KERNEL_STAT /* New kABIs which uses generic pre 64-bit time Linux ABI, e.g. csky, nios2 */ int r = INLINE_SYSCALL_CALL (fstatat64, AT_FDCWD, name, buf, 0); return r ?: stat_overflow (buf); # else /* Old kABIs with old non-LFS support, e.g. arm, i386, hppa, m68k, microblaze, s390, sh, powerpc, and sparc32. */ return INLINE_SYSCALL_CALL (stat, name, buf); # endif } default: { # if STAT_IS_KERNEL_STAT return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); # else struct stat64 buf64; int r = INLINE_SYSCALL_CALL (stat64, name, &buf64); return r ?: __xstat32_conv (vers, &buf64, buf); #endif } } } For _STAT_VER_KERNEL, we should be able to call stat directly. Thanks, Florian -- Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn, Commercial register: Amtsgericht Muenchen, HRB 153243, Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill