All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v2 0/2] net: ipa: fix page free in two spots
@ 2022-05-26 15:23 Alex Elder
  2022-05-26 15:23 ` [PATCH net v2 1/2] net: ipa: fix page free in ipa_endpoint_trans_release() Alex Elder
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alex Elder @ 2022-05-26 15:23 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni
  Cc: mka, evgreen, bjorn.andersson, quic_cpratapa, quic_avuyyuru,
	quic_jponduru, quic_subashab, elder, netdev, linux-arm-msm,
	linux-kernel

When a receive buffer is not wrapped in an SKB and passed to the
network stack, the (compound) page gets freed within the IPA driver.
This is currently quite rare.

The pages are freed using __free_pages(), but they should instead be
freed using page_put().  This series fixes this, in two spots.

These patches work for the current linus/master branch, but won't
apply cleanly to earlier stable branches.  (Nevertheless, the fix is
a trivial substitution everwhere __free_pages() is called.)

Version 2 is just rebased on today's net/master branch.

					-Alex

Alex Elder (2):
  net: ipa: fix page free in ipa_endpoint_trans_release()
  net: ipa: fix page free in ipa_endpoint_replenish_one()

 drivers/net/ipa/ipa_endpoint.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

-- 
2.32.0


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

* [PATCH net v2 1/2] net: ipa: fix page free in ipa_endpoint_trans_release()
  2022-05-26 15:23 [PATCH net v2 0/2] net: ipa: fix page free in two spots Alex Elder
@ 2022-05-26 15:23 ` Alex Elder
  2022-05-26 15:23 ` [PATCH net v2 2/2] net: ipa: fix page free in ipa_endpoint_replenish_one() Alex Elder
  2022-05-28  2:20 ` [PATCH net v2 0/2] net: ipa: fix page free in two spots patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Alex Elder @ 2022-05-26 15:23 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni
  Cc: mka, evgreen, bjorn.andersson, quic_cpratapa, quic_avuyyuru,
	quic_jponduru, quic_subashab, elder, netdev, linux-arm-msm,
	linux-kernel

Currently the (possibly compound) page used for receive buffers are
freed using __free_pages().  But according to this comment above the
definition of that function, that's wrong:
    If you want to use the page's reference count to decide when
    to free the allocation, you should allocate a compound page,
    and use put_page() instead of __free_pages().

Convert the call to __free_pages() in ipa_endpoint_trans_release()
to use put_page() instead.

Fixes: ed23f02680caa ("net: ipa: define per-endpoint receive buffer size")
Signed-off-by: Alex Elder <elder@linaro.org>
---
 drivers/net/ipa/ipa_endpoint.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c
index 385aa63ab4bbc..e92aa9447f6e7 100644
--- a/drivers/net/ipa/ipa_endpoint.c
+++ b/drivers/net/ipa/ipa_endpoint.c
@@ -1418,11 +1418,8 @@ void ipa_endpoint_trans_release(struct ipa_endpoint *endpoint,
 	} else {
 		struct page *page = trans->data;
 
-		if (page) {
-			u32 buffer_size = endpoint->config.rx.buffer_size;
-
-			__free_pages(page, get_order(buffer_size));
-		}
+		if (page)
+			put_page(page);
 	}
 }
 
-- 
2.32.0


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

* [PATCH net v2 2/2] net: ipa: fix page free in ipa_endpoint_replenish_one()
  2022-05-26 15:23 [PATCH net v2 0/2] net: ipa: fix page free in two spots Alex Elder
  2022-05-26 15:23 ` [PATCH net v2 1/2] net: ipa: fix page free in ipa_endpoint_trans_release() Alex Elder
@ 2022-05-26 15:23 ` Alex Elder
  2022-05-28  2:20 ` [PATCH net v2 0/2] net: ipa: fix page free in two spots patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Alex Elder @ 2022-05-26 15:23 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni
  Cc: mka, evgreen, bjorn.andersson, quic_cpratapa, quic_avuyyuru,
	quic_jponduru, quic_subashab, elder, netdev, linux-arm-msm,
	linux-kernel

Currently the (possibly compound) pages used for receive buffers are
freed using __free_pages().  But according to this comment above the
definition of that function, that's wrong:
    If you want to use the page's reference count to decide
    when to free the allocation, you should allocate a compound
    page, and use put_page() instead of __free_pages().

Convert the call to __free_pages() in ipa_endpoint_replenish_one()
to use put_page() instead.

Fixes: 6a606b90153b8 ("net: ipa: allocate transaction in replenish loop")
Signed-off-by: Alex Elder <elder@linaro.org>
---
 drivers/net/ipa/ipa_endpoint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c
index e92aa9447f6e7..d3b3255ac3d12 100644
--- a/drivers/net/ipa/ipa_endpoint.c
+++ b/drivers/net/ipa/ipa_endpoint.c
@@ -1095,7 +1095,7 @@ static int ipa_endpoint_replenish_one(struct ipa_endpoint *endpoint,
 
 	ret = gsi_trans_page_add(trans, page, len, offset);
 	if (ret)
-		__free_pages(page, get_order(buffer_size));
+		put_page(page);
 	else
 		trans->data = page;	/* transaction owns page now */
 
-- 
2.32.0


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

* Re: [PATCH net v2 0/2] net: ipa: fix page free in two spots
  2022-05-26 15:23 [PATCH net v2 0/2] net: ipa: fix page free in two spots Alex Elder
  2022-05-26 15:23 ` [PATCH net v2 1/2] net: ipa: fix page free in ipa_endpoint_trans_release() Alex Elder
  2022-05-26 15:23 ` [PATCH net v2 2/2] net: ipa: fix page free in ipa_endpoint_replenish_one() Alex Elder
@ 2022-05-28  2:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-05-28  2:20 UTC (permalink / raw)
  To: Alex Elder
  Cc: davem, edumazet, kuba, pabeni, mka, evgreen, bjorn.andersson,
	quic_cpratapa, quic_avuyyuru, quic_jponduru, quic_subashab,
	elder, netdev, linux-arm-msm, linux-kernel

Hello:

This series was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 26 May 2022 10:23:12 -0500 you wrote:
> When a receive buffer is not wrapped in an SKB and passed to the
> network stack, the (compound) page gets freed within the IPA driver.
> This is currently quite rare.
> 
> The pages are freed using __free_pages(), but they should instead be
> freed using page_put().  This series fixes this, in two spots.
> 
> [...]

Here is the summary with links:
  - [net,v2,1/2] net: ipa: fix page free in ipa_endpoint_trans_release()
    https://git.kernel.org/netdev/net/c/155c0c90bca9
  - [net,v2,2/2] net: ipa: fix page free in ipa_endpoint_replenish_one()
    https://git.kernel.org/netdev/net/c/70132763d5d2

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-05-28  2:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-26 15:23 [PATCH net v2 0/2] net: ipa: fix page free in two spots Alex Elder
2022-05-26 15:23 ` [PATCH net v2 1/2] net: ipa: fix page free in ipa_endpoint_trans_release() Alex Elder
2022-05-26 15:23 ` [PATCH net v2 2/2] net: ipa: fix page free in ipa_endpoint_replenish_one() Alex Elder
2022-05-28  2:20 ` [PATCH net v2 0/2] net: ipa: fix page free in two spots patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.