Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1247595imm; Fri, 29 Jun 2018 14:18:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeJWGHIkoNhevyLWGHDjExFXS30W1YDx7RQEI36TK8xbdQjFTaKv0RvU7uH27zuek09kbCV X-Received: by 2002:a62:2fc4:: with SMTP id v187-v6mr16159643pfv.100.1530307102252; Fri, 29 Jun 2018 14:18:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530307102; cv=none; d=google.com; s=arc-20160816; b=PLhk9lT7YEcrJj29bBvxErBWa04H9sc4T4nw2E2RQ7gFZBQRsQesEsIsX6s6m8a0Uf fF9SLYkiuq6+A326Aepo0vdoVqE8TYZODLPFBueMw2HrL7UmtGY8IYqEzkTexvLLWJSZ ICAGH/CQx93kV+f7Z9m7Hm4voKAa8WQj4HWpDQmLP2cdAL6UVGZrkMmDd1SXhqbVIgVN 5DNgce1quDbhu42tfm7dSBWoKvIxmsJJHCNbJnioWr3ZJni7edYHHe0tAJLJe++LU0M4 2KFz4C48DZf4+4ExZvghGEhYFSp+ut0UgJD2QQ3kbJl+GzHF6oXyybf6t2krCQ8fNCWe xVCA== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=0SuGM8blz8HcsIDoH86MI1r8RbSvlEjQap/IrEM9G40=; b=iEhq9/W2Qduhb7YQGvi3T8O07AwFlKMjYuwGzOqYMz37QGqRT+crbc1OQOl8U2fNR+ 3yJ3icIqXk6utot8ihD9mXDVckFO+UsS0c+PMTBlLfYHgSBP/CTCeV022/C3XTNx+l7K 2xhSyRTM07YTn1TxVorwMOIDsg4xbl+eRDhMLxp/W+0LiHYXHHVefaIeYyudPFmAIdP0 8eZEgnESIskYqbllICO0J+7bb2zIEZup1sZjfg6bmYP/oyv5ju/L7oZ6ePHp7ghBP+Sd q1Xa2YdRFAYbd2ozBn87bxgWQUaIeRKoHNIO79LCfJqfhfXh0XiQaWhKK8Sq1UmayyVH QekQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b="y/bcBWGH"; 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 73-v6si7865735pgh.343.2018.06.29.14.18.07; Fri, 29 Jun 2018 14:18:22 -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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b="y/bcBWGH"; 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 S937209AbeF2Ujp (ORCPT + 99 others); Fri, 29 Jun 2018 16:39:45 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:55102 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936349AbeF2Ujm (ORCPT ); Fri, 29 Jun 2018 16:39:42 -0400 Received: by mail-wm0-f67.google.com with SMTP id i139-v6so3372473wmf.4 for ; Fri, 29 Jun 2018 13:39:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=0SuGM8blz8HcsIDoH86MI1r8RbSvlEjQap/IrEM9G40=; b=y/bcBWGHilUkhcag3XPrUpjIQ2FJXjMo/JXbmC/lwCvD9dCIy7Qk5BZMzRdCdFfZ8g wqEsv58SDeVPYwqNmHsLKxx10CfXI5dVOPEPimd04qv4A4yOSYj5jqJtDfcO8VaZQG99 1GWp8bFZIhRMY0jDyoEMAspPIcJ5zTbhzcgtzoIBfsu0fvLbFwS1MRcF9F9attHs6G6b 1F1zbkD1DDZq7CezaU0+HMtuxzZ/R+CuWTWdLguZZMsJYNLAGayRS79kUe428idbQAxp 6F99IrVN+mxDHHkUo8rRp4EaDSyBrtwpblhnUfEzzaODguK1quTaL2zxVpk1welqXBXW pIHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=0SuGM8blz8HcsIDoH86MI1r8RbSvlEjQap/IrEM9G40=; b=ZyPrggfKPgZoZLtNUAGtd5TSdKdfKqsgGPanD3EemPDN6Zyx1vzWCzEjUW1vkmJqJm WDq+CFbE8qIL5T2K18Y3zMisJUAJsuRZ63FDX+R1QfKbi8VRJiTsSXt/jsDDST4EAzoq rWUfufMTz7AtRTVxdNP0uhuCMFDVGFLXDT+FVd5zUlxfEnVgEB/CPqqz2eZgSkE5CRSG eJVxYZV2bv302aqHCm5TnXin/nZNZc5mUefoLnmiQzN/iSo7xPPSLHVPeGXI2mdhFu/H SttdTMx2OEEKE7FxLRtGOPUa+90ui+6hc+j7GF4pKHbN5fvmfPruu6m/UZKNg4+31G19 vawg== X-Gm-Message-State: APt69E1F6uNVBCjzETod99f0pb2AHBe83qzf4lFCSdH3WDCMNiICDibf mEFpNxZrSTAAN0uRqYnl/acCPu1UJcSqPdOLdy1J+A== X-Received: by 2002:a1c:8313:: with SMTP id f19-v6mr2585851wmd.144.1530304780946; Fri, 29 Jun 2018 13:39:40 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1c:7e92:0:0:0:0:0 with HTTP; Fri, 29 Jun 2018 13:39:20 -0700 (PDT) In-Reply-To: <184287091.10022.1530301738384.JavaMail.zimbra@efficios.com> References: <20180628162359.9054-1-mathieu.desnoyers@efficios.com> <1706339668.9644.1530281144560.JavaMail.zimbra@efficios.com> <729451355.9702.1530284622326.JavaMail.zimbra@efficios.com> <247789350.9741.1530288432573.JavaMail.zimbra@efficios.com> <184287091.10022.1530301738384.JavaMail.zimbra@efficios.com> From: Andy Lutomirski Date: Fri, 29 Jun 2018 13:39:20 -0700 Message-ID: Subject: Re: [RFC PATCH for 4.18 1/2] rseq: validate rseq_cs fields are < TASK_SIZE To: Mathieu Desnoyers Cc: Linus Torvalds , Andy Lutomirski , Thomas Gleixner , linux-kernel , linux-api , Peter Zijlstra , "Paul E. McKenney" , Boqun Feng , Dave Watson , Paul Turner , Andrew Morton , Russell King , Ingo Molnar , "H. Peter Anvin" , Andi Kleen , Chris Lameter , Ben Maurer , rostedt , Josh Triplett , Catalin Marinas , Will Deacon , Michael Kerrisk , Joel Fernandes 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 Fri, Jun 29, 2018 at 12:48 PM, Mathieu Desnoyers wrote: > There are two aspects I'm concerned about here: > > 1) security: we don't want 32-bit user-space to feed a 64-bit value over 4GB > as abort_ip that may end up causing OOPSes on architectures that would > lack proper validation of those values on return to userspace. I'm not too worried about this. As long as you're doing it from signal-delivery context (which you are AFAICT) you're fine. But I re-read the code and I think I have a really straightforward solution. Two choices: (1) Change instruction_pointer_set() to return an error code if the address passed in is garbage in a way that could cause unexpected behavior (like >=2^32 on x86_64 if regs->cs is 32-bit). It has very very few callers. (2) Add instruction_pointer_validate() to go along with instruction_pointer_set(). That should be enough to solve the problem, right?