public inbox for [email protected]
 help / color / mirror / Atom feed
* [bug report] io_uring: free io_buffer_list entries via RCU
@ 2023-12-05 12:36 Dan Carpenter
  2023-12-05 14:01 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2023-12-05 12:36 UTC (permalink / raw)
  To: axboe; +Cc: io-uring

Hello Jens Axboe,

This is a semi-automatic email about new static checker warnings.

The patch 5cf4f52e6d8a: "io_uring: free io_buffer_list entries via 
RCU" from Nov 27, 2023, leads to the following Smatch complaint:

    io_uring/kbuf.c:766 io_pbuf_get_address()
    warn: variable dereferenced before check 'bl' (see line 764)

io_uring/kbuf.c
   753  void *io_pbuf_get_address(struct io_ring_ctx *ctx, unsigned long bgid)
   754  {
   755          struct io_buffer_list *bl;
   756  
   757          bl = __io_buffer_get_list(ctx, smp_load_acquire(&ctx->io_bl), bgid);
   758  
   759          /*
   760           * Ensure the list is fully setup. Only strictly needed for RCU lookup
   761           * via mmap, and in that case only for the array indexed groups. For
   762           * the xarray lookups, it's either visible and ready, or not at all.
   763           */
   764          if (!smp_load_acquire(&bl->is_ready))
                                      ^^^^^
bl dereferenced here

   765                  return NULL;
   766          if (!bl || !bl->is_mmap)
                    ^^^
Checked for NULL too late.

   767                  return NULL;
   768  
   769          return bl->buf_ring;
   770  }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] io_uring: free io_buffer_list entries via RCU
  2023-12-05 12:36 [bug report] io_uring: free io_buffer_list entries via RCU Dan Carpenter
@ 2023-12-05 14:01 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2023-12-05 14:01 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: io-uring

On 12/5/23 5:36 AM, Dan Carpenter wrote:
> Hello Jens Axboe,
> 
> This is a semi-automatic email about new static checker warnings.
> 
> The patch 5cf4f52e6d8a: "io_uring: free io_buffer_list entries via 
> RCU" from Nov 27, 2023, leads to the following Smatch complaint:
> 
>     io_uring/kbuf.c:766 io_pbuf_get_address()
>     warn: variable dereferenced before check 'bl' (see line 764)
> 
> io_uring/kbuf.c
>    753  void *io_pbuf_get_address(struct io_ring_ctx *ctx, unsigned long bgid)
>    754  {
>    755          struct io_buffer_list *bl;
>    756  
>    757          bl = __io_buffer_get_list(ctx, smp_load_acquire(&ctx->io_bl), bgid);
>    758  
>    759          /*
>    760           * Ensure the list is fully setup. Only strictly needed for RCU lookup
>    761           * via mmap, and in that case only for the array indexed groups. For
>    762           * the xarray lookups, it's either visible and ready, or not at all.
>    763           */
>    764          if (!smp_load_acquire(&bl->is_ready))
>                                       ^^^^^
> bl dereferenced here
> 
>    765                  return NULL;
>    766          if (!bl || !bl->is_mmap)
>                     ^^^
> Checked for NULL too late.
> 
>    767                  return NULL;
>    768  
>    769          return bl->buf_ring;
>    770  }

Thanks, yeah we should just move the check below the NULL check. I'll
queue up a fixlet.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-12-05 14:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-05 12:36 [bug report] io_uring: free io_buffer_list entries via RCU Dan Carpenter
2023-12-05 14:01 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox