Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp992246imm; Sat, 14 Jul 2018 19:04:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc/TfJxnm3enbbKp8GsPyU2LfY5YEbtCUjwbTnzreQ5R0TQut2RVh68oMlGJM9p1rgRZZdL X-Received: by 2002:a63:4106:: with SMTP id o6-v6mr11313877pga.453.1531620299529; Sat, 14 Jul 2018 19:04:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531620299; cv=none; d=google.com; s=arc-20160816; b=FmwQZYl2My9v5RpD8jU8WNSJhwPhU++UEBJW2RFIiHGza+suFYpvAaX2EyU2ZyV5OO 1f9bTAkx6N9LtAJXD7KZZazJ3Dr6MSsbxYcjPsK6KmEFdZjM23yGZEInn7dflmNbNogV ppYTQjLZoB2vRL7OV1Y3S4PLWjoa3kml4Y+mSdYH7j6K3Iam7hQGwRaO7kDMDuUY4khL pzKK0dOcMv4HleSXXU65Cr1PCuzWYqlw/GG5wmi6Drn2YwaBapp5FzFpCJBZFYNk6Z8/ FxFYGOBg5nJ8pjD6lo9nOd7Cf4ecQhGVhel/3HM2WwLG+6X3Y7Cg6EajNQk8dy6t0oim pWQQ== 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=Opw9YTo5mdk3/DqPQzulhLZI1mMwEuZJhJs46BCxq5Q=; b=O+pxDXgwZ4eiBbw2S7ZJi8WiVCih3m9qFVcx899QNzcWnj45u8+Fgxw2iV5Kaz75V5 pC7LjrMsB/viAOX5+75eRyWk3tqbMnKyckjRSM24z4n51pxO8GlRxwWrDoMn/B49xp4q 05FMqWyF5BoriLxeSllT4ii9htl4jiSfcO7UEEwteBa3rspX3CxlJ11a5ZHpsrZSv3dd BMXY13bG7bmpVMVauzpC/Zpflpu2om42NI515TWOdLYRuC3cuN9Tx7k3MvklffgWsXW/ Wb/VgwpHNgoKCcMaG1EVALxf5A6/EqcQKaO5ReLNnSKKvTf3Z4YM8B09nOcGV2B/S4v/ jpjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=A4rAyfic; dkim=fail header.i=@chromium.org header.s=google header.b=Qd5hKnMr; 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 v129-v6si20167863pfv.278.2018.07.14.19.04.43; Sat, 14 Jul 2018 19:04:59 -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=fail header.i=@google.com header.s=20161025 header.b=A4rAyfic; dkim=fail header.i=@chromium.org header.s=google header.b=Qd5hKnMr; 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 S1732001AbeGOCZR (ORCPT + 99 others); Sat, 14 Jul 2018 22:25:17 -0400 Received: from mail-yb0-f195.google.com ([209.85.213.195]:37415 "EHLO mail-yb0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731944AbeGOCZQ (ORCPT ); Sat, 14 Jul 2018 22:25:16 -0400 Received: by mail-yb0-f195.google.com with SMTP id r3-v6so14222119ybo.4 for ; Sat, 14 Jul 2018 19:04:09 -0700 (PDT) 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=Opw9YTo5mdk3/DqPQzulhLZI1mMwEuZJhJs46BCxq5Q=; b=A4rAyficBU94rrB9or+N1uOz1+JxlulBtYb0/88VGkZJcsJ4qy7b/ikTVtYJYV1Dr2 kODIDsdrP9cy8/3eARO08f1Pa//x9axFZJV1U4vMmN610FMETSJlCBRxNhluWUUKzkrR YcwWnIWO4ECg/tzsA5M5AbRbOgDVDohw7rQZdtMcJRi/eu1zLFzqpN0A+L4sXtwjd5cA eGoNES80bk1SwgVQrRklT8rSDseAE3hcVq/6Q1jSur3ic1Lk0nPSiAIB2DfOm2qkPO/b Bp3N0ydDe+7JnZdDNzsMpm+pL9KvQvgfn8Hb7nd9+tnv/NGdqafqWbQoNYny6i+5JBNg O66g== 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=Opw9YTo5mdk3/DqPQzulhLZI1mMwEuZJhJs46BCxq5Q=; b=Qd5hKnMrIrTf6WpB7uJtB/r2OVEVfiV/BR5xD2kYUSJEGRi0wQQ9VG9UcI/HVF1t9w 3AITaomy1NtYpZ/aTHaujPSRLUakeRYbwPIF3NetqGh3gpYrPNWOC/sOb//vY8BLnOqt STGTHnqaAG0ATXyyrPB1h+g6pb7vZpkzoqZ2I= 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=Opw9YTo5mdk3/DqPQzulhLZI1mMwEuZJhJs46BCxq5Q=; b=Zs8glLGri5xb4NvuTa6Fuo7peldO4JS4V5Qdl3RWXS7JdPbLkeiVhZ01wwgbyLH6/a iyl7M2Inoeg4f+00m5hC64seF3lE03qUHLS1VHqAWs3y7othpJ/iV/AisBcsreKaoZR4 lkbvzY1mWNyXxHPTZpLokNZaXh9mDha6TnavGWtH4Toy4Bh09ZK7lFlJCZhZRU46v9Gz 68QMngJrSuhdTrTP/MROh5jJnkRSj2GGFx8wpV8imHk+jrAnxg1GlgP+iQ38KrSunjLb aYxPjvLlnmwfhfev7o3SN+8/f6055xqP3W7RALrE6zmdMJ2MUirlJ0QjLciFOcUAQ6GE Uabg== X-Gm-Message-State: AOUpUlGB2jYU5SW8QpI0ETNfu5xWdtQR0nXIWAVq1Xefgy2VYOGAifub c2Brc0J4JeQeb4vhFtEfXEvmxV+WouJ9e48jIaIr6g== X-Received: by 2002:a25:a302:: with SMTP id d2-v6mr6363016ybi.193.1531620248646; Sat, 14 Jul 2018 19:04:08 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:6602:0:0:0:0:0 with HTTP; Sat, 14 Jul 2018 19:04:07 -0700 (PDT) In-Reply-To: <0bf9be39-82bb-ad3a-a3c3-e41bebedba7e@suse.cz> References: <1530646988-25546-1-git-send-email-crecklin@redhat.com> <0bf9be39-82bb-ad3a-a3c3-e41bebedba7e@suse.cz> From: Kees Cook Date: Sat, 14 Jul 2018 19:04:07 -0700 X-Google-Sender-Auth: wvU6EJW1WHgTJ00HtvUZwoeqwuw Message-ID: Subject: Re: [PATCH v7] add param that allows bootline control of hardened usercopy To: Vlastimil Babka Cc: Chris von Recklinghausen , Laura Abbott , Paolo Abeni , LKML , Linux-MM , Kernel Hardening 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, Jul 4, 2018 at 10:47 AM, Vlastimil Babka wrote: > On 07/04/2018 06:52 PM, Kees Cook wrote: >> This produces less efficient code in the general case, and I'd like to >> keep the general case (hardening enabled) as fast as possible. > > How specifically is the code less efficient? It should be always a > static key check (no-op thanks to the code patching involved) and a > function call in the "hardening enabled" case, just in different order. > And in either case compiled out if it's a constant. My understanding from reading the jump label comments[1] is that on order produces: NOP do normal thing label1: do rest of function RET label2: do exceptional thing jump label1 where "NOP" is changed to "JMP label2" when toggled, and the other is: JMP label1 do exceptional thing JMP label2 label1: do normal thing label2: do rest of function RET where "JMP label1" is changed to NOP when toggled. (i.e. does the default do NOP, thing, function, or does the default to JMP, thing, JMP, function) -Kees [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/jump_label.h#n334 -- Kees Cook Pixel Security