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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D067CC46467 for ; Sat, 7 Jan 2023 03:38:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0/rLsSQDgrPVLz7Mi/3s28z8mOMKUQV8csBxU8DgXKI=; b=ztakkMg7DS6v1u 79IB8N6JGwWKfIaDIhwDMQO3dGGdmj4rXI6geKLwqOO8R1beg+Kk6XkJNcOHgmTeC4GyqJM2inG2d t3iQWLvabPaRlSWseZfgG64bR/3167DY5HS5sTjInDqdX5jX9n49rtQOQ5vfM4xIl7D9ZZJBNKjyR 4pXUr+l9507M2gTVve6Nin6LBOyGyNZ2Sb5DCThMmWnMhe3tR2koG6xPkSx9TKQNQg7xWgh76mYTD 50+PptzOL5wcJiJjqN3bIegHAatkDayjh/efH+v1oOBuu8Z0/xlBdRt4igDcR27Y1Py34yt2XFVTR GkS6lG4LVy/MMgtysxYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pE012-000N2Y-IX; Sat, 07 Jan 2023 03:37:04 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pE00y-000MYI-TX for linux-arm-kernel@lists.infradead.org; Sat, 07 Jan 2023 03:37:02 +0000 Received: by mail-pl1-x636.google.com with SMTP id p24so3695498plw.11 for ; Fri, 06 Jan 2023 19:36:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=IG6jyzU3lw3az+t92iu8S5izMXVZhaCOIqMcxfJexWE=; b=NEAvXPf/xTu2tpdypsnKOo4nSfblr/MqWDOi40t8QE2Kf/PqMxdj4KIhtINy1VIOzD WCy1ejLWzWQq9uo+PzIAueREk0LziXCeBvIl++P8aAmjp47VTtsmmUNnJT0nIUS1PkwF GO4+j/raiuHUR8QZVCKqAhW4jHxuWErUht/rk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=IG6jyzU3lw3az+t92iu8S5izMXVZhaCOIqMcxfJexWE=; b=mDdodXVrJnjdeyheejLlburiq5MhCeCnoa0QcZZ5SV50Fog5mwyTbuayjkry0rzHCg i9QAOdDBG0YcQuLQmFDA8aGklEpI1RVIHxvo93USHqCynqi0KKUYqfPzgiWNYP8tdwaq nHqT2V9rOU9xxxVuYma6Hu1xAArx2lOMNilkalPliahCz9WMvLCu3IzO4eDM12Kuzz/V qf5eI0m3GwS/U9MTtrJT7PMrYilbRnVJtH9t3s//v23zDthE1KQI8M8XKxc/FC/7oUVW 8JEvKJCv+N7tXdIldzR8UaHNLtbspwSGXFP3mPiLPXyUcGml0eENs7qkr2vGge2QxDoj MKbg== X-Gm-Message-State: AFqh2kotVsELyQCpNo7moovHdDH04ma3wrtLX7iFTjToaCj4QTs30ov0 xuiSnOwGx6VkaSJ9uwi+XqxXjw== X-Google-Smtp-Source: AMrXdXswcLN5mWPATgzm302bp7TvnFeozvA0yc1NDxHL+S9s7T4PUgVZSIRWY1sUdTsi35IdtODQcA== X-Received: by 2002:a17:902:b78c:b0:193:1fc5:f611 with SMTP id e12-20020a170902b78c00b001931fc5f611mr82042pls.38.1673062613952; Fri, 06 Jan 2023 19:36:53 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id t2-20020a1709027fc200b00190fb8f9e0asm1580783plb.249.2023.01.06.19.36.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 19:36:52 -0800 (PST) Date: Fri, 6 Jan 2023 19:36:52 -0800 From: Kees Cook To: Dan Li Cc: Peter Zijlstra , Masahiro Yamada , Michal Marek , Nick Desaulniers , Catalin Marinas , Will Deacon , Sami Tolvanen , Nathan Chancellor , Tom Rix , Mark Rutland , Josh Poimboeuf , Qing Zhao , "Paul E. McKenney" , Frederic Weisbecker , "Eric W. Biederman" , Marco Elver , Christophe Leroy , Song Liu , Andrew Morton , Uros Bizjak , Kumar Kartikeya Dwivedi , Juergen Gross , Luis Chamberlain , Borislav Petkov , Masami Hiramatsu , Dmitry Torokhov , Aaron Tomlin , Kalesh Singh , Yuntao Wang , Changbin Du , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev Subject: Re: [RFC/RFT] CFI: Add support for gcc CFI in aarch64 Message-ID: <202301061929.6881F6CD40@keescook> References: <20221219061758.23321-1-ashimida.1990@gmail.com> <20221219132731.6ng4sz2nv6ujvu7i@ubuntu> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221219132731.6ng4sz2nv6ujvu7i@ubuntu> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230106_193701_023386_29C5C842 X-CRM114-Status: GOOD ( 35.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Dec 19, 2022 at 05:32:04AM -0800, Dan Li wrote: > Hi Peter, > > On 12/19, Peter Zijlstra wrote: > > On Sun, Dec 18, 2022 at 10:17:58PM -0800, Dan Li wrote: > > > > > 1. When a typeid mismatch is detected, the cfi_check_failed function > > > will be called instead of the brk instruction. This function needs > > > to be implemented by the compiler user. > > > If there are user mode programs or other systems that want to use > > > this feature, it may be more convenient to use a callback (so this > > > compilation option is set to -fsanitize=cfi instead of kcfi). > > > > This is not going to be acceptible for x86_64. > > I'm not familiar enough with the x86_64 platform, could you please > tell me why this is not acceptable? Is there a similar situation > on the arm64 platform? > > > > 5. The current implementation of gcc only supports the aarch64 platform. > > > > What, if any, are the plans for x86_64 support? > > I'd like to implement something similar on x86_64 later, but > currently I'm doing this in my spare time, so it might take a > little longer. :( Hi! First of all, thank you thank you for working on this in GCC. This will make a big difference for folks that don't have the option to build with Clang to gain CFI coverage. As for the implementation details, the core issue is really that this type of CFI is specifically designed for the Linux kernel, and it took a rather long time to figure out all the specifics needed (down to the byte counts and instruction layouts). GCC's version will ultimately need to exactly match the Clang output, or Linux is unlikely to support it. We're already on our second CFI -- the original Clang CFI was just too clunky for long-term use in Linux, so unless we're going to improve on the latest Clang KCFI implementation in some way, it's better to stick to exactly byte-for-byte identical results. The KCFI support in Linux depends on the arm64 and x86_64 runtimes for catching the traps, and the post-processing done (on x86_64) with objtool that prepares the kernel for IBT use, and converts to the optional FineIBT CFI mechanism. With all those moving parts, there needs to be a very compelling reason to have GCC KCFI implementation differ from Clang's. Hopefully that context helps a little. I'm excited to try out future versions! -Kees -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel