public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: fix uninitialised msghdr->sg_from_iter
@ 2022-07-21 14:25 Pavel Begunkov
  2022-07-22 22:00 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2022-07-21 14:25 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: David S . Miller, Jakub Kicinski, David Ahern, Pavel Begunkov

Because of how struct msghdr is usually initialised some fields and
sg_from_iter in particular might be left out not initialised, so we
can't safely use it in __zerocopy_sg_from_iter().

For now use the callback only when there is ->msg_ubuf set relying on
the fact that they're used together and we properly zero ->msg_ubuf.

Fixes: ebe73a284f4de8 ("net: Allow custom iter handler in msghdr")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---

It's not the best approach long term but let's fix first and later
I'm going to clean up msghdr initialisation.

 net/core/datagram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/datagram.c b/net/core/datagram.c
index 28cdb79df74d..ecbc0f471089 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -619,7 +619,7 @@ int __zerocopy_sg_from_iter(struct msghdr *msg, struct sock *sk,
 {
 	int frag;
 
-	if (msg && msg->sg_from_iter)
+	if (msg && msg->msg_ubuf && msg->sg_from_iter)
 		return msg->sg_from_iter(sk, skb, from, length);
 
 	frag = skb_shinfo(skb)->nr_frags;
-- 
2.37.0


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

* Re: [PATCH net-next] net: fix uninitialised msghdr->sg_from_iter
  2022-07-21 14:25 [PATCH net-next] net: fix uninitialised msghdr->sg_from_iter Pavel Begunkov
@ 2022-07-22 22:00 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-07-22 22:00 UTC (permalink / raw)
  To: Pavel Begunkov; +Cc: netdev, linux-kernel, davem, kuba, dsahern

Hello:

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

On Thu, 21 Jul 2022 15:25:46 +0100 you wrote:
> Because of how struct msghdr is usually initialised some fields and
> sg_from_iter in particular might be left out not initialised, so we
> can't safely use it in __zerocopy_sg_from_iter().
> 
> For now use the callback only when there is ->msg_ubuf set relying on
> the fact that they're used together and we properly zero ->msg_ubuf.
> 
> [...]

Here is the summary with links:
  - [net-next] net: fix uninitialised msghdr->sg_from_iter
    https://git.kernel.org/netdev/net-next/c/2829a267fca2

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] 2+ messages in thread

end of thread, other threads:[~2022-07-22 22:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-21 14:25 [PATCH net-next] net: fix uninitialised msghdr->sg_from_iter Pavel Begunkov
2022-07-22 22:00 ` patchwork-bot+netdevbpf

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