Skip to content

Commit 43f63c8

Browse files
committed
Merge git://git.samba.org/sfrench/cifs-2.6
Pull CIFS fixes from Steve French. * git://git.samba.org/sfrench/cifs-2.6: Fix UNC parsing on mount Remove unnecessary check for NULL in password parser CIFS: Fix VFS lock usage for oplocked files Revert "CIFS: Fix VFS lock usage for oplocked files" cifs: writing past end of struct in cifs_convert_address() cifs: silence compiler warnings showing up with gcc-4.7.0 CIFS: Fix VFS lock usage for oplocked files
2 parents 6c216ec + e4b41fb commit 43f63c8

File tree

6 files changed

+37
-25
lines changed

6 files changed

+37
-25
lines changed

fs/cifs/cifssmb.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3892,13 +3892,12 @@ CIFSSMBSetCIFSACL(const int xid, struct cifs_tcon *tcon, __u16 fid,
38923892
int rc = 0;
38933893
int bytes_returned = 0;
38943894
SET_SEC_DESC_REQ *pSMB = NULL;
3895-
NTRANSACT_RSP *pSMBr = NULL;
3895+
void *pSMBr;
38963896

38973897
setCifsAclRetry:
3898-
rc = smb_init(SMB_COM_NT_TRANSACT, 19, tcon, (void **) &pSMB,
3899-
(void **) &pSMBr);
3898+
rc = smb_init(SMB_COM_NT_TRANSACT, 19, tcon, (void **) &pSMB, &pSMBr);
39003899
if (rc)
3901-
return (rc);
3900+
return rc;
39023901

39033902
pSMB->MaxSetupCount = 0;
39043903
pSMB->Reserved = 0;
@@ -3926,9 +3925,8 @@ CIFSSMBSetCIFSACL(const int xid, struct cifs_tcon *tcon, __u16 fid,
39263925
pSMB->AclFlags = cpu_to_le32(aclflag);
39273926

39283927
if (pntsd && acllen) {
3929-
memcpy((char *) &pSMBr->hdr.Protocol + data_offset,
3930-
(char *) pntsd,
3931-
acllen);
3928+
memcpy((char *)pSMBr + offsetof(struct smb_hdr, Protocol) +
3929+
data_offset, pntsd, acllen);
39323930
inc_rfc1001_len(pSMB, byte_count + data_count);
39333931
} else
39343932
inc_rfc1001_len(pSMB, byte_count);
@@ -5708,7 +5706,8 @@ CIFSSMBSetFileInfo(const int xid, struct cifs_tcon *tcon,
57085706
param_offset = offsetof(struct smb_com_transaction2_sfi_req, Fid) - 4;
57095707
offset = param_offset + params;
57105708

5711-
data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
5709+
data_offset = (char *)pSMB +
5710+
offsetof(struct smb_hdr, Protocol) + offset;
57125711

57135712
count = sizeof(FILE_BASIC_INFO);
57145713
pSMB->MaxParameterCount = cpu_to_le16(2);
@@ -5977,7 +5976,7 @@ CIFSSMBUnixSetFileInfo(const int xid, struct cifs_tcon *tcon,
59775976
u16 fid, u32 pid_of_opener)
59785977
{
59795978
struct smb_com_transaction2_sfi_req *pSMB = NULL;
5980-
FILE_UNIX_BASIC_INFO *data_offset;
5979+
char *data_offset;
59815980
int rc = 0;
59825981
u16 params, param_offset, offset, byte_count, count;
59835982

@@ -5999,8 +5998,9 @@ CIFSSMBUnixSetFileInfo(const int xid, struct cifs_tcon *tcon,
59995998
param_offset = offsetof(struct smb_com_transaction2_sfi_req, Fid) - 4;
60005999
offset = param_offset + params;
60016000

6002-
data_offset = (FILE_UNIX_BASIC_INFO *)
6003-
((char *)(&pSMB->hdr.Protocol) + offset);
6001+
data_offset = (char *)pSMB +
6002+
offsetof(struct smb_hdr, Protocol) + offset;
6003+
60046004
count = sizeof(FILE_UNIX_BASIC_INFO);
60056005

60066006
pSMB->MaxParameterCount = cpu_to_le16(2);
@@ -6022,7 +6022,7 @@ CIFSSMBUnixSetFileInfo(const int xid, struct cifs_tcon *tcon,
60226022
inc_rfc1001_len(pSMB, byte_count);
60236023
pSMB->ByteCount = cpu_to_le16(byte_count);
60246024

6025-
cifs_fill_unix_set_info(data_offset, args);
6025+
cifs_fill_unix_set_info((FILE_UNIX_BASIC_INFO *)data_offset, args);
60266026

60276027
rc = SendReceiveNoRsp(xid, tcon->ses, (char *) pSMB, 0);
60286028
if (rc)

fs/cifs/connect.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,8 +1565,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
15651565

15661566
/* Obtain the value string */
15671567
value = strchr(data, '=');
1568-
if (value != NULL)
1569-
*value++ = '\0';
1568+
value++;
15701569

15711570
/* Set tmp_end to end of the string */
15721571
tmp_end = (char *) value + strlen(value);
@@ -1649,6 +1648,13 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
16491648
goto cifs_parse_mount_err;
16501649
}
16511650

1651+
vol->UNC = kmalloc(temp_len+1, GFP_KERNEL);
1652+
if (vol->UNC == NULL) {
1653+
printk(KERN_WARNING "CIFS: no memory for UNC\n");
1654+
goto cifs_parse_mount_err;
1655+
}
1656+
strcpy(vol->UNC, string);
1657+
16521658
if (strncmp(string, "//", 2) == 0) {
16531659
vol->UNC[0] = '\\';
16541660
vol->UNC[1] = '\\';
@@ -1658,13 +1664,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
16581664
goto cifs_parse_mount_err;
16591665
}
16601666

1661-
vol->UNC = kmalloc(temp_len+1, GFP_KERNEL);
1662-
if (vol->UNC == NULL) {
1663-
printk(KERN_WARNING "CIFS: no memory "
1664-
"for UNC\n");
1665-
goto cifs_parse_mount_err;
1666-
}
1667-
strcpy(vol->UNC, string);
16681667
break;
16691668
case Opt_domain:
16701669
string = match_strdup(args);

fs/cifs/file.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,13 +835,21 @@ cifs_posix_lock_set(struct file *file, struct file_lock *flock)
835835
if ((flock->fl_flags & FL_POSIX) == 0)
836836
return rc;
837837

838+
try_again:
838839
mutex_lock(&cinode->lock_mutex);
839840
if (!cinode->can_cache_brlcks) {
840841
mutex_unlock(&cinode->lock_mutex);
841842
return rc;
842843
}
843-
rc = posix_lock_file_wait(file, flock);
844+
845+
rc = posix_lock_file(file, flock, NULL);
844846
mutex_unlock(&cinode->lock_mutex);
847+
if (rc == FILE_LOCK_DEFERRED) {
848+
rc = wait_event_interruptible(flock->fl_wait, !flock->fl_next);
849+
if (!rc)
850+
goto try_again;
851+
locks_delete_block(flock);
852+
}
845853
return rc;
846854
}
847855

fs/cifs/netmisc.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,7 @@ cifs_convert_address(struct sockaddr *dst, const char *src, int len)
197197
memcpy(scope_id, pct + 1, slen);
198198
scope_id[slen] = '\0';
199199

200-
rc = strict_strtoul(scope_id, 0,
201-
(unsigned long *)&s6->sin6_scope_id);
200+
rc = kstrtouint(scope_id, 0, &s6->sin6_scope_id);
202201
rc = (rc == 0) ? 1 : 0;
203202
}
204203

fs/locks.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,12 +510,13 @@ static void __locks_delete_block(struct file_lock *waiter)
510510

511511
/*
512512
*/
513-
static void locks_delete_block(struct file_lock *waiter)
513+
void locks_delete_block(struct file_lock *waiter)
514514
{
515515
lock_flocks();
516516
__locks_delete_block(waiter);
517517
unlock_flocks();
518518
}
519+
EXPORT_SYMBOL(locks_delete_block);
519520

520521
/* Insert waiter into blocker's block list.
521522
* We use a circular list so that processes can be easily woken up in

include/linux/fs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,7 @@ extern int vfs_setlease(struct file *, long, struct file_lock **);
12151215
extern int lease_modify(struct file_lock **, int);
12161216
extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
12171217
extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
1218+
extern void locks_delete_block(struct file_lock *waiter);
12181219
extern void lock_flocks(void);
12191220
extern void unlock_flocks(void);
12201221
#else /* !CONFIG_FILE_LOCKING */
@@ -1359,6 +1360,10 @@ static inline int lock_may_write(struct inode *inode, loff_t start,
13591360
return 1;
13601361
}
13611362

1363+
static inline void locks_delete_block(struct file_lock *waiter)
1364+
{
1365+
}
1366+
13621367
static inline void lock_flocks(void)
13631368
{
13641369
}

0 commit comments

Comments
 (0)