Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp523869imm; Mon, 2 Jul 2018 16:27:35 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdBsRd3wB/1/MCwUEnlWKCxJWDo8cwmHJHz2eBHj3OszZ659+Fh08xNqKMEcl/wc0+DQ36o X-Received: by 2002:a17:902:9f81:: with SMTP id g1-v6mr7482688plq.304.1530574055769; Mon, 02 Jul 2018 16:27:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530574055; cv=none; d=google.com; s=arc-20160816; b=LK5aOllStyri0iI6gy2wbjFN98WAaRXSihd5ZVa3wVUhh7PoDEXmLhdMo5jvqOin6y HSALNDBkUT0ZOSS12y0KBrTtSEMiFwEiFpRREe5oLfZGj9xOQB3FAPQ7XKhG7ZhZ40Sr aL7nbfZNsH8ANF4l5CBT13aK02ZQ+4gHZGgdHsY/fsiZdj8ozJFgh2QLjO0xQXEEs9mT +PyvcfxGVtcAXGecUrqWooTwzq94cOjEUAcf8arRT6/g+wh7NX4gnjEYznVbc1pMzlNP y3VBWuQFGS2+tqqskBQhtUyBzdyf4lscMrp5YJCPUKEE1yJ6+QczLRRy2c0we4trC/0w lhEg== 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=XvSr0vIdhKoWrNh1Ln6YdEFDz//AISB11KCyotqURwA=; b=OmA6kjP4FlkrhfEvYxCgM9niNUonkZU4koWLEJ3Q0bkRNPgWxNYg8MAYgqt9GQTO9T xD5T0QFkIbljuQkRghceilxosawG1J1jA5mCK5UTOaIzusMrPHpvD9p3H0c/M6ULpx+a TKxDgFNjqwgsmcupT2ddSwtWXHEx+qOqnJecEz1205k4JjwmuokupQRSCvqiborH/EiI BNF5Z6gMw6C+DgLA1+TNNuB+ACb7Eh5ymuQAhhuFRYWdcK9BqVYhpkpfuS8XbCx/wdjS ZztnU6s5JzM6Wc2xel/iiERuZsvIMgw4DVjuSfXCN1vj/HaNXqmRngR313lsaUzm2Bfm VSvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=tZwAcedc; 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 o12-v6si17050686plg.154.2018.07.02.16.27.21; Mon, 02 Jul 2018 16:27:35 -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=tZwAcedc; 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 S1753608AbeGBXZz (ORCPT + 99 others); Mon, 2 Jul 2018 19:25:55 -0400 Received: from mail.efficios.com ([167.114.142.138]:49410 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753342AbeGBXZy (ORCPT ); Mon, 2 Jul 2018 19:25:54 -0400 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id C28A522F0CB; Mon, 2 Jul 2018 19:25:53 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id I4QQgmYMT-iX; Mon, 2 Jul 2018 19:25:53 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 69BB122F0C8; Mon, 2 Jul 2018 19:25:53 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 69BB122F0C8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1530573953; bh=XvSr0vIdhKoWrNh1Ln6YdEFDz//AISB11KCyotqURwA=; h=Date:From:To:Message-ID:MIME-Version; b=tZwAcedcvsVlSMq5gWZAOpURCsNeRZaBgzqFzz+il4sFX4MswUHAmgUVrHGmLArBi fea2L85eP91tod1pMxu6tSg5ZNupHTwdbnKhXcsPdb2A0bjAVv4CclVeBaJY+F4/Vk LI51EHKdS43sPIxF9Np80N/QLv4YuMC41DRqA0Xjfk1DP96DkDipgYgtaUY0pBFFex etSYbYE6H/NbMqN8aDtxSQFhyIH2ZrjyH7H6bwjmt5L9aEC4wVEwpRAtswG6Q4Z4/4 2W6PV79WmnKQT7ro3VUXVPm6v1dG/99mOocDw0M58Z3itD/V6Uo+B6GNM4Jwx7dqAZ xJDyoVm77B9Ug== 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 bZ6GhQomaV3h; Mon, 2 Jul 2018 19:25:53 -0400 (EDT) Received: from mail02.efficios.com (mail02.efficios.com [167.114.142.138]) by mail.efficios.com (Postfix) with ESMTP id 4F63D22F0C1; Mon, 2 Jul 2018 19:25:53 -0400 (EDT) Date: Mon, 2 Jul 2018 19:25:53 -0400 (EDT) From: Mathieu Desnoyers To: Linus Torvalds Cc: Thomas Gleixner , linux-kernel , linux-api , Peter Zijlstra , "Paul E. McKenney" , Boqun Feng , Andy Lutomirski , 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: <321013411.10852.1530573953298.JavaMail.zimbra@efficios.com> In-Reply-To: References: <20180702223143.4663-1-mathieu.desnoyers@efficios.com> <415287289.10831.1530572418907.JavaMail.zimbra@efficios.com> <825871008.10839.1530573419561.JavaMail.zimbra@efficios.com> Subject: Re: [RFC PATCH for 4.18] rseq: use __u64 for rseq_cs fields, validate user inputs 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: use __u64 for rseq_cs fields, validate user inputs Thread-Index: 5yY1eXdGH2Vutk85uxDq25+e1DocAA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Jul 2, 2018, at 7:22 PM, Linus Torvalds torvalds@linux-foundation.org wrote: > On Mon, Jul 2, 2018 at 4:17 PM Mathieu Desnoyers > wrote: >> >> Are there any kind of guarantees that a __u64 update on a 32-bit architecture >> won't be torn into something daft like byte-per-byte stores when performed >> from C code ? > > Guarantees? No. Not that there are any guarantees that the same won't > happen for a plain 32-bit value either. > > Will compilers generate that kind of code? I guess some crazy compiler > could simply be really bad at handling 64-bit values, and just happen > to handle 32-bit values better. So in that sense a 64-bit entity is > certainly a bit riskier. But that would be a really bad compiler, I > have to say. Given that the only C code updating that field is rseq_prepare_unload() (the rest is only ever updated from assembly), we could perhaps mandate that user-space always update it from assembly, and therefore implement rseq_prepare_unload as an inline asm which clears rseq->rseq_cs. Does it sound better than the LINUX_FIELD_u32_u64 macro ? Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com