Rust for Linux List
 help / color / mirror / Atom feed
From: "Gary Guo" <gary@garyguo.net>
To: "Andreas Hindborg" <a.hindborg@kernel.org>,
	"Priya Bala Govindasamy" <pgovind2@uci.edu>,
	"Breno Leitao" <leitao@debian.org>
Cc: <boqun@kernel.org>, <gary@garyguo.net>,
	<bjorn3_gh@protonmail.com>, <lossin@kernel.org>,
	<aliceryhl@google.com>, <tmgross@umich.edu>, <dakr@kernel.org>,
	<daniel.almeida@collabora.com>, <tamird@kernel.org>,
	<acourbot@nvidia.com>, <work@onurozkan.dev>,
	<rust-for-linux@vger.kernel.org>, <ardalan@uci.edu>,
	<zhiyunq@cs.ucr.edu>, <dzueck@uci.edu>, <ojeda@kernel.org>
Subject: Re: [PATCH 0/1] rust: configfs: Fix reference creation from uninitialized data in `Attribute::show`
Date: Fri, 09 Oct 2026 13:54:23 +0100	[thread overview]
Message-ID: <DM0BMX11TPKW.3SXBKY2XRLHQJ@garyguo.net> (raw)
In-Reply-To: <87se2fca48.fsf@kernel.org>

On Fri Oct 9, 2026 at 1:49 PM BST, Andreas Hindborg wrote:
> Andreas Hindborg <a.hindborg@kernel.org> writes:
>
> Actually there may be a problem, but I think it may be in C configfs. If
> you take a look at the function that reads data from the iov_iter:
>
>   static int fill_write_buffer(struct configfs_buffer *buffer,
>             struct iov_iter *from)
>   {
>     int copied;
>
>     if (!buffer->page)
>       buffer->page = kmalloc(PAGE_SIZE, GFP_KERNEL); // <- HERE
>     if (!buffer->page)
>       return -ENOMEM;
>
>     copied = copy_from_iter(buffer->page, SIMPLE_ATTR_SIZE - 1, from);
>     buffer->needs_read_fill = 1;
>     /* if buf is assumed to contain a string, terminate it by \0,
>     * so e.g. sscanf() can scan the string easily */
>     buffer->page[copied] = 0;
>     return copied ? : -EFAULT;
>   }
>
> This function does not zero the page that is written into. This,
> combined with the buffer being per file handle means that you can read
> the original data in the page. The `kmalloc` should be probably be
> replaced with a `kzalloc`. This should be a problem for C modules as
> well.

Why is this an issue? The extra uninitialized bytes should not be used.

Best,
Gary

>
> Cc: Breno Leitao <leitao@debian.org>
>
> Looks like I only replied Priya when replying, so I'm adding back
> everyone from the original email.
>
> Best regards,
> Andreas Hindborg



  reply	other threads:[~2026-10-09 12:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cUqSvTsTaMYu_TRrAABCYTNz0HZf5JeFdIq_Vv4e_-GFMgI5NwVfZJDcy8CTgc4fH_1OoiiMg2I2LIzQX1y3Rg==@protonmail.internalid>
2026-10-08 23:42 ` [PATCH 0/1] rust: configfs: Fix reference creation from uninitialized data in `Attribute::show` Priya Bala Govindasamy
2026-10-08 23:42   ` [PATCH] " Priya Bala Govindasamy
     [not found]   ` <87v77bcg0m.fsf@kernel.org>
2026-10-09 12:49     ` [PATCH 0/1] " Andreas Hindborg
2026-10-09 12:54       ` Gary Guo [this message]
     [not found]         ` <f-SD-RJDAM9vxqOj3MupDr-geggiu7qcKsYBwlTK02DS6siKkRU643dmvGb-ihkpH5LKF6zW1DH2KHAmzXjvNg==@protonmail.internalid>
     [not found]           ` <CAPPBnEZBeB2cZ7_2Syt_Vy0HcXWrRF6j-M1HmZQwKkwG=1nz-Q@mail.gmail.com>
2026-10-09 20:17             ` Andreas Hindborg
2026-10-09 20:32         ` Andreas Hindborg
2026-10-09 22:15           ` Gary Guo
2026-10-09 21:19         ` Priya Bala Govindasamy

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=DM0BMX11TPKW.3SXBKY2XRLHQJ@garyguo.net \
    --to=gary@garyguo.net \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=ardalan@uci.edu \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=dzueck@uci.edu \
    --cc=leitao@debian.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=pgovind2@uci.edu \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=work@onurozkan.dev \
    --cc=zhiyunq@cs.ucr.edu \
    /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