From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753236AbbJFUxB (ORCPT ); Tue, 6 Oct 2015 16:53:01 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:57937 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752760AbbJFUxA (ORCPT ); Tue, 6 Oct 2015 16:53:00 -0400 From: Arnd Bergmann To: netdev@vger.kernel.org Cc: Aaron Conole , Eric Dumazet , David Miller , James Morris , linux-security-module@vger.kernel.org, "Serge E. Hallyn" , linux-kernel@vger.kernel.org Subject: [PATCH] af_unix: introduce unix_sk_const helper Date: Tue, 06 Oct 2015 22:52:46 +0200 Message-ID: <10735490.HC94hyceBX@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:+4iZ0+uzSJHVh7XfvpwT+LMCC0Xr1WBAAD7XfSv4yQrqCKgbYUM kinxkVyOyzIHN8BZNwBsgw63E2Za51GpVFSevKqUIz5osW5mnpDSbtTgJTCGiXDZ7VRwq80 4b78utoKnCRQbOhUeaWNmuK1buZI1t4nPU51bqO1E06R/dGOgB5ZNRf3/ec6PSES+XTeaDm aLoRziZmUnj/vR0Hq8d8A== X-UI-Out-Filterresults: notjunk:1;V01:K0:g8RuqnSEx5A=:W1P4K590PQK+hJ2D8NDBpU PEvF9GVkE/K8pXVMzEtNuU41EEsef3diaigwyPuT48JQyvu1p4BjUZ83fjfcTRPjtInc/jYKM MPL5+9qJQJ0VRqlRIDlP0ShRs7MRsbPv2qwQkvhg5bMi2iq9md3HlyD6o4Y1zTyfwm6xO6SqT JYuZQ9OKImz4oKSZ/58+e+FCvFBcOwBo3Te7+vkkbWf9rdym8mCO3uIjSy2HciERxJ4MIlt7D WIc+YVGuMQE0zIlCqyTkx6kN8Zfsf8fTE3VdF3INNcW4GJRE3R/T2wxqScQ9ogsb3U98vZkrF jtocwZ+PQESF9Xgge62H+UZsvgdzMTx3PvJ1gZny6bJsxAMhJ494h0lUS9rjrj68XOURJL+Li vaE4qlIDuwC4bMWtPqkmni2eS0nTkE3W9kZ15u/Am6xupXEOzlJaUIaQM/C7yJ20iYofC/BWl 9iNbsMc7uankVc1OSdqXe8fo80Szn8MXQxAob5Y1xClXzMyjWRsSdaG2rgoQf3PY11qlnLYDt hb0HGwCop01bYuZfwR22MW9SyrjDEapBiWEDzQaGNOpdSl3s2hjAT82x1pWlkfIfOW1pvwpTK 5t5mziGiXASG8q9oDRY7nsxgXQfSA+Kp2s8lOsG1Amby458a+pYYKlEc9PZxpru/n7Ien1Jfg SaycKgrPhPxyxDUcL9PNTvsMrdAJ28kEYKHGIJRQg/jv/88gXl14WK1yssWe/2emOuuKvIABj nupZ1wlUXakElqKt Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 124613012db1 ("af_unix: Convert the unix_sk macro to an inline function for type safety") was recently added to catch incorrect uses of the unix_sk helper using compiler warnings. It has now caught one such case in lsm_audit.c. The code is technically correct, but as it converts a const pointer to a non-const pointer, the annotation got lost, which gcc now warns about. This patch avoids the warning by introducing an additional helper that has const input and output, which makes the lsm_audit code build cleanly again. Signed-off-by: Arnd Bergmann --- I'm not entirely happy with this workaround myself, but could not come up with a better one. diff --git a/include/net/af_unix.h b/include/net/af_unix.h index cb1b9bbda332..1871b6436ee9 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h @@ -69,6 +69,11 @@ static inline struct unix_sock *unix_sk(struct sock *sk) return (struct unix_sock *)sk; } +static inline const struct unix_sock *unix_sk_const(const struct sock *sk) +{ + return (const struct unix_sock *)sk; +} + #define peer_wait peer_wq.wait long unix_inq_len(struct sock *sk); diff --git a/security/lsm_audit.c b/security/lsm_audit.c index 2deace208db2..cb07f1318a27 100644 --- a/security/lsm_audit.c +++ b/security/lsm_audit.c @@ -307,7 +307,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; int len = 0; char *p = NULL; @@ -337,7 +337,7 @@ static void dump_common_audit_data(struct audit_buffer *ab, } #endif case AF_UNIX: - u = unix_sk(sk); + u = unix_sk_const(sk); if (u->path.dentry) { audit_log_d_path(ab, " path=", &u->path); break;