Skip to contentSkip to conversation

fs/smb/client/cifsacl.c:839:26: warning: variable 'end_of_dacl' set but not used

PATCH Applied kernel test robot 3 participants 3 messages Apr 21

Subsystems (2)
lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   bee6ea30c48788e18348309f891ed8afbf7702ac
commit: 149822e5541c7e9c1b4445ef94b6f7c0401ce88e [14127/14297] smb: client: validate the whole DACL before rewriting it in cifsacl
config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20260422/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260422/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

fs/smb/client/cifsacl.c: In function 'parse_dacl':

>> fs/smb/client/cifsacl.c:839:26: warning: variable 'end_of_dacl' set but not used [-Wunused-but-set-variable]
     839 |         char *acl_base, *end_of_dacl;
         |                          ^~~~~~~~~~~

vim +/end_of_dacl +839 fs/smb/client/cifsacl.c

831
832 static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl,
833 struct smb_sid *pownersid, struct smb_sid *pgrpsid,
834 struct cifs_fattr *fattr, bool mode_from_special_sid)
835 {
836 int i;
837 u16 num_aces = 0;
838 int acl_size;

 > 839		char *acl_base, *end_of_dacl;

840 struct smb_ace **ppace;
841
842 /* BB need to add parm so we can store the SID BB */
843
844 if (!pdacl) {
845 /* no DACL in the security descriptor, set
846 all the permissions for user/group/other */
847 fattr->cf_mode |= 0777;
848 return;
849 }
850
851 if (validate_dacl(pdacl, end_of_acl))
852 return;
853
854 cifs_dbg(NOISY, "DACL revision %d size %d num aces %d\n",
855 le16_to_cpu(pdacl->revision), le16_to_cpu(pdacl->size),
856 le16_to_cpu(pdacl->num_aces));
857
858 /* reset rwx permissions for user/group/other.
859 Also, if num_aces is 0 i.e. DACL has no ACEs,
860 user/group/other have no permissions */
861 fattr->cf_mode &= ~(0777);
862
863 end_of_dacl = (char *)pdacl + le16_to_cpu(pdacl->size);
864 acl_base = (char *)pdacl;
865 acl_size = sizeof(struct smb_acl);
866
867 num_aces = le16_to_cpu(pdacl->num_aces);
868 if (num_aces > 0) {
869 umode_t denied_mode = 0;
870
871 ppace = kmalloc_objs(struct smb_ace *, num_aces);
872 if (!ppace)
873 return;
874
875 for (i = 0; i < num_aces; ++i) {
876 ppace[i] = (struct smb_ace *) (acl_base + acl_size);
877

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#1 lore raw

PATCH 1/1 smb: client: scope end_of_dacl to CIFS_DEBUG2 use in parse_dacl

After validate_dacl() was factored out in commit 149822e5541c, the local end_of_dacl in parse_dacl() is only read by the dump_ace() call under #ifdef CONFIG_CIFS_DEBUG2. With CIFS_DEBUG2 off the variable is assigned but never used, which gcc -W=1 flags as -Wunused-but-set-variable.

Remove the local and compute the end-of-dacl pointer inline at the single call site inside the existing CIFS_DEBUG2 guard. No functional change: when CIFS_DEBUG2 is enabled the argument value is identical to what the removed local carried; when CIFS_DEBUG2 is disabled the code was already dead.

Fixes 149822e5541c ("smb: client: validate the whole DACL before rewriting it in cifsacl")
Assisted-by Claude:claude-opus-4-7
---
 fs/smb/client/cifsacl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/smb/client/cifsacl.c +3 -3
index 4ec204d2c774..ec5d47779304 100644
@@ -836,7 +836,7 @@ static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl,
 	int i;
 	u16 num_aces = 0;
 	int acl_size;
-	char *acl_base, *end_of_dacl;
+	char *acl_base;
 	struct smb_ace **ppace;
 
 	/* BB need to add parm so we can store the SID BB */
@@ -860,7 +860,6 @@ static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl,
 	   user/group/other have no permissions */
 	fattr->cf_mode &= ~(0777);
 
-	end_of_dacl = (char *)pdacl + le16_to_cpu(pdacl->size);
 	acl_base = (char *)pdacl;
 	acl_size = sizeof(struct smb_acl);
 
@@ -876,7 +875,8 @@ static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl,
 			ppace[i] = (struct smb_ace *) (acl_base + acl_size);
 
 #ifdef CONFIG_CIFS_DEBUG2
-			dump_ace(ppace[i], end_of_dacl);
+			dump_ace(ppace[i],
+				 (char *)pdacl + le16_to_cpu(pdacl->size));
 #endif
 			if (mode_from_special_sid &&
 			    ppace[i]->sid.num_subauth >= 3 &&
Signature · 1 line
2.53.0
Applied
#2 lore raw

Re: [PATCH] smb: client: scope end_of_dacl to CIFS_DEBUG2 use in parse_dacl

merged into cifs-2.6.git for-next

Quoted 57 lines · Michael Bommarito

After validate_dacl() was factored out in commit 149822e5541c, the local end_of_dacl in parse_dacl() is only read by the dump_ace() call under #ifdef CONFIG_CIFS_DEBUG2. With CIFS_DEBUG2 off the variable is assigned but never used, which gcc -W=1 flags as -Wunused-but-set-variable.

Remove the local and compute the end-of-dacl pointer inline at the single call site inside the existing CIFS_DEBUG2 guard. No functional change: when CIFS_DEBUG2 is enabled the argument value is identical to what the removed local carried; when CIFS_DEBUG2 is disabled the code was already dead.

Fixes 149822e5541c ("smb: client: validate the whole DACL before rewriting it in cifsacl")
Assisted-by Claude:claude-opus-4-7
---
 fs/smb/client/cifsacl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/smb/client/cifsacl.c +3 -4
index 4ec204d2c774..ec5d47779304 100644
@@ -836,7 +836,7 @@ static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl,
        int i;
        u16 num_aces = 0;
        int acl_size;
-       char *acl_base, *end_of_dacl;
+       char *acl_base;
        struct smb_ace **ppace;
 
        /* BB need to add parm so we can store the SID BB */
@@ -860,7 +860,6 @@ static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl,
           user/group/other have no permissions */
        fattr->cf_mode &= ~(0777);
 
-       end_of_dacl = (char *)pdacl + le16_to_cpu(pdacl->size);
        acl_base = (char *)pdacl;
        acl_size = sizeof(struct smb_acl);
 
@@ -876,7 +875,8 @@ static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl,
                        ppace[i] = (struct smb_ace *) (acl_base + acl_size);
 
 #ifdef CONFIG_CIFS_DEBUG2
-                       dump_ace(ppace[i], end_of_dacl);
+                       dump_ace(ppace[i],
+                                (char *)pdacl + le16_to_cpu(pdacl->size));
 #endif
                        if (mode_from_special_sid &&
                            ppace[i]->sid.num_subauth >= 3 &&
--

2.53.0

Signature · 3 lines
Thanks,

Steve