git: 59ce044a7856 - main - sockets: on shutdown(2) do sorflush() only in case of generic sockbuf
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 09 Jan 2024 01:21:06 UTC
The branch main has been updated by glebius:
URL: https://cgit.FreeBSD.org/src/commit/?id=59ce044a7856b16803f7eb0aa5c54cfe6e13cff7
commit 59ce044a7856b16803f7eb0aa5c54cfe6e13cff7
Author: Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2024-01-09 01:20:31 +0000
Commit: Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2024-01-09 01:20:31 +0000
sockets: on shutdown(2) do sorflush() only in case of generic sockbuf
This is a quick plug to fix panic with Netlink which has protocol specific
buffers. Note that PF_UNIX/SOCK_DGRAM, which also has its own buffers,
avoids the panic due to being SOCK_DGRAM. A correct but more complicated
fix that needs to be done is to merge pr_shutdown, pr_flush and dom_dispose
into one protocol method that may call sorflush for generic sockets or do
their own stuff for protocol which has own buffers.
Reviewed by: tuexen
Differential Revision: https://reviews.freebsd.org/D43367
Reported-by: syzbot+a58e1615881c01a51653@syzkaller.appspotmail.com
---
sys/kern/uipc_socket.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index efa349d140ff..3409a7085df6 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -3007,7 +3007,7 @@ soshutdown(struct socket *so, int how)
pr = so->so_proto;
if (pr->pr_flush != NULL)
pr->pr_flush(so, how);
- if (how != SHUT_WR)
+ if (how != SHUT_WR && !(pr->pr_flags & PR_SOCKBUF))
sorflush(so);
if (how != SHUT_RD) {
error = pr->pr_shutdown(so);