]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
af_unix: preserve const qualifier in unix_sk()
authorEric Dumazet <edumazet@google.com>
Fri, 17 Mar 2023 15:55:35 +0000 (15:55 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 18 Mar 2023 12:23:33 +0000 (12:23 +0000)
We can change unix_sk() to propagate its argument const qualifier,
thanks to container_of_const().

We need to change dump_common_audit_data() 'struct unix_sock *u'
local var to get a const attribute.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/af_unix.h
security/lsm_audit.c

index 45ebde587138e59f8331d358420d3fca79d9ee66..824c258143a3ab360b870fda38ba684b70068eee 100644 (file)
@@ -74,10 +74,7 @@ struct unix_sock {
 #endif
 };
 
-static inline struct unix_sock *unix_sk(const struct sock *sk)
-{
-       return (struct unix_sock *)sk;
-}
+#define unix_sk(ptr) container_of_const(ptr, struct unix_sock, sk)
 
 #define peer_wait peer_wq.wait
 
index 00d3bdd386e294ecd562bfa8ce502bf179ad32d9..368e77ca43c4a5d5f71a7e9a0a1e58a006796aa6 100644 (file)
@@ -310,7 +310,7 @@ static void dump_common_audit_data(struct audit_buffer *ab,
        case LSM_AUDIT_DATA_NET:
                if (a->u.net->sk) {
                        const struct sock *sk = a->u.net->sk;
-                       struct unix_sock *u;
+                       const struct unix_sock *u;
                        struct unix_address *addr;
                        int len = 0;
                        char *p = NULL;