Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp7308361imm; Thu, 28 Jun 2018 01:17:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcklval3bDHppW8LmgReLlCQ/jIrJzyWkak4G0XBmaQk8MII4E4uiSkwyOfBNvUvx5zYM4M X-Received: by 2002:a62:f5da:: with SMTP id b87-v6mr9212491pfm.113.1530173876019; Thu, 28 Jun 2018 01:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530173875; cv=none; d=google.com; s=arc-20160816; b=cqmEWOhibax2NQYv4/f3VB6xRL5M9O7/7O/w4MV8syvr/6WyPLFbAZpoHPpDaMWFb8 RgKpflpLAb2tW05f+Y7lQrcV5unDQUR84izlhPxJUye+C1B6sw2tD6G7ghQ440hYjeWx f771WeGtHzfbf8v44YhCa4H4TUu7B9yzql9Xsg0wue+gFqe/pHSA38X2iYZQWOLn6IsM o8UqGaJdMLtDwWwtWUy93wv5Jz2DvQVR0v43RxA7DuXlHDvA8JfIC2UglABKHzdTUMd5 dr2G+nfo1AwyUeEL9tiEgQ8pLV7YDNo3kd865jtGaYhUgNa+H402dBkO+Rc2p4UIyei1 XWnA== 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 :arc-authentication-results; bh=yI/HNfx9H1rFlz/2C60B/e6jvsoMWJUsXcvoBpnFSnA=; b=brC5j9FVfqB0MNHJx+hrVSaO/rkuz/bZ9+Ugp8wOX9HKa2/Fh0zG+kVajTG5OUp0qS yW2SNX2IYRGNIGrJgFsDx4s4lwuSh/69qWFqWP8hJjlOASrmIjFdGbpsA0nMljFdeHwd o7j25Uyn4fpX3zu+L5nfWrAZ0UgQr1+C+f1UNvYElctWea0bWWpebkLTFj43lOPTVoHK TPmMd86gWxViuTMxZAdITuz2x/UCJ8nsTaOfuwvM/XLQjhwO20W4scRPqicAGc7syOBd 1aRsO6SVorAuOgkqRizC4Vfg3kN1ImbU9svXZzyFbmw9tLnt/Vz93SvQx1NHuUe6rvpb 6aUw== 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 x3-v6si6167338pfe.318.2018.06.28.01.17.38; Thu, 28 Jun 2018 01:17:55 -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; 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 S933551AbeF1IGa (ORCPT + 99 others); Thu, 28 Jun 2018 04:06:30 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:55507 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932245AbeF1IGZ (ORCPT ); Thu, 28 Jun 2018 04:06:25 -0400 Received: from hsi-kbw-5-158-153-55.hsi19.kabel-badenwuerttemberg.de ([5.158.153.55] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fYRvF-00036j-Ky; Thu, 28 Jun 2018 10:04:57 +0200 Date: Thu, 28 Jun 2018 10:04:51 +0200 (CEST) From: Thomas Gleixner To: Andy Lutomirski cc: Mathieu Desnoyers , linux-kernel@vger.kernel.org, Joel Fernandes , Peter Zijlstra , Catalin Marinas , Dave Watson , Will Deacon , Andi Kleen , "H . Peter Anvin" , Chris Lameter , Russell King , Andrew Hunter , Michael Kerrisk , "Paul E . McKenney" , Paul Turner , Boqun Feng , Josh Triplett , Steven Rostedt , Ben Maurer , linux-api@vger.kernel.org, linux-arch@vger.kernel.org, x86@kernel.org, Andrew Morton , Linus Torvalds Subject: Re: [RFC PATCH for 4.18 2/2] rseq: compat: clear high bits of rseq_cs fields In-Reply-To: Message-ID: References: <20180626211617.8933-1-mathieu.desnoyers@efficios.com> <20180626211617.8933-2-mathieu.desnoyers@efficios.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-627297609-1530173097=:1778" X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-627297609-1530173097=:1778 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Tue, 26 Jun 2018, Andy Lutomirski wrote: > > On Jun 26, 2018, at 2:16 PM, Mathieu Desnoyers wrote: > > > > Make the behavior rseq on compat tasks more robust by ensuring that > > kernel/rseq.c:rseq_get_rseq_cs() clears the high bits of > > rseq_cs->abort_ip, rseq_cs->start_ip and rseq_cs->post_commit_offset > > when a 32-bit binary is run on a 64-bit kernel. > > > > The intent here is that if user-space has garbage rather than zeroes > > in its struct rseq_cs fields padding, the behavior will be the same > > whether the binary is run on 32-bit or 64-bit kernels. > > > > Use in_compat_syscall() when rseq_get_rseq_cs() is invoked from > > system call context, and use is_compat_frame() when invoked from > > signal delivery. > > > > And when it’s invoked due to preemption unrelated to a syscall or signal, > you malfunction? > > I think the only sane solution is to make these fields be u64, delete the > LINUX_FIELD_ macros, and possibly teach the x86 slowpath return to inject > a signal if it’s trying to return to a 32-bit context with garbage in the > high bits of regs->ip so that we determistically fail if the user screws > up. Right. That's the only sane solution. Trying to play games with 32/64bit for a dubious value is going to bite us within no time and just create ugly workarounds left and right. Forcing a clear handling upfront avoids all of that. Thanks, tglx --8323329-627297609-1530173097=:1778--