From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
To: Alice Ryhl <aliceryhl@google.com>
Cc: rust-for-linux@vger.kernel.org, linux-fsdevel@vger.kernel.org,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Christian Brauner" <brauner@kernel.org>,
"Wedson Almeida Filho" <wedsonaf@gmail.com>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
linux-kernel@vger.kernel.org, patches@lists.linux.dev
Subject: Re: [RFC PATCH v1 5/5] rust: file: add `DeferredFdCloser`
Date: Thu, 20 Jul 2023 20:22:34 +0200 [thread overview]
Message-ID: <CANiq72=44YaQ--QV7+H5cQUY4o9i6hbz3OD_F_u0JGV4PzV-OQ@mail.gmail.com> (raw)
In-Reply-To: <20230720152820.3566078-6-aliceryhl@google.com>
Hi Alice,
A quick comment on referencing commits:
On Thu, Jul 20, 2023 at 5:29 PM Alice Ryhl <aliceryhl@google.com> wrote:
>
> See comments on `binder_do_fd_close` and commit `80cd795630d65` for
> motivation.
The convention is to write these commit references like this:
commit 80cd795630d6 ("binder: fix use-after-free due to
ksys_close() during fdget()")
I recommend generating them with a Git pretty format -- see the config
in the bottom part of the section at
https://docs.kernel.org/process/submitting-patches.html#describe-your-changes.
Also, given it is a kernel convention, please avoid the Markdown
backticks in this case.
> +/// See comments on `binder_do_fd_close` and commit `80cd795630d65`.
Same here, i.e. in comments and documentation too (and emails too,
especially if not referenced elsewhere).
While I am at it, a few other notes below too I noticed:
> + /// Create a new `DeferredFdCloser`.
[`DeferredFdCloser`]
> + /// Schedule a task work that closes the file descriptor when this task returns to userspace.
> + pub fn close_fd(mut self, fd: u32) {
> + let file = unsafe { bindings::close_fd_get_file(fd) };
> + if !file.is_null() {
Please use the early return style here, if possible, to unindent all this.
> + // SAFETY: Since DeferredFdCloserInner is `#[repr(C)]`, casting the pointers gives a
`DeferredFdCloserInner`
> + // Note: fl_owner_t is currently a void pointer.
`fl_owner_t`
> + // SAFETY: The `inner` pointer is compatible with the `do_close_fd` method.
> + //
> + // The call to `task_work_add` can't fail, because we are scheduling the task work to
> + // the current task.
> + unsafe {
> + bindings::init_task_work(inner, Some(Self::do_close_fd));
> + bindings::task_work_add(current, inner, bindings::task_work_notify_mode_TWA_RESUME);
> + }
Should this block be split?
> /// Represents the EBADF error code.
> ///
> /// Used for methods that can only fail with EBADF.
Doclink them if possible; otherwise `EBADF`.
Cheers,
Miguel
next prev parent reply other threads:[~2023-07-20 18:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-20 15:28 [RFC PATCH v1 0/5] Various Rust bindings for files Alice Ryhl
2023-07-20 15:28 ` [RFC PATCH v1 1/5] rust: file: add bindings for `struct file` Alice Ryhl
2023-08-09 2:59 ` Martin Rodriguez Reboredo
2023-07-20 15:28 ` [RFC PATCH v1 2/5] rust: cred: add Rust bindings for `struct cred` Alice Ryhl
2023-07-20 15:28 ` [RFC PATCH v1 3/5] rust: file: add `FileDescriptorReservation` Alice Ryhl
2023-08-09 4:02 ` Martin Rodriguez Reboredo
2023-07-20 15:28 ` [RFC PATCH v1 4/5] rust: file: add bindings for `poll_table` Alice Ryhl
2023-07-20 15:28 ` [RFC PATCH v1 5/5] rust: file: add `DeferredFdCloser` Alice Ryhl
2023-07-20 18:22 ` Miguel Ojeda [this message]
2023-08-09 4:33 ` Martin Rodriguez Reboredo
2023-08-09 9:00 ` Miguel Ojeda
2023-08-09 9:09 ` Miguel Ojeda
2023-08-09 20:15 ` Martin Rodriguez Reboredo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CANiq72=44YaQ--QV7+H5cQUY4o9i6hbz3OD_F_u0JGV4PzV-OQ@mail.gmail.com' \
--to=miguel.ojeda.sandonis@gmail.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=brauner@kernel.org \
--cc=gary@garyguo.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=patches@lists.linux.dev \
--cc=rust-for-linux@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=wedsonaf@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).