Skip to contentSkip to conversation

apparmor: remove unused variable

PATCH In review Arnd Bergmann 4 participants 4 messages Jan 22, 2025 – Jan 24, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 apparmor: remove unused variable

From: Arnd Bergmann <[email protected]>

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")
---
 security/apparmor/file.c | 3 ---
 1 file changed, 3 deletions(-)
security/apparmor/file.c +0 -3
index 85f89814af1e..e3a858649942 100644
@@ -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;
Signature · 1 line
2.39.5
Acked-by Serge Hallyn on v1 1/1
#1 lore raw
Quoted 10 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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.

Quoted 2 lines
Fixes c05e705812d1 ("apparmor: add fine grained af_unix mediation")
Quoted 23 lines
---
 security/apparmor/file.c | 3 ---
 1 file changed, 3 deletions(-)
security/apparmor/file.c +0 -3
index 85f89814af1e..e3a858649942 100644
@@ -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;
Signature · 1 line
2.39.5
#2 lore raw
Quoted 10 lines · On Wed, Jan 22, 2025 at 08:03:34PM +0000, [email protected] wrote:
Quoted 9 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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;

Quoted 6 lines
Quoted 1 line

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

maintainer
#3 lore raw
In reply to Arnd Bergmann
Quoted 5 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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

Quoted 8 lines

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")

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

Quoted 20 lines
---
  security/apparmor/file.c | 3 ---
  1 file changed, 3 deletions(-)
security/apparmor/file.c +0 -3
index 85f89814af1e..e3a858649942 100644
@@ -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;