Skip to content

Commit 22d3d4f

Browse files
committed
Merge branch 'for-next' of git://git.samba.org/sfrench/cifs-2.6
Pull CIFS fixes from Steve French: "A few misc important cifs fixes, including a fix for a 4.9 regression in posix_acl xattr handling" * 'for-next' of git://git.samba.org/sfrench/cifs-2.6: CIFS: iterate over posix acl xattr entry correctly in ACL_to_cifs_posix() Call echo service immediately after socket reconnect CIFS: Fix BUG() in calc_seckey()
2 parents ab59d1f + ae9ebe7 commit 22d3d4f

3 files changed

Lines changed: 28 additions & 12 deletions

File tree

‎fs/cifs/cifsencrypt.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -808,15 +808,19 @@ calc_seckey(struct cifs_ses *ses)
808808
struct crypto_skcipher *tfm_arc4;
809809
struct scatterlist sgin, sgout;
810810
struct skcipher_request *req;
811-
unsigned char sec_key[CIFS_SESS_KEY_SIZE]; /* a nonce */
811+
unsigned char *sec_key;
812+
813+
sec_key = kmalloc(CIFS_SESS_KEY_SIZE, GFP_KERNEL);
814+
if (sec_key == NULL)
815+
return -ENOMEM;
812816

813817
get_random_bytes(sec_key, CIFS_SESS_KEY_SIZE);
814818

815819
tfm_arc4 = crypto_alloc_skcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
816820
if (IS_ERR(tfm_arc4)) {
817821
rc = PTR_ERR(tfm_arc4);
818822
cifs_dbg(VFS, "could not allocate crypto API arc4\n");
819-
return rc;
823+
goto out;
820824
}
821825

822826
rc = crypto_skcipher_setkey(tfm_arc4, ses->auth_key.response,
@@ -854,7 +858,8 @@ calc_seckey(struct cifs_ses *ses)
854858

855859
out_free_cipher:
856860
crypto_free_skcipher(tfm_arc4);
857-
861+
out:
862+
kfree(sec_key);
858863
return rc;
859864
}
860865

‎fs/cifs/cifssmb.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3427,6 +3427,7 @@ static __u16 ACL_to_cifs_posix(char *parm_data, const char *pACL,
34273427
__u16 rc = 0;
34283428
struct cifs_posix_acl *cifs_acl = (struct cifs_posix_acl *)parm_data;
34293429
struct posix_acl_xattr_header *local_acl = (void *)pACL;
3430+
struct posix_acl_xattr_entry *ace = (void *)(local_acl + 1);
34303431
int count;
34313432
int i;
34323433

@@ -3453,8 +3454,7 @@ static __u16 ACL_to_cifs_posix(char *parm_data, const char *pACL,
34533454
return 0;
34543455
}
34553456
for (i = 0; i < count; i++) {
3456-
rc = convert_ace_to_cifs_ace(&cifs_acl->ace_array[i],
3457-
(struct posix_acl_xattr_entry *)(local_acl + 1));
3457+
rc = convert_ace_to_cifs_ace(&cifs_acl->ace_array[i], &ace[i]);
34583458
if (rc != 0) {
34593459
/* ACE not converted */
34603460
break;

‎fs/cifs/connect.c‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,9 @@ cifs_reconnect(struct TCP_Server_Info *server)
412412
}
413413
} while (server->tcpStatus == CifsNeedReconnect);
414414

415+
if (server->tcpStatus == CifsNeedNegotiate)
416+
mod_delayed_work(cifsiod_wq, &server->echo, 0);
417+
415418
return rc;
416419
}
417420

@@ -421,17 +424,25 @@ cifs_echo_request(struct work_struct *work)
421424
int rc;
422425
struct TCP_Server_Info *server = container_of(work,
423426
struct TCP_Server_Info, echo.work);
424-
unsigned long echo_interval = server->echo_interval;
427+
unsigned long echo_interval;
428+
429+
/*
430+
* If we need to renegotiate, set echo interval to zero to
431+
* immediately call echo service where we can renegotiate.
432+
*/
433+
if (server->tcpStatus == CifsNeedNegotiate)
434+
echo_interval = 0;
435+
else
436+
echo_interval = server->echo_interval;
425437

426438
/*
427-
* We cannot send an echo if it is disabled or until the
428-
* NEGOTIATE_PROTOCOL request is done, which is indicated by
429-
* server->ops->need_neg() == true. Also, no need to ping if
430-
* we got a response recently.
439+
* We cannot send an echo if it is disabled.
440+
* Also, no need to ping if we got a response recently.
431441
*/
432442

433443
if (server->tcpStatus == CifsNeedReconnect ||
434-
server->tcpStatus == CifsExiting || server->tcpStatus == CifsNew ||
444+
server->tcpStatus == CifsExiting ||
445+
server->tcpStatus == CifsNew ||
435446
(server->ops->can_echo && !server->ops->can_echo(server)) ||
436447
time_before(jiffies, server->lstrp + echo_interval - HZ))
437448
goto requeue_echo;
@@ -442,7 +453,7 @@ cifs_echo_request(struct work_struct *work)
442453
server->hostname);
443454

444455
requeue_echo:
445-
queue_delayed_work(cifsiod_wq, &server->echo, echo_interval);
456+
queue_delayed_work(cifsiod_wq, &server->echo, server->echo_interval);
446457
}
447458

448459
static bool

0 commit comments

Comments
 (0)