lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Sat, 3 Jul 2021 19:17:38 +0800
From:   kernel test robot <lkp@...el.com>
To:     Qinglang Miao <miaoqinglang@...wei.com>
Cc:     clang-built-linux@...glegroups.com, kbuild-all@...ts.01.org,
        linux-kernel@...r.kernel.org, Steve French <stfrench@...rosoft.com>
Subject: fs/cifs/connect.c:5117:16: warning: taking address of packed member
 'smb_buf_length' of class or structure 'smb_hdr' may result in an unaligned
 pointer value

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   4b820e167bf6f410ace479d8df5b15a574000e75
commit: 1a0e7f7c3c573a79bcd787d8a05e80651041b815 cifs: convert to use be32_add_cpu()
date:   11 months ago
config: mips-randconfig-r006-20210703 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project cb5de7c813f976dd458bd2a7f40702ba648bf650)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install mips cross compiling tool for clang build
        # apt-get install binutils-mips-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1a0e7f7c3c573a79bcd787d8a05e80651041b815
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 1a0e7f7c3c573a79bcd787d8a05e80651041b815
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>

All warnings (new ones prefixed by >>):

   arch/mips/include/asm/checksum.h:195:9: error: unsupported inline asm: input with type 'unsigned long' matching output with type '__wsum' (aka 'unsigned int')
           : "0" ((__force unsigned long)daddr),
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from fs/cifs/connect.c:45:
   In file included from include/net/ipv6.h:12:
   In file included from include/linux/ipv6.h:87:
   In file included from include/linux/icmpv6.h:13:
   include/linux/netdevice.h:565:11: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
           } while (cmpxchg(&n->state, val, new) != val);
                    ^
   arch/mips/include/asm/cmpxchg.h:194:7: note: expanded from macro 'cmpxchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
   In file included from fs/cifs/connect.c:45:
   In file included from include/net/ipv6.h:12:
   In file included from include/linux/ipv6.h:87:
   In file included from include/linux/icmpv6.h:13:
   include/linux/netdevice.h:565:11: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
   arch/mips/include/asm/cmpxchg.h:204:7: note: expanded from macro 'cmpxchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
   In file included from fs/cifs/connect.c:45:
   In file included from include/net/ipv6.h:12:
   In file included from include/linux/ipv6.h:88:
   In file included from include/linux/tcp.h:19:
   In file included from include/net/sock.h:61:
   include/linux/poll.h:142:27: warning: division by zero is undefined [-Wdivision-by-zero]
                   M(RDNORM) | M(RDBAND) | M(WRNORM) | M(WRBAND) |
                                           ^~~~~~~~~
   include/linux/poll.h:140:32: note: expanded from macro 'M'
   #define M(X) (__force __poll_t)__MAP(val, POLL##X, (__force __u16)EPOLL##X)
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/poll.h:126:51: note: expanded from macro '__MAP'
           (from < to ? (v & from) * (to/from) : (v & from) / (from/to))
                                                            ^ ~~~~~~~~~
   include/linux/poll.h:142:39: warning: division by zero is undefined [-Wdivision-by-zero]
                   M(RDNORM) | M(RDBAND) | M(WRNORM) | M(WRBAND) |
                                                       ^~~~~~~~~
   include/linux/poll.h:140:32: note: expanded from macro 'M'
   #define M(X) (__force __poll_t)__MAP(val, POLL##X, (__force __u16)EPOLL##X)
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/poll.h:126:51: note: expanded from macro '__MAP'
           (from < to ? (v & from) * (to/from) : (v & from) / (from/to))
                                                            ^ ~~~~~~~~~
   In file included from fs/cifs/connect.c:45:
   In file included from include/net/ipv6.h:12:
   In file included from include/linux/ipv6.h:88:
   In file included from include/linux/tcp.h:19:
   include/net/sock.h:1971:12: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
           old_dst = xchg((__force struct dst_entry **)&sk->sk_dst_cache, dst);
                     ^
   arch/mips/include/asm/cmpxchg.h:102:7: note: expanded from macro 'xchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
   In file included from fs/cifs/connect.c:45:
   In file included from include/net/ipv6.h:12:
   In file included from include/linux/ipv6.h:88:
   In file included from include/linux/tcp.h:19:
   include/net/sock.h:2219:8: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
           err = xchg(&sk->sk_err, 0);
                 ^
   arch/mips/include/asm/cmpxchg.h:102:7: note: expanded from macro 'xchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
   In file included from fs/cifs/connect.c:49:
   In file included from fs/cifs/cifsglob.h:32:
   fs/cifs/smb2pdu.h:28:10: error: 'cifsacl.h' file not found with <angled> include; use "quotes" instead
   #include <cifsacl.h>
            ^~~~~~~~~~~
            "cifsacl.h"
   fs/cifs/connect.c:1261:17: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
           task_to_wake = xchg(&server->tsk, NULL);
                          ^
   arch/mips/include/asm/cmpxchg.h:102:7: note: expanded from macro 'xchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
   fs/cifs/connect.c:2725:9: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
           task = xchg(&server->tsk, NULL);
                  ^
   arch/mips/include/asm/cmpxchg.h:102:7: note: expanded from macro 'xchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
