Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp562500imm; Mon, 2 Jul 2018 17:24:11 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe6Xs4t5ruz77RrflCoIwKWVbUVdeLcLHXnXZX8N2P6koFs9cgPAtshz/IPt2Xzg7bQvM8z X-Received: by 2002:a62:5e06:: with SMTP id s6-v6mr27339326pfb.253.1530577451287; Mon, 02 Jul 2018 17:24:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530577451; cv=none; d=google.com; s=arc-20160816; b=phDSkcaVfQoPRjUGzVo7Ph3RWWxggCrPKcW7aaw/TKkn3tyWT/NCyxSaxwoIGshywB tj4/FMg/2qRObxy8/ER58A3hJVWIq+mvJ0UmglgDD5ONP6n1IwvxcVf0n9No0VOhCfo6 DX4Qq5AwTIgXNGph3Y4hVPlfcBV4HqEwK7hHc+BC0jYbjbET3L6m1DNFWDRiyp7xXSs7 DMU40eovSy2AcEn7NyaqnR16X01OqMOVVy8K3XJqMRZMjBlzwPw7TSBt7MHpuapQr+xU Fi2RXQcvMGNtD6Pb2w0JsOYeXJkVgE54o3GL8nSSxclbRhnDiS6kDyz9m7RIWVw5OvcX iCCA== 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=Mekz8bfQ386HfKn0lhl8BNLWDIFW6+GBcrYLrBOufXs=; b=dFSWkPjFYasb0oV3EYtjVEJhXw9Q/aDvYIx4gllg53Z2wZeV/aRFS+kbzxvd7bP1ls 8Ak+n2Y9s0PWqs5YsxGuEhsMzfcy+N+p1UHc7zPiuLF+SodBJCBCthqIeM0clNnWIKsf LX2OHE/Axv6NA6/31OiT4FeZJnfhrya27/rr8XXxdQqOeAYrBKowG7g+9RAxAA3mk3SP 8zeC+fU8atJluO5Wj+kzkZef7NtEdO7JX/s5LTZ8/xO2slKkRz9pSFJsytUTk6L38b5Q Tla5IAWN2/Xv5c+1O2MqPBwYAesPScUw2mRPqAxs28o97wvxQ2BePGUVa/NEyYGt7xKm FmZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=JsyKSSMM; 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 e39-v6si17369396plg.168.2018.07.02.17.23.56; Mon, 02 Jul 2018 17:24:11 -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=JsyKSSMM; 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 S1752992AbeGCAXP (ORCPT + 99 others); Mon, 2 Jul 2018 20:23:15 -0400 Received: from mail.efficios.com ([167.114.142.138]:52544 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752686AbeGCAXN (ORCPT ); Mon, 2 Jul 2018 20:23:13 -0400 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 97AA522F2A1; Mon, 2 Jul 2018 20:23:12 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id qCX1u_7Lva5O; Mon, 2 Jul 2018 20:23:12 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 0A58222F29A; Mon, 2 Jul 2018 20:23:12 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 0A58222F29A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1530577392; bh=Mekz8bfQ386HfKn0lhl8BNLWDIFW6+GBcrYLrBOufXs=; h=Date:From:To:Message-ID:MIME-Version; b=JsyKSSMM864b3jX6zDTZyUlmiF8DxuMzyKX3UjsLy3DoqdwrvoilgCbGhamrY0PfG ZSdtz769VYUeLTfok5+CWK7yXVYrm7QAo2lzJYW3gm5F0eJK64LJ+hmvRyOXbMPwe5 xjRv2IUlHRDg6qPxbZc+0RsXI7I83ZKEKHe48aHLYjG+TJNWNeF04ZgB3xoagBGWli fQKA9eKV22hU/1PuJNPHR1utPO9k7VsWUIOkJG0rDq3s1RQZmgRwI5QTZNk+8kzOhp LwSRiKpcE6/nxITZRQ/Tkyb7hvY/eIeO2PyKtltOI/kJACPHQc5hjwrcCgYax8Tf3s MlhyPTWYmojVQ== 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 RATme5mK_nh1; Mon, 2 Jul 2018 20:23:11 -0400 (EDT) Received: from mail02.efficios.com (mail02.efficios.com [167.114.142.138]) by mail.efficios.com (Postfix) with ESMTP id E2B5F22F287; Mon, 2 Jul 2018 20:23:11 -0400 (EDT) Date: Mon, 2 Jul 2018 20:23:11 -0400 (EDT) From: Mathieu Desnoyers To: Chris Lameter Cc: Linus Torvalds , 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 , Ben Maurer , rostedt , Josh Triplett , Catalin Marinas , Will Deacon , Michael Kerrisk , Joel Fernandes Message-ID: <1020760632.10855.1530577391822.JavaMail.zimbra@efficios.com> In-Reply-To: <010001645d81f652-8a506dd2-cd49-47f9-950a-24ef52bda9f7-000000@email.amazonses.com> References: <20180702223143.4663-1-mathieu.desnoyers@efficios.com> <415287289.10831.1530572418907.JavaMail.zimbra@efficios.com> <825871008.10839.1530573419561.JavaMail.zimbra@efficios.com> <010001645d81f652-8a506dd2-cd49-47f9-950a-24ef52bda9f7-000000@email.amazonses.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: Qfic5CuPU8u4f935Vywe9GGxSdDRDA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Jul 2, 2018, at 8:19 PM, Chris Lameter cl@linux.com wrote: > On Mon, 2 Jul 2018, 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 ? >> >> I don't worry whether the upper bits get updated or how, but I really care >> about not having store tearing of the low bits update. > > Platforms with 32 bit word size only guarantee atomicity of a 32 bit > write or RMV instruction. > > Special instructions may exist on a platform to perform 64 bit atomic > updates. We use cmpxchg64 f.e. on Intel 32 bit platforms to guarantee > atomicity8. > > So use the macros that we have to guarantee 64 bit ops and you should be > fine. See linux/arch/x86/include/asm/atomic64_32.h We are talking about user-space here. What we need is a single instruction atomic store, similar to what WRITE_ONCE() does in the kernel. The discussion is about whether doing the user-space equivalent of a WRITE_ONCE() to a u64 on a 32-bit architecture should be considered to provide single-copy atomicity on the low 32 bits. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com