Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1387553imm; Tue, 3 Jul 2018 10:12:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc59agjmzCZCz0oJ2nXW8CC0ZZQiJGcZWXkOiUl5KNPZfMgHm2Uo9y4IyK6pCh1DtAr165Z X-Received: by 2002:a62:9c9c:: with SMTP id u28-v6mr30814086pfk.90.1530637948804; Tue, 03 Jul 2018 10:12:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530637948; cv=none; d=google.com; s=arc-20160816; b=ObMs3OCNnJVp7epGKsqIjwDZiMgj6nBMF6oSnT8lyaLoy1Ncl3N20STdekoBrGeLNB ESQ+LNfVZMBh4vVQrJMZiPCKIxxM2izPGUE7ge4HjvDL4CVWvsAGYSePxnUdh8RW/iMb YO10+1QNosMeOa4OSjGjefAmZOkJ0iRB21M8lv1t8GOJ7KZySOGa0K2psxoRELo5qNWb FUBBKuSZcJH4Z1mskiCGOUJ4w3gb6ODi3oO7h/NUkkB5HIjSlDrrzgtUbevER7MN+5kt qUig8FgVr4CBY2n6I1DLR9M1GWn2ulD6zK6vU46ThYq+fl8pBrwrXUtm9D1q0ky50anM 5ogA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=p+slRbcnqGd4/KZcc2S7pJQLk2sJu2KDzj8lIgFLp5s=; b=PsmBBkXz148zKiksGfcph/z1Q0N8THcBatLYY+udZRyWaHL5fE2ZcAAw8oo3uQVsf0 cY1WrsD5+0jjvzcj7MuX4Lm6lPuLM3xSCjyv46J/V02RWreHuBiKRLY8lFEVLMlSilUU Wx6XY5WczdbnI0nqdu0IatZ2WzS7iRgtsPW3qcGE1YmxmvQlgXtcSEQZRTUh+Ot2v6TP MPZtu1U9AdbXhZhAdKO94EE2R86UCPLgx7ZzJAJQWiR/eZ0A5MWErwJzGAWp2iyl31G5 /S4Z5XqRPysiEgxoKF+M+c5aOgqfk4F5OlkG4w0oxgIruVw4isEjYENz8kBa2bsxGqum fGlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=IyfPfSbu; 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 v4-v6si1331111pgv.624.2018.07.03.10.12.13; Tue, 03 Jul 2018 10:12:28 -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=pass header.i=@linux-foundation.org header.s=google header.b=IyfPfSbu; 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 S933988AbeGCRKv (ORCPT + 99 others); Tue, 3 Jul 2018 13:10:51 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:36702 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751735AbeGCRKt (ORCPT ); Tue, 3 Jul 2018 13:10:49 -0400 Received: by mail-it0-f66.google.com with SMTP id j185-v6so3908502ite.1; Tue, 03 Jul 2018 10:10:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=p+slRbcnqGd4/KZcc2S7pJQLk2sJu2KDzj8lIgFLp5s=; b=IyfPfSbuFM+3UaUpxKuuEB19/w88CdKvUzRSg1tLkK8X1Ci540zadZEPbmxNYYy3s3 q59g/4q8JY93iaW7cvACb1vWXjaz5WBQw7R2yxmPm1cIHyiZfb2rms/G0ibgqu+RZX2n /yxrsjTBS7LNuX3DZHjert8DovRKO5S1yawSY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=p+slRbcnqGd4/KZcc2S7pJQLk2sJu2KDzj8lIgFLp5s=; b=p2mTE0+KArV1wkjjhPyvwrfKb4P3td1+XUvityaO/n47M4D0Kvnj7tX+ZWxgcZ+LlQ ZmU99YloO4hUxbQrT9jSDGLf8Oej2OsaSEXmq7iGkzbRy6bTbq4xO71vblzzOKt+VNdd uWEK9z3FoJNMRwWuk4ARa3qumnN1/Rh3S2qwmL7bCPPINkQMrR7P2bmvw8aJlXTvFjs+ xvih8U3/MFrVLiPjPdPvRMFxcn/RpQjmRzB0qL/6naPwUBmGp/2LLUihPodijmQYkc9N mmtu/4LYTDHK+dcTWa2iX6oow9blDJ1HdinpEwucQ8aQ2Ftx90O5cuMElkml+Wck41uG 0PPw== X-Gm-Message-State: APt69E35WkqftNdDJ5J4TdOHpuuBVmwFfQF2S0uVc32UIM8XvV+J3x1a QbdvTL8FYQpV2ZNSrhdMwqIORiUivj7EAf6SwVg= X-Received: by 2002:a02:89a3:: with SMTP id p32-v6mr25317034jaj.10.1530637848289; Tue, 03 Jul 2018 10:10:48 -0700 (PDT) MIME-Version: 1.0 References: <8B2E4CEB-3080-4602-8B62-774E400892EB@amacapital.net> <459661281.10865.1530580742205.JavaMail.zimbra@efficios.com> <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> In-Reply-To: <20180703164048.i2te5gjemcafqzwf@two.firstfloor.org> From: Linus Torvalds Date: Tue, 3 Jul 2018 10:10:37 -0700 Message-ID: Subject: Re: [RFC PATCH for 4.18] rseq: use __u64 for rseq_cs fields, validate user inputs To: Andi Kleen Cc: Peter Zijlstra , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. So all the atomicity worries for the kernel are a red herring. They'd arguably be nice to have - but only for an insane case that makes absolutely no sense (a different thread trying to change the value). Can we please stop the idiocy already? The kernel could read the rseq pointer one bit at a time, and do a little dance with "yield()" in between, and take interrupts and page faults, and it wouldn't matter AT ALL. It's not even that we read the value from an interrupt context, it's that as we return to user space (which can be the result of an interrupt) we can read the value. This whole thread has been filled with crazy "what if" things that don't matter. Linus