Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1130230rwb; Tue, 27 Sep 2022 08:48:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7TKXDwCtsyi91SE7+4G2rL0+s22q2KKGR3HuZkHeTlYELlVPXqaKUOTm/nyp7haevBa3yo X-Received: by 2002:a63:6c06:0:b0:43c:783f:46b3 with SMTP id h6-20020a636c06000000b0043c783f46b3mr15787101pgc.101.1664293688946; Tue, 27 Sep 2022 08:48:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664293688; cv=none; d=google.com; s=arc-20160816; b=Zac94B2QKuEpQGSYK/XtYKST3VLBFA19rnX1+ExOOFPHhtLfxajGDltDhdPUgHF3+9 ePWZK1jBzSiW41brIxgkCjdzd/yEVnzeBGwGei4L7nk0UaAvnY3uenCAq6FJ8YIp5jXp xAshCA4epxLdXH7TmdcMaAbpqF5CX6WLCs8O93ibG0dqcYb5drNOkQaXPk+ks1msYamG 180Jb1/lro7YrNSArp/ud0VcoYASxxQlFuUfcjezUO16ehO0nr2WsS8WsU0+pw5w4Z3y 3ljnu6S5mXYHVkVeiRmzqbJ7uoJapOIWSgI5bH1tm9U+UXQGUC52NoSzHqEvXgtjFNS9 07eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=5SilAd2d7at9TBirA91ku46gD+/cBYT4XK0+SXDdesc=; b=RmQy4XAGmFisyIDXbH/NovKu75XGsPr96pQ8YxZMKO7KkLbHL9RNeHpiw6LmwqetBb J7MQwxpiVxRAJKtIlQR2NObBOcOn0h7Y3Bi5LTSAGYgc4dcrXsJOtoljZrBAwdeh6l+x s4fG8Tq3nn+WfXTY2GWV7wpsXLMYR0PYS2ptuu/QzoCH6Fq72etkGAQ/GyV3m5TLy/X7 8YtfHfW1AA9RBH4tE30BsUh81WJVET1fGkFyjVNYUwfZYMrVQ2h2Zt70IM+gX+kBS3BE XN5LPhtzlv1Otfkx/vqT5E7bVLFw12CIHPDOelENl3+vXNgnkmhlHghXtUxxJVkyahEc J7MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AOGV6xrr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j6-20020a170902da8600b001749dafb822si2494357plx.507.2022.09.27.08.47.57; Tue, 27 Sep 2022 08:48:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AOGV6xrr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231529AbiI0PXi (ORCPT + 99 others); Tue, 27 Sep 2022 11:23:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230443AbiI0PXf (ORCPT ); Tue, 27 Sep 2022 11:23:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC905160E66; Tue, 27 Sep 2022 08:23:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7F977B81B2B; Tue, 27 Sep 2022 15:23:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B573EC433C1; Tue, 27 Sep 2022 15:23:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664292211; bh=LyIAB0lF9FCQiumvTQTwbtjhCItevMYwMDFfh2e4kzU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AOGV6xrrWAqcDC+CEV28UP2bfyMDvzxOt3CAOBGkG1KmY04WzaTIdt41JgaFCjaw3 ROFQzJPwOcDzk+uevNtwmnIR8iu8Jgqm2ApKmuWTtuUcPQWQXgYJKWNdj9o9mHbnid IGLJBo2OErm4CHBOoKAi5rn8PTOl99aLs39T9994= Date: Tue, 27 Sep 2022 17:23:28 +0200 From: Greg Kroah-Hartman To: Miguel Ojeda Cc: Linus Torvalds , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, patches@lists.linux.dev, Jarkko Sakkinen , Alex Gaynor , Finn Behrens , Wedson Almeida Filho , Sven Van Asbroeck , Gary Guo , Maciej Falkowski , Jiapeng Chong , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Boqun Feng Subject: Re: [PATCH v10 11/27] rust: add `bindings` crate Message-ID: References: <20220927131518.30000-1-ojeda@kernel.org> <20220927131518.30000-12-ojeda@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220927131518.30000-12-ojeda@kernel.org> X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 27, 2022 at 03:14:42PM +0200, Miguel Ojeda wrote: > This crate contains the bindings to the C side of the kernel. > > Calling C (in general, FFI) is assumed to be unsafe in Rust > and, in many cases, this is accurate. For instance, virtually > all C functions that take a pointer are unsafe since, typically, > it will be dereferenced at some point (and in most cases there > is no way for the callee to check its validity beforehand). > > Since one of the goals of using Rust in the kernel is precisely > to avoid unsafe code in "leaf" kernel modules (e.g. drivers), > these bindings should not be used directly by them. > > Instead, these bindings need to be wrapped into safe abstractions. > These abstractions provide a safe API that kernel modules can use. > In this way, unsafe code in kernel modules is minimized. > > Co-developed-by: Alex Gaynor > Signed-off-by: Alex Gaynor > Co-developed-by: Finn Behrens > Signed-off-by: Finn Behrens > Co-developed-by: Wedson Almeida Filho > Signed-off-by: Wedson Almeida Filho > Co-developed-by: Sven Van Asbroeck > Signed-off-by: Sven Van Asbroeck > Co-developed-by: Gary Guo > Signed-off-by: Gary Guo > Co-developed-by: Maciej Falkowski > Signed-off-by: Maciej Falkowski > Co-developed-by: Jiapeng Chong > Signed-off-by: Jiapeng Chong > Co-developed-by: Bj?rn Roy Baron > Signed-off-by: Bj?rn Roy Baron > Signed-off-by: Miguel Ojeda > --- > rust/bindings/bindings_helper.h | 13 ++++++++ > rust/bindings/lib.rs | 53 +++++++++++++++++++++++++++++++++ > 2 files changed, 66 insertions(+) > create mode 100644 rust/bindings/bindings_helper.h > create mode 100644 rust/bindings/lib.rs Reviewed-by: Greg Kroah-Hartman