[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <175707084146.356946.8866336484834458029.b4-ty@kernel.dk>
Date: Fri, 05 Sep 2025 05:14:01 -0600
From: Jens Axboe <axboe@...nel.dk>
To: Caleb Sander Mateos <csander@...estorage.com>
Cc: io-uring@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] io_uring/rsrc: initialize io_rsrc_data nodes array
On Thu, 04 Sep 2025 19:25:34 -0600, Caleb Sander Mateos wrote:
> io_rsrc_data_alloc() allocates an array of io_rsrc_node pointers and
> assigns it to io_rsrc_data's nodes field along with the size in the nr
> field. However, it doesn't initialize the io_rsrc_node pointers in the
> array. If an error in io_sqe_buffers_register(), io_alloc_file_tables(),
> io_sqe_files_register(), or io_clone_buffers() causes them to exit
> before all the io_rsrc_node pointers in the array have been assigned,
> io_rsrc_data_free() will read the uninitialized elements, triggering
> undefined behavior.
> Additionally, if dst_off exceeds the current size of the destination
> buffer table in io_clone_buffers(), the io_rsrc_node pointers in between
> won't be initialized. Any access to those registered buffer indices will
> result in undefined behavior.
> Allocate the array with kvcalloc() instead of kvmalloc_array() to ensure
> the io_rsrc_node pointers are initialized to NULL (indicating no
> registered buffer/file node).
>
> [...]
Applied, thanks!
[1/1] io_uring/rsrc: initialize io_rsrc_data nodes array
commit: 0f51a5c0a89921deca72e42583683e44ff742d06
Best regards,
--
Jens Axboe
Powered by blists - more mailing lists