Skip to content

Commit 8def5f5

Browse files
committed
Merge git://git.samba.org/sfrench/cifs-2.6
* git://git.samba.org/sfrench/cifs-2.6: cifs: check for NULL last_entry before calling cifs_save_resume_key cifs: attempt to freeze while looping on a receive attempt cifs: Fix sparse warning when calling cifs_strtoUCS CIFS: Add descriptions to the brlock cache functions
2 parents a776878 + 7023676 commit 8def5f5

File tree

4 files changed

+39
-5
lines changed

4 files changed

+39
-5
lines changed

fs/cifs/connect.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ cifs_readv_from_socket(struct TCP_Server_Info *server, struct kvec *iov_orig,
441441
smb_msg.msg_controllen = 0;
442442

443443
for (total_read = 0; to_read; total_read += length, to_read -= length) {
444+
try_to_freeze();
445+
444446
if (server_unresponsive(server)) {
445447
total_read = -EAGAIN;
446448
break;

fs/cifs/file.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,13 @@ cifs_find_lock_conflict(struct cifsInodeInfo *cinode, struct cifsLockInfo *lock,
702702
lock->type, lock->netfid, conf_lock);
703703
}
704704

705+
/*
706+
* Check if there is another lock that prevents us to set the lock (mandatory
707+
* style). If such a lock exists, update the flock structure with its
708+
* properties. Otherwise, set the flock type to F_UNLCK if we can cache brlocks
709+
* or leave it the same if we can't. Returns 0 if we don't need to request to
710+
* the server or 1 otherwise.
711+
*/
705712
static int
706713
cifs_lock_test(struct cifsInodeInfo *cinode, __u64 offset, __u64 length,
707714
__u8 type, __u16 netfid, struct file_lock *flock)
@@ -739,6 +746,12 @@ cifs_lock_add(struct cifsInodeInfo *cinode, struct cifsLockInfo *lock)
739746
mutex_unlock(&cinode->lock_mutex);
740747
}
741748

749+
/*
750+
* Set the byte-range lock (mandatory style). Returns:
751+
* 1) 0, if we set the lock and don't need to request to the server;
752+
* 2) 1, if no locks prevent us but we need to request to the server;
753+
* 3) -EACCESS, if there is a lock that prevents us and wait is false.
754+
*/
742755
static int
743756
cifs_lock_add_if(struct cifsInodeInfo *cinode, struct cifsLockInfo *lock,
744757
bool wait)
@@ -778,6 +791,13 @@ cifs_lock_add_if(struct cifsInodeInfo *cinode, struct cifsLockInfo *lock,
778791
return rc;
779792
}
780793

794+
/*
795+
* Check if there is another lock that prevents us to set the lock (posix
796+
* style). If such a lock exists, update the flock structure with its
797+
* properties. Otherwise, set the flock type to F_UNLCK if we can cache brlocks
798+
* or leave it the same if we can't. Returns 0 if we don't need to request to
799+
* the server or 1 otherwise.
800+
*/
781801
static int
782802
cifs_posix_lock_test(struct file *file, struct file_lock *flock)
783803
{
@@ -800,6 +820,12 @@ cifs_posix_lock_test(struct file *file, struct file_lock *flock)
800820
return rc;
801821
}
802822

823+
/*
824+
* Set the byte-range lock (posix style). Returns:
825+
* 1) 0, if we set the lock and don't need to request to the server;
826+
* 2) 1, if we need to request to the server;
827+
* 3) <0, if the error occurs while setting the lock.
828+
*/
803829
static int
804830
cifs_posix_lock_set(struct file *file, struct file_lock *flock)
805831
{

fs/cifs/readdir.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,15 +554,21 @@ static int find_cifs_entry(const int xid, struct cifs_tcon *pTcon,
554554
rc);
555555
return rc;
556556
}
557-
cifs_save_resume_key(cifsFile->srch_inf.last_entry, cifsFile);
557+
/* FindFirst/Next set last_entry to NULL on malformed reply */
558+
if (cifsFile->srch_inf.last_entry)
559+
cifs_save_resume_key(cifsFile->srch_inf.last_entry,
560+
cifsFile);
558561
}
559562

560563
while ((index_to_find >= cifsFile->srch_inf.index_of_last_entry) &&
561564
(rc == 0) && !cifsFile->srch_inf.endOfSearch) {
562565
cFYI(1, "calling findnext2");
563566
rc = CIFSFindNext(xid, pTcon, cifsFile->netfid,
564567
&cifsFile->srch_inf);
565-
cifs_save_resume_key(cifsFile->srch_inf.last_entry, cifsFile);
568+
/* FindFirst/Next set last_entry to NULL on malformed reply */
569+
if (cifsFile->srch_inf.last_entry)
570+
cifs_save_resume_key(cifsFile->srch_inf.last_entry,
571+
cifsFile);
566572
if (rc)
567573
return -ENOENT;
568574
}

fs/cifs/smbencrypt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16,
209209
{
210210
int rc;
211211
int len;
212-
__u16 wpwd[129];
212+
__le16 wpwd[129];
213213

214214
/* Password cannot be longer than 128 characters */
215215
if (passwd) /* Password must be converted to NT unicode */
@@ -219,8 +219,8 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16,
219219
*wpwd = 0; /* Ensure string is null terminated */
220220
}
221221

222-
rc = mdfour(p16, (unsigned char *) wpwd, len * sizeof(__u16));
223-
memset(wpwd, 0, 129 * sizeof(__u16));
222+
rc = mdfour(p16, (unsigned char *) wpwd, len * sizeof(__le16));
223+
memset(wpwd, 0, 129 * sizeof(__le16));
224224

225225
return rc;
226226
}

0 commit comments

Comments
 (0)