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 5F0A1C67861 for ; Thu, 4 Apr 2024 21:27:45 +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=cA45wC7OnbqdYHqqa6glwXqCDME9b90K9niuLRYAHBU=; b=GSeP7dqpB5+uIj tA0kpy5lVRrbs8ODv5KkstUm77JmkiGbchi0TFxE5Obl9rgHr+6VLkgzIv6q4vok8eKTDDwg16jL4 noPQvwlTMM+gGv25mK9yayWiXVR6mUOwreMZ7h7rXJFo3IStE3fS2GRT1MCvX70g1EtHRCAI1pL38 URq1K2OHGqlHFxNCMLj7Y0HC4DCBKJh+4L1oFiylHPmamqCcjVGAwL0BBt64J24+OEysLA8lRn8VH LicJpPqxV+Atgmz5OE1kt0oNp2ATqqnDHFfJzzeGxdhD9JY8kLYIUbdKo7PW9/Xxk0dwmM3IJBahb AVsVlNc7imIwG7jNqGMQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rsUcR-00000004KHx-20SO; Thu, 04 Apr 2024 21:27:35 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rsUcN-00000004KFD-3FkY for linux-arm-kernel@lists.infradead.org; Thu, 04 Apr 2024 21:27:33 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1e29328289eso11676325ad.0 for ; Thu, 04 Apr 2024 14:27:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1712266047; x=1712870847; darn=lists.infradead.org; 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=5Y44qs4OUh5ul6NtjE+55E8vlpwqKRAnt03mDTkQinM=; b=Dj9smp8F2mFYbaAh/uR/QYf6/YIxaCqcDgtQn9+PSODG1Eiyvfs7PsswoP4TVH+iS2 KVWBj+uoFX5E/i4850Ew8FpCdaoSY7l3bIgoqg5NsIMxXS0xWhOzgM74pfIJl+8MhYdO 552y5p46gFDehDi1sjn9F8IvQukyzGpgomkDA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712266047; x=1712870847; 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=5Y44qs4OUh5ul6NtjE+55E8vlpwqKRAnt03mDTkQinM=; b=SemIv9/ONpWok04kHItMYtsrZN85Kteat6OulbMoS6LYk0thmOjUomsNRJsrzR2hOT BRQxF97d5vU+lBlm8pr9cwRx5kMh+0zqvxXZqKEsZOSNJlk1TCin7PwV2QpyICi+8pCP U6PYfRS9PU/T/w3XHij2ARjRHGJb/1m5nyT8YmDI0MVnIGzdu6s/7K9FKsSkmTgmCyOV fooDeI45xCaWgXwoX1gTYoPWYuoAIIBEdKHKx2K3J1+51ed/mH8d5tCLqqZV3eKm4Il/ kUwWgx0QYmL/qUlvfBw/ibqldBW9DIeMgkeaCUC/uuOk/V9Zn0v57Cj3ZqH9E+uhnXep GFSA== X-Forwarded-Encrypted: i=1; AJvYcCWoVtkowsSFtgfqL/iOEpS/KfY9gcnuSKutnuEyc1T/EBxotx6SsKzyeTk3HscPaopBLbLomwxRFib0V0aPWK5edShXmAWgdKrfqBGgTOqh0Ol5IOI= X-Gm-Message-State: AOJu0YyPFp/ZufovX927dYagNupYh8j/XfG7h2Zpu0cDnB3fF3IXgqIk CI2r6Z555EtRoY/vt9NsZof3Kr3lNLHKxvp4ed57lFCJ0waBI45LoJeuDawR9A== X-Google-Smtp-Source: AGHT+IHi38RDnlKmYx0khv6mZQJ7Liv0SUQJ59Uq5gOOAeCsZSf0YQQlHiQV7NO8+/ZIFA1CRlITrQ== X-Received: by 2002:a17:902:c94a:b0:1e2:7c72:767 with SMTP id i10-20020a170902c94a00b001e27c720767mr3397197pla.30.1712266047076; Thu, 04 Apr 2024 14:27:27 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id f7-20020a170902684700b001dc01efaec2sm81777pln.168.2024.04.04.14.27.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 14:27:26 -0700 (PDT) Date: Thu, 4 Apr 2024 14:27:25 -0700 From: Kees Cook To: Linus Walleij Cc: Russell King , Sami Tolvanen , Nathan Chancellor , Nick Desaulniers , Ard Biesheuvel , Arnd Bergmann , linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev Subject: Re: [PATCH v4 0/8] CFI for ARM32 using LLVM Message-ID: <202404041427.E2A40D1@keescook> References: <20240328-arm32-cfi-v4-0-a11046139125@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240328-arm32-cfi-v4-0-a11046139125@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240404_142731_845677_EE01F987 X-CRM114-Status: GOOD ( 29.72 ) 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 Thu, Mar 28, 2024 at 09:19:23AM +0100, Linus Walleij wrote: > This is a first patch set to support CLANG CFI (Control Flow > Integrity) on ARM32. > > For information about what CFI is, see: > https://clang.llvm.org/docs/ControlFlowIntegrity.html > > For the kernel KCFI flavor, see: > https://lwn.net/Articles/898040/ > > The base changes required to bring up KCFI on ARM32 was mostly > related to the use of custom vtables in the kernel, combined > with defines to call into these vtable members directly from > sites where they are used. > > We annotate all assembly calls that are called directly from > C with SYM_TYPED_FUNC_START()/SYM_FUNC_END() so it is easy > to see while reading the assembly that these functions are > called from C and can have CFI prototype information prefixed > to them. > > As protype prefix information is just some random bytes, it is > not possible to "fall through" into an assembly function that > is tagged with SYM_TYPED_FUNC_START(): there will be some > binary noise in front of the function so this design pattern > needs to be explicitly avoided at each site where it occurred. > > The approach to binding the calls to C is two-fold: > > - Either convert the affected vtable struct to C and provide > per-CPU prototypes for all the calls (done for TLB, cache) > or: > > - Provide prototypes in a special files just for CFI and tag > all these functions addressable. > > The permissive mode handles the new breakpoint type (0x03) that > LLVM CLANG is emitting. > > To runtime-test the patches: > - Enable CONFIG_LKDTM > - echo CFI_FORWARD_PROTO > /sys/kernel/debug/provoke-crash/DIRECT > > The patch set has been booted to userspace on the following > test platforms: > > - Arm Versatile (QEMU) > - Arm Versatile Express (QEMU) > - multi_v7 booted on Versatile Express (QEMU) > - Footbridge Netwinder (SA110 ARMv4) > - Ux500 (ARMv7 SMP) > - Gemini (FA526) > > I am not saying there will not be corner cases that we need > to fix in addition to this, but it is enough to get started. > Looking at what was fixed for arm64 I am a bit weary that > e.g. BPF might need something to trampoline properly. > > But hopefullt people can get to testing it and help me fix > remaining issues before the final version, or we can fix it > in-tree. > > Signed-off-by: Linus Walleij For the series: Tested-by: Kees Cook Thanks for making this work! -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel