Message ID | 20240118-alice-file-v3-0-9694b6f9580c@google.com |
---|---|
Headers |
Return-Path: <linux-kernel+bounces-30201-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp383341dyb; Thu, 18 Jan 2024 06:37:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHtAguT+aa0bZ34bEIk8g2J5BxM2raULfFnoMipAc//u7wkjBHgIe8mn7S7TLOg918+n3uD X-Received: by 2002:a17:906:3b0f:b0:a28:c7fe:5458 with SMTP id g15-20020a1709063b0f00b00a28c7fe5458mr525726ejf.94.1705588657020; Thu, 18 Jan 2024 06:37:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705588657; cv=pass; d=google.com; s=arc-20160816; b=cZGhrmyOE4K4WIXLj57v7Hehcm8D4/SZ6Pfs+821ZXTH6asulW32aLY0i9O2toOwY0 fQ/+2lMir6f37AhsAdb2rl8IRCixWr0m6GTm4VPvBPeNvaEDLykBGwwxQ/84CVtmK7BP zlWcgYNCUqWsyDr66kYQXzBHsp8GcSMjGuyLbAd31fKAx8VYZDRNy8vx5KgF74PbQb5E rmt1G+/5Ik/4XesanuzAxDllEdwZQ70Xx1LXjM6D1aUCUNY4XtNMjmV2WJELKmcVv+AQ lTEIQrQeWar5/olG9CEEjKtuZryHNWz9u9hVV6mNNqkirOhsOBcZdyWHbGCWgHw1sU8H mQSg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=0v0DKUVm/o60VD+s4pHxHrhv8BixZc6h40304F/G0T0=; fh=OP+vvG9ih/wBlPG6J6WwyVN77+HGWDbQuR6Uf4lsYyg=; b=lcFdi5AMvxMiiHV8SY5lGTInVvgCI5B58w0QjtIsurVL5ha3ginQHDnFPZ9Nc5ot4R CsM4gx8PaFI40KHkAwFXFBJ0sCurLKYIiGWBWxd8LtJcoUnDVMxXwQY2fNV2fhwQkmAF znVpSYWE9j3+GgRIZ2CzLskxlGVQwcXXxqsawgBP8Ih3c/zl0p7441grXUgMuEPTR9Gs eEhe4CtlhFX7qlxVLhtdkK+JJ8F+mvcgNO/yYYA7tjGykdm0J3/KVRtxC0FoJL4ubu8Z Ags2h5TvABDNjYbI8g90edFcoyMA4CLWG14iFA0SwMymLv3TCM0oFYRV4Bz69CeU9xvL OfcA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vZ6nQwB3; arc=pass (i=1 spf=pass spfdomain=flex--aliceryhl.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-30201-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30201-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id k9-20020a17090666c900b00a2f1bc99283si662736ejp.625.2024.01.18.06.37.36 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 06:37:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30201-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vZ6nQwB3; arc=pass (i=1 spf=pass spfdomain=flex--aliceryhl.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-30201-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30201-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7CFF71F21A9D for <ouuuleilei@gmail.com>; Thu, 18 Jan 2024 14:37:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 70C0528DA0; Thu, 18 Jan 2024 14:36:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vZ6nQwB3" Received: from mail-lf1-f73.google.com (mail-lf1-f73.google.com [209.85.167.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C5D91DDCE for <linux-kernel@vger.kernel.org>; Thu, 18 Jan 2024 14:36:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705588616; cv=none; b=Ef34mu74CH/Pj8pNL8zs4fmfaIZmdaDNI/ksWUGNjybLCKEHvnY2av2axMHGEQMxRSL8c7zhkVaVgBoeUQsunEjn6kpTENUcepAgtIIu8iXqp+K+61SuKkFJcroFPIGsmIJq2h5EyOMFHMpr2aBw6wMDAzym1wM0aqinPcyR52c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705588616; c=relaxed/simple; bh=jhNAUl+zNRT0DrGGSk/2IHTE6BjJ/ijabDZTUKUpX+o=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:Date: Mime-Version:X-Developer-Key:X-Developer-Signature:X-Mailer: Message-ID:Subject:From:To:Cc:Content-Type; b=U2u8VXtqeqWS0wa+e82ZD8khUaWvBf+azUTJdrT306i1OhnxkuX5fGQMQ6WXx7A1RDGcogjshUpv/D3cPMa418FWqyZxqmyWj5P93nfWI7wr7JOwlc+BpQ9NqeocBvFAkvYsC95yfTEvXD86TiuHm9TlLxwznq7zb4EDALJrCyg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=vZ6nQwB3; arc=none smtp.client-ip=209.85.167.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Received: by mail-lf1-f73.google.com with SMTP id 2adb3069b0e04-50e75f8d722so387467e87.0 for <linux-kernel@vger.kernel.org>; Thu, 18 Jan 2024 06:36:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705588612; x=1706193412; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=0v0DKUVm/o60VD+s4pHxHrhv8BixZc6h40304F/G0T0=; b=vZ6nQwB3rF9RTmCwwzjKD2KEIdqtgr0KLnHrSxJL2zk8sXvhd6qYWtegXpkjj8qdIC pHFpRjwyld5aCBq6ajCNCzkBzZDod4NBaLqv9sGvrgzTrKNn77BYjmlU14htf0ERuvDq BFINVc5iNyeiN830lIZWYJ/WsPWjWrGR28WKNK/LnpWpcpFffwtm2dsbUsFX37snAQkF kdiyAuRTyT93bY598ii8s04i1xC+rB08NpHkUs8kiuTL6kinup0jxt6voRzw2buFadDf vnPfzU0vVsfv9T4BASs68dWq4i9A7220APwzAD6p4UNU2Zk0EdAqZvbEeLxh1ymlXehn 3zsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705588612; x=1706193412; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=0v0DKUVm/o60VD+s4pHxHrhv8BixZc6h40304F/G0T0=; b=PIGg6pT/ibJpWO8w7zQR4Vp9Vg0aZTvx1ajC8ucQ/85SvbVDEpm5K4TehCncZAqWsO Z3U/W0sAz4MXlXKfNSXyMv/gBFd/xEpUsQojjIV+ZJKl/231wjrnbl2ZDz6F0nCkPwRY /9OzXX4SKCdCiUTZNlwRYDzBekSr0J3X3jp37gl6e4qwKESkzo9ooArYDIm77KJHJEyg hkbUOES85qrgKZwRjEF8rb1f2EqDvswKKQXyW+XprBtATHaIox64Vn5mj4F2yRsJE7QQ /kUy9rUt8zxzKtOLcVq/FgnGjl9udJXWuRbt0jYKiU/GYnDphvUaVskzhuiD4sTsGCEI dqaA== X-Gm-Message-State: AOJu0YzIEtt0mFYea4OoiN5OkqVTJEOW1FP5hAj9jNqiXvqZm+XufA+G WIKjQR//SGlePLTwSK0/LcwQctPyoa2djjQt4S/I+k1fi/BB0t58+f4KFIa+aF6frUaog6xWXys GNK8Lw769ymQGpw== X-Received: from aliceryhl2.c.googlers.com ([fda3:e722:ac3:cc00:68:949d:c0a8:572]) (user=aliceryhl job=sendgmr) by 2002:a05:6512:34c1:b0:50e:b2ba:147 with SMTP id w1-20020a05651234c100b0050eb2ba0147mr6622lfr.2.1705588612573; Thu, 18 Jan 2024 06:36:52 -0800 (PST) Date: Thu, 18 Jan 2024 14:36:41 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> Mime-Version: 1.0 X-Developer-Key: i=aliceryhl@google.com; a=openpgp; fpr=49F6C1FAA74960F43A5B86A1EE7A392FDE96209F X-Developer-Signature: v=1; a=openpgp-sha256; l=4635; i=aliceryhl@google.com; h=from:subject; bh=jhNAUl+zNRT0DrGGSk/2IHTE6BjJ/ijabDZTUKUpX+o=; b=owEBbQKS/ZANAwAKAQRYvu5YxjlGAcsmYgBlqTHLOLO4pSaf2+zw3LdhQoTIc4w+uP2NKl9Y9 /cn6Z7VrtmJAjMEAAEKAB0WIQSDkqKUTWQHCvFIvbIEWL7uWMY5RgUCZakxywAKCRAEWL7uWMY5 Rk99D/0TYZ05gVZnIv1O/8NQ7Qj2KOYRm7SGdDQU0riJGIupvyVGm85cuWSZ+eFKcM2VZQIbXqQ AKCyaWC79/EkRmp0tOTOA8dWiYyfYcAsdUCaEDMuPeGV72JyAeYpHSYHdOSgBOqf2EMr4dPBTA8 lK7aYxg/qAUulf8m8m4uEHjVy0qSglOrzsshCv7uM6U0F3RjjdjcsQh2YnvBEXHV4gBT15TmLP4 EY9QNde/ga8sOa7g4jIRvKg9TbpuImJQbL781fMYeXpfziHfGQqUoWX2N9PYym8i2i4raxaHaRO CeItS4DcdWjdqqgHAxRI2LA97Aou6+QeD7irIJmsm1E9LClzp0XaUGNlJ2QRFYIndXRzq5gNQC6 szUZZcnDUdFW8JTMDTgNXnpNR6H+xL4rtW6aLwO530sIYCeSKpa1SgnqLwbo8Dhpmz52O9/IIuf J9BIO3+QS6OQAoMc/wm1F8rnH8Y3EFaAp0RNVEtET3HldJjSC5WH+fw7vP/E7YMPddtpa/lQXRI x2J4ruw9QgvhMQvEZ9ui2v9J+hQHIbVjuWoWb103Ga0kRT2g3oVkYcIFVA63Q0+Rjm6Bp60Nr37 hXK6bG4BCWgN01WrjKI6GvH/32QP+6h+2SlX/3YzYu/4pe3tjebyngBh9tP9hTVwCNGrExsbf3M DOXWb0TOVvL4wXA== X-Mailer: git-send-email 2.43.0.381.gb435a96ce8-goog Message-ID: <20240118-alice-file-v3-0-9694b6f9580c@google.com> Subject: [PATCH v3 0/9] File abstractions needed by Rust Binder From: Alice Ryhl <aliceryhl@google.com> To: Miguel Ojeda <ojeda@kernel.org>, Alex Gaynor <alex.gaynor@gmail.com>, Wedson Almeida Filho <wedsonaf@gmail.com>, Boqun Feng <boqun.feng@gmail.com>, Gary Guo <gary@garyguo.net>, " =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= " <bjorn3_gh@protonmail.com>, Benno Lossin <benno.lossin@proton.me>, Andreas Hindborg <a.hindborg@samsung.com>, Peter Zijlstra <peterz@infradead.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Christian Brauner <brauner@kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, " =?utf-8?q?Arve_Hj=C3=B8n?= =?utf-8?q?nev=C3=A5g?= " <arve@android.com>, Todd Kjos <tkjos@android.com>, Martijn Coenen <maco@android.com>, Joel Fernandes <joel@joelfernandes.org>, Carlos Llamas <cmllamas@google.com>, Suren Baghdasaryan <surenb@google.com> Cc: Dan Williams <dan.j.williams@intel.com>, Kees Cook <keescook@chromium.org>, Matthew Wilcox <willy@infradead.org>, Thomas Gleixner <tglx@linutronix.de>, Daniel Xu <dxu@dxuuu.xyz>, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alice Ryhl <aliceryhl@google.com> Content-Type: text/plain; charset="UTF-8" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788439331694604352 X-GMAIL-MSGID: 1788439331694604352 |
Series |
File abstractions needed by Rust Binder
|
|
Message
Alice Ryhl
Jan. 18, 2024, 2:36 p.m. UTC
This patchset contains the file abstractions needed by the Rust
implementation of the Binder driver.
Please see the Rust Binder RFC for usage examples:
https://lore.kernel.org/rust-for-linux/20231101-rust-binder-v1-0-08ba9197f637@google.com/
Users of "rust: file: add Rust abstraction for `struct file`":
[PATCH RFC 02/20] rust_binder: add binderfs support to Rust binder
[PATCH RFC 03/20] rust_binder: add threading support
Users of "rust: cred: add Rust abstraction for `struct cred`":
[PATCH RFC 05/20] rust_binder: add nodes and context managers
[PATCH RFC 06/20] rust_binder: add oneway transactions
[PATCH RFC 11/20] rust_binder: send nodes in transaction
[PATCH RFC 13/20] rust_binder: add BINDER_TYPE_FD support
Users of "rust: security: add abstraction for secctx":
[PATCH RFC 06/20] rust_binder: add oneway transactions
Users of "rust: types: add `NotThreadSafe`":
[PATCH 5/9] rust: file: add `FileDescriptorReservation`
Users of "rust: file: add `FileDescriptorReservation`":
[PATCH RFC 13/20] rust_binder: add BINDER_TYPE_FD support
[PATCH RFC 14/20] rust_binder: add BINDER_TYPE_FDA support
Users of "rust: task: add `Task::current_raw`":
[PATCH 7/9] rust: file: add `Kuid` wrapper
[PATCH 8/9] rust: file: add `DeferredFdCloser`
Users of "rust: file: add `Kuid` wrapper":
[PATCH RFC 05/20] rust_binder: add nodes and context managers
[PATCH RFC 06/20] rust_binder: add oneway transactions
Users of "rust: file: add `DeferredFdCloser`":
[PATCH RFC 14/20] rust_binder: add BINDER_TYPE_FDA support
Users of "rust: file: add abstraction for `poll_table`":
[PATCH RFC 07/20] rust_binder: add epoll support
This patchset has some uses of read_volatile in place of READ_ONCE.
Please see the following rfc for context on this:
https://lore.kernel.org/all/20231025195339.1431894-1-boqun.feng@gmail.com/
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
Changes in v3:
- Completely rewrite comments about refcounting in the first patch.
- And add a note to the documentation in fs/file.c.
- Discuss speculation gadgets in commit message for the Kuid wrapper.
- Introduce NotThreadSafe and Task::current_raw patches and use them in
later patches.
- Improve safety comments in DeferredFdCloser.
- Some other minor changes.
- Link to v2: https://lore.kernel.org/r/20231206-alice-file-v2-0-af617c0d9d94@google.com
Changes in v2:
- Update various docs and safety comments.
- Rename method names to match the C name.
- Use ordinary read instead of READ_ONCE in File::cred.
- Changed null check in secctx.
- Add type alias for PhantomData in FileDescriptorReservation.
- Use Kuid::from_raw in Kuid::current_euid.
- Make DeferredFdCloser fallible if it is unable to schedule a task
work. And also schedule the task work *before* closing the file.
- Moved PollCondVar to rust/kernel/sync.
- Updated PollCondVar to use wake_up_pollfree.
- Link to v1: https://lore.kernel.org/all/20231129-alice-file-v1-0-f81afe8c7261@google.com/
Link to RFC:
https://lore.kernel.org/all/20230720152820.3566078-1-aliceryhl@google.com/
---
Alice Ryhl (6):
rust: security: add abstraction for secctx
rust: types: add `NotThreadSafe`
rust: task: add `Task::current_raw`
rust: file: add `Kuid` wrapper
rust: file: add `DeferredFdCloser`
rust: file: add abstraction for `poll_table`
Wedson Almeida Filho (3):
rust: file: add Rust abstraction for `struct file`
rust: cred: add Rust abstraction for `struct cred`
rust: file: add `FileDescriptorReservation`
fs/file.c | 7 +
rust/bindings/bindings_helper.h | 8 +
rust/helpers.c | 94 ++++++
rust/kernel/cred.rs | 74 +++++
rust/kernel/file.rs | 512 ++++++++++++++++++++++++++++++++
rust/kernel/lib.rs | 3 +
rust/kernel/security.rs | 71 +++++
rust/kernel/sync.rs | 1 +
rust/kernel/sync/lock.rs | 15 +-
rust/kernel/sync/poll.rs | 113 +++++++
rust/kernel/task.rs | 112 ++++++-
rust/kernel/types.rs | 17 ++
12 files changed, 1015 insertions(+), 12 deletions(-)
create mode 100644 rust/kernel/cred.rs
create mode 100644 rust/kernel/file.rs
create mode 100644 rust/kernel/security.rs
create mode 100644 rust/kernel/sync/poll.rs
---
base-commit: 711cbfc717650532624ca9f56fbaf191bed56e67
change-id: 20231123-alice-file-525b98e8a724
Best regards,
--
Alice Ryhl <aliceryhl@google.com>