>> fs/cifs/connect.c:5117:16: warning: taking address of packed member 'smb_buf_length' of class or structure 'smb_hdr' may result in an unaligned pointer value [-Waddress-of-packed-member]
           be32_add_cpu(&pSMB->hdr.smb_buf_length, count);
                         ^~~~~~~~~~~~~~~~~~~~~~~~
   21 warnings and 5 errors generated.
--
   In file included from include/linux/ethtool.h:18:
   In file included from include/uapi/linux/ethtool.h:19:
   In file included from include/linux/if_ether.h:19:
   In file included from include/linux/skbuff.h:17:
   In file included from include/linux/bvec.h:13:
   In file included from include/linux/mm.h:32:
   In file included from include/linux/pgtable.h:6:
   arch/mips/include/asm/pgtable.h:210:3: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
   arch/mips/include/asm/cmpxchg.h:220:2: note: expanded from macro 'cmpxchg64'
           cmpxchg((ptr), (o), (n));                                       \
           ^
   arch/mips/include/asm/cmpxchg.h:204:7: note: expanded from macro 'cmpxchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
   In file included from fs/cifs/sess.c:24:
   In file included from fs/cifs/cifspdu.h:25:
   In file included from include/net/sock.h:46:
   In file included from include/linux/netdevice.h:37:
   In file included from include/linux/ethtool.h:18:
   In file included from include/uapi/linux/ethtool.h:19:
   In file included from include/linux/if_ether.h:19:
   In file included from include/linux/skbuff.h:28:
   In file included from include/net/checksum.h:22:
   arch/mips/include/asm/checksum.h:195:9: error: unsupported inline asm: input with type 'unsigned long' matching output with type '__wsum' (aka 'unsigned int')
           : "0" ((__force unsigned long)daddr),
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from fs/cifs/sess.c:24:
   In file included from fs/cifs/cifspdu.h:25:
   In file included from include/net/sock.h:46:
   include/linux/netdevice.h:565:11: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
           } while (cmpxchg(&n->state, val, new) != val);
                    ^
   arch/mips/include/asm/cmpxchg.h:194:7: note: expanded from macro 'cmpxchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
   In file included from fs/cifs/sess.c:24:
   In file included from fs/cifs/cifspdu.h:25:
   In file included from include/net/sock.h:46:
   include/linux/netdevice.h:565:11: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
   arch/mips/include/asm/cmpxchg.h:204:7: note: expanded from macro 'cmpxchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
   In file included from fs/cifs/sess.c:24:
   In file included from fs/cifs/cifspdu.h:25:
   In file included from include/net/sock.h:61:
   include/linux/poll.h:142:27: warning: division by zero is undefined [-Wdivision-by-zero]
                   M(RDNORM) | M(RDBAND) | M(WRNORM) | M(WRBAND) |
                                           ^~~~~~~~~
   include/linux/poll.h:140:32: note: expanded from macro 'M'
   #define M(X) (__force __poll_t)__MAP(val, POLL##X, (__force __u16)EPOLL##X)
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/poll.h:126:51: note: expanded from macro '__MAP'
           (from < to ? (v & from) * (to/from) : (v & from) / (from/to))
                                                            ^ ~~~~~~~~~
   include/linux/poll.h:142:39: warning: division by zero is undefined [-Wdivision-by-zero]
                   M(RDNORM) | M(RDBAND) | M(WRNORM) | M(WRBAND) |
                                                       ^~~~~~~~~
   include/linux/poll.h:140:32: note: expanded from macro 'M'
   #define M(X) (__force __poll_t)__MAP(val, POLL##X, (__force __u16)EPOLL##X)
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/poll.h:126:51: note: expanded from macro '__MAP'
           (from < to ? (v & from) * (to/from) : (v & from) / (from/to))
                                                            ^ ~~~~~~~~~
   In file included from fs/cifs/sess.c:24:
   In file included from fs/cifs/cifspdu.h:25:
   include/net/sock.h:1971:12: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
           old_dst = xchg((__force struct dst_entry **)&sk->sk_dst_cache, dst);
                     ^
   arch/mips/include/asm/cmpxchg.h:102:7: note: expanded from macro 'xchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
   In file included from fs/cifs/sess.c:24:
   In file included from fs/cifs/cifspdu.h:25:
   include/net/sock.h:2219:8: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
           err = xchg(&sk->sk_err, 0);
                 ^
   arch/mips/include/asm/cmpxchg.h:102:7: note: expanded from macro 'xchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
   In file included from fs/cifs/sess.c:25:
   In file included from fs/cifs/cifsglob.h:32:
   fs/cifs/smb2pdu.h:28:10: error: 'cifsacl.h' file not found with <angled> include; use "quotes" instead
   #include <cifsacl.h>
            ^~~~~~~~~~~
            "cifsacl.h"
>> fs/cifs/sess.c:941:16: warning: taking address of packed member 'smb_buf_length' of class or structure 'smb_hdr' may result in an unaligned pointer value [-Waddress-of-packed-member]
           be32_add_cpu(&smb_buf->smb_buf_length, count);
                         ^~~~~~~~~~~~~~~~~~~~~~~
   19 warnings and 5 errors generated.


vim +5117 fs/cifs/connect.c

  5015	
  5016	/*
  5017	 * Issue a TREE_CONNECT request.
  5018	 */
  5019	int
  5020	CIFSTCon(const unsigned int xid, struct cifs_ses *ses,
  5021		 const char *tree, struct cifs_tcon *tcon,
  5022		 const struct nls_table *nls_codepage)
  5023	{
  5024		struct smb_hdr *smb_buffer;
  5025		struct smb_hdr *smb_buffer_response;
  5026		TCONX_REQ *pSMB;
  5027		TCONX_RSP *pSMBr;
  5028		unsigned char *bcc_ptr;
  5029		int rc = 0;
  5030		int length;
  5031		__u16 bytes_left, count;
  5032	
  5033		if (ses == NULL)
  5034			return -EIO;
  5035	
  5036		smb_buffer = cifs_buf_get();
  5037		if (smb_buffer == NULL)
  5038			return -ENOMEM;
  5039	
  5040		smb_buffer_response = smb_buffer;
  5041	
  5042		header_assemble(smb_buffer, SMB_COM_TREE_CONNECT_ANDX,
  5043				NULL /*no tid */ , 4 /*wct */ );
  5044	
  5045		smb_buffer->Mid = get_next_mid(ses->server);
  5046		smb_buffer->Uid = ses->Suid;
  5047		pSMB = (TCONX_REQ *) smb_buffer;
  5048		pSMBr = (TCONX_RSP *) smb_buffer_response;
  5049	
  5050		pSMB->AndXCommand = 0xFF;
  5051		pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO);
  5052		bcc_ptr = &pSMB->Password[0];
  5053		if (tcon->pipe || (ses->server->sec_mode & SECMODE_USER)) {
  5054			pSMB->PasswordLength = cpu_to_le16(1);	/* minimum */
  5055			*bcc_ptr = 0; /* password is null byte */
  5056			bcc_ptr++;              /* skip password */
  5057			/* already aligned so no need to do it below */
  5058		} else {
  5059			pSMB->PasswordLength = cpu_to_le16(CIFS_AUTH_RESP_SIZE);
  5060			/* BB FIXME add code to fail this if NTLMv2 or Kerberos
  5061			   specified as required (when that support is added to
  5062			   the vfs in the future) as only NTLM or the much
  5063			   weaker LANMAN (which we do not send by default) is accepted
  5064			   by Samba (not sure whether other servers allow
  5065			   NTLMv2 password here) */
  5066	#ifdef CONFIG_CIFS_WEAK_PW_HASH
  5067			if ((global_secflags & CIFSSEC_MAY_LANMAN) &&
  5068			    (ses->sectype == LANMAN))
  5069				calc_lanman_hash(tcon->password, ses->server->cryptkey,
  5070						 ses->server->sec_mode &
  5071						    SECMODE_PW_ENCRYPT ? true : false,
  5072						 bcc_ptr);
  5073			else
  5074	#endif /* CIFS_WEAK_PW_HASH */
  5075			rc = SMBNTencrypt(tcon->password, ses->server->cryptkey,
  5076						bcc_ptr, nls_codepage);
  5077			if (rc) {
  5078				cifs_dbg(FYI, "%s Can't generate NTLM rsp. Error: %d\n",
  5079					 __func__, rc);
  5080				cifs_buf_release(smb_buffer);
  5081				return rc;
  5082			}
  5083	
  5084			bcc_ptr += CIFS_AUTH_RESP_SIZE;
  5085			if (ses->capabilities & CAP_UNICODE) {
  5086				/* must align unicode strings */
  5087				*bcc_ptr = 0; /* null byte password */
  5088				bcc_ptr++;
  5089			}
  5090		}
  5091	
  5092		if (ses->server->sign)
  5093			smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
  5094	
  5095		if (ses->capabilities & CAP_STATUS32) {
  5096			smb_buffer->Flags2 |= SMBFLG2_ERR_STATUS;
  5097		}
  5098		if (ses->capabilities & CAP_DFS) {
  5099			smb_buffer->Flags2 |= SMBFLG2_DFS;
  5100		}
  5101		if (ses->capabilities & CAP_UNICODE) {
  5102			smb_buffer->Flags2 |= SMBFLG2_UNICODE;
  5103			length =
  5104			    cifs_strtoUTF16((__le16 *) bcc_ptr, tree,
  5105				6 /* max utf8 char length in bytes */ *
  5106				(/* server len*/ + 256 /* share len */), nls_codepage);
  5107			bcc_ptr += 2 * length;	/* convert num 16 bit words to bytes */
  5108			bcc_ptr += 2;	/* skip trailing null */
  5109		} else {		/* ASCII */
  5110			strcpy(bcc_ptr, tree);
  5111			bcc_ptr += strlen(tree) + 1;
  5112		}
  5113		strcpy(bcc_ptr, "?????");
  5114		bcc_ptr += strlen("?????");
  5115		bcc_ptr += 1;
  5116		count = bcc_ptr - &pSMB->Password[0];
> 5117		be32_add_cpu(&pSMB->hdr.smb_buf_length, count);
  5118		pSMB->ByteCount = cpu_to_le16(count);
  5119	
  5120		rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, &length,
  5121				 0);
  5122	
  5123		/* above now done in SendReceive */
  5124		if (rc == 0) {
  5125			bool is_unicode;
  5126	
  5127			tcon->tidStatus = CifsGood;
  5128			tcon->need_reconnect = false;
  5129			tcon->tid = smb_buffer_response->Tid;
  5130			bcc_ptr = pByteArea(smb_buffer_response);
  5131			bytes_left = get_bcc(smb_buffer_response);
  5132			length = strnlen(bcc_ptr, bytes_left - 2);
  5133			if (smb_buffer->Flags2 & SMBFLG2_UNICODE)
  5134				is_unicode = true;
  5135			else
  5136				is_unicode = false;
  5137	
  5138	
  5139			/* skip service field (NB: this field is always ASCII) */
  5140			if (length == 3) {
  5141				if ((bcc_ptr[0] == 'I') && (bcc_ptr[1] == 'P') &&
  5142				    (bcc_ptr[2] == 'C')) {
  5143					cifs_dbg(FYI, "IPC connection\n");
  5144					tcon->ipc = true;
  5145					tcon->pipe = true;
  5146				}
  5147			} else if (length == 2) {
  5148				if ((bcc_ptr[0] == 'A') && (bcc_ptr[1] == ':')) {
  5149					/* the most common case */
  5150					cifs_dbg(FYI, "disk share connection\n");
  5151				}
  5152			}
  5153			bcc_ptr += length + 1;
  5154			bytes_left -= (length + 1);
  5155			strlcpy(tcon->treeName, tree, sizeof(tcon->treeName));
  5156	
  5157			/* mostly informational -- no need to fail on error here */
  5158			kfree(tcon->nativeFileSystem);
  5159			tcon->nativeFileSystem = cifs_strndup_from_utf16(bcc_ptr,
  5160							      bytes_left, is_unicode,
  5161							      nls_codepage);
  5162	
  5163			cifs_dbg(FYI, "nativeFileSystem=%s\n", tcon->nativeFileSystem);
  5164	
  5165			if ((smb_buffer_response->WordCount == 3) ||
  5166				 (smb_buffer_response->WordCount == 7))
  5167				/* field is in same location */
  5168				tcon->Flags = le16_to_cpu(pSMBr->OptionalSupport);
  5169			else
  5170				tcon->Flags = 0;
  5171			cifs_dbg(FYI, "Tcon flags: 0x%x\n", tcon->Flags);
  5172		}
  5173	
  5174		cifs_buf_release(smb_buffer);
  5175		return rc;
  5176	}
  5177	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

Download attachment ".config.gz" of type "application/gzip" (28117 bytes)

Powered by blists - more mailing lists