Skip to content

Commit 56831a1

Browse files
committed
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
* 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6: [CIFS] list entry can not return null turn cifs_setattr into a multiplexor that calls the correct function move file time and dos attribute setting logic into new function spin off cifs_setattr with unix extensions to its own function [CIFS] Code cleanup in old sessionsetup code [CIFS] cifs_mkdir and cifs_create should respect the setgid bit on parent dir Rename CIFSSMBSetFileTimes to CIFSSMBSetFileInfo and add PID arg change CIFSSMBSetTimes to CIFSSMBSetPathInfo [CIFS] fix trailing whitespace bundle up Unix SET_PATH_INFO args into a struct and change name Fix missing braces in cifs_revalidate() remove locking around tcpSesAllocCount atomic variable [CIFS] properly account for new user= field in SPNEGO upcall string allocation [CIFS] remove level of indentation from decode_negTokenInit [CIFS] cifs send2 not retrying enough in some cases on full socket [CIFS] oid should also be checked against class in cifs asn
2 parents 6724cce + ad8b15f commit 56831a1

File tree

14 files changed

+652
-509
lines changed

14 files changed

+652
-509
lines changed

fs/cifs/CHANGES

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Version 1.54
2+
------------
3+
Fix premature write failure on congested networks (we would give up
4+
on EAGAIN from the socket too quickly on large writes).
5+
Cifs_mkdir and cifs_create now respect the setgid bit on parent dir.
6+
Fix endian problems in acl (mode from/to cifs acl) on bigendian
7+
architectures.
8+
19
Version 1.53
210
------------
311
DFS support added (Microsoft Distributed File System client support needed

fs/cifs/asn1.c

Lines changed: 124 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -483,160 +483,150 @@ decode_negTokenInit(unsigned char *security_blob, int length,
483483

484484
asn1_open(&ctx, security_blob, length);
485485

486+
/* GSSAPI header */
486487
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
487488
cFYI(1, ("Error decoding negTokenInit header"));
488489
return 0;
489490
} else if ((cls != ASN1_APL) || (con != ASN1_CON)
490491
|| (tag != ASN1_EOC)) {
491492
cFYI(1, ("cls = %d con = %d tag = %d", cls, con, tag));
492493
return 0;
493-
} else {
494-
/* remember to free obj->oid */
495-
rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag);
496-
if (rc) {
497-
if ((tag == ASN1_OJI) && (con == ASN1_PRI)) {
498-
rc = asn1_oid_decode(&ctx, end, &oid, &oidlen);
499-
if (rc) {
500-
rc = compare_oid(oid, oidlen,
501-
SPNEGO_OID,
502-
SPNEGO_OID_LEN);
503-
kfree(oid);
504-
}
505-
} else
506-
rc = 0;
507-
}
494+
}
508495

509-
if (!rc) {
510-
cFYI(1, ("Error decoding negTokenInit header"));
511-
return 0;
512-
}
496+
/* Check for SPNEGO OID -- remember to free obj->oid */
497+
rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag);
498+
if (rc) {
499+
if ((tag == ASN1_OJI) && (con == ASN1_PRI) &&
500+
(cls == ASN1_UNI)) {
501+
rc = asn1_oid_decode(&ctx, end, &oid, &oidlen);
502+
if (rc) {
503+
rc = compare_oid(oid, oidlen, SPNEGO_OID,
504+
SPNEGO_OID_LEN);
505+
kfree(oid);
506+
}
507+
} else
508+
rc = 0;
509+
}
513510

514-
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
515-
cFYI(1, ("Error decoding negTokenInit"));
516-
return 0;
517-
} else if ((cls != ASN1_CTX) || (con != ASN1_CON)
518-
|| (tag != ASN1_EOC)) {
519-
cFYI(1,
520-
("cls = %d con = %d tag = %d end = %p (%d) exit 0",
521-
cls, con, tag, end, *end));
522-
return 0;
523-
}
511+
/* SPNEGO OID not present or garbled -- bail out */
512+
if (!rc) {
513+
cFYI(1, ("Error decoding negTokenInit header"));
514+
return 0;
515+
}
524516

525-
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
526-
cFYI(1, ("Error decoding negTokenInit"));
527-
return 0;
528-
} else if ((cls != ASN1_UNI) || (con != ASN1_CON)
529-
|| (tag != ASN1_SEQ)) {
530-
cFYI(1,
531-
("cls = %d con = %d tag = %d end = %p (%d) exit 1",
532-
cls, con, tag, end, *end));
533-
return 0;
534-
}
517+
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
518+
cFYI(1, ("Error decoding negTokenInit"));
519+
return 0;
520+
} else if ((cls != ASN1_CTX) || (con != ASN1_CON)
521+
|| (tag != ASN1_EOC)) {
522+
cFYI(1,
523+
("cls = %d con = %d tag = %d end = %p (%d) exit 0",
524+
cls, con, tag, end, *end));
525+
return 0;
526+
}
535527

