Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4313483imu; Mon, 12 Nov 2018 09:02:24 -0800 (PST) X-Google-Smtp-Source: AJdET5coTUWnnj7mL/+h0vrLZk78I33MiwliaBIbL/Spk9G3ZWbAIJCF6nrhDugqaq0chS7D1g8H X-Received: by 2002:a63:cf56:: with SMTP id b22mr1418367pgj.336.1542042144228; Mon, 12 Nov 2018 09:02:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542042144; cv=none; d=google.com; s=arc-20160816; b=hMx2M5cFPZA0GrU3n+kLBYey+efWT1M6mzwov79cIENrhdynOaNGJxTlvEYvAXkKMo hXY3+b35Zc/tdQMaTgtEoXwRE5JZoDVAUlkMrIbtopRtaPbBw11D+vhrf6ZkEJI9pf30 7RF0pIMqm/gJXRQX5x7rGanDRKZ0EaLJEVIDh+pfEyU68CQUZ0aJPuPlVahBGruIiO26 UE4DvCQ0mbN9CCBJ+XaLZ8FFohDRfcv80n1p1PTbq6k2LEHtuSEH1I5H1uLdQVs2ZNTi SVYZVHkc6m6jOaUJGUx5zfSjHQF50TKiLyEcbrQP08xNIrlygSrkoMGq4BJrnbDr+Wb4 oZLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=EzL5bm3Oohk/QezIb1gyeZdsFd3Jp/082dGSI4zG4Mo=; b=X6Y/J3BTiiG461QAbl6xD7KqqMKmReF0T0bkt/y5SHYvsjE9WpLW9AkzQUwpiYUsIz s3oHQuE1wmyjkPbewKjcD54SyzfoPKbX6ullXBtVyWCAtQ9H3kRTb9hRwLKfYe6ZlGms TdbNi0rq5IgWQdlrLe7z2oEHeYHjDcycWdxFPFShKoPdSR6A5uz/9I70yUmicZEt7T9+ /QiUXknRyctSFuBW2SIThQcwopjA4fMWHDxENnOHKx0WVh4MQbuyonCBXHbyWgD6AXl8 GXfn/0ZmS03oh1VIFQmFR21OWmo41OH2nmA5yxliTNDR3WH0ZFXJzhcKs6KE0KvuPgQx Se8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3-v6si18422066pld.435.2018.11.12.09.02.01; Mon, 12 Nov 2018 09:02:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729757AbeKMCyG (ORCPT + 99 others); Mon, 12 Nov 2018 21:54:06 -0500 Received: from relay1.mentorg.com ([192.94.38.131]:42544 "EHLO relay1.mentorg.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727130AbeKMCyG (ORCPT ); Mon, 12 Nov 2018 21:54:06 -0500 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-MBX-03.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1gMFZ8-0004m9-Nb from joseph_myers@mentor.com ; Mon, 12 Nov 2018 08:59:58 -0800 Received: from digraph.polyomino.org.uk (137.202.0.90) by SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Mon, 12 Nov 2018 16:59:55 +0000 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.90_1) (envelope-from ) id 1gMFZ4-0002jk-QD; Mon, 12 Nov 2018 16:59:54 +0000 Date: Mon, 12 Nov 2018 16:59:54 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: Florian Weimer CC: Willy Tarreau , "Michael Kerrisk (man-pages)" , Daniel Colascione , linux-kernel , Joel Fernandes , Linux API , Vlastimil Babka , Carlos O'Donell , "libc-alpha@sourceware.org" Subject: Re: Official Linux system wrapper library? In-Reply-To: <87zhufvntw.fsf@oldenburg.str.redhat.com> Message-ID: References: <20181111081725.GA30248@1wt.eu> <3664a508-ca74-4ff0-39a6-34543194a24e@gmail.com> <20181111111143.GB4189@1wt.eu> <87zhufvntw.fsf@oldenburg.str.redhat.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) To SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 11 Nov 2018, Florian Weimer wrote: > The kernel does not know about TCB layout, so a lot of low-level > threading aspects are defined by userspace. > > The kernel does not know about POSIX cancellation. Directly calling > system calls breaks support for that. Indeed. Where cancellation is involved, glibc needs to know exactly what instructions might be calling a cancellable syscall and what instructions are before or after the syscall (see Adhemerval's patches for bug 12683). This involves an ABI that is not just specific to a particular libc, but specific to a particular libc version. So it's inherently unsuitable to put cancellable syscalls in libc_nonshared.a, as well as unsuitable to put them in any kernel-provided library. The interface for setting errno may also be libc-specific, for any syscalls involving setting errno. Syscalls often involve types in their interfaces such as off_t and struct timespec. libcs may have multiple different variants of those types; the variants available, and the ways of selecting them, are libc-specific and libc-version-specific. So for any syscall for which the proper userspace interface involves one of those types, wrappers for it are inherently specific to a particular libc and libc version. (See e.g. how preadv2 and pwritev2 syscalls also have preadv64v2 and pwritev64v2 APIs in glibc, with appropriate redirections hased on __USE_FILE_OFFSET64, which is in turn based on _FILE_OFFSET_BITS.) There are many ABI variants that are relevant to glibc but not to the kernel. Some of these involve ABI tagging of object files to indicate which ABI variant an object is built for (and those that don't have such tagging ought to have it), to prevent accidental linking of objects for different ABIs. How to build objects for different userspace ABIs is not something the kernel should need to know anything about; it's most naturally dealt with at the level of building compiler multilibs and libc. glibc deliberately avoids depending at compile time on the existence of libgcc_s.so to facilitate bootstrap builds (a stripped glibc binary built with a C-only static-only inhibit_libc GCC that was built without glibc should be identical to the result of a longer alternating sequence of GCC and glibc builds). I don't think any kernel-provided library would be any better to depend on. What one might suggest is that when new syscalls are added, kernel developers should at least obtain agreement on linux-api from libc people about what the userspace interface to the syscall should be. That means the userspace-level types (such as off_t and struct timespec), and the choice of error handling (returning error number or setting errno), and the name of the header declaring the function, and the name of the function, and how the syscall relates to thread cancellation, for example - and whatever other issues may be raised. -- Joseph S. Myers joseph@codesourcery.com