Received: by 10.223.176.5 with SMTP id f5csp1307021wra; Wed, 7 Feb 2018 16:59:30 -0800 (PST) X-Google-Smtp-Source: AH8x226aM5DMcKaiNPLMx1UJoN+9BGdtdKpktWVtXArKjJIcOIPJvVo8uuOiR7AEV6B5zzl2vgQa X-Received: by 2002:a17:902:46:: with SMTP id 64-v6mr7896057pla.341.1518051570384; Wed, 07 Feb 2018 16:59:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518051570; cv=none; d=google.com; s=arc-20160816; b=yQyqwgaENAfu7KCLcC1o71qEl2gznFbhS5aIMoNSvV29E6S+CHnpQiMUOHTsvvmFiG 4y3Hx9WBc85gZosQy2mU+bQSSDiBCBNTzv1tEW1fB0puKrFFun6E2n3cppAztDtpv6v3 Zm7QxHrBQll+O4epJz+3graHFXEExzpA7hYLCu+6mryUcfyZrkibJkusiZy8uREVWVtL NfV/AH7RE2dXiR01N60vQvqtv3zJUOUg2/R2zXIVEabLNwgsX/oHDTDYEwyhaMS7nwzM +mZ3/rEMmZUV7XB/mu2A5RAGue0jPM6nex93puo+OQiZF2mAi46SmQC1Itt1CfzoYPNt 6YlQ== 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 :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=vhTJ5LQEQHc0CNBIPor7Dpem1d9eF5jOrT7/68oH5UM=; b=xfUqkOryqmcG2RWulNhmARoF1uc+jcizIjd3SI7q8aOfufoG8i6/PAOz7hVZNvFbWY A12EguqKp+fVKLFMlIshoA8zpMgyiaB5+WCMFMRc5CYFAIG9IKV1MXyfsI4+7CnU7brK CMk2+34cX4rE6lEbcrFlxz5usyRWPDBo5y2ESvGCfgLDgTNkommdj3lZXy1O5/Eaqz8G j0RNAz5MC/2gu848ylqzlkHuRiMjy95vi5J+15a79KEBdtjGZZnsFlXZHj5xYth+hMb8 h/XjW1B7eLK/9Krx7j9j+7ST85ixG7gtQwpdhflt2a0nCtvxukeI6Th/SRTUoWHqb5u9 XBtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=V4lo81Mn; dkim=fail header.i=@chromium.org header.s=google header.b=A+N4kl9u; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e19si311452pfb.211.2018.02.07.16.59.15; Wed, 07 Feb 2018 16:59:30 -0800 (PST) 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=fail header.i=@google.com header.s=20161025 header.b=V4lo81Mn; dkim=fail header.i=@chromium.org header.s=google header.b=A+N4kl9u; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751848AbeBHA6C (ORCPT + 99 others); Wed, 7 Feb 2018 19:58:02 -0500 Received: from mail-ua0-f195.google.com ([209.85.217.195]:38234 "EHLO mail-ua0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751574AbeBHA6A (ORCPT ); Wed, 7 Feb 2018 19:58:00 -0500 Received: by mail-ua0-f195.google.com with SMTP id e25so1839555uan.5 for ; Wed, 07 Feb 2018 16:57:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=vhTJ5LQEQHc0CNBIPor7Dpem1d9eF5jOrT7/68oH5UM=; b=V4lo81MncvRk6agp2Vk8AvR4dF5h9dSmslV9+4Asbeqtc3M44FMB4VkI2sZv4i3Yhu xPHJvXr6e7hlLb5Xr6bInfWWHuGtVAkEtnq4tIs5EF3BNVa2N7pRVBsjPjRDbE+SHNgq pseIwLdKOw8G9HMApCkb64f1DdI64pX4Yi7oe9eLq9URhxyR7cOXSwcGYJ8RI0Hirjgl CBycGoYjV06L4fyV8LGatlMGxw3Ju6w0F1bV0aTkOd5uUOnQ2tx/ruJqQeWYlP1BQZS+ fJvO01/L7kfFlPn9IjxXPGnJg8fWImqpHJZkygosIZhWcJr6rOIiltXNGV3tbejilS2+ xGiQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=vhTJ5LQEQHc0CNBIPor7Dpem1d9eF5jOrT7/68oH5UM=; b=A+N4kl9uwuQzkmncPiKgjGcqekUfMu5F58yfNW9JlFFljZhcJrJFS/sLmMNxz8G9es gvhPr2s0yC6zUjTkk3pLe1ABuPf4kWIBr6pAU5Z5Fmcfs8fvDj7yIkhpolXroa7TA1da MEX6BMFK9razd9gpPBc9pOmjKZikO4zPEeut4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=vhTJ5LQEQHc0CNBIPor7Dpem1d9eF5jOrT7/68oH5UM=; b=V2mh5IhKmns2vQ2NDuyTABmPYRr7yxvcEhIYtMKpg65BnSjMtlzz2Qc2OZpx//bfXO QyGuJXjaeXmhoW8hhDgXE14qyDH/7+L6bkONGCxHv1shayV/6o+7kBD1//7+MzmDECoh eE7ReRcV8Nj6Qn8x/ll2vbjnqfsj9FvQMU9O2sKUds6iokXiRJ0oMcDNpMb5q0qcC1hz 0vpIZ6yAH4ouPIRRNUM/PipdBEaokRBVCRS+BWSDk/G8IfYwRqL49VGzAmeJ5I73Rmjb 8W9dmQQjqtZiusLkS/FfknmPMbtwN9x2fP7CWeK1GSE/ym6UtSXpTLYLFGzE/dmXoQoN vO6w== X-Gm-Message-State: APf1xPCiafGWXRcHDXTnUlFtwBwC34hJ/VMnGulHnB6ml1BSdmb7trBj gWHnOHh7a2Mmmz+SHgLeDDfgf42nA/6EKsxe4w+rbQ== X-Received: by 10.159.60.8 with SMTP id u8mr7229615uah.156.1518051478973; Wed, 07 Feb 2018 16:57:58 -0800 (PST) MIME-Version: 1.0 Received: by 10.31.67.196 with HTTP; Wed, 7 Feb 2018 16:57:58 -0800 (PST) In-Reply-To: References: <1517986811-27819-1-git-send-email-schwidefsky@de.ibm.com> <1517986811-27819-7-git-send-email-schwidefsky@de.ibm.com> <20180207100726.GB31392@amd> <1518005275.3677.112.camel@infradead.org> <20180207131719.4aeb316e@mschwideX1> From: Kees Cook Date: Thu, 8 Feb 2018 11:57:58 +1100 X-Google-Sender-Auth: adjQD5utoNym3WZNIAMnnL8hTNE Message-ID: Subject: Re: [PATCH 6/6] s390: introduce execute-trampolines for branches To: Masahiro Yamada Cc: Linus Torvalds , Martin Schwidefsky , David Woodhouse , Pavel Machek , Linux Kernel Mailing List , linux-s390 , Heiko Carstens , Christian Borntraeger , Cornelia Huck , David Hildenbrand , Greg Kroah-Hartman , Jon Masters , Marcus Meissner , Jiri Kosina , Dominik Brodowski , Alan Cox , Ulf Magnusson 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 Thu, Feb 8, 2018 at 10:44 AM, Masahiro Yamada wrote: > 2018-02-08 2:55 GMT+09:00 Linus Torvalds : >> What I would really want - and this is entirely unrelated to this >> particular case - is to have those damn compiler option tests as part >> of the config phase in general. We now have about a million of these >> crazy things, where we have config options that simply depend on which >> compiler we have, and we have no sane way to show them at >> configuration time. >> >> Though Andrew's tree I got yet another ugly hack >> (CONFIG_CC_STACKPROTECTOR_AUTO) that handles just _one_ special case >> by turning it into a special magic Kconfig entry in the main Makefile. >> See commit 44c6dc940b19 ("Makefile: introduce >> CONFIG_CC_STACKPROTECTOR_AUTO"). I wasn't sure if I really wanted it, >> and honestly, I'm still thinking of just reverting it, because it's >> _so_ ugly and _so_ wrong. >> >> What we need is an extension to the Kconfig language itself so that we can do >> >> config CC_HAS_RETPOLINE >> cc_option "-mindirect-branch=thunk -mindirect-branch-table" >> >> or something. And then we can make sane _conditional_ dependencies at >> Kconfig time, and our makefiles would be much cleaner too when you >> could just do >> >> cflags-$(USE_RETPOLINE) += -mfunction-return=thunk -mindirect-branch-table >> >> because the validity of the C compiler flag has been tested when configuring. >> >> And then we could add that warning at configure time (or just disable >> the option there thanks to "depends on CC_HAS_xyz" logic). >> >> All our compiler option handling right now is just nasty nasty nasty crud. >> >> Adding more people in the hopes that somebody gets motivated.. I've >> talked about this before, so far we haven't made any progress. > > > Sorry for slow progress. > > I agreed this before, and still motivated. > (because I also motivated to remove kbuild cache. > This turned out not so clever as I first thought) > > I was trying to do this, but in this development cycle > I spent most of my time to flush out lots of piled up Kconfig patches. > Sorry. > > Unless somebody is working, I will. FWIW, I did try to do this before I went with the STACKPROTECTOR_AUTO solution, and it defeated me at every turn. Between the circular dependency of the Makefile setting up KBUILD flags and Kconfig wanting to know about the compiler, I got stuck. And it also seemed like the cache was a problem too, as I couldn't find a way to re-evaluate the script-controlled CONFIG items once it got cached. And ultimately, a lot of the operational logic ended up sticking around in the Makefile anyway (to provide fallback decisions, warns, and errors). To correctly deal with the complex corner-cases for stack-protector, I end up with three pieces: the user config: - do you want auto, weak, strong, or off? the compiler tests: - which of weak, strong, or off are supported? - does the flag _actually produce working code_ for this architecture/compiler version/etc? and the build behavior: - for auto, choose best available flag and warn if none - for user-selected weak or strong, stop if unavailable/non-functional - for off (or auto-none) use the "off" flag, if it is supported (to force-disable it on ssp-by-default distro compilers) And all of this needs to bypass the Kconfig cache, since if it gets cached, it won't get re-evaluated when a selection is changed. If we had a working "option shell $(CC) ..." then I could do the "compiler tests" part in Kconfig, and I could probably do the bulk of the "build behavior" logic in Kconfig too, though any intermediate configs would need to avoid getting cached too. The ssp handling has always been extremely complex due to all its gory details, but I've tried _really_ hard to improve it, keep it documented, and in one place (e.g. the compiler tests used to be stuffed in per-arch Makefile). -Kees -- Kees Cook Pixel Security