Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5024385yba; Wed, 10 Apr 2019 09:41:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGP3hXt/f31dI4PwFziwBeZLJw3zlVYIq1ePwwHnpOmA4E26qzIaZnITwx3ma8h/52b51P X-Received: by 2002:a63:744b:: with SMTP id e11mr41618301pgn.327.1554914502384; Wed, 10 Apr 2019 09:41:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554914502; cv=none; d=google.com; s=arc-20160816; b=qyREjGHj496iIwbluN76a5gNfa29m3/eUqkL4LSmGwqzRE2GYmp5J22pvppjgfOqjc g3/m4fW1EJ4LlL+GpVBXqgh5BcYmO8H+AyQmJ5XttquQ4NOCqC/XzHiWvwRHJh8qeyWn YIJLnhiVndnXswpnd8p6plGROVzs2OCv7aJIRj+8PFdEZiK3DPjFCDAABqhSJ+CjkPdI k1My7vrq2hRZzhrFappmtgVfprBuVTWe6SoNJ1iRFvW0SoYNPLE0zofJyGQ+1zbBaf/v fAIj4DFN+9+YXVz6izXjSXrhhTOas4YUya/xntJ8v6BCi37lDnZJ83csJsNsl1OjCMgQ kC4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=jjgs2YU2VziafSJo5WLn66FAf49BcCExRQig95xwiD8=; b=AsdwIdvUr6VYE82AOxiQuMdSMe3km8tRCdWGj9t7tRSHwLQO/YqURXYL0T8PHD0LzF DvzC9fyR34ODqXLHN2cPDUJwhA+Btq7RHUBPIFG39fZpJgwJ758e0Cotq5bj5QIMk5tl I5ALWsgfqCZp+cFxb7+xiQzP3RWYRw/qvoQ0cwOhRy1KePE2h9DLBBWFdVkcQK9itnOh kc/rLZkPUGp2dQviVvYZOHwN5x8TFtJXjl8F9t7AdPSi6wthGZezr4MuriJvQKSnMqmE z6Gwj/oCP0O0W1uz+HkTJtUeMXEu2Fg2c1tp5KBNVItoYkBCQ/rDErB0CALjUSvLxTQX yJjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P3ABfPnf; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v43si16035853pgn.32.2019.04.10.09.41.25; Wed, 10 Apr 2019 09:41:42 -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=@kernel.org header.s=default header.b=P3ABfPnf; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732716AbfDJOtJ (ORCPT + 99 others); Wed, 10 Apr 2019 10:49:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:47804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728729AbfDJOtJ (ORCPT ); Wed, 10 Apr 2019 10:49:09 -0400 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5BF6E2083E for ; Wed, 10 Apr 2019 14:49:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554907748; bh=vkRTarru/CyLjxWJ+sBiiSbpijenoKX4UvMBtAiy+NU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=P3ABfPnfMC76isg+PeSMHobH7l1fVbgwGXZBcHUGriaDSg1/RNxUnSs/qfX/13AuS O1g/Sg6AzeZWR9GthBTPdGi9xqZudvGVGcUiOEdMoaEYw18zdb2RDKxQO55V6YyZc0 JxKPR0/Qt88Uo1qcefYqfSGPF9t3bVbLuIwi3aXk= Received: by mail-wm1-f46.google.com with SMTP id a184so2930520wma.2 for ; Wed, 10 Apr 2019 07:49:08 -0700 (PDT) X-Gm-Message-State: APjAAAXHQbMx8eEVCkJGYSSgaB8BRTnaWUrV4r67AaBVoYWlGxaSLGlN zo3LLrGEHsdORfpdzvSexnnifaWmZ4R4NyRt1BqE7w== X-Received: by 2002:a1c:99d5:: with SMTP id b204mr3031078wme.95.1554907746873; Wed, 10 Apr 2019 07:49:06 -0700 (PDT) MIME-Version: 1.0 References: <20190410112103.15170-1-elena.reshetova@intel.com> <20190410112103.15170-2-elena.reshetova@intel.com> <20190410114259.GB9293@gmail.com> In-Reply-To: <20190410114259.GB9293@gmail.com> From: Andy Lutomirski Date: Wed, 10 Apr 2019 07:48:55 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/1] x86/entry/64: randomize kernel stack offset upon syscall To: Ingo Molnar Cc: Elena Reshetova , Andrew Lutomirski , LKML , Josh Poimboeuf , Kees Cook , Jann Horn , "Perla, Enrico" , Ingo Molnar , Borislav Petkov , Thomas Gleixner , Peter Zijlstra , Greg KH Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 10, 2019 at 4:43 AM Ingo Molnar wrote: > > > * Elena Reshetova wrote: > > > 2) Andy's tests, misc-tests: ./timing_test_64 10M sys_enosys > > base: 10000000 loops in 1.62224s = 162.22 nsec / loop > > random_offset (prandom_u32() every syscall): 10000000 loops in 1.64660s = 166.26 nsec / loop > > Stupid question, how did you manage to buil timing_test_64? Here it fails > with a bog standard gcc 7.3.0 x86-64 distro toolchain: > > dagon:~/luto-misc-tests.git> make timing_test_64 > g++ -m64 -o timing_test_64 -O2 -g -std=gnu++11 -pthread -Wall timing_test.cc -lrt -ldl > /usr/bin/ld: /tmp/cc8VRkuV.o: relocation R_X86_64_32S against `.text.startup' can not be used when making a PIE object; recompile with -fPIC > /usr/bin/ld: final link failed: Nonrepresentable section on outputcollect2: error: ld returned 1 exit status > Makefile:39: recipe for target 'timing_test_64' failed > I think your toolchain is screwy. If I create this file as ingo.c: #include int main(int argc, char **argv) { printf("Hello world!"); return 0; } And build it like this, it fails: $ gcc -o ingo -g ingo.c -pie /usr/bin/ld: /tmp/ccofYU9N.o: relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: final link failed: nonrepresentable section on output collect2: error: ld returned 1 exit status Which I assume means that -pie requires -fPIC, and your toolchain is screwed up and is defaulting to useless options. I'm guessing you should file a bug against your distro gcc package. For me, it works if I remove -pie.