summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKuniyuki Iwashima <kuniyu@amazon.com>2025-05-21 18:27:08 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-06-04 15:40:23 +0300
commit6b7a036eaa3e0a79f2442f4c5affbc4fa1145845 (patch)
tree8c28083c890bc7f46107539424213244ee444b60 /include
parent1002e86c46968e5567174e5f14292d351fec2e90 (diff)
downloadlinux-6b7a036eaa3e0a79f2442f4c5affbc4fa1145845.tar.xz
af_unix: Allocate struct unix_edge for each inflight AF_UNIX fd.
commit 29b64e354029cfcf1eea4d91b146c7b769305930 upstream. As with the previous patch, we preallocate to skb's scm_fp_list an array of struct unix_edge in the number of inflight AF_UNIX fds. There we just preallocate memory and do not use immediately because sendmsg() could fail after this point. The actual use will be in the next patch. When we queue skb with inflight edges, we will set the inflight socket's unix_sock as unix_edge->predecessor and the receiver's unix_sock as successor, and then we will link the edge to the inflight socket's unix_vertex.edges. Note that we set NULL to cloned scm_fp_list.edges in scm_fp_dup() so that MSG_PEEK does not change the shape of the directed graph. Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Acked-by: Paolo Abeni <pabeni@redhat.com> Link: https://lore.kernel.org/r/20240325202425.60930-3-kuniyu@amazon.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Lee Jones <lee@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/net/af_unix.h6
-rw-r--r--include/net/scm.h5
2 files changed, 11 insertions, 0 deletions
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index b41aff1ac688..279087595966 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -33,6 +33,12 @@ struct unix_vertex {
unsigned long out_degree;
};
+struct unix_edge {
+ struct unix_sock *predecessor;
+ struct unix_sock *successor;
+ struct list_head vertex_entry;
+};
+
struct sock *unix_peer_get(struct sock *sk);
#define UNIX_HASH_MOD (256 - 1)
diff --git a/include/net/scm.h b/include/net/scm.h
index 4183495d1981..19d7d802ed6c 100644
--- a/include/net/scm.h
+++ b/include/net/scm.h
@@ -21,12 +21,17 @@ struct scm_creds {
kgid_t gid;
};
+#ifdef CONFIG_UNIX
+struct unix_edge;
+#endif
+
struct scm_fp_list {
short count;
short count_unix;
short max;
#ifdef CONFIG_UNIX
struct list_head vertices;
+ struct unix_edge *edges;
#endif
struct user_struct *user;
struct file *fp[SCM_MAX_FD];