ACK: [PATCH] UBUNTU: SAUCE: apparmor: Fix build error, make sk parameter const

Krzysztof Kozlowski krzysztof.kozlowski at canonical.com
Fri Mar 26 19:49:38 UTC 2021


On 26/03/2021 18:27, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
> 
> Make the sk parameter const to fix a build error with clang:
> 
> security/apparmor/net.c:143:35: error: passing 'const struct sock *' to
> parameter of type 'struct sock *' discards qualifiers
> [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
>                         audit_unix_sk_addr(ab, "addr", sa->u.net->sk);
>                                                        ^~~~~~~~~~~~~
> /home/ubuntu/hirsute/security/apparmor/net.c:98:24: note: passing argument
> to parameter 'sk' here
>                                struct sock *sk)
>                                             ^
> 
> Fixes: 2775e0786896 ("UBUNTU: SAUCE: apparmor: af_unix mediation")
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>  security/apparmor/net.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/security/apparmor/net.c b/security/apparmor/net.c
> index e2e759b21e44..f379aec0f7e6 100644
> --- a/security/apparmor/net.c
> +++ b/security/apparmor/net.c
> @@ -95,7 +95,7 @@ static void audit_unix_addr(struct audit_buffer *ab, const char *str,
>  }
>  
>  static void audit_unix_sk_addr(struct audit_buffer *ab, const char *str,
> -			       struct sock *sk)
> +			       const struct sock *sk)

Makes sense for the build warning/error but no difference for compiler
since the only purpose of unix_sk() is to drop the const :). It's also
weird that unix_sk() uses strict ordering of members instead of using
container_of().

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski at canonical.com>

>  {
>  	struct unix_sock *u = unix_sk(sk);
>  	if (u && u->addr)
> 


Best regards,
Krzysztof



More information about the kernel-team mailing list