Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp147630imm; Mon, 2 Jul 2018 09:06:07 -0700 (PDT) X-Google-Smtp-Source: AAOMgpch+V0vlWf+IsrfbspMyZculp89Utjj/YdfkQFlE7Z5y86D04kQGd0DoLkf0vJvKvYFx7KW X-Received: by 2002:a62:4308:: with SMTP id q8-v6mr6122634pfa.86.1530547567586; Mon, 02 Jul 2018 09:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530547567; cv=none; d=google.com; s=arc-20160816; b=COdbsIOegUfoRGzUzJlzgnXg533zs452NVzXvYowoyd2xjMAaBloe2bZABZ6NswJRc BqlTU2xpFts5nhdmXcnDZEPygP5hTagh6E5WFp/MyvPP/oynbmLA60Z39IcszA6hdelt hfO0P3YkWKQdIrIDC4p14BwTQCUSHEuGgu6wSJXjOERuMmMXzBXwknOTl+7StygyYcTW vHxmVlVf/cvQavNzPzygi6JOfADVx7+VbfRrSCbuRx7udjKu4KKyva+FUm3TXpzjBIpU 7nXx1z1m4wMktravSmpvjS6VPgQKOprpPn6+eTOxNR56GHOlMkFhviFsrfXUPXEgXn9U zQjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter :arc-authentication-results; bh=U1dqsbvXtwxHzrMnSb5rQAmsEYMWW8zLp5Wyj0Ib2Fs=; b=JaBGaCm7rAaOzhCfIU9XqGPSxaxYLqIjtSvoZeeEV//+spyxvdPKTtHy6Q0VJskZpm RczjF1BiBefizX3SrLVds0yl8kll/LinGRY2JYz+bRQ3apHGoKCZF2y9BTXtb051sYjC if+jsmZUOiZW9eYxahNXaV/k5eWdCfIwyH8gHiR7eIA3TUpNNKjV5iyFJbOXvoKI4v5W rVnijNj3eZcRnImFbroQUXSCF0O7FLT++aduUEFNj0cCSfbA4MBcFRymn8rds0iD99PU wyYn9ggnafW+GthOH4RhJQgYfo4MpzSkRL5qec2gPs9RK9slaiMytrvJHBIEO55P9zwA ptlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=Aqprwe3L; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l13-v6si6229782pgr.291.2018.07.02.09.05.52; Mon, 02 Jul 2018 09:06:07 -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=@efficios.com header.s=default header.b=Aqprwe3L; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752271AbeGBQEZ (ORCPT + 99 others); Mon, 2 Jul 2018 12:04:25 -0400 Received: from mail.efficios.com ([167.114.142.138]:49726 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752237AbeGBQEW (ORCPT ); Mon, 2 Jul 2018 12:04:22 -0400 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 8EFC01C3A37; Mon, 2 Jul 2018 12:04:21 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id kD-IIupezc1v; Mon, 2 Jul 2018 12:04:21 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 1F6931C3A32; Mon, 2 Jul 2018 12:04:21 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 1F6931C3A32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1530547461; bh=U1dqsbvXtwxHzrMnSb5rQAmsEYMWW8zLp5Wyj0Ib2Fs=; h=Date:From:To:Message-ID:MIME-Version; b=Aqprwe3LyZ7FfqffamX7wZ2plxlEqSOyrGYty2z59HXa45XXO2evjksJ6FzWwWuI4 eEn3ugZHu7TTL7WwFPPfzuAwmLlVxxbcUbqbQkksJjmbjaL/acAe+XxZK0zYZhqVF3 Mj2zIBiKUA4a8XIPzqDWmtzm8LmOb4YOOhnGK6+Gt9bNgXvr5IMQzt55Y9dw1r1gdd Zt9jIlEqRLaTiZ/UE5KSJJB/DodXCI/uXo/kXY4573N8/GN5dxZ6mlUq4jkNaq0182 JqHC+wicy+bqyqnED51ZDWqnDBRWaMFWNnLIIjMlHdE6KsrwPEnGdste8QRGKJN13M vcS5ovLSNPjdg== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id 7-BByj4dMqCR; Mon, 2 Jul 2018 12:04:21 -0400 (EDT) Received: from mail02.efficios.com (mail02.efficios.com [167.114.142.138]) by mail.efficios.com (Postfix) with ESMTP id DD3661C3A2B; Mon, 2 Jul 2018 12:04:20 -0400 (EDT) Date: Mon, 2 Jul 2018 12:04:20 -0400 (EDT) From: Mathieu Desnoyers To: Andy Lutomirski 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 Message-ID: <4741715.10696.1530547460698.JavaMail.zimbra@efficios.com> In-Reply-To: <1527399163.10673.1530541966296.JavaMail.zimbra@efficios.com> References: <20180628162359.9054-1-mathieu.desnoyers@efficios.com> <247789350.9741.1530288432573.JavaMail.zimbra@efficios.com> <184287091.10022.1530301738384.JavaMail.zimbra@efficios.com> <1527399163.10673.1530541966296.JavaMail.zimbra@efficios.com> Subject: Re: [RFC PATCH for 4.18 1/2] rseq: validate rseq_cs fields are < TASK_SIZE MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.142.138] X-Mailer: Zimbra 8.8.8_GA_2096 (ZimbraWebClient - FF52 (Linux)/8.8.8_GA_1703) Thread-Topic: rseq: validate rseq_cs fields are < TASK_SIZE Thread-Index: EfNoEXYdmNtWTN5CDgNZeik/VS9bfCDUAY2S Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Jul 2, 2018, at 10:32 AM, Mathieu Desnoyers mathieu.desnoyers@efficios.com wrote: [...] > > But rather than trying to play games with input validation, I would > favor an approach that would allow rseq to validate all its inputs > straightforwardly. Introducing user_64bit_mode(struct pt_regs *) > across all architectures would allow doing just that. rseq signal > delivery and return to usermode code could then ensure that high bits are > cleared by 32-bit tasks for all fields and thus provide a consistent > behavior for 32-bit tasks running on 32-bit and 64-bit kernels. AFAIU this could be achieved by re-introducing is_compat_task() on x86 as: #ifdef CONFIG_COMPAT static bool is_compat_task(void) { return user_64bit_mode(current_pt_regs())); } #else static bool is_compat_task(void) { return false; }; #endif Or am I missing something ? Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com