Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-next' of git://git.samba.org/sfrench/cifs-2.6

Pull CIFS fixes from Steve French:
"A set of small cifs fixes, including 3 relating to symlink handling"

* 'for-next' of git://git.samba.org/sfrench/cifs-2.6:
cifs: don't instantiate new dentries in readdir for inodes that need to be revalidated immediately
cifs: set sb->s_d_op before calling d_make_root()
cifs: fix bad error handling in crypto code
cifs: file: initialize oparms.reconnect before using it
Do not attempt to do cifs operations reading symlinks with SMB2
cifs: extend the buffer length enought for sprintf() using

+98 -51
+9 -5
fs/cifs/cifsencrypt.c
··· 43 43 server->secmech.md5 = crypto_alloc_shash("md5", 0, 0); 44 44 if (IS_ERR(server->secmech.md5)) { 45 45 cifs_dbg(VFS, "could not allocate crypto md5\n"); 46 - return PTR_ERR(server->secmech.md5); 46 + rc = PTR_ERR(server->secmech.md5); 47 + server->secmech.md5 = NULL; 48 + return rc; 47 49 } 48 50 49 51 size = sizeof(struct shash_desc) + 50 52 crypto_shash_descsize(server->secmech.md5); 51 53 server->secmech.sdescmd5 = kmalloc(size, GFP_KERNEL); 52 54 if (!server->secmech.sdescmd5) { 53 - rc = -ENOMEM; 54 55 crypto_free_shash(server->secmech.md5); 55 56 server->secmech.md5 = NULL; 56 - return rc; 57 + return -ENOMEM; 57 58 } 58 59 server->secmech.sdescmd5->shash.tfm = server->secmech.md5; 59 60 server->secmech.sdescmd5->shash.flags = 0x0; ··· 422 421 if (blobptr + attrsize > blobend) 423 422 break; 424 423 if (type == NTLMSSP_AV_NB_DOMAIN_NAME) { 425 - if (!attrsize) 424 + if (!attrsize || attrsize >= CIFS_MAX_DOMAINNAME_LEN) 426 425 break; 427 426 if (!ses->domainName) { 428 427 ses->domainName = ··· 592 591 593 592 static int crypto_hmacmd5_alloc(struct TCP_Server_Info *server) 594 593 { 594 + int rc; 595 595 unsigned int size; 596 596 597 597 /* check if already allocated */ ··· 602 600 server->secmech.hmacmd5 = crypto_alloc_shash("hmac(md5)", 0, 0); 603 601 if (IS_ERR(server->secmech.hmacmd5)) { 604 602 cifs_dbg(VFS, "could not allocate crypto hmacmd5\n"); 605 - return PTR_ERR(server->secmech.hmacmd5); 603 + rc = PTR_ERR(server->secmech.hmacmd5); 604 + server->secmech.hmacmd5 = NULL; 605 + return rc; 606 606 } 607 607 608 608 size = sizeof(struct shash_desc) +
+5 -6
fs/cifs/cifsfs.c
··· 147 147 goto out_no_root; 148 148 } 149 149 150 + if (cifs_sb_master_tcon(cifs_sb)->nocase) 151 + sb->s_d_op = &cifs_ci_dentry_ops; 152 + else 153 + sb->s_d_op = &cifs_dentry_ops; 154 + 150 155 sb->s_root = d_make_root(inode); 151 156 if (!sb->s_root) { 152 157 rc = -ENOMEM; 153 158 goto out_no_root; 154 159 } 155 - 156 - /* do that *after* d_make_root() - we want NULL ->d_op for root here */ 157 - if (cifs_sb_master_tcon(cifs_sb)->nocase) 158 - sb->s_d_op = &cifs_ci_dentry_ops; 159 - else 160 - sb->s_d_op = &cifs_dentry_ops; 161 160 162 161 #ifdef CONFIG_CIFS_NFSD_EXPORT 163 162 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
+4
fs/cifs/cifsglob.h
··· 44 44 #define MAX_TREE_SIZE (2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1) 45 45 #define MAX_SERVER_SIZE 15 46 46 #define MAX_SHARE_SIZE 80 47 + #define CIFS_MAX_DOMAINNAME_LEN 256 /* max domain name length */ 47 48 #define MAX_USERNAME_SIZE 256 /* reasonable maximum for current servers */ 48 49 #define MAX_PASSWORD_SIZE 512 /* max for windows seems to be 256 wide chars */ 49 50 ··· 370 369 void (*generate_signingkey)(struct TCP_Server_Info *server); 371 370 int (*calc_signature)(struct smb_rqst *rqst, 372 371 struct TCP_Server_Info *server); 372 + int (*query_mf_symlink)(const unsigned char *path, char *pbuf, 373 + unsigned int *pbytes_read, struct cifs_sb_info *cifs_sb, 374 + unsigned int xid); 373 375 }; 374 376 375 377 struct smb_version_values {
+3 -1
fs/cifs/cifsproto.h
··· 497 497 struct cifs_writedata *cifs_writedata_alloc(unsigned int nr_pages, 498 498 work_func_t complete); 499 499 void cifs_writedata_release(struct kref *refcount); 500 - 500 + int open_query_close_cifs_symlink(const unsigned char *path, char *pbuf, 501 + unsigned int *pbytes_read, struct cifs_sb_info *cifs_sb, 502 + unsigned int xid); 501 503 #endif /* _CIFSPROTO_H */
+4 -3
fs/cifs/connect.c
··· 1675 1675 if (string == NULL) 1676 1676 goto out_nomem; 1677 1677 1678 - if (strnlen(string, 256) == 256) { 1678 + if (strnlen(string, CIFS_MAX_DOMAINNAME_LEN) 1679 + == CIFS_MAX_DOMAINNAME_LEN) { 1679 1680 printk(KERN_WARNING "CIFS: domain name too" 1680 1681 " long\n"); 1681 1682 goto cifs_parse_mount_err; ··· 2277 2276 2278 2277 #ifdef CONFIG_KEYS 2279 2278 2280 - /* strlen("cifs:a:") + INET6_ADDRSTRLEN + 1 */ 2281 - #define CIFSCREDS_DESC_SIZE (7 + INET6_ADDRSTRLEN + 1) 2279 + /* strlen("cifs:a:") + CIFS_MAX_DOMAINNAME_LEN + 1 */ 2280 + #define CIFSCREDS_DESC_SIZE (7 + CIFS_MAX_DOMAINNAME_LEN + 1) 2282 2281 2283 2282 /* Populate username and pw fields from keyring if possible */ 2284 2283 static int
+1
fs/cifs/file.c
··· 647 647 oflags, &oplock, &cfile->fid.netfid, xid); 648 648 if (rc == 0) { 649 649 cifs_dbg(FYI, "posix reopen succeeded\n"); 650 + oparms.reconnect = true; 650 651 goto reopen_success; 651 652 } 652 653 /*
+53 -31
fs/cifs/link.c
··· 305 305 } 306 306 307 307 int 308 - CIFSCheckMFSymlink(struct cifs_fattr *fattr, 309 - const unsigned char *path, 310 - struct cifs_sb_info *cifs_sb, unsigned int xid) 308 + open_query_close_cifs_symlink(const unsigned char *path, char *pbuf, 309 + unsigned int *pbytes_read, struct cifs_sb_info *cifs_sb, 310 + unsigned int xid) 311 311 { 312 312 int rc; 313 313 int oplock = 0; 314 314 __u16 netfid = 0; 315 315 struct tcon_link *tlink; 316 - struct cifs_tcon *pTcon; 316 + struct cifs_tcon *ptcon; 317 317 struct cifs_io_parms io_parms; 318 - u8 *buf; 319 - char *pbuf; 320 - unsigned int bytes_read = 0; 321 318 int buf_type = CIFS_NO_BUFFER; 322 - unsigned int link_len = 0; 323 319 FILE_ALL_INFO file_info; 324 - 325 - if (!CIFSCouldBeMFSymlink(fattr)) 326 - /* it's not a symlink */ 327 - return 0; 328 320 329 321 tlink = cifs_sb_tlink(cifs_sb); 330 322 if (IS_ERR(tlink)) 331 323 return PTR_ERR(tlink); 332 - pTcon = tlink_tcon(tlink); 324 + ptcon = tlink_tcon(tlink); 333 325 334 - rc = CIFSSMBOpen(xid, pTcon, path, FILE_OPEN, GENERIC_READ, 326 + rc = CIFSSMBOpen(xid, ptcon, path, FILE_OPEN, GENERIC_READ, 335 327 CREATE_NOT_DIR, &netfid, &oplock, &file_info, 336 328 cifs_sb->local_nls, 337 329 cifs_sb->mnt_cifs_flags & 338 330 CIFS_MOUNT_MAP_SPECIAL_CHR); 339 - if (rc != 0) 340 - goto out; 331 + if (rc != 0) { 332 + cifs_put_tlink(tlink); 333 + return rc; 334 + } 341 335 342 336 if (file_info.EndOfFile != cpu_to_le64(CIFS_MF_SYMLINK_FILE_SIZE)) { 343 - CIFSSMBClose(xid, pTcon, netfid); 337 + CIFSSMBClose(xid, ptcon, netfid); 338 + cifs_put_tlink(tlink); 344 339 /* it's not a symlink */ 345 - goto out; 340 + return rc; 346 341 } 342 + 343 + io_parms.netfid = netfid; 344 + io_parms.pid = current->tgid; 345 + io_parms.tcon = ptcon; 346 + io_parms.offset = 0; 347 + io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE; 348 + 349 + rc = CIFSSMBRead(xid, &io_parms, pbytes_read, &pbuf, &buf_type); 350 + CIFSSMBClose(xid, ptcon, netfid); 351 + cifs_put_tlink(tlink); 352 + return rc; 353 + } 354 + 355 + 356 + int 357 + CIFSCheckMFSymlink(struct cifs_fattr *fattr, 358 + const unsigned char *path, 359 + struct cifs_sb_info *cifs_sb, unsigned int xid) 360 + { 361 + int rc = 0; 362 + u8 *buf = NULL; 363 + unsigned int link_len = 0; 364 + unsigned int bytes_read = 0; 365 + struct cifs_tcon *ptcon; 366 + 367 + if (!CIFSCouldBeMFSymlink(fattr)) 368 + /* it's not a symlink */ 369 + return 0; 347 370 348 371 buf = kmalloc(CIFS_MF_SYMLINK_FILE_SIZE, GFP_KERNEL); 349 372 if (!buf) { 350 373 rc = -ENOMEM; 351 374 goto out; 352 375 } 353 - pbuf = buf; 354 - io_parms.netfid = netfid; 355 - io_parms.pid = current->tgid; 356 - io_parms.tcon = pTcon; 357 - io_parms.offset = 0; 358 - io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE; 359 376 360 - rc = CIFSSMBRead(xid, &io_parms, &bytes_read, &pbuf, &buf_type); 361 - CIFSSMBClose(xid, pTcon, netfid); 362 - if (rc != 0) { 363 - kfree(buf); 377 + ptcon = tlink_tcon(cifs_sb_tlink(cifs_sb)); 378 + if ((ptcon->ses) && (ptcon->ses->server->ops->query_mf_symlink)) 379 + rc = ptcon->ses->server->ops->query_mf_symlink(path, buf, 380 + &bytes_read, cifs_sb, xid); 381 + else 364 382 goto out; 365 - } 383 + 384 + if (rc != 0) 385 + goto out; 386 + 387 + if (bytes_read == 0) /* not a symlink */ 388 + goto out; 366 389 367 390 rc = CIFSParseMFSymlink(buf, bytes_read, &link_len, NULL); 368 - kfree(buf); 369 391 if (rc == -EINVAL) { 370 392 /* it's not a symlink */ 371 393 rc = 0; ··· 403 381 fattr->cf_mode |= S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO; 404 382 fattr->cf_dtype = DT_LNK; 405 383 out: 406 - cifs_put_tlink(tlink); 384 + kfree(buf); 407 385 return rc; 408 386 } 409 387
+8
fs/cifs/readdir.c
··· 111 111 return; 112 112 } 113 113 114 + /* 115 + * If we know that the inode will need to be revalidated immediately, 116 + * then don't create a new dentry for it. We'll end up doing an on 117 + * the wire call either way and this spares us an invalidation. 118 + */ 119 + if (fattr->cf_flags & CIFS_FATTR_NEED_REVAL) 120 + return; 121 + 114 122 dentry = d_alloc(parent, name); 115 123 if (!dentry) 116 124 return;
+3 -3
fs/cifs/sess.c
··· 197 197 bytes_ret = 0; 198 198 } else 199 199 bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->domainName, 200 - 256, nls_cp); 200 + CIFS_MAX_DOMAINNAME_LEN, nls_cp); 201 201 bcc_ptr += 2 * bytes_ret; 202 202 bcc_ptr += 2; /* account for null terminator */ 203 203 ··· 255 255 256 256 /* copy domain */ 257 257 if (ses->domainName != NULL) { 258 - strncpy(bcc_ptr, ses->domainName, 256); 259 - bcc_ptr += strnlen(ses->domainName, 256); 258 + strncpy(bcc_ptr, ses->domainName, CIFS_MAX_DOMAINNAME_LEN); 259 + bcc_ptr += strnlen(ses->domainName, CIFS_MAX_DOMAINNAME_LEN); 260 260 } /* else we will send a null domain name 261 261 so the server will default to its own domain */ 262 262 *bcc_ptr = 0;
+1
fs/cifs/smb1ops.c
··· 944 944 .mand_lock = cifs_mand_lock, 945 945 .mand_unlock_range = cifs_unlock_range, 946 946 .push_mand_locks = cifs_push_mandatory_locks, 947 + .query_mf_symlink = open_query_close_cifs_symlink, 947 948 }; 948 949 949 950 struct smb_version_values smb1_values = {
+7 -2
fs/cifs/smb2transport.c
··· 42 42 static int 43 43 smb2_crypto_shash_allocate(struct TCP_Server_Info *server) 44 44 { 45 + int rc; 45 46 unsigned int size; 46 47 47 48 if (server->secmech.sdeschmacsha256 != NULL) ··· 51 50 server->secmech.hmacsha256 = crypto_alloc_shash("hmac(sha256)", 0, 0); 52 51 if (IS_ERR(server->secmech.hmacsha256)) { 53 52 cifs_dbg(VFS, "could not allocate crypto hmacsha256\n"); 54 - return PTR_ERR(server->secmech.hmacsha256); 53 + rc = PTR_ERR(server->secmech.hmacsha256); 54 + server->secmech.hmacsha256 = NULL; 55 + return rc; 55 56 } 56 57 57 58 size = sizeof(struct shash_desc) + ··· 90 87 server->secmech.sdeschmacsha256 = NULL; 91 88 crypto_free_shash(server->secmech.hmacsha256); 92 89 server->secmech.hmacsha256 = NULL; 93 - return PTR_ERR(server->secmech.cmacaes); 90 + rc = PTR_ERR(server->secmech.cmacaes); 91 + server->secmech.cmacaes = NULL; 92 + return rc; 94 93 } 95 94 96 95 size = sizeof(struct shash_desc) +