Message ID | 20210813195644.937810-3-lsahlber@redhat.com |
---|---|
State | New |
Headers | show |
Series | [1/3] cifs: only compile in smb1ops.c if we configure CIFS_ALLOW_INSECURE_LEGACY | expand |
Hi Ronnie, Thank you for the patch! Yet something to improve: [auto build test ERROR on cifs/for-next] [also build test ERROR on v5.14-rc5 next-20210813] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Ronnie-Sahlberg/cifs-only-compile-in-smb1ops-c-if-we-configure-CIFS_ALLOW_INSECURE_LEGACY/20210814-045731 base: git://git.samba.org/sfrench/cifs-2.6.git for-next config: hexagon-randconfig-r041-20210814 (attached as .config) compiler: clang version 12.0.0 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 # https://github.com/0day-ci/linux/commit/2a89ec2d759f8c3c9035498c5ef1bf66a8f8b07b git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Ronnie-Sahlberg/cifs-only-compile-in-smb1ops-c-if-we-configure-CIFS_ALLOW_INSECURE_LEGACY/20210814-045731 git checkout 2a89ec2d759f8c3c9035498c5ef1bf66a8f8b07b # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=hexagon If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): >> fs/cifs/smb1ops.c:51:26: error: implicitly declaring library function 'toupper' with type 'int (int)' [-Werror,-Wimplicit-function-declaration] password_with_pad[i] = toupper(password_with_pad[i]); ^ fs/cifs/smb1ops.c:51:26: note: include the header <ctype.h> or explicitly provide a declaration for 'toupper' 1 error generated. vim +51 fs/cifs/smb1ops.c 16 17 #ifdef CONFIG_CIFS_WEAK_PW_HASH 18 int calc_lanman_hash(const char *password, const char *cryptkey, bool encrypt, 19 char *lnm_session_key) 20 { 21 int i, len; 22 int rc; 23 char password_with_pad[CIFS_ENCPWD_SIZE] = {0}; 24 25 if (password) { 26 for (len = 0; len < CIFS_ENCPWD_SIZE; len++) 27 if (!password[len]) 28 break; 29 30 memcpy(password_with_pad, password, len); 31 } 32 33 if (!encrypt && global_secflags & CIFSSEC_MAY_PLNTXT) { 34 memcpy(lnm_session_key, password_with_pad, 35 CIFS_ENCPWD_SIZE); 36 return 0; 37 } 38 39 /* calculate old style session key */ 40 /* calling toupper is less broken than repeatedly 41 calling nls_toupper would be since that will never 42 work for UTF8, but neither handles multibyte code pages 43 but the only alternative would be converting to UCS-16 (Unicode) 44 (using a routine something like UniStrupr) then 45 uppercasing and then converting back from Unicode - which 46 would only worth doing it if we knew it were utf8. Basically 47 utf8 and other multibyte codepages each need their own strupper 48 function since a byte at a time will ont work. */ 49 50 for (i = 0; i < CIFS_ENCPWD_SIZE; i++) > 51 password_with_pad[i] = toupper(password_with_pad[i]); 52 53 rc = SMBencrypt(password_with_pad, cryptkey, lnm_session_key); 54 55 return rc; 56 } 57 #endif /* CIFS_WEAK_PW_HASH */ 58 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Hi Ronnie, Thank you for the patch! Yet something to improve: [auto build test ERROR on cifs/for-next] [also build test ERROR on v5.14-rc5 next-20210813] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Ronnie-Sahlberg/cifs-only-compile-in-smb1ops-c-if-we-configure-CIFS_ALLOW_INSECURE_LEGACY/20210814-045731 base: git://git.samba.org/sfrench/cifs-2.6.git for-next config: sh-allmodconfig (attached as .config) compiler: sh4-linux-gcc (GCC) 11.2.0 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 # https://github.com/0day-ci/linux/commit/2a89ec2d759f8c3c9035498c5ef1bf66a8f8b07b git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Ronnie-Sahlberg/cifs-only-compile-in-smb1ops-c-if-we-configure-CIFS_ALLOW_INSECURE_LEGACY/20210814-045731 git checkout 2a89ec2d759f8c3c9035498c5ef1bf66a8f8b07b # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=sh If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): fs/cifs/smb1ops.c: In function 'calc_lanman_hash': >> fs/cifs/smb1ops.c:51:40: error: implicit declaration of function 'toupper'; did you mean 'UniToupper'? [-Werror=implicit-function-declaration] 51 | password_with_pad[i] = toupper(password_with_pad[i]); | ^~~~~~~ | UniToupper cc1: some warnings being treated as errors Kconfig warnings: (for reference only) WARNING: unmet direct dependencies detected for SND_ATMEL_SOC_PDC Depends on SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC && HAS_DMA Selected by - SND_ATMEL_SOC_SSC && SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC - SND_ATMEL_SOC_SSC_PDC && SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC && ATMEL_SSC vim +51 fs/cifs/smb1ops.c 16 17 #ifdef CONFIG_CIFS_WEAK_PW_HASH 18 int calc_lanman_hash(const char *password, const char *cryptkey, bool encrypt, 19 char *lnm_session_key) 20 { 21 int i, len; 22 int rc; 23 char password_with_pad[CIFS_ENCPWD_SIZE] = {0}; 24 25 if (password) { 26 for (len = 0; len < CIFS_ENCPWD_SIZE; len++) 27 if (!password[len]) 28 break; 29 30 memcpy(password_with_pad, password, len); 31 } 32 33 if (!encrypt && global_secflags & CIFSSEC_MAY_PLNTXT) { 34 memcpy(lnm_session_key, password_with_pad, 35 CIFS_ENCPWD_SIZE); 36 return 0; 37 } 38 39 /* calculate old style session key */ 40 /* calling toupper is less broken than repeatedly 41 calling nls_toupper would be since that will never 42 work for UTF8, but neither handles multibyte code pages 43 but the only alternative would be converting to UCS-16 (Unicode) 44 (using a routine something like UniStrupr) then 45 uppercasing and then converting back from Unicode - which 46 would only worth doing it if we knew it were utf8. Basically 47 utf8 and other multibyte codepages each need their own strupper 48 function since a byte at a time will ont work. */ 49 50 for (i = 0; i < CIFS_ENCPWD_SIZE; i++) > 51 password_with_pad[i] = toupper(password_with_pad[i]); 52 53 rc = SMBencrypt(password_with_pad, cryptkey, lnm_session_key); 54 55 return rc; 56 } 57 #endif /* CIFS_WEAK_PW_HASH */ 58 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c index ecf15d845dbd..79572d18ad7a 100644 --- a/fs/cifs/cifsencrypt.c +++ b/fs/cifs/cifsencrypt.c @@ -289,48 +289,6 @@ int setup_ntlm_response(struct cifs_ses *ses, const struct nls_table *nls_cp) return rc; } -#ifdef CONFIG_CIFS_WEAK_PW_HASH -int calc_lanman_hash(const char *password, const char *cryptkey, bool encrypt, - char *lnm_session_key) -{ - int i, len; - int rc; - char password_with_pad[CIFS_ENCPWD_SIZE] = {0}; - - if (password) { - for (len = 0; len < CIFS_ENCPWD_SIZE; len++) - if (!password[len]) - break; - - memcpy(password_with_pad, password, len); - } - - if (!encrypt && global_secflags & CIFSSEC_MAY_PLNTXT) { - memcpy(lnm_session_key, password_with_pad, - CIFS_ENCPWD_SIZE); - return 0; - } - - /* calculate old style session key */ - /* calling toupper is less broken than repeatedly - calling nls_toupper would be since that will never - work for UTF8, but neither handles multibyte code pages - but the only alternative would be converting to UCS-16 (Unicode) - (using a routine something like UniStrupr) then - uppercasing and then converting back from Unicode - which - would only worth doing it if we knew it were utf8. Basically - utf8 and other multibyte codepages each need their own strupper - function since a byte at a time will ont work. */ - - for (i = 0; i < CIFS_ENCPWD_SIZE; i++) - password_with_pad[i] = toupper(password_with_pad[i]); - - rc = SMBencrypt(password_with_pad, cryptkey, lnm_session_key); - - return rc; -} -#endif /* CIFS_WEAK_PW_HASH */ - /* Build a proper attribute value/target info pairs blob. * Fill in netbios and dns domain name and workstation name * and client time (total five av pairs and + one end of fields indicator. diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c index 3b83839fc2c2..eef378055a24 100644 --- a/fs/cifs/smb1ops.c +++ b/fs/cifs/smb1ops.c @@ -14,6 +14,48 @@ #include "cifs_unicode.h" #include "fs_context.h" +#ifdef CONFIG_CIFS_WEAK_PW_HASH +int calc_lanman_hash(const char *password, const char *cryptkey, bool encrypt, + char *lnm_session_key) +{ + int i, len; + int rc; + char password_with_pad[CIFS_ENCPWD_SIZE] = {0}; + + if (password) { + for (len = 0; len < CIFS_ENCPWD_SIZE; len++) + if (!password[len]) + break; + + memcpy(password_with_pad, password, len); + } + + if (!encrypt && global_secflags & CIFSSEC_MAY_PLNTXT) { + memcpy(lnm_session_key, password_with_pad, + CIFS_ENCPWD_SIZE); + return 0; + } + + /* calculate old style session key */ + /* calling toupper is less broken than repeatedly + calling nls_toupper would be since that will never + work for UTF8, but neither handles multibyte code pages + but the only alternative would be converting to UCS-16 (Unicode) + (using a routine something like UniStrupr) then + uppercasing and then converting back from Unicode - which + would only worth doing it if we knew it were utf8. Basically + utf8 and other multibyte codepages each need their own strupper + function since a byte at a time will ont work. */ + + for (i = 0; i < CIFS_ENCPWD_SIZE; i++) + password_with_pad[i] = toupper(password_with_pad[i]); + + rc = SMBencrypt(password_with_pad, cryptkey, lnm_session_key); + + return rc; +} +#endif /* CIFS_WEAK_PW_HASH */ + /* * An NT cancel request header looks just like the original request except: *
This is only used by SMB1 so lets move it to smb1ops which is conditionally compiled in depending on CIFS_ALLOW_INSECURE_LEGACY Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> --- fs/cifs/cifsencrypt.c | 42 ------------------------------------------ fs/cifs/smb1ops.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 42 deletions(-)