From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6071CC433E0 for ; Tue, 23 Jun 2020 00:56:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 218B22070E for ; Tue, 23 Jun 2020 00:56:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="nAdHPfYX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 218B22070E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9F4596B0002; Mon, 22 Jun 2020 20:56:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A35B6B0005; Mon, 22 Jun 2020 20:56:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 892276B0006; Mon, 22 Jun 2020 20:56:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0187.hostedemail.com [216.40.44.187]) by kanga.kvack.org (Postfix) with ESMTP id 703716B0002 for ; Mon, 22 Jun 2020 20:56:25 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 0F330180AD81D for ; Tue, 23 Jun 2020 00:56:25 +0000 (UTC) X-FDA: 76958660730.18.club06_050960a26e37 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id E367E1003CD0F for ; Tue, 23 Jun 2020 00:56:24 +0000 (UTC) X-HE-Tag: club06_050960a26e37 X-Filterd-Recvd-Size: 4434 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Tue, 23 Jun 2020 00:56:24 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id d66so9266965pfd.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=XyQHtbOd7Gzz150sbdiUwCaENRa3CPxTA7WB5ipWl+LgbfaYEWIwi+KgGClE+r1Za1 NCTGFkh1E2vC8u+WOV+dOlklhXv3fdhk2dP0mtjZRzZwH+uIcKkpQPLfsCQg1Rg8q/rN +SOA77328T5VADbtm47ryNkoSfb+rxU6gGFsBLFV5vGpQtTmTxxUWVztDZubIcklFQAw B3dqxOgrADZ9KBmbD4dkAYAfsVy9NdkoHRlgOk8aBMwyzuGc0zX3MM7vXi10BXhfV8Fr 8cJ2w6q7HSjmcFNBdh6QMlSTaDwfjieXbvZgc493XZlCiwwnH3EYaq646asVX1Eycflp tELQ== X-Gm-Message-State: AOAM5320L7V5eeszxGH9Fjm1DWUV23qFjUnbUtURdhJ0mNdb6FeZ78nW kPfCJpxwDxTb8diY2p2wAj/mqA== X-Google-Smtp-Source: ABdhPJzcouPDWEUYGfs6mnKQxNW21WTL2h/cvt4aWHu1LneMG7v+1KMi+E4KPxR8Q7oPaJp1wkS5WA== 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> X-Rspamd-Queue-Id: E367E1003CD0F X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000008, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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