536-
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
537-
cFYI(1, ("Error decoding 2nd part of negTokenInit"));
538-
return 0;
539-
} else if ((cls != ASN1_CTX) || (con != ASN1_CON)
540-
|| (tag != ASN1_EOC)) {
541-
cFYI(1,
542-
("cls = %d con = %d tag = %d end = %p (%d) exit 0",
543-
cls, con, tag, end, *end));
544-
return 0;
545-
}
528+
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
529+
cFYI(1, ("Error decoding negTokenInit"));
530+
return 0;
531+
} else if ((cls != ASN1_UNI) || (con != ASN1_CON)
532+
|| (tag != ASN1_SEQ)) {
533+
cFYI(1,
534+
("cls = %d con = %d tag = %d end = %p (%d) exit 1",
535+
cls, con, tag, end, *end));
536+
return 0;
537+
}
546538

547-
if (asn1_header_decode
548-
(&ctx, &sequence_end, &cls, &con, &tag) == 0) {
549-
cFYI(1, ("Error decoding 2nd part of negTokenInit"));
550-
return 0;
551-
} else if ((cls != ASN1_UNI) || (con != ASN1_CON)
552-
|| (tag != ASN1_SEQ)) {
553-
cFYI(1,
554-
("cls = %d con = %d tag = %d end = %p (%d) exit 1",
555-
cls, con, tag, end, *end));
556-
return 0;
557-
}
539+
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
540+
cFYI(1, ("Error decoding 2nd part of negTokenInit"));
541+
return 0;
542+
} else if ((cls != ASN1_CTX) || (con != ASN1_CON)
543+
|| (tag != ASN1_EOC)) {
544+
cFYI(1,
545+
("cls = %d con = %d tag = %d end = %p (%d) exit 0",
546+
cls, con, tag, end, *end));
547+
return 0;
548+
}
558549

559-
while (!asn1_eoc_decode(&ctx, sequence_end)) {
560-
rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag);
561-
if (!rc) {
562-
cFYI(1,
563-
("Error decoding negTokenInit hdr exit2"));
564-
return 0;
565-
}
566-
if ((tag == ASN1_OJI) && (con == ASN1_PRI)) {
567-
if (asn1_oid_decode(&ctx, end, &oid, &oidlen)) {
568-
569-
cFYI(1,
570-
("OID len = %d oid = 0x%lx 0x%lx "
571-
"0x%lx 0x%lx",
572-
oidlen, *oid, *(oid + 1),
573-
*(oid + 2), *(oid + 3)));
574-
575-
if (compare_oid(oid, oidlen,
576-
MSKRB5_OID,
577-
MSKRB5_OID_LEN))
578-
use_kerberos = true;
579-
else if (compare_oid(oid, oidlen,
580-
KRB5_OID,
581-
KRB5_OID_LEN))
582-
use_kerberos = true;
583-
else if (compare_oid(oid, oidlen,
584-
NTLMSSP_OID,
585-
NTLMSSP_OID_LEN))
586-
use_ntlmssp = true;
587-
588-
kfree(oid);
589-
}
590-
} else {
591-
cFYI(1, ("Should be an oid what is going on?"));
592-
}
593-
}
550+
if (asn1_header_decode
551+
(&ctx, &sequence_end, &cls, &con, &tag) == 0) {
552+
cFYI(1, ("Error decoding 2nd part of negTokenInit"));
553+
return 0;
554+
} else if ((cls != ASN1_UNI) || (con != ASN1_CON)
555+
|| (tag != ASN1_SEQ)) {
556+
cFYI(1,
557+
("cls = %d con = %d tag = %d end = %p (%d) exit 1",
558+
cls, con, tag, end, *end));
559+
return 0;
560+
}
594561

595-
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
596-
cFYI(1,
597-
("Error decoding last part negTokenInit exit3"));
598-
return 0;
599-
} else if ((cls != ASN1_CTX) || (con != ASN1_CON)) {
600-
/* tag = 3 indicating mechListMIC */
562+
while (!asn1_eoc_decode(&ctx, sequence_end)) {
563+
rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag);
564+
if (!rc) {
601565
cFYI(1,
602-
("Exit 4 cls = %d con = %d tag = %d end = %p (%d)",
603-
cls, con, tag, end, *end));
566+
("Error decoding negTokenInit hdr exit2"));
604567
return 0;
605568
}
606-
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
607-
cFYI(1,
608-
("Error decoding last part negTokenInit exit5"));
609-
return 0;
610-
} else if ((cls != ASN1_UNI) || (con != ASN1_CON)
611-
|| (tag != ASN1_SEQ)) {
612-
cFYI(1, ("cls = %d con = %d tag = %d end = %p (%d)",
613-
cls, con, tag, end, *end));
569+
if ((tag == ASN1_OJI) && (con == ASN1_PRI)) {
570+
if (asn1_oid_decode(&ctx, end, &oid, &oidlen)) {
571+
572+
cFYI(1, ("OID len = %d oid = 0x%lx 0x%lx "
573+
"0x%lx 0x%lx", oidlen, *oid,
574+
*(oid + 1), *(oid + 2), *(oid + 3)));
575+
576+
if (compare_oid(oid, oidlen, MSKRB5_OID,
577+
MSKRB5_OID_LEN))
578+
use_kerberos = true;
579+
else if (compare_oid(oid, oidlen, KRB5_OID,
580+
KRB5_OID_LEN))
581+
use_kerberos = true;
582+
else if (compare_oid(oid, oidlen, NTLMSSP_OID,
583+
NTLMSSP_OID_LEN))
584+
use_ntlmssp = true;
585+
586+
kfree(oid);
587+
}
588+
} else {
589+
cFYI(1, ("Should be an oid what is going on?"));
614590
}
591+
}
615592

616-
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
617-
cFYI(1,
618-
("Error decoding last part negTokenInit exit 7"));
619-
return 0;
620-
} else if ((cls != ASN1_CTX) || (con != ASN1_CON)) {
621-
cFYI(1,
622-
("Exit 8 cls = %d con = %d tag = %d end = %p (%d)",
623-
cls, con, tag, end, *end));
624-
return 0;
625-
}
626-
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
627-
cFYI(1,
628-
("Error decoding last part negTokenInit exit9"));
629-
return 0;
630-
} else if ((cls != ASN1_UNI) || (con != ASN1_PRI)
631-
|| (tag != ASN1_GENSTR)) {
632-
cFYI(1,
633-
("Exit10 cls = %d con = %d tag = %d end = %p (%d)",
634-
cls, con, tag, end, *end));
635-
return 0;
636-
}
637-
cFYI(1, ("Need to call asn1_octets_decode() function for %s",
638-
ctx.pointer)); /* is this UTF-8 or ASCII? */
593+
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
594+
cFYI(1, ("Error decoding last part negTokenInit exit3"));
595+
return 0;
596+
} else if ((cls != ASN1_CTX) || (con != ASN1_CON)) {
597+
/* tag = 3 indicating mechListMIC */
598+
cFYI(1, ("Exit 4 cls = %d con = %d tag = %d end = %p (%d)",
599+
cls, con, tag, end, *end));
600+
return 0;
601+
}
602+
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
603+
cFYI(1, ("Error decoding last part negTokenInit exit5"));
604+
return 0;
605+
} else if ((cls != ASN1_UNI) || (con != ASN1_CON)
606+
|| (tag != ASN1_SEQ)) {
607+
cFYI(1, ("cls = %d con = %d tag = %d end = %p (%d)",
608+
cls, con, tag, end, *end));
609+
}
610+
611+
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
612+
cFYI(1, ("Error decoding last part negTokenInit exit 7"));
613+
return 0;
614+
} else if ((cls != ASN1_CTX) || (con != ASN1_CON)) {
615+
cFYI(1, ("Exit 8 cls = %d con = %d tag = %d end = %p (%d)",
616+
cls, con, tag, end, *end));
617+
return 0;
618+
}
619+
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
620+
cFYI(1, ("Error decoding last part negTokenInit exit9"));
621+
return 0;
622+
} else if ((cls != ASN1_UNI) || (con != ASN1_PRI)
623+
|| (tag != ASN1_GENSTR)) {
624+
cFYI(1, ("Exit10 cls = %d con = %d tag = %d end = %p (%d)",
625+
cls, con, tag, end, *end));
626+
return 0;
639627
}
628+
cFYI(1, ("Need to call asn1_octets_decode() function for %s",
629+
ctx.pointer)); /* is this UTF-8 or ASCII? */
640630

641631
if (use_kerberos)
642632
*secType = Kerberos;

fs/cifs/cifs_debug.c

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -79,27 +79,25 @@ void cifs_dump_mids(struct TCP_Server_Info *server)
7979
spin_lock(&GlobalMid_Lock);
8080
list_for_each(tmp, &server->pending_mid_q) {
8181
mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
82-
if (mid_entry) {
83-
cERROR(1, ("State: %d Cmd: %d Pid: %d Tsk: %p Mid %d",
84-
mid_entry->midState,
85-
(int)mid_entry->command,
86-
mid_entry->pid,
87-
mid_entry->tsk,
88-
mid_entry->mid));
82+
cERROR(1, ("State: %d Cmd: %d Pid: %d Tsk: %p Mid %d",
83+
mid_entry->midState,
84+
(int)mid_entry->command,
85+
mid_entry->pid,
86+
mid_entry->tsk,
87+
mid_entry->mid));
8988
#ifdef CONFIG_CIFS_STATS2
90-
cERROR(1, ("IsLarge: %d buf: %p time rcv: %ld now: %ld",
91-
mid_entry->largeBuf,
92-
mid_entry->resp_buf,
93-
mid_entry->when_received,
94-
jiffies));
89+
cERROR(1, ("IsLarge: %d buf: %p time rcv: %ld now: %ld",
90+
mid_entry->largeBuf,
91+
mid_entry->resp_buf,
92+
mid_entry->when_received,
93+
jiffies));
9594
#endif /* STATS2 */
96-
cERROR(1, ("IsMult: %d IsEnd: %d", mid_entry->multiRsp,
97-
mid_entry->multiEnd));
98-
if (mid_entry->resp_buf) {
99-
cifs_dump_detail(mid_entry->resp_buf);
100-
cifs_dump_mem("existing buf: ",
101-
mid_entry->resp_buf, 62);
102-
}
95+
cERROR(1, ("IsMult: %d IsEnd: %d", mid_entry->multiRsp,
96+
mid_entry->multiEnd));
97+
if (mid_entry->resp_buf) {
98+
cifs_dump_detail(mid_entry->resp_buf);
99+
cifs_dump_mem("existing buf: ",
100+
mid_entry->resp_buf, 62);
103101
}
104102
}
105103
spin_unlock(&GlobalMid_Lock);
@@ -163,16 +161,13 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
163161
mid_entry = list_entry(tmp1, struct
164162
mid_q_entry,
165163
qhead);
166-
if (mid_entry) {
167-
seq_printf(m,
168-
"State: %d com: %d pid:"
169-
" %d tsk: %p mid %d\n",
170-
mid_entry->midState,
171-
(int)mid_entry->command,
172-
mid_entry->pid,
173-
mid_entry->tsk,
174-
mid_entry->mid);
175-
}
164+
seq_printf(m, "State: %d com: %d pid:"
165+
" %d tsk: %p mid %d\n",
166+
mid_entry->midState,
167+
(int)mid_entry->command,
168+
mid_entry->pid,
169+
mid_entry->tsk,
170+
mid_entry->mid);
176171
}
177172
spin_unlock(&GlobalMid_Lock);
178173
}

fs/cifs/cifs_spnego.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ struct key_type cifs_spnego_key_type = {
6666
.describe = user_describe,
6767
};
6868

69-
#define MAX_VER_STR_LEN 9 /* length of longest version string e.g.
70-
strlen(";ver=0xFF") */
69+
#define MAX_VER_STR_LEN 8 /* length of longest version string e.g.
70+
strlen("ver=0xFF") */
7171
#define MAX_MECH_STR_LEN 13 /* length of longest security mechanism name, eg
7272
in future could have strlen(";sec=ntlmsspi") */
7373
#define MAX_IPV6_ADDR_LEN 42 /* eg FEDC:BA98:7654:3210:FEDC:BA98:7654:3210/60 */
@@ -81,11 +81,15 @@ cifs_get_spnego_key(struct cifsSesInfo *sesInfo)
8181
struct key *spnego_key;
8282
const char *hostname = server->hostname;
8383

84-
/* BB: come up with better scheme for determining length */
85-
/* length of fields (with semicolons): ver=0xyz ipv4= ipaddress host=
86-
hostname sec=mechanism uid=0x uid */
87-
desc_len = MAX_VER_STR_LEN + 5 + MAX_IPV6_ADDR_LEN + 1 + 6 +
88-
strlen(hostname) + MAX_MECH_STR_LEN + 8 + (sizeof(uid_t) * 2);
84+
/* length of fields (with semicolons): ver=0xyz ip4=ipaddress
85+
host=hostname sec=mechanism uid=0xFF user=username */
86+
desc_len = MAX_VER_STR_LEN +
87+
6 /* len of "host=" */ + strlen(hostname) +
88+
5 /* len of ";ipv4=" */ + MAX_IPV6_ADDR_LEN +
89+
MAX_MECH_STR_LEN +
90+
7 /* len of ";uid=0x" */ + (sizeof(uid_t) * 2) +
91+
6 /* len of ";user=" */ + strlen(sesInfo->userName) + 1;
92+
8993
spnego_key = ERR_PTR(-ENOMEM);
9094
description = kzalloc(desc_len, GFP_KERNEL);
9195
if (description == NULL)

0 commit comments

Comments
 (0)