Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1410856imm; Tue, 3 Jul 2018 10:36:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpftnQMhEqa+OgTScu7+YfxEyFf+cATlsmHYDlaBWgR7Ks2plNjuuN326TPddl4mS1uuyDzK X-Received: by 2002:a62:455b:: with SMTP id s88-v6mr11321696pfa.203.1530639414209; Tue, 03 Jul 2018 10:36:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530639414; cv=none; d=google.com; s=arc-20160816; b=xlrWgtyQ+cAeWk9711QWIf4ZDvV1LqC5oUlMlV+Gl3N5Gj7M7RcMXGyXLlkRSRk/W+ HGevum60Pkg1xfy/HvYRg/k2zD/qsGsf6qaczpK1aecXXa3/I01Cuc2y5QXC0hLsG+kw fIky/YLCBBh4GoZqiBjEjH3DEXOC3RN95Q/FCj7W2/oKEpY9mhNhGru90yS4Zv1VEu68 7UvPvRCjH4PAKcn4V5CMgW4eJPAv3wWO3lkMFnnydDLgbf4MshXohY0xTcEvxkraxbNm 07xOIN7akbajQuqxFhCVyC+1kF1tfUP7Sn35n+HgRgwTX7J0YKzGsUL/f8Wlt+2OjZw4 EMZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=vGzXPoW/Bg8Pd8Sl1LtBAwnJAJ4zXa3kozmVXoSBEBw=; b=LC3a+EtrSuCL5RPACHXYqRBcsMlNNQYxSRC9xeU2KBwXuthnXhxlSPnguNDkbqDK7U OgaCMU7kMVNst3tvbgnydYSb+Ztrybv0Uh2G/8t9tu32UUv0+bSozqHT8bRfCNSRNFIO gD0DKju8JwFlablRQu7e154MZ20ahGbRPDPsrLePow5uZxJWWcK1kxsBSG10Ppwplh9i zRcTOh0jFPV7A5KCmNxt829Xm1fRQyfcDdKI5JoCO7F/r/j01KrS375ix1eaQ8BQJofK LvqWbTFO2C1GjHBLt9+/h2jt17BQSSaWxZTy6F/lyTkpm91VB18FhmBYaZ03tKCgKS0W udpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=gSOb6JK7; 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 q20-v6si1459447pgl.573.2018.07.03.10.36.39; Tue, 03 Jul 2018 10:36:54 -0700 (PDT) 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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=gSOb6JK7; 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 S934379AbeGCRfu (ORCPT + 99 others); Tue, 3 Jul 2018 13:35:50 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38336 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934237AbeGCRfr (ORCPT ); Tue, 3 Jul 2018 13:35:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=vGzXPoW/Bg8Pd8Sl1LtBAwnJAJ4zXa3kozmVXoSBEBw=; b=gSOb6JK7SCo6MDqkNpOo/qJSb GijR0GC0IEQu5i+bZaH60CDOxXpSDL3WpYQ1OpbbxmRReQJbDFrrQEP/vzTwDmHUW+lzZcz+sjM7G f3RK6Fbw+DETPp6qyRls9SP2ZaeuxU4FetJKH6Z3e5iV2XI+q7uN/gpBa6gHmpGSUHN1zLjNRt0h3 ugmDVZorAJZalfMTjyJQWly/2dZUItBcZcs7jv8iJNcyoD070dyw6kkJ1SwS+DCx4RbYGZBEIF7BO 4Zjw8ja56O2zh8aevHiVaWmVgIq/ATy8UzfiiYYDewXTR2oAZYb61wYV/G/N9lpa4csDB70qwzbsw /N8RRczJA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1faPCX-0001Qu-PV; Tue, 03 Jul 2018 17:34:53 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id B23B120289333; Tue, 3 Jul 2018 19:34:51 +0200 (CEST) Date: Tue, 3 Jul 2018 19:34:51 +0200 From: Peter Zijlstra To: Linus Torvalds Cc: Andi Kleen , Heiko Carstens , Mathieu Desnoyers , Andy Lutomirski , Thomas Gleixner , Linux Kernel Mailing List , Linux API , Paul McKenney , Boqun Feng , Dave Watson , Paul Turner , Andrew Morton , Russell King - ARM Linux , Ingo Molnar , Peter Anvin , Christoph Lameter , Ben Maurer , Steven Rostedt , Josh Triplett , Catalin Marinas , Will Deacon , Michael Kerrisk , Joel Fernandes , Michal Simek , Martin Schwidefsky , gor@linux.ibm.com Subject: Re: [RFC PATCH for 4.18] rseq: use __u64 for rseq_cs fields, validate user inputs Message-ID: <20180703173451.GX2494@hirez.programming.kicks-ass.net> References: <858886246.10882.1530583291379.JavaMail.zimbra@efficios.com> <1776351430.10902.1530585009519.JavaMail.zimbra@efficios.com> <20180703081449.GT2494@hirez.programming.kicks-ass.net> <20180703082955.GH3704@osiris> <20180703084312.GU2494@hirez.programming.kicks-ass.net> <20180703085546.GJ3704@osiris> <20180703092113.GV2494@hirez.programming.kicks-ass.net> <20180703164048.i2te5gjemcafqzwf@two.firstfloor.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 03, 2018 at 10:10:37AM -0700, Linus Torvalds wrote: > On Tue, Jul 3, 2018 at 9:40 AM Andi Kleen wrote: > > > > So it sounds like architectures that don't have an instruction atomic u64 > > *_user need to disable interrupts during the access, and somehow handle that > > case when a page fault happens? > > No. It's actually the store by *user* space that is the critical one. > Not the whole 64-bit value, just the low pointer part. > > The kernel could do it as a byte-by-byte load, really. It's > per-thread, and once the kernel is running, it's not going to change. > The kernel never changes the value, it just loads it from user space. The kernel doesn't change _this_ value, but the kernel does change other values, like for instance rseq->cpu_id. But even there, it could use byte stores and it is again the userspace load of that field that is critical again and needs to be a single op.