Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3193892ybt; Mon, 22 Jun 2020 18:01:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYQrA8Mmro0y5QHPVpu5+1ZBc8xOz8agjBZSYpW1yP/fAQ/AmOaqvZhCkGbYxD9Y7lI7fz X-Received: by 2002:a17:906:958f:: with SMTP id r15mr4244151ejx.77.1592874079620; Mon, 22 Jun 2020 18:01:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592874079; cv=none; d=google.com; s=arc-20160816; b=yoFD3QQgW/bi7kKJvBEBgZ+8eOB5DxVg1REGVYSXVNkuT4oKNLaNE+ZsH0+2nSV0Gn /1TxIbBboJOglBrxDDTH3ogaObSWwPLYK/dOKo5akyASDVsh7MpqkgsUpkUlZhnSfSdW EsUoVXQlofCTsdcTl4ZWPqKCZMMdx1OY0fT35fXjsViUl0NJo8td9pFX6AecxZRGiZTc CzMvhN5QB/ZSgaJeB6DkwNmZaSCyjD9D6CvJjX/aIGut1iReKpVVDE88gU84ncriJvCF xDYXfqDFSzX6WdsNsXMaGk7uA8Mb7qqC/sF3qW3RmS2krolXlQjLpx6vFmEDTKot60++ KIcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ddZISy/nnQaDTw5hRGQzjmZlz/IMEisCTFQ7iFu0Th0=; b=e3N+EWvfy1eJ4K+rBe38XqcRFb2EeFG9Ovs9Mvha3jRBU3H0CzUMhMuYHGcX74zwr9 uWWd+/pfvzOG04xuETjFxu0RZTpIh8aySe4djrKIWOWfZ5tWBH3kr2IREtiYhmhepa4i YwYNCGGdIOYcKX5RCGMiOhERE3oxGLF+oLy/ABcC1M/bHFzlaoBlq3kffONKriIikphE fAfka9SVtDEuuzBshdq8dgO0fj2zsZ1Jrm3FHzZeYyYJiZ6D0r7J3LQqRVgYKpwtuxmv SQAcgicoDuTB6KWmA1qOI0FwnmMS4W3Uizsxkfyb8U4+bMwUFQyXesSvshzqEXp/4bpz 9YcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nAdHPfYX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v8si279691edr.557.2020.06.22.18.00.56; Mon, 22 Jun 2020 18:01:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nAdHPfYX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732450AbgFWA41 (ORCPT + 99 others); Mon, 22 Jun 2020 20:56:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732431AbgFWA4Y (ORCPT ); Mon, 22 Jun 2020 20:56:24 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B2F0C061573 for ; Mon, 22 Jun 2020 17:56:24 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id z5so596922pgb.6 for ; Mon, 22 Jun 2020 17:56:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ddZISy/nnQaDTw5hRGQzjmZlz/IMEisCTFQ7iFu0Th0=; b=nAdHPfYXVzWTBCeDEMmkeKJ+hHfd7oErRWwLQb9dB7/Ol4YD/npR6fC0vwGRXy/c29 GGQ0oMgXVfEfwUNLWB5Mq3C346cIetMwNMMUd76j9Ztr+rPIR33dCIUpM2i+4VJOQ8xU A1KmHa9YIl4kewOB9Lmi3GBsCMQ5u7F38OPjo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ddZISy/nnQaDTw5hRGQzjmZlz/IMEisCTFQ7iFu0Th0=; b=XvCH3MPKb/aOX0sU/8ghNQUXwaZSrESJQ9l0jS9EVGIhAL+hKzJNgO/d0kn4VBZLd0 LNPAjrv8Z9dgUclHuS0DgNKC8BtDTHoEvGr2J3/+w4yHTLb9YAuPNEIr8Yu7Od1lUhoC bH8Ek/JLgDLttbmwApQC1oBUwby8qBpiv1/RXN+T4C0iSOciDd28nXW9hSNVe7OvGaSp /aXtmXanVao/V5kM57e8GAz4gojmx3D9GPH4FmYJYyZXWE0YP51DUTh76ZS/bbff66LA zOBWZ5meS6w58WPiEhTSDiYQKHpJzSzML3ejNT09uezxfUHo6a7xYOgcgWvlzbNqdgwY A/dQ== X-Gm-Message-State: AOAM532WFETasErYjoP6zl9jLfh2lLnjUGB8uI0kH8j9nNy1FTEDL3Z3 9h4fQDLMELUBYN8mu7XmtsCBYA== X-Received: by 2002:a63:35cc:: with SMTP id c195mr14777269pga.180.1592873783576; Mon, 22 Jun 2020 17:56:23 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id y187sm15258705pfb.46.2020.06.22.17.56.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 17:56:22 -0700 (PDT) Date: Mon, 22 Jun 2020 17:56:21 -0700 From: Kees Cook To: Arvind Sankar Cc: Thomas Gleixner , Elena Reshetova , x86@kernel.org, Andy Lutomirski , Peter Zijlstra , Catalin Marinas , Will Deacon , Mark Rutland , Alexander Potapenko , Alexander Popov , Ard Biesheuvel , Jann Horn , kernel-hardening@lists.openwall.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 3/5] stack: Optionally randomize kernel stack offset each syscall Message-ID: <202006221748.DA27A7FFC@keescook> References: <20200622193146.2985288-1-keescook@chromium.org> <20200622193146.2985288-4-keescook@chromium.org> <20200622225615.GA3511702@rani.riverdale.lan> <202006221604.871B13DE3@keescook> <20200623000510.GA3542245@rani.riverdale.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200623000510.GA3542245@rani.riverdale.lan> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 22, 2020 at 08:05:10PM -0400, Arvind Sankar wrote: > But I still don't see anything _stopping_ the compiler from optimizing > this better in the future. The "=m" is not a barrier: it just informs > the compiler that the asm produces an output value in *ptr (and no other > outputs). If nothing can consume that output, it doesn't stop the > compiler from freeing the allocation immediately after the asm instead > of at the end of the function. Ah, yeah, I get what you mean. > I'm talking about something like > asm volatile("" : : "r" (ptr) : "memory"); > which tells the compiler that the asm may change memory arbitrarily. Yeah, I will adjust it. > Here, we don't use it really as a barrier, but to tell the compiler that > the asm may have stashed the value of ptr somewhere in memory, so it's > not free to reuse the space that it pointed to until the function > returns (unless it can prove that nothing accesses memory, not just that > nothing accesses ptr). -- Kees Cook