Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp920161rdb; Wed, 6 Dec 2023 04:01:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHFo7+m0i6ruV7Qgqt62yo1RmPRcFxWsok0xj1nzLe9IFgJsKN8z1U7in0dctnRAjiPYBOJ X-Received: by 2002:a17:90b:4c06:b0:286:c166:4db0 with SMTP id na6-20020a17090b4c0600b00286c1664db0mr557405pjb.46.1701864062440; Wed, 06 Dec 2023 04:01:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701864062; cv=none; d=google.com; s=arc-20160816; b=yPlFDj4bX3tYO/0yYQWk3UuUKmfeFRBOVdvyLe4klLjG2kbLyzS/qxsPiykZ4MMZvx IDrET3e/v3wugEDgPL1226/c4hcDZQHT03DW07lXk9xN3VVzAPd0OBimeX8qSQhiPe1T Vtd+CNKDo+9F/czEw4sSA6NmFAeLxQe8dV5E8HYyLWQWyXQMbrMIb80JD2KZLV/XYXum 6Jc2wQNXwAS1wqXue1q2amtXRLSCcdvEfFt7PYhMvhReb1OjOyIl7CaioGa52xNE9Z0K R8vX8a2dxcfLTm3GLDzusRyhaO/qby+FluFNJgTKU10Xc4HtF+MlZK2H3vSkPORhl9MW 32Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=bs2sSu7jP2NPZiCyS3HRAfCV2YiHx8SRHP9dJ3Owk1U=; fh=T6834Aktx7Xb+pPtXPn7W/cinKjAb/YxUL0rKizMDmY=; b=qujWsOsoueH8qjPmUMgUyKLRJXqbIq6h+7+TWCVdb15R2cQLq8u+JoGjWJQwiWDSTy whCVkzQvF8VC8aVpQr7YJmemgHOeze2uCa1LGhqXuM3HY6FyasjJejPNof7Q/ubU+6pU buBO/D2ukeW2cGDPlQoMmyXumSSQ3UGst/vf+3okbR2vef3OWHUUlZQOOlCX8uN4nNl3 A2HWs3zfYi0wT++3J5Hgq6osIcVEJw2fOHSH8PTJz5CllR518va/J+i4DgyrLnNjGpV+ PquSTqECnPox+IsznNG8ebXs7KIteG7HK5kTJuQXhH4tSw3nujJ6F5K8apZDB2qyaL4p E+yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ab3ksY1s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id lb10-20020a17090b4a4a00b00286a5319395si5628137pjb.123.2023.12.06.04.01.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 04:01:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ab3ksY1s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id BBF51807A582; Wed, 6 Dec 2023 04:00:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378085AbjLFL77 (ORCPT + 99 others); Wed, 6 Dec 2023 06:59:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377792AbjLFL75 (ORCPT ); Wed, 6 Dec 2023 06:59:57 -0500 Received: from mail-lj1-x249.google.com (mail-lj1-x249.google.com [IPv6:2a00:1450:4864:20::249]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60F5F1BF for ; Wed, 6 Dec 2023 04:00:02 -0800 (PST) Received: by mail-lj1-x249.google.com with SMTP id 38308e7fff4ca-2c9fdb15388so31489641fa.2 for ; Wed, 06 Dec 2023 04:00:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701864000; x=1702468800; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=bs2sSu7jP2NPZiCyS3HRAfCV2YiHx8SRHP9dJ3Owk1U=; b=ab3ksY1smRD7UsYS63q4Q5vv6b00yeagsS9vqYyFCEW1xm3RTdOUKlgmEpbrN/1CGt Y+HFHcNv4mxeQ446KuXztq3vloAlLtm1dtA58Djxw9QhCF+gUNJZTJKQ6V+LVLArpJ++ XN/SYyok6MV1ZROqIHUlSODPm11p1rrn3lysUJwpUEOkEFwaWFkb6lzWk6JZvkV59YjT GGZskqWX1cg5xl+T+BdU6qZulUko5HQKfDOsMW9vWP6ObreePaeLduy6Wbp58s2UVtFK 8zcI30dM/PJLJXn39NBViZMxhhV9RftsudWhjFh+OYixgxUH/I0AvwUn4MzJY/1SHT5s 40Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701864000; x=1702468800; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=bs2sSu7jP2NPZiCyS3HRAfCV2YiHx8SRHP9dJ3Owk1U=; b=B6Td7/LbMGPMazszaAP/j3N7WfL93O8TQyMm2E5gbuw9YtxmIM+a+7mUDaS/x6QXlb HK5pRb/TXELHcdhwprz8CKCTiVODYQqvo789sidmnJPFUsAeT+g74gBZvhSDNIGShFOK Xeffnx/nSRFr5ITuepof/Dn4ucsPkBVxQIyfIKyKysK7jbIhNuKyWHAeEB9QZNCmASlh 1mJdNQbQ4WlMSy64yC7WHlWXNAidk4KkNmuYmHxR/0y5Xl7lIq7UM1PxexMD9srA2Bs+ B+Q0HBfc0NCR+y0aE3+6zQrOFglDXE3Ca0lmX+CG1jen9bTaNuTexkFm5j7k8TNSRxiP 2USA== X-Gm-Message-State: AOJu0YzJkfD5//iTndhyk+15wRk7OcnGb0XSMoxxeDDcEl6v1NeqpEZI dtvptrV86ZvzhgoyRWhWVMtd6qYxFRtK8jI= X-Received: from aliceryhl2.c.googlers.com ([fda3:e722:ac3:cc00:68:949d:c0a8:572]) (user=aliceryhl job=sendgmr) by 2002:a2e:a4cc:0:b0:2ca:217:3ad6 with SMTP id p12-20020a2ea4cc000000b002ca02173ad6mr9921ljm.8.1701864000377; Wed, 06 Dec 2023 04:00:00 -0800 (PST) Date: Wed, 06 Dec 2023 11:59:45 +0000 Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIADFicGUC/03MQQrCMBCF4auUWRtpptamrryHdBHjJB2IjSQSl JK7GwuCy//B+1ZIFJkSnJoVImVOHJYauGvAzHpxJPhWG7DFTkrshPZsSFj2JHrsr6MipQc8QD0 8Ill+bdhlqj1zeob43uwsv+uPGf+ZLEUrrJLakjIDHuXZheA87U24w1RK+QCfI8FDpQAAAA== X-Developer-Key: i=aliceryhl@google.com; a=openpgp; fpr=49F6C1FAA74960F43A5B86A1EE7A392FDE96209F X-Developer-Signature: v=1; a=openpgp-sha256; l=3570; i=aliceryhl@google.com; h=from:subject:message-id; bh=ZtzAhf7x6vcHPQRySpbobpUqBvYjeJWg+KMtSmYWzlM=; b=owEBbQKS/ZANAwAKAQRYvu5YxjlGAcsmYgBlcGI4FncNrgyduHzDoDmHvtMDvKXsJQ+z4dAxN 3XjiaHaNF+JAjMEAAEKAB0WIQSDkqKUTWQHCvFIvbIEWL7uWMY5RgUCZXBiOAAKCRAEWL7uWMY5 RnG6D/9AYE0+4oRYwt77OJ3shdfyOzoTjvMm15rhUlKWpLWmHL71RXAwpBA8JSzXitefrJMhwSa M6kVu9QqTY1sCpLDGlt5wsNrMZL6BBvrTWzC7H2Lr2ifSf9LGzGaznEM/aWJgwGl5p05E1svT8T R0aqgoIYkIvucq/lOWyBmOBS0uqI/Fq43fuOzTbMzQCaw2IlqxBeBtUNlJ59DH7N+75Ib4NtL9C Y/ksXJi8nATaWY0Ea4tOgyO+vEwinVYglQSMuaT0JcWX3ZJaBmTCHVfQOPySsohtzotExn3e8EF nSKVjBYCb5leRqmA0IoOCZ7sjk+T5ljrKXknaw6cNnawO1D2tL5XDzRtq+/+YGs/lNXpw203wPL gCcax7y5Q3abpK3f75Lmqtqk1tBtApK1dD1IC0c4q3dy4fm9tJEfl6YiAoySvFkttaVym+LVQ2u XF/eAdxXq5jjaCC4DuZsn3XNm5JSM65FZMicORQm9q83Z5MLSAhZYUuB8H4+UwZ4O+s+QUONU3W v5XeF+cp42jO2rVdo3bc+xzb7vr/0EP1M9DADBLh40ew22lTk3F7a/tXG7zz0hwTRVMpN97Fx6b wh5cstlVcei/ccB8+SeFBBrWqfNLx1EFHf+P4t1w+2xvCFFJ0ZiHd1M4McemO69CxsRq3+0WQiT qHNjnhnNYWp3IAQ== X-Mailer: b4 0.13-dev-26615 Message-ID: <20231206-alice-file-v2-0-af617c0d9d94@google.com> Subject: [PATCH v2 0/7] File abstractions needed by Rust Binder From: Alice Ryhl To: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , "=?utf-8?q?Bj=C3=B6rn_Roy_Baron?=" , Benno Lossin , Andreas Hindborg , Peter Zijlstra , Alexander Viro , Christian Brauner , Greg Kroah-Hartman , "=?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?=" , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan Cc: Dan Williams , Kees Cook , Matthew Wilcox , Thomas Gleixner , Daniel Xu , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alice Ryhl Content-Type: text/plain; charset="utf-8" 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,T_SCC_BODY_TEXT_LINE, 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 agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 06 Dec 2023 04:00:17 -0800 (PST) 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 security_secid_to_secctx": [PATCH RFC 06/20] rust_binder: add oneway transactions 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: file: add kuid getters": [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 --- 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 (4): rust: security: add abstraction for secctx 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` rust/bindings/bindings_helper.h | 9 + rust/bindings/lib.rs | 1 + rust/helpers.c | 94 +++++++++ rust/kernel/cred.rs | 73 +++++++ rust/kernel/file.rs | 431 ++++++++++++++++++++++++++++++++++++++++ rust/kernel/lib.rs | 3 + rust/kernel/security.rs | 79 ++++++++ rust/kernel/sync.rs | 1 + rust/kernel/sync/poll.rs | 103 ++++++++++ rust/kernel/task.rs | 68 ++++++- rust/kernel/types.rs | 10 + 11 files changed, 871 insertions(+), 1 deletion(-) --- base-commit: 98b1cc82c4affc16f5598d4fa14b1858671b2263 change-id: 20231123-alice-file-525b98e8a724 Best regards, -- Alice Ryhl