From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/9547 Path: news.gmane.org!not-for-mail From: Ingo Molnar Newsgroups: gmane.linux.kernel,gmane.linux.lib.musl.general Subject: Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers Date: Thu, 10 Mar 2016 12:16:46 +0100 Message-ID: <20160310111646.GA13102@gmail.com> References: <06079088639eddd756e2092b735ce4a682081308.1457486598.git.luto@kernel.org> <20160309085631.GA3247@gmail.com> <20160309113449.GZ29662@port70.net> <20160310033446.GL9349@brightrain.aerifal.cx> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1457608637 32452 80.91.229.3 (10 Mar 2016 11:17:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 10 Mar 2016 11:17:17 +0000 (UTC) Cc: Linus Torvalds , Andy Lutomirski , the arch/x86 maintainers , Linux Kernel Mailing List , Borislav Petkov , "musl@lists.openwall.com" , Andrew Morton , Thomas Gleixner , Peter Zijlstra To: Rich Felker Original-X-From: linux-kernel-owner@vger.kernel.org Thu Mar 10 12:17:08 2016 Return-path: Envelope-to: glk-linux-kernel-3@plane.gmane.org Original-Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1adyaZ-00048M-Da for glk-linux-kernel-3@plane.gmane.org; Thu, 10 Mar 2016 12:17:07 +0100 Original-Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965672AbcCJLQw (ORCPT ); Thu, 10 Mar 2016 06:16:52 -0500 Original-Received: from mail-wm0-f67.google.com ([74.125.82.67]:33021 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932895AbcCJLQu (ORCPT ); Thu, 10 Mar 2016 06:16:50 -0500 Original-Received: by mail-wm0-f67.google.com with SMTP id n186so3183010wmn.0 for ; Thu, 10 Mar 2016 03:16:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=gHQ6SzHNd7g6mku/tnxiLhPgRaR1ikaY7tJKbk1Yguc=; b=jjjABI4Sek91/eFPXISEEekeSrkOQzhF14KwwKppiEvBmMCcyJl0Mwx0KkKm6VantJ KpTOm6fKW4JxQTN6DsB75lSwlkE/E+KGjVyjrjh14VESZix5EOVHpVZXCK68/W9+S8qU MG/7kd9etLfLQipv8epvf1DDMO7xpmr8FGfQs1BU2P2U5ez0YB4RJoRvLqIP0LLakbR6 MzTCEfzxmvE2L56nXz++KR7srm4HKkIbrE7+ZUR857Yc27GK1Cnx1juEnrNaYxbbF14L rRKslEth6hH3XY1VLUV2B9GyuKWn+IRDs4GZY1s7ihZtf0zM0f1rZrX3/ttvUTYIg8lJ zZig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=gHQ6SzHNd7g6mku/tnxiLhPgRaR1ikaY7tJKbk1Yguc=; b=arjPn5OUHi2QmZgNZTiRMg7iH42f9k65Wj6bA1GW2Ml8nL1ywwB4LCR0DpwCKGjDEF y2zg9FEV7zN+EupD7UrKYfuQ/hGnZNutwErsgz/ZAUu/I3TzbowrL2LZX0F5Jlgz41CG pbT+CPV8KbXQXZjUgki2fRwj8OmhgESYqzYyuGkpO2Sj7+Of6Euu6PwdauGd1sTvl+zF Zw7A2sCozYKH8TtXKViTsHtyAUMCLPKIiHix2XIgwB5uhFHjXqClAOFfIzuxpngplg/P 4bNjo8U01n6OJ8ndvnDrAMYc+gBMH/kBuGtlbXmnViJCcmmLwJ8fpS9umRL3+xZJ21lI bD9g== X-Gm-Message-State: AD7BkJLZLV1PHk9EWluAb3OBFH1sLlLwWQyf916kF/xJkNdmjqwJ1CS8mkSHXPgzEOGv/Q== X-Received: by 10.194.75.164 with SMTP id d4mr3096195wjw.15.1457608609493; Thu, 10 Mar 2016 03:16:49 -0800 (PST) Original-Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id o128sm3008537wmb.19.2016.03.10.03.16.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Mar 2016 03:16:48 -0800 (PST) Content-Disposition: inline In-Reply-To: <20160310033446.GL9349@brightrain.aerifal.cx> User-Agent: Mutt/1.5.23 (2014-03-12) Original-Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Xref: news.gmane.org gmane.linux.kernel:2174015 gmane.linux.lib.musl.general:9547 Archived-At: * Rich Felker wrote: > [...] > > I believe a new kernel cancellation API with a sticky cancellation flag (rather > than a signal), and a flag or'd onto the syscall number to make it cancellable > at the call point, could work, but then userspace needs to support fairly > different old and new kernel APIs in order to be able to run on old kernels > while also taking advantage of new ones, and it's not clear to me that it would > actually be worthwhile to do so. I could see doing it for a completely new > syscall API, but as a second syscall API for a system that already has one it > seems gratuitous. From my perspective the existing approach (checking program > counter from signal handler) is very clean and simple. After all it made enough > sense that I was able to convince the glibc folks to adopt it. I concur with your overall analysis, but things get a bit messy once we consider AT_SYSINFO which is a non-atomic mix of user-space and kernel-space code. Trying to hand cancellation status through that results in extra complexity: arch/x86/entry/vdso/Makefile | 3 +- arch/x86/entry/vdso/vdso32/cancellation_helpers.c | 116 ++++++++++++++++++++++ arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 + tools/testing/selftests/x86/unwind_vdso.c | 57 +++++++++-- 4 files changed, 171 insertions(+), 7 deletions(-) So instead of a sticky cancellation flag, we could introduce a sticky cancellation signal. A 'sticky signal' is not cleared from signal_pending() when the signal handler executes, but it's automatically blocked so no signal handler recursion occurs. (A sticky signal could still be cleared via a separate mechanism, by the cancellation cleanup code.) Such a 'sticky cancellation signal' would, in the racy situation, cause new blocking system calls to immediately return with -EINTR. Non-blocking syscalls could still be used. (So the cancellation signal handler itself would still have access to various fundamental system calls.) I think this would avoid messy coupling between the kernel's increasingly more varied system call entry code and C libraries. Sticky signals could be requested via a new SA_ flag. What do you think? Thanks, Ingo