Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp601233rdg; Thu, 12 Oct 2023 15:27:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExBHmB7+x09GpGMJoGRjz9NYB2PlqqBz9rnaf5IlfGbbNOFiZBJq4oZhN3DQEmonkFTV5L X-Received: by 2002:a05:6a00:22d3:b0:690:3abc:8043 with SMTP id f19-20020a056a0022d300b006903abc8043mr27244025pfj.8.1697149639836; Thu, 12 Oct 2023 15:27:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697149639; cv=none; d=google.com; s=arc-20160816; b=WRRaGprRyPxvL1rdFtQhFlEsDwNb+4zH+o6bTSmeKlxMfD5fvy6g/k9ZcasGjUY8P6 w9OKx8HQYYBl1VNr6bZkIZsIO6I/fkSCLZF2GnlDLW9c2IDBnqkypqrM1urw7/DZLPmY IP896Fl5KoVHO8fOXw0dlDdPpEK2Zu0Ok8QClq6oq+1kfdfCHxj7QbIoSvdvzdy6bHKK tDuGJn0B6ayKX3fXY7+Q7ZPx3XMFZRnNndbMGwcQPM9U7d782u6UrCvp6OGn1p7jbU7m QYeD39bFpVWPI1RNB1VmXCf61m8kRAoffKR2xs4ApyufsrMIQoEvzdN/NX6ls8AefZNJ 1etQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=cHyo9fSi27Id6LrPtS/9KH9PdJ59imXr1RZnXM53Toc=; fh=ytjt7Hab1OPlNxCYlkhPsHFgyUt6hJ7q+GxXJy7GhL4=; b=GKXP+v4igMq07k8CF45UaswPg7uhQz/cp0c6PtNiad5CYebxSTMattfgEWtSPLhXMi KfLkOVo/mu+QkhUkis37t29grqc18lYocLGjee9QTCu2lvEhFAms5ZoiALvIaQPcG6cu /ZMKB3+ZZENNEnZ6RjU//GuKsdLaZ7jHMwE/gczJFfQtMJhpzWFVO78i+ixZFLSCSOid dAMHy3jLo6QSmxqfezk7YE5UVz+0Ml+V4AErlNXsjZBahMwoIIfh06XvQL2mj+U/obiD 4dEa5mIlDLpVZQf0XvCxVoZYlk/rJfpFTFew+WB0pFfVaiH5RoT+HvLsRBvj5X6/m5jz 1kkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Fc6Wu7Ax; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id cz4-20020aa79304000000b0068fea05ecd7si14778003pfb.164.2023.10.12.15.27.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 15:27:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Fc6Wu7Ax; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 09CC3828F4E8; Thu, 12 Oct 2023 15:27:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442973AbjJLW1H (ORCPT + 99 others); Thu, 12 Oct 2023 18:27:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344180AbjJLW1G (ORCPT ); Thu, 12 Oct 2023 18:27:06 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A79B9BB for ; Thu, 12 Oct 2023 15:27:04 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-9ada2e6e75fso257505166b.2 for ; Thu, 12 Oct 2023 15:27:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697149623; x=1697754423; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=cHyo9fSi27Id6LrPtS/9KH9PdJ59imXr1RZnXM53Toc=; b=Fc6Wu7AxnwLnFyy6wpgTW0M8x+YAUjXBLShtkcjTRNYBjS/G2TBOfw+BUwjEG4jwf2 uuDrECctgZN+L+YfhZ7xxs0+8+bdMTSXSAlsNi1YF5Zy2dVJrhZ+msZJfou8iQiBWDDJ tZCacoKvCglAIwtzQ1bZF2Ovjh+vMbZyeE1nUwsZcfXy8Aq92fltbNtlRRl3gduOhXXX KcMVzqHMb2FJsf9X7PIk0kj94OnVDPoYgPShWGooftLUHgFxZtm7dgqs/ARCXECeNnAy c+vwDU6eS4fP/RMfLV9ed1Oe7lB/KQAsn3Ut80k/gQbeCXtgWSlJuBe+QLJDKqI0av0y FyOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697149623; x=1697754423; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cHyo9fSi27Id6LrPtS/9KH9PdJ59imXr1RZnXM53Toc=; b=HCcq4HSh8JnFT8T5FULXC4n5GxAyFfVDCbqvlAKxRpO5VYIlrV14AGUeHlyNdnjaWC Y/pfALp/ir3R9iW9fkFo6AOzRPAUSxkQBDCQ0yAwCV+cyNQOhiR2Hj8qVxbNZQrTZzCm rqlsdnmXSxOq7fRPML5nna1rGvTX6vZ+bLvUpugH96Uyw9Nc/xsnoQKYCRdJvwmZvF3X PeRtWrANiLpV//qH87sxlNJXONTba3OtJEXIe6GCkexn2ik39GgiMocik2QZVNefv4JH xKq7P8SNJK/BsCWodJ97jm3MGcJX2XFOVZRrrOWu605YlOyfeEs9+kyDQGkuV/wzgifT Tvbg== X-Gm-Message-State: AOJu0Yxf+tkscTpVZMfy9VmhT+nDTE65H9Otsm4kqGQeAvowMLikxHGI 0fNK1/GePgPv+ySanTfyJ1KIqct1YIV3/eQU9tLt9g== X-Received: by 2002:a17:907:760a:b0:9bd:8bf6:887c with SMTP id jx10-20020a170907760a00b009bd8bf6887cmr2835890ejc.53.1697149623041; Thu, 12 Oct 2023 15:27:03 -0700 (PDT) MIME-Version: 1.0 References: <20220927131518.30000-1-ojeda@kernel.org> <20220927131518.30000-26-ojeda@kernel.org> <20231012104741.GN6307@noisy.programming.kicks-ass.net> <202310121130.256F581823@keescook> In-Reply-To: <202310121130.256F581823@keescook> From: Ramon de C Valle Date: Thu, 12 Oct 2023 15:26:51 -0700 Message-ID: Subject: Re: [PATCH v10 25/27] x86: enable initial Rust support To: Kees Cook Cc: Sami Tolvanen , Peter Zijlstra , Miguel Ojeda , Miguel Ojeda , Linus Torvalds , Greg Kroah-Hartman , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, patches@lists.linux.dev, Jarkko Sakkinen , Alex Gaynor , Wedson Almeida Filho , David Gow , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-doc@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 12 Oct 2023 15:27:17 -0700 (PDT) On Thu, Oct 12, 2023 at 11:31=E2=80=AFAM Kees Cook = wrote: > > On Thu, Oct 12, 2023 at 10:50:36AM -0700, Sami Tolvanen wrote: > > On Thu, Oct 12, 2023 at 3:47=E2=80=AFAM Peter Zijlstra wrote: > > > > > > On Fri, Oct 14, 2022 at 11:34:30AM -0700, Sami Tolvanen wrote: > > > > On Fri, Oct 14, 2022 at 11:05 AM Miguel Ojeda > > > > wrote: > > > > > > > > > > On Tue, Oct 11, 2022 at 1:16 AM Sami Tolvanen wrote: > > > > > > > > > > > > Rust supports IBT with -Z cf-protection=3Dbranch, but I don't s= ee this > > > > > > option being enabled in the kernel yet. Cross-language CFI is g= oing to > > > > > > require a lot more work though because the type systems are not= quite > > > > > > compatible: > > > > > > > > > > > > https://github.com/rust-lang/rfcs/pull/3296 > > > > > > > > > > I have pinged Ramon de C Valle as he is the author of the RFC abo= ve > > > > > and implementation work too; since a month or so ago he also lead= s the > > > > > Exploit Mitigations Project Group in Rust. > > > > > > > > Thanks, Miguel. I also talked to Ramon about KCFI earlier this week > > > > and he expressed interest in helping with rustc support for it. In = the > > > > meanwhile, I think we can just add a depends on !CFI_CLANG to avoid > > > > issues here. > > > > > > Having just read up on the thing it looks like the KCFI thing is > > > resolved. > > > > > > I'm not sure I understand most of the objections in that thread throu= gh > > > -- enabling CFI *will* break stuff, so what. > > > > > > Squashing the integer types seems a workable compromise I suppose. On= e > > > thing that's been floated in the past is adding a 'seed' attribute to > > > some functions in order to distinguish functions of otherwise identic= al > > > signature. > > > > > > The Rust thing would then also need to support this attribute. > > > > > > Are there any concrete plans for this? It would allow, for example, > > > to differentiate address_space_operations::swap_deactivate() from any > > > other random function that takes only a file argument, say: > > > locks_remove_file(). > > > > I haven't really had time to look into it, so no concrete plans yet. > > Adding an attribute shouldn't be terribly difficult, but Kees > > expressed interest in automatic salting as well, which might be a more > > involved project: > > > > https://github.com/ClangBuiltLinux/linux/issues/1736 > > Automatic would be nice, but having an attribute would let us at least > start the process manually (or apply salting from static analysis > output, etc). An idea would be to add something like the Rust cfi_encoding attribute[1] and use it with something similar to the Newtype Pattern[2], but in C[3], for aggregating function pointers that otherwise would be aggregated in the same group in different groups. [1]: https://doc.rust-lang.org/nightly/unstable-book/language-features/cfi-= encoding.html [2]: https://doc.rust-lang.org/book/ch19-04-advanced-types.html#using-the-n= ewtype-pattern-for-type-safety-and-abstraction [3]: Wrapping a type in a struct should achieve something similar even without using the cfi_encoding attribute since the encoding for structs is , where is .