cifs: decoding negTokenInit with generic ASN1 decoder
Subsystems (2)
PATCH v2 1/1 cifs: decoding negTokenInit with generic ASN1 decoder
Decode negTokenInit with lib/asn1_decoder. For that, add OIDs in linux/oid_registry.h and a negTokenInit ASN1 file, "spnego_negtokeninit.asn1".
And define decoder's callback functions, which are the gssapi_this_mech for checking SPENGO oid and the neg_token_init_mech_type for getting authentication mechanisms supported by a server.
---
changes from v1:
- Select CONFIG_OID_REGISTRY
fs/cifs/Kconfig | 2 + fs/cifs/Makefile | 4 +- fs/cifs/asn1.c | 624 ++----------------------------- fs/cifs/spnego_negtokeninit.asn1 | 40 ++ include/linux/oid_registry.h | 8 + 5 files changed, 90 insertions(+), 588 deletions(-) create mode 100644 fs/cifs/spnego_negtokeninit.asn1
fs/cifs/Kconfig +2 -0
@@ -19,6 +19,8 @@ config CIFS select CRYPTO_LIB_DES select KEYS select DNS_RESOLVER + select ASN1 + select OID_REGISTRY help This is the client VFS module for the SMB3 family of NAS protocols, (including support for the most recent, most secure dialect SMB3.1.1)
fs/cifs/Makefile +3 -1
@@ -5,13 +5,15 @@ ccflags-y += -I$(src) # needed for trace events obj-$(CONFIG_CIFS) += cifs.o +$(obj)/spnego_negtokeninit.asn1.o: $(obj)/spnego_negtokeninit.asn1.c $(obj)/spnego_negtokeninit.asn1.h + cifs-y := trace.o cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o \ inode.o link.o misc.o netmisc.o smbencrypt.o transport.o asn1.o \ cifs_unicode.o nterr.o cifsencrypt.o \ readdir.o ioctl.o sess.o export.o smb1ops.o unc.o winucase.o \ smb2ops.o smb2maperror.o smb2transport.o \ smb2misc.o smb2pdu.o smb2inode.o smb2file.o cifsacl.o fs_context.o \ - dns_resolve.o + dns_resolve.o spnego_negtokeninit.asn1.o cifs-$(CONFIG_CIFS_XATTR) += xattr.o
fs/cifs/asn1.c +37 -587
649 lines not on this page · raw message
fs/cifs/spnego_negtokeninit.asn1 new file +40 -0
@@ -0,0 +1,40 @@ +GSSAPI ::= + [APPLICATION 0] IMPLICIT SEQUENCE { + thisMech + OBJECT IDENTIFIER ({gssapi_this_mech}), + negotiationToken + NegotiationToken + } + +MechType ::= OBJECT IDENTIFIER ({neg_token_init_mech_type}) + +MechTypeList ::= SEQUENCE OF MechType + +NegHints ::= SEQUENCE { + hintName + [0] GeneralString OPTIONAL, + hintAddress + [1] OCTET STRING OPTIONAL + } + +NegTokenInit2 ::= + SEQUENCE { + mechTypes + [0] MechTypeList OPTIONAL, + reqFlags + [1] BIT STRING OPTIONAL, + mechToken + [2] OCTET STRING OPTIONAL, + negHints + [3] NegHints OPTIONAL, + mechListMIC + [3] OCTET STRING OPTIONAL + } + +NegotiationToken ::= + CHOICE { + negTokenInit + [0] NegTokenInit2, + negTokenTarg + [1] ANY + }
include/linux/oid_registry.h +8 -0
@@ -54,6 +54,10 @@ enum OID { OID_md4,/* 1.2.840.113549.2.4 */ OID_md5,/* 1.2.840.113549.2.5 */ + OID_mskrb5,/* 1.2.840.48018.1.2.2 */ + OID_krb5,/* 1.2.840.113554.1.2.2 */ + OID_krb5u2u,/* 1.2.840.113554.1.2.2.3 */ +/* Microsoft Authenticode & Software Publishing */ OID_msIndirectData,/* 1.3.6.1.4.1.311.2.1.4 */ OID_msStatementType, /* 1.3.6.1.4.1.311.2.1.11 */
@@ -62,6 +66,10 @@ enum OID { OID_msIndividualSPKeyPurpose,/* 1.3.6.1.4.1.311.2.1.21 */ OID_msOutlookExpress,/* 1.3.6.1.4.1.311.16.4 */ + OID_ntlmssp,/* 1.3.6.1.4.1.311.2.2.10 */ + + OID_spnego,/* 1.3.6.1.5.5.2 */ + OID_certAuthInfoAccess,/* 1.3.6.1.5.5.7.1.1 */ OID_sha1,/* 1.3.14.3.2.26 */ OID_id_ansip384r1, /* 1.3.132.0.34 */
Signature · 1 line
2.25.1
Hi Hyunchul,
The existence of multiple ASN1 decoder has been a regular complaint, this looks nice. Have you tested it against any servers?
I think we need to make sure it works with Windows Server (including increased ones with the increased security flag, Steve do you remember the name of that flag?) and Samba at least.
There is the SDC EMEA plugfest coming up, might be a good time to try it out against other vendors as well.
Cheers,
Signature · 4 lines
Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)
Hi Aurélien,
2021년 5월 21일 (금) 오후 5:43, Aurélien Aptel <[email protected]>님이 작성:
Quoted 6 lines
Hi Hyunchul,
The existence of multiple ASN1 decoder has been a regular complaint, this looks nice. Have you tested it against any servers?
Yes, I have tested this patch against Windows 10, Samba 4.11.6, and cifsd. If you have trouble, you need to rebuild the kernel due to rebuilding the OID registry.
Quoted 4 lines
I think we need to make sure it works with Windows Server (including increased ones with the increased security flag, Steve do you remember the name of that flag?) and Samba at least.
If you let me know the option, I will try.
Quoted 3 lines
There is the SDC EMEA plugfest coming up, might be a good time to try it out against other vendors as well.
Yes, but I am not gonna to attend the plugfest because of personal reasons. Is there any other way to test this against other vendors?
Thanks,
Hyunchul
Quoted 7 lines
Cheers,
--
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)
kernel test robot
build botThank you for the patch! Perhaps something to improve:
Hi Hyunchul,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on cifs/for-next]
[also build test WARNING on linux/master linus/master v5.13-rc2 next-20210521] [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/Hyunchul-Lee/cifs-decoding-negTokenInit-with-generic-ASN1-decoder/20210522-232614 base: git://git.samba.org/sfrench/cifs-2.6.git for-next config: i386-defconfig (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce (this is a W=1 build): # https://github.com/0day-ci/linux/commit/e1097df7e174530fece6a8afc49d61d34b904869 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Hyunchul-Lee/cifs-decoding-negTokenInit-with-generic-ASN1-decoder/20210522-232614 git checkout e1097df7e174530fece6a8afc49d61d34b904869 # save the attached .config to linux build tree make W=1 ARCH=i386
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> fs/cifs/asn1.c:11:1: warning: no previous prototype for 'decode_negTokenInit' [-Wmissing-prototypes]
11 | decode_negTokenInit(unsigned char *security_blob, int length,
| ^~~~~~~~~~~~~~~~~~~
vim +/decode_negTokenInit +11 fs/cifs/asn1.c
9
10 int
> 11 decode_negTokenInit(unsigned char *security_blob, int length,
12 struct TCP_Server_Info *server)
13 {
14 if (asn1_ber_decoder(&spnego_negtokeninit_decoder, server,
15 security_blob, length) == 0)
16 return 1;
17 else
18 return 0;
19 }
20 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi Hyunchul,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on cifs/for-next]
[also build test ERROR on linux/master linus/master v5.13-rc2 next-20210521] [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/Hyunchul-Lee/cifs-decoding-negTokenInit-with-generic-ASN1-decoder/20210522-232614 base: git://git.samba.org/sfrench/cifs-2.6.git for-next config: um-allmodconfig (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/e1097df7e174530fece6a8afc49d61d34b904869
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Hyunchul-Lee/cifs-decoding-negTokenInit-with-generic-ASN1-decoder/20210522-232614 git checkout e1097df7e174530fece6a8afc49d61d34b904869
# save the attached .config to linux build tree
make W=1 ARCH=um
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> fs/cifs/asn1.c:8:10: fatal error: spnego_negtokeninit.asn1.h: No such file or directory
8 | #include "spnego_negtokeninit.asn1.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
vim +8 fs/cifs/asn1.c
2
3 #include <linux/module.h>
4 #include <linux/kernel.h>
5 #include <linux/oid_registry.h>
6 #include "cifsglob.h"
7 #include "cifs_debug.h"
> 8 #include "spnego_negtokeninit.asn1.h"
9 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Quoted 9 lines · Aurélien Aptel via samba-technical
Hi Hyunchul,
The existence of multiple ASN1 decoder has been a regular complaint, this looks nice. Have you tested it against any servers?
I think we need to make sure it works with Windows Server (including increased ones with the increased security flag, Steve do you remember the name of that flag?) and Samba at least.
Are you thinking about the authentication problem to Windows when a stricter registry setting is chosen for server name hardening?
This involves populating the ntlmv2 response area of an NTLMSSP blob with the "Target Name" attribute ie missing MsvAvTargetNamefield and maybe also
MsvAvTimestamp and NTLMSSP_AVFLAG_MIC_IN_AUTHENTICATE_MESSAGE in
MsvAvFlags. These (the target name field in particular) are required
when Windows servers set the registry parm SmbServerNameHardeningLevel to 2
Quoted 2 lines
There is the SDC EMEA plugfest coming up, might be a good time to try it out against other vendors as well.
Yes - definitely need to try with various cases (krb5 and ntlmssp in SPNEGO) to various servers (Macs, NetApp, Windows, Azure, Samba,ksmbd etc)
Signature · 3 lines
Thanks, Steve