Ideas to improve glibc and Kernel interaction. Adhemerval Zanella

Similar documents
ECE 574 Cluster Computing Lecture 8

ECE 598 Advanced Operating Systems Lecture 23

Chapter 4: Threads. Operating System Concepts. Silberschatz, Galvin and Gagne

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

UMTX OP (2) FreeBSD System Calls Manual UMTX OP (2)

Inside core.async Channels. Rich Hickey

Memory management. Johan Montelius KTH

Functions (API) Setup Functions

Threads Cannot Be Implemented As a Library

Chapter 4: Threads. Operating System Concepts with Java 8 th Edition

The Performance of µ-kernel-based Systems

Unix System Programming - Chapter 8

System Calls. A contract between processes and the operating system. Michael E. Locasto. Department of Computer Science UofC CPSC 457

Design Overview of the FreeBSD Kernel CIS 657

OPERATING SYSTEM. Chapter 4: Threads

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent?

pthreads CS449 Fall 2017

Dead ways in multithreaded programing. Zdeněk Kotala Revenue Product Engineer Sun Microsystems

Questions from last time

Deterministic Futexes Revisited

CS342 - Spring 2019 Project #3 Synchronization and Deadlocks

Thread Concept. Thread. No. 3. Multiple single-threaded Process. One single-threaded Process. Process vs. Thread. One multi-threaded Process

Last class: Today: Thread Background. Thread Systems

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

Linux Driver and Embedded Developer

Concurrency, Thread. Dongkun Shin, SKKU

Shared Memory Parallel Programming with Pthreads An overview

Fall 2014:: CSE 506:: Section 2 (PhD) Threading. Nima Honarmand (Based on slides by Don Porter and Mike Ferdman)

Pebbles Kernel Specification September 26, 2004

Processes. Johan Montelius KTH

POSIX Threads: a first step toward parallel programming. George Bosilca

Chapter 4: Threads. Chapter 4: Threads

Embedded Systems Programming

A process. the stack

Chapter 4: Threads. Operating System Concepts 9 th Edit9on

Checkpointing using DMTCP, Condor, Matlab and FReD

CS 5523 Operating Systems: Midterm II - reivew Instructor: Dr. Tongping Liu Department Computer Science The University of Texas at San Antonio

Chapter 4: Multithreaded Programming. Operating System Concepts 8 th Edition,

Chapter 4: Threads. Chapter 4: Threads

Intel Transactional Synchronization Extensions (Intel TSX) Linux update. Andi Kleen Intel OTC. Linux Plumbers Sep 2013

Overview. Thread Packages. Threads The Thread Model (1) The Thread Model (2) The Thread Model (3) Thread Usage (1)

CSE 451 Midterm 1. Name:

Chapter 4: Threads. Chapter 4: Threads. Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues

Native POSIX Thread Library (NPTL) CSE 506 Don Porter

Threads. What is a thread? Motivation. Single and Multithreaded Processes. Benefits

seccomp-nurse Nicolas Bareil ekoparty 2010 EADS CSC Innovation Works France seccomp-nurse: sandboxing environment

CS510 Advanced Topics in Concurrency. Jonathan Walpole

Status Report on A New Linux OpenGL ABI

Operating Systems 2 nd semester 2016/2017. Chapter 4: Threads

LINUX INTERNALS & NETWORKING Weekend Workshop

Chapter 4: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads. Operating System Concepts

Operating Systems, Assignment 2 Threads and Synchronization

Multithreaded Programming

RCU in the Linux Kernel: One Decade Later

Chapter 12 IoT Projects Case Studies. Lesson-01: Introduction

Chapter 4: Threads. Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads

Outline. Threads. Single and Multithreaded Processes. Benefits of Threads. Eike Ritter 1. Modified: October 16, 2012

CS Lecture 3! Threads! George Mason University! Spring 2010!

Protection and System Calls. Otto J. Anshus

Developing Real-Time Applications

SDC 2015 Santa Clara

CS307: Operating Systems

Applications of. Virtual Memory in. OS Design

ECE 471 Embedded Systems Lecture 4

13th ANNUAL WORKSHOP 2017 VERBS KERNEL ABI. Liran Liss, Matan Barak. Mellanox Technologies LTD. [March 27th, 2017 ]

Lecture 4 Threads. (chapter 4)

Semantics of fork() and exec()

On Supporting Per-Process based System Call Vectors in Linux Kernel

Distributed Systems Operation System Support

Principles of Programming Languages. Objective-C. Joris Kluivers

4.8 Summary. Practice Exercises

Chapter 4: Threads. Operating System Concepts 9 th Edition

Laboratory Assignment #3. Extending scull, a char pseudo-device

Definition Multithreading Models Threading Issues Pthreads (Unix)

CS 450 Operating System Week 4 Lecture Notes

Using persistent memory to

Porting Linux to x86-64

High Performance Computing Course Notes Shared Memory Parallel Programming

Deviations are things that modify a thread s normal flow of control. Unix has long had signals, and these must be dealt with in multithreaded

Threading and Synchronization. Fahd Albinali

CSE 4/521 Introduction to Operating Systems

Introduction to PThreads and Basic Synchronization

Chapter 4: Threads. Operating System Concepts 9 th Edition

CS 326: Operating Systems. Process Execution. Lecture 5

Processes & Threads. Recap of the Last Class. Microkernel System Architecture. Layered Structure

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)

Embedded Linux Conference EU Complex Cameras on Linux. Mauro Carvalho Chehab. Oct, SRBR Samsung R&D Institute Brazil

CNIT 127: Exploit Development. Ch 3: Shellcode. Updated

Threads. studykorner.org

Transitioning from uclibc to musl for embedded development. Embedded Linux Conference 2015 Rich Felker, maintainer, musl libc March 24, 2015

Outline. Relationship between file descriptors and open files

User-Kernel Reactive Threads for Linux

CS 5523: Operating Systems

SUPPORTING NATIVE PTHREADS IN SYSCALL EMULATION MODE BRANDON POTTER JUNE 14 TH, 2015

syscall_intercept A user space library for intercepting system calls Author Name, Company Krzysztof Czuryło, Intel

CS420: Operating Systems

VEOS high level design. Revision 2.1 NEC

EECE.4810/EECE.5730: Operating Systems Spring 2017 Homework 2 Solution

Secure Software Programming and Vulnerability Analysis

SYSTEM CALL IMPLEMENTATION. CS124 Operating Systems Fall , Lecture 14

Transcription:

Ideas to improve glibc and Kernel interaction Adhemerval Zanella <adhemerval.zanella@linaro.org>

Overview This is RFC session to check kernel features glibc lacks (such as termios2), some features glibc might require to implement correctly some standards (such as pthread cancellation), and how to improve communication between kernel and gnu toolchain developers. Each slide basically describes a current glibc issue, improvement, and/or idea to improve kernel support

Syscalls wrappers The main issue is glibc might not provide the latest Linux syscalls There is a recent discussion on libc-alpha about provide thin syscall wrappers to accomplish glibc handles all standards requirements for syscalls (errno, pthread cancellation, kernel optional flags, etc.) Some syscalls uses fallback implementation or use optimized implementations (vdso) What about different calling conventions depending of build flags (off_t/off64_t and time_t/time64_t in near future)? Some exported APIs differ from kernel API (termios for instance) Does make sense to export all possible syscalls? What about deprecated ones (sysctl, socketcall, osf_*, etc.)? What about possible interoperation issues with glibc expectation (set_robust_list for instance)?

Formal description of syscall interface It would be interesting to follow up on this such that glibc, and other consumers can use this data without recreating Declarative, machine-readable approach to obtain system call numbers and error numbers from the kernel sources. This was discussed at LPC 2016. https://lkml.org/lkml/2016/11/6/126

Consistent kernel support for arch-independent system calls New system calls which are not arch-specific should be wired up at the same time for all architectures Avoid issues like a syscall added to unistd.h for an architecture, but not added to the syscall table Or a syscall added to the native syscall table for some ABI but not added to the corresponding compat syscall table Even now we stumble on issue on syscalls being wire-up on different version on different architectures

Kernel and glibc header coordination Create and grow a set of tests in glibc or in the kernel to verify key headers work in both include directions. Continue to support libc_compat.h as the method to support inclusion header guards where possible. Not all header inclusion ordering is valid we should not attempt to just solve this by permuting all headers there is too much invalid garbage produced in that kind of result.

Have identified points of contact glibc maintains points of contact for all major distributions https://sourceware.org/glibc/wiki/maintainers#distribution_maintainers We use the points of contact to discuss things like switching to Python 3.4 for build scripting and tooling. We need something to get clarification of userspace ABI evolution (future plans) and how to deal with ABI changes after the fact. Do we need similar to discuss interaction between libc and kernel? Maybe Linux API <linux-api@vger.kernel.org>?

Integrate termios2 interface with a GNU extension Linux has supported arbitrary baud rates for 12 years Added in kernel version 2.6.20 New ioctl()s TCGETS2/TCSETS2 glibc only supports POSIX defined baud rates (up to B38400) plus some Linux specific one (B4000000) Also only uses old ioctl interface Current work is to cleanup glibc termios implementation and add a GNU extension (cf[gs]et[io]bps) H. Peter Anvin work Tracked on sourceware bugzilla: https://sourceware.org/bugzilla/show_bug.cgi?id=10339

Pthread cancellation handling The idea is to use musl-libc strategy to use a syscall entrypoint along with address markers glibc check if cancelled syscall has side-effects by comparing the SA_SIGINFO returned IP against the markers It works well on almost every architecture The issue is x86-32 will require to use int80 instead of vdso, slowing down cancellable syscalls in multithreaded environments Recent kernel discussion about providing a new way to accomplish stalled Tracked on sourceware bugzilla: https://sourceware.org/bugzilla/show_bug.cgi?id=12683

Fork async-signal-safeness This requires a way to determine when a function is executed in a signal handler So we an act on atfork handler properly On some other system this is accomplished by a pure-userspace solution (for instance FreeBSD). A possible solution on glibc might be add signal handler wrappers This imposes some serialization and less scalability due lock/atomic operations My WIP work basically uses a recursive plus enable/disable cancellation for SA_NODEFER Could kernel help us by providing an atomic update on a variable when signal handler is executed, similar to tid set in clone? One global wrapper (set via prctl) which is called by the kernel with the handler function as an argument would be sufficient

Save and restore errno around signal handler? Can we extend a possible solution for atomic update on a variable when signal handler is executed to save/restore arbitrary values? This will stop the mistakes that users commit by not saving and restoring errno on their own. It could also be conditionally disabled if users didn t care about it.

Making EPERM friendlier Additional error delivery information for file operations and mmap For exemplo explanations of failures from security modules, nftables, etc. Obtained from a GNU extension Does kernel currently supports provide such information? Previous discussion at https://lwn.net/articles/532771/

Robust Mutexes Fundamental Flaw There is a race where the kernel will corrupt a mapping in the same place as the previous robust TID that is has to zero out. This is ABA issue, where the share memory referenced by a robust mutex is deallocated and reallocated to another object Propose solution on glibc BZ#14485 is to add a global lock on mmap/munmap and the robust operations to remove the mutex from the thread's linked list, unlock, and clear the "pending" slot Do we need to redesign the protocol between userspace and the kernel to fix this? Tracked on sourceware bugzilla: https://sourceware.org/bugzilla/show_bug.cgi?id=14485