Thread (2 messages) 2 messages, 2 authors, 2025-01-24

Re: [PATCH] apparmor: Remove unused variable 'sock' in __file_sock_perm()

From: John Johansen <john.johansen@canonical.com>
Date: 2025-01-24 22:02:31
Also in: linux-patches

On 1/20/25 05:21, Nathan Chancellor wrote:
When CONFIG_SECURITY_APPARMOR_DEBUG_ASSERTS is disabled, there is a
warning that sock is unused:

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

sock was moved into aa_sock_file_perm(), where the same check is
present, so remove sock and the assertion from __file_sock_perm() to fix
the warning.

Fixes: c05e705812d1 ("apparmor: add fine grained af_unix mediation")
Reported-by: kernel test robot <redacted>
Closes: https://lore.kernel.org/oe-kbuild-all/202501190757.myuLxLyL-lkp@intel.com/ (local)
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
yep, thanks
Acked-by: John Johansen <john.johansen@canonical.com>

I have pulled this into my tree

quoted hunk ↗ jump to hunk
---
  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;
---
base-commit: e6b087676954e36a7b1ed51249362bb499f8c1c2
change-id: 20250120-apparmor-fix-unused-sock-__file_sock_perm-0e4627bcefb7

Best regards,
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help