Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH 6.12] block: fix memory leak in in bio_map_user_iov()
       [not found] ` <20260507212200-2614841ccc112a082cab6938-pchelkin@ispras>
@ 2026-05-08  8:30   ` Dmitry Antipov
  2026-05-08 11:16     ` Fedor Pchelkin
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Antipov @ 2026-05-08  8:30 UTC (permalink / raw)
  To: Fedor Pchelkin
  Cc: Greg Kroah-Hartman, stable, Jens Axboe, linux-block,
	Christoph Hellwig, lvc-project, netdev

On Thu, 2026-05-07 at 21:52 +0300, Fedor Pchelkin wrote:

> In some form the issue is present in current upstream as well.  For
> example, there is another callsite of iov_iter_extract_pages() in
> block/bio-integrity.c where the same pattern still persists. 

Good point, and skb_splice_from_iter() looks suspicious as well:

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 7dad68e3b518..bf053372acb2 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -7343,12 +7343,16 @@ ssize_t skb_splice_from_iter(struct sk_buff *skb, struct iov_iter *iter,
 
                len = iov_iter_extract_pages(iter, &ppages, maxsize, nr, 0, &off);
                if (len <= 0) {
+                       /* Possible memory leak - ppages should be vfree()'d
+                          if reallocated (ppages != pages)? */
                        ret = len ?: -EIO;
                        break;
                }
 
                i = 0;
                do {
+                       /* This looks wrong if reallocated - ppages[i++]
+                          should be used instead? */
                        struct page *page = pages[i++];
                        size_t part = min_t(size_t, PAGE_SIZE - off, len);

This issue likely crosses the boundaries of block subsystem so netdev
people are encouraged to look as well.

Dmitry

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

* Re: [PATCH 6.12] block: fix memory leak in in bio_map_user_iov()
  2026-05-08  8:30   ` [PATCH 6.12] block: fix memory leak in in bio_map_user_iov() Dmitry Antipov
@ 2026-05-08 11:16     ` Fedor Pchelkin
  0 siblings, 0 replies; 2+ messages in thread
From: Fedor Pchelkin @ 2026-05-08 11:16 UTC (permalink / raw)
  To: Dmitry Antipov
  Cc: Greg Kroah-Hartman, stable, Jens Axboe, linux-block,
	Christoph Hellwig, lvc-project, netdev

On Fri, 08. May 11:30, Dmitry Antipov wrote:
> On Thu, 2026-05-07 at 21:52 +0300, Fedor Pchelkin wrote:
> 
> > In some form the issue is present in current upstream as well.  For
> > example, there is another callsite of iov_iter_extract_pages() in
> > block/bio-integrity.c where the same pattern still persists. 
> 
> Good point, and skb_splice_from_iter() looks suspicious as well:
> 
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 7dad68e3b518..bf053372acb2 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -7343,12 +7343,16 @@ ssize_t skb_splice_from_iter(struct sk_buff *skb, struct iov_iter *iter,
>  
>                 len = iov_iter_extract_pages(iter, &ppages, maxsize, nr, 0, &off);

This function does allocate memory for @pages argument only if *@pages is
NULL.  I don't think it's NULL here, *@pages points to a stack-allocated
array.

>                 if (len <= 0) {
> +                       /* Possible memory leak - ppages should be vfree()'d
> +                          if reallocated (ppages != pages)? */
>                         ret = len ?: -EIO;
>                         break;
>                 }
>  
>                 i = 0;
>                 do {
> +                       /* This looks wrong if reallocated - ppages[i++]
> +                          should be used instead? */
>                         struct page *page = pages[i++];
>                         size_t part = min_t(size_t, PAGE_SIZE - off, len);
> 
> This issue likely crosses the boundaries of block subsystem so netdev
> people are encouraged to look as well.

Not in this case.  The situations where iov_iter_extract_pages() needs to
allocate memory for @pages on its own happen when *@pages is NULL.  In
current mainline it can occur at block/bio-integrity.c and probably
that's all.

Mind to prepare the patch, please?  There are better chances to discuss
the problem directly with the patch at hand instead of expecting someone
to look at this [PATCH 6.12] thread.

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

end of thread, other threads:[~2026-05-08 11:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260505094529.406783-1-dmantipov@yandex.ru>
     [not found] ` <20260507212200-2614841ccc112a082cab6938-pchelkin@ispras>
2026-05-08  8:30   ` [PATCH 6.12] block: fix memory leak in in bio_map_user_iov() Dmitry Antipov
2026-05-08 11:16     ` Fedor Pchelkin

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