Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2936712pxb; Tue, 24 Aug 2021 10:58:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAT69O/2Ni2bIhvRMrAAZ16iY2+Gz+7qgHaeVtL1dqf2fNuNAFiQPm1R2qixQVp53/91mc X-Received: by 2002:a5e:da44:: with SMTP id o4mr6565748iop.147.1629827936059; Tue, 24 Aug 2021 10:58:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629827936; cv=none; d=google.com; s=arc-20160816; b=t79kfzBqnu3KZwbTahV9/O6YJjPylWE8MZcjwzy3oKDWV2jAkVVLRzh1MorjQV/KMy 0LH4YlW4b1kka2RqFm3xgyG0KYXIxOoYwkoStqCC6VlvpYOAXL5Nxm0TaEQWOwKEgnVZ LYCLvzbo3AtCbQWSS8ejmVprDp9paxtcRV4AU3J3AGnF3WauhELYiQnUriFeLVaJVph/ v+XwAIWdNifY39v4R07vlQDG3fJ8shAyC8Hu0kXQtPe2LLysYxcRuS3qsKwDCtfSFUYh 4VN9d71cemg128sCxqXDgoDmqkVnylU7GO6K8OgZ+vqRyxUgooYyJKT+BsHRF1ltdloZ Y3UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Qy5AIG6IAw5l/UjdlTFWswRnp3Bis0SbvNsE5T3Il2w=; b=ab7kCXtWv4aroWPk7p72VIKZJxUAyYbvcs3chNIp7IX8XayYMDQ9z9ML/DmJX7eXhj hmUZa2OXSk/kzDJZBX+8WW2XhL/YdFFZR0jTnpwXwwbcwNs30gCQkQnDdLqMgc9+Q6iO w0p4F8+24MqcX9e/trJ71DTVI8glrbcWguzyj1EJNIRJqaSKGEPA7ZtQxqjEw6pouLQo /Ri9GCai9Uj1hdwn0rd1gLotuU9MFN+X1nY3IvpGmMf85hztmBPr098vCy2G6p+VZ0Fg g/3UEApRJk9p5SpxcP9l5q0FuNaDFledzKk9Ymah+ijX/NytAPfrynV92Bdl2S2yZbuq hq0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=VfHskVSd; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 10si15900794ilz.71.2021.08.24.10.58.43; Tue, 24 Aug 2021 10:58:56 -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=@google.com header.s=20161025 header.b=VfHskVSd; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241399AbhHXR5a (ORCPT + 99 others); Tue, 24 Aug 2021 13:57:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240792AbhHXR5Y (ORCPT ); Tue, 24 Aug 2021 13:57:24 -0400 Received: from mail-yb1-xb30.google.com (mail-yb1-xb30.google.com [IPv6:2607:f8b0:4864:20::b30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46E3EC0C175B for ; Tue, 24 Aug 2021 10:31:07 -0700 (PDT) Received: by mail-yb1-xb30.google.com with SMTP id z128so42492881ybc.10 for ; Tue, 24 Aug 2021 10:31:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Qy5AIG6IAw5l/UjdlTFWswRnp3Bis0SbvNsE5T3Il2w=; b=VfHskVSdG1gsmTXp1PfQvFG0VZnTvg9PP8Er/13S5ik/PHR1yoCy26jnVMO3U6kiFZ yFVWxryNXm0lMHWz2KXsgA4J0NavHxyj38pIwSqEx+mcIB7u84B+volIh425RH6qw0XM QyIw+hK0Su8Bji5pUnT3nHCluB66iwXC8JiGMFcSrqinr6TzM+D4EG2gf3E92zONOI5g YVpuHIU405wCBHy1RuJoxdnRgTqSdFYvkWGF6oEB3dT2U3mh6x+PdVgJ6qOjpsp21fFq CFN/e/Au7cRTRt2wtUlJqrwoc4YfRpzSo+ps/Tz05hlVCpdGFlzjDD8cArqwXXDOjmY8 rgBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Qy5AIG6IAw5l/UjdlTFWswRnp3Bis0SbvNsE5T3Il2w=; b=OYILGSZdhQAMNNSbS+msXGltGDnSDQL/l+FRWJsncPytEhratiIBKTTqekZgptBtjm LeYJiGTqRFSDe2kNV+CAFd2W061IJ+AdJ2B7H8ebx+DKvAr59ZzASjk9BOEwLP08zWq/ vT9EzuDoqiGEIpWfOkp6BxiAAsRAGF8NbE4TuNbgIa13d6+FEmH4jjBnSKR1gNH/rFRc 11EJrq1fJJXjsSKPMWa0ACANtBEN9VwO+zBRLFpt6SHIpVWc3SX3R1aeZuq3XCMk57NQ phLjiY6ZwdjFGvTkBW9H4IBevZlSVf8DV45qBne8mV+2cW9og/dv62DPofTnnZZ4hM6d oB+A== X-Gm-Message-State: AOAM532Xb6QjGwVrOCpd9H94cKMRvKV+lrEQOrdxw4PnoZmK9wnSxbq8 d8l+H4CfEzH3yLiWZDq0lgkGnGUdaNyH3qgS23iWmg== X-Received: by 2002:a25:7ac6:: with SMTP id v189mr51220058ybc.485.1629826266324; Tue, 24 Aug 2021 10:31:06 -0700 (PDT) MIME-Version: 1.0 References: <20210823171318.2801096-1-samitolvanen@google.com> <1706ee8e-c21c-f867-c0be-24814a92b853@redhat.com> <9349a92d-f2a7-9ee4-64db-98d30eadc505@redhat.com> In-Reply-To: <9349a92d-f2a7-9ee4-64db-98d30eadc505@redhat.com> From: Sami Tolvanen Date: Tue, 24 Aug 2021 10:30:55 -0700 Message-ID: Subject: Re: [PATCH v2 00/14] x86: Add support for Clang CFI To: Tom Stellard Cc: X86 ML , Kees Cook , Josh Poimboeuf , Peter Zijlstra , Nathan Chancellor , Nick Desaulniers , Sedat Dilek , linux-hardening@vger.kernel.org, LKML , clang-built-linux Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 24, 2021 at 10:26 AM Tom Stellard wrote: > > On 8/23/21 10:20 AM, Sami Tolvanen wrote: > > On Mon, Aug 23, 2021 at 10:16 AM Tom Stellard wrote: > >> > >> On 8/23/21 10:13 AM, 'Sami Tolvanen' via Clang Built Linux wrote: > >>> This series adds support for Clang's Control-Flow Integrity (CFI) > >>> checking to x86_64. With CFI, the compiler injects a runtime > >>> check before each indirect function call to ensure the target is > >>> a valid function with the correct static type. This restricts > >>> possible call targets and makes it more difficult for an attacker > >>> to exploit bugs that allow the modification of stored function > >>> pointers. For more details, see: > >>> > >>> https://clang.llvm.org/docs/ControlFlowIntegrity.html > >>> > >>> Version 2 depends on Clang >=14, where we fixed the issue with > >>> referencing static functions from inline assembly. Based on the > >>> feedback for v1, this version also changes the declaration of > >>> functions that are not callable from C to use an opaque type, > >>> which stops the compiler from replacing references to them. This > >>> avoids the need to sprinkle function_nocfi() macros in the kernel > >>> code. > >> > >> How invasive are the changes in clang 14 necessary to make CFI work? > >> Would it be possible to backport them to LLVM 13? > > > > I'm not sure what the LLVM backport policy is, but this specific fix > > was quite simple: > > > > https://reviews.llvm.org/rG7ce1c4da7726 > > > > That looks like something we could backport, I filed a bug to track > the backport: https://bugs.llvm.org/show_bug.cgi?id=51588. Great, thanks! > Do you have any concerns about backporting it or do you think it's pretty > safe? No concerns, it should be safe to backport. Sami