linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] apparmor: remove unused variable
@ 2025-01-22  6:55 Arnd Bergmann
  2025-01-22 20:03 ` sergeh
  2025-01-24 23:46 ` John Johansen
  0 siblings, 2 replies; 4+ messages in thread
From: Arnd Bergmann @ 2025-01-22  6:55 UTC (permalink / raw)
  To: John Johansen, Paul Moore, James Morris, Serge E. Hallyn
  Cc: Arnd Bergmann, Colin Ian King, apparmor, linux-security-module,
	linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

The local 'sock' variable has become unused after a change to the
aa_sock_file_perm() calling conventions:

security/apparmor/file.c: In function '__file_sock_perm':
security/apparmor/file.c:544:24: error: unused variable 'sock' [-Werror=unused-variable]
  544 |         struct socket *sock = (struct socket *) file->private_data;

Remove it here.

Fixes: c05e705812d1 ("apparmor: add fine grained af_unix mediation")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 security/apparmor/file.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/security/apparmor/file.c b/security/apparmor/file.c
index 85f89814af1e..e3a858649942 100644
--- a/security/apparmor/file.c
+++ b/security/apparmor/file.c
@@ -541,11 +541,8 @@ static int __file_sock_perm(const char *op, const struct cred *subj_cred,
 			    struct aa_label *flabel, struct file *file,
 			    u32 request, u32 denied)
 {
-	struct socket *sock = (struct socket *) file->private_data;
 	int error;
 
-	AA_BUG(!sock);
-
 	/* revalidation due to label out of date. No revocation at this time */
 	if (!denied && aa_label_is_subset(flabel, label))
 		return 0;
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] apparmor: remove unused variable
  2025-01-22  6:55 [PATCH] apparmor: remove unused variable Arnd Bergmann
@ 2025-01-22 20:03 ` sergeh
  2025-01-24 21:02   ` Guenter Roeck
  2025-01-24 23:46 ` John Johansen
  1 sibling, 1 reply; 4+ messages in thread
From: sergeh @ 2025-01-22 20:03 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: John Johansen, Paul Moore, James Morris, Serge E. Hallyn,
	Arnd Bergmann, Colin Ian King, apparmor, linux-security-module,
	linux-kernel

On Wed, Jan 22, 2025 at 07:55:35AM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The local 'sock' variable has become unused after a change to the
> aa_sock_file_perm() calling conventions:
> 
> security/apparmor/file.c: In function '__file_sock_perm':
> security/apparmor/file.c:544:24: error: unused variable 'sock' [-Werror=unused-variable]
>   544 |         struct socket *sock = (struct socket *) file->private_data;
> 
> Remove it here.

That's interesting.  The aa_sock_file_perm() further in will
still trip the AA_BUG(!sock) if there's some shenanigans going
on so no big loss in dropping the AA_BUG.

> Fixes: c05e705812d1 ("apparmor: add fine grained af_unix mediation")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Serge Hallyn <serge@hallyn.com>

> ---
>  security/apparmor/file.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/security/apparmor/file.c b/security/apparmor/file.c
> index 85f89814af1e..e3a858649942 100644
> --- a/security/apparmor/file.c
> +++ b/security/apparmor/file.c
> @@ -541,11 +541,8 @@ static int __file_sock_perm(const char *op, const struct cred *subj_cred,
>  			    struct aa_label *flabel, struct file *file,
>  			    u32 request, u32 denied)
>  {
> -	struct socket *sock = (struct socket *) file->private_data;
>  	int error;
>  
> -	AA_BUG(!sock);
> -
>  	/* revalidation due to label out of date. No revocation at this time */
>  	if (!denied && aa_label_is_subset(flabel, label))
>  		return 0;
> -- 
> 2.39.5
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] apparmor: remove unused variable
  2025-01-22 20:03 ` sergeh
@ 2025-01-24 21:02   ` Guenter Roeck
  0 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2025-01-24 21:02 UTC (permalink / raw)
  To: sergeh
  Cc: Arnd Bergmann, John Johansen, Paul Moore, James Morris,
	Serge E. Hallyn, Arnd Bergmann, Colin Ian King, apparmor,
	linux-security-module, linux-kernel

On Wed, Jan 22, 2025 at 08:03:34PM +0000, sergeh@kernel.org wrote:
> On Wed, Jan 22, 2025 at 07:55:35AM +0100, Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd@arndb.de>
> > 
> > The local 'sock' variable has become unused after a change to the
> > aa_sock_file_perm() calling conventions:
> > 
> > security/apparmor/file.c: In function '__file_sock_perm':
> > security/apparmor/file.c:544:24: error: unused variable 'sock' [-Werror=unused-variable]
> >   544 |         struct socket *sock = (struct socket *) file->private_data;
> > 
> > Remove it here.
> 
> That's interesting.  The aa_sock_file_perm() further in will
> still trip the AA_BUG(!sock) if there's some shenanigans going
> on so no big loss in dropping the AA_BUG.
> 

AA_BUG(X, args) extends to
	AA_BUG_FMT((X), "" args);
which is
	#define AA_BUG_FMT(X, fmt, args...) no_printk(fmt, ##args)

if CONFIG_SECURITY_APPARMOR_DEBUG_ASSERTS=n. That means the first
parameter is dropped and sock is indeed unused in that case.

Guenter

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] apparmor: remove unused variable
  2025-01-22  6:55 [PATCH] apparmor: remove unused variable Arnd Bergmann
  2025-01-22 20:03 ` sergeh
@ 2025-01-24 23:46 ` John Johansen
  1 sibling, 0 replies; 4+ messages in thread
From: John Johansen @ 2025-01-24 23:46 UTC (permalink / raw)
  To: Arnd Bergmann, Paul Moore, James Morris, Serge E. Hallyn
  Cc: Arnd Bergmann, Colin Ian King, apparmor, linux-security-module,
	linux-kernel

On 1/21/25 22:55, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The local 'sock' variable has become unused after a change to the
> aa_sock_file_perm() calling conventions:
> 
> security/apparmor/file.c: In function '__file_sock_perm':
> security/apparmor/file.c:544:24: error: unused variable 'sock' [-Werror=unused-variable]
>    544 |         struct socket *sock = (struct socket *) file->private_data;
> 
> Remove it here.
> 
> Fixes: c05e705812d1 ("apparmor: add fine grained af_unix mediation")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

yeah, unfortunately Nathan beat you by a few hours with
   [PATCH] apparmor: remove unused variable

and since I am walking the backlog in time order I pulled his version of the patch.

All the same thanks for taking the time to fix this, it is much appreciated

john

> ---
>   security/apparmor/file.c | 3 ---
>   1 file changed, 3 deletions(-)
> 
> diff --git a/security/apparmor/file.c b/security/apparmor/file.c
> index 85f89814af1e..e3a858649942 100644
> --- a/security/apparmor/file.c
> +++ b/security/apparmor/file.c
> @@ -541,11 +541,8 @@ static int __file_sock_perm(const char *op, const struct cred *subj_cred,
>   			    struct aa_label *flabel, struct file *file,
>   			    u32 request, u32 denied)
>   {
> -	struct socket *sock = (struct socket *) file->private_data;
>   	int error;
>   
> -	AA_BUG(!sock);
> -
>   	/* revalidation due to label out of date. No revocation at this time */
>   	if (!denied && aa_label_is_subset(flabel, label))
>   		return 0;


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-24 23:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-22  6:55 [PATCH] apparmor: remove unused variable Arnd Bergmann
2025-01-22 20:03 ` sergeh
2025-01-24 21:02   ` Guenter Roeck
2025-01-24 23:46 ` John Johansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).