@@ -1186,6 +1186,10 @@ static void unix_connect_peers(struct aa_sk_ctx *sk_ctx,
1186
1186
* @peer_sk: sk that is accepting the connection
1187
1187
* @newsk: new sk created for this connection
1188
1188
* peer is locked when this hook is called
1189
+ *
1190
+ * Return:
1191
+ * 0 if connection is permitted
1192
+ * error code on denial or failure
1189
1193
*/
1190
1194
static int apparmor_unix_stream_connect (struct sock * sk , struct sock * peer_sk ,
1191
1195
struct sock * newsk )
@@ -1221,8 +1225,16 @@ static int apparmor_unix_stream_connect(struct sock *sk, struct sock *peer_sk,
1221
1225
* @sock: socket sending the message
1222
1226
* @peer: socket message is being send to
1223
1227
*
1228
+ * Performs bidirectional permission checks for Unix domain socket communication:
1229
+ * 1. Verifies sender has AA_MAY_SEND to target socket
1230
+ * 2. Verifies receiver has AA_MAY_RECEIVE from source socket
1231
+ *
1224
1232
* sock and peer are locked when this hook is called
1225
1233
* called by: dgram_connect peer setup but path not copied to newsk
1234
+ *
1235
+ * Return:
1236
+ * 0 if transmission is permitted
1237
+ * error code on denial or failure
1226
1238
*/
1227
1239
static int apparmor_unix_may_send (struct socket * sock , struct socket * peer )
1228
1240
{
@@ -1339,9 +1351,17 @@ static int apparmor_socket_socketpair(struct socket *socka,
1339
1351
1340
1352
/**
1341
1353
* apparmor_socket_bind - check perms before bind addr to socket
1342
- * @sock: socket to bind the address to
1343
- * @address: address that is being bound
1354
+ * @sock: socket to bind the address to (must be non-NULL)
1355
+ * @address: address that is being bound (must be non-NULL)
1344
1356
* @addrlen: length of @address
1357
+ *
1358
+ * Performs security checks before allowing a socket to bind to an address.
1359
+ * Handles Unix domain sockets specially through aa_unix_bind_perm().
1360
+ * For other socket families, uses generic permission check via aa_sk_perm().
1361
+ *
1362
+ * Return:
1363
+ * 0 if binding is permitted
1364
+ * error code on denial or invalid parameters
1345
1365
*/
1346
1366
static int apparmor_socket_bind (struct socket * sock ,
1347
1367
struct sockaddr * address , int addrlen )
0 commit comments