Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144407470
D46755.id143651.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D46755.id143651.diff
View Options
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -153,6 +153,7 @@
#include <net/vnet.h>
#include <security/mac/mac_framework.h>
+#include <security/mac/mac_internal.h>
#include <vm/uma.h>
@@ -1485,6 +1486,10 @@
sbrcv_timeo = so->so_rcv.sb_timeo;
sbsnd_timeo = so->so_snd.sb_timeo;
+#ifdef MAC
+ mac_socketpeer_label_free(so->so_peerlabel);
+#endif
+
if (!(so->so_proto->pr_flags & PR_SOCKBUF)) {
sbdestroy(so, SO_SND);
sbdestroy(so, SO_RCV);
diff --git a/sys/security/mac/mac_internal.h b/sys/security/mac/mac_internal.h
--- a/sys/security/mac/mac_internal.h
+++ b/sys/security/mac/mac_internal.h
@@ -242,6 +242,7 @@
void mac_pipe_label_free(struct label *label);
struct label *mac_socket_label_alloc(int flag);
void mac_socket_label_free(struct label *label);
+void mac_socketpeer_label_free(struct label *label);
struct label *mac_vnode_label_alloc(void);
void mac_vnode_label_free(struct label *label);
diff --git a/sys/security/mac/mac_socket.c b/sys/security/mac/mac_socket.c
--- a/sys/security/mac/mac_socket.c
+++ b/sys/security/mac/mac_socket.c
@@ -170,7 +170,7 @@
mac_labelzone_free(label);
}
-static void
+void
mac_socketpeer_label_free(struct label *label)
{
@@ -185,8 +185,10 @@
if (so->so_label != NULL) {
mac_socket_label_free(so->so_label);
so->so_label = NULL;
- mac_socketpeer_label_free(so->so_peerlabel);
- so->so_peerlabel = NULL;
+ if (!SOLISTENING(so)) {
+ mac_socketpeer_label_free(so->so_peerlabel);
+ so->so_peerlabel = NULL;
+ }
}
}
@@ -579,10 +581,15 @@
buffer = malloc(mac->m_buflen, M_MACTEMP, M_WAITOK | M_ZERO);
intlabel = mac_socket_label_alloc(M_WAITOK);
SOCK_LOCK(so);
- mac_socket_copy_label(so->so_label, intlabel);
+ if (SOLISTENING(so))
+ error = EINVAL;
+ else
+ mac_socket_copy_label(so->so_label, intlabel);
SOCK_UNLOCK(so);
- error = mac_socket_externalize_label(intlabel, elements, buffer,
- mac->m_buflen);
+ if (error == 0) {
+ error = mac_socket_externalize_label(intlabel, elements, buffer,
+ mac->m_buflen);
+ }
mac_socket_label_free(intlabel);
if (error == 0)
error = copyout(buffer, mac->m_string, strlen(buffer)+1);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Feb 9, 7:05 AM (34 m, 40 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28550757
Default Alt Text
D46755.id143651.diff (2 KB)
Attached To
Mode
D46755: MAC: improve handling of listening sockets
Attached
Detach File
Event Timeline
Log In to Comment