Skip to content

Commit f2257b7

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6: cifs: make sure we allocate enough storage for socket address [CIFS] Make socket retry timeouts consistent between blocking and nonblocking cases [CIFS] some cleanup to dir.c prior to addition of posix_open [CIFS] revalidate parent inode when rmdir done within that directory [CIFS] Rename md5 functions to avoid collision with new rt modules cifs: turn smb_send into a wrapper around smb_sendv
2 parents 1737ef7 + a9ac49d commit f2257b7

9 files changed

Lines changed: 121 additions & 161 deletions

File tree

‎fs/cifs/CHANGES‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ rather than posix (advisory) byte range locks, even though server would
55
support posix byte range locks. Fix query of root inode when prefixpath
66
specified and user does not have access to query information about the
77
top of the share. Fix problem in 2.6.28 resolving DFS paths to
8-
Samba servers (worked to Windows).
8+
Samba servers (worked to Windows). Fix rmdir so that pending search
9+
(readdir) requests do not get invalid results which include the now
10+
removed directory.
911

1012
Version 1.55
1113
------------

‎fs/cifs/cifsencrypt.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ static int cifs_calculate_signature(const struct smb_hdr *cifs_pdu,
4848
if ((cifs_pdu == NULL) || (signature == NULL) || (key == NULL))
4949
return -EINVAL;
5050

51-
MD5Init(&context);
52-
MD5Update(&context, (char *)&key->data, key->len);
53-
MD5Update(&context, cifs_pdu->Protocol, cifs_pdu->smb_buf_length);
51+
cifs_MD5_init(&context);
52+
cifs_MD5_update(&context, (char *)&key->data, key->len);
53+
cifs_MD5_update(&context, cifs_pdu->Protocol, cifs_pdu->smb_buf_length);
5454

55-
MD5Final(signature, &context);
55+
cifs_MD5_final(signature, &context);
5656
return 0;
5757
}
5858

@@ -96,8 +96,8 @@ static int cifs_calc_signature2(const struct kvec *iov, int n_vec,
9696
if ((iov == NULL) || (signature == NULL) || (key == NULL))
9797
return -EINVAL;
9898

99-
MD5Init(&context);
100-
MD5Update(&context, (char *)&key->data, key->len);
99+
cifs_MD5_init(&context);
100+
cifs_MD5_update(&context, (char *)&key->data, key->len);
101101
for (i = 0; i < n_vec; i++) {
102102
if (iov[i].iov_len == 0)
103103
continue;
@@ -110,13 +110,13 @@ static int cifs_calc_signature2(const struct kvec *iov, int n_vec,
110110
if (i == 0) {
111111
if (iov[0].iov_len <= 8) /* cmd field at offset 9 */
112112
break; /* nothing to sign or corrupt header */
113-
MD5Update(&context, iov[0].iov_base+4,
113+
cifs_MD5_update(&context, iov[0].iov_base+4,
114114
iov[0].iov_len-4);
115115
} else
116-
MD5Update(&context, iov[i].iov_base, iov[i].iov_len);
116+
cifs_MD5_update(&context, iov[i].iov_base, iov[i].iov_len);
117117
}
118118

119-
MD5Final(signature, &context);
119+
cifs_MD5_final(signature, &context);
120120

121121
return 0;
122122
}

‎fs/cifs/cifsproto.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ extern struct smb_hdr *cifs_buf_get(void);
3535
extern void cifs_buf_release(void *);
3636
extern struct smb_hdr *cifs_small_buf_get(void);
3737
extern void cifs_small_buf_release(void *);
38-
extern int smb_send(struct socket *, struct smb_hdr *,
39-
unsigned int /* length */ , struct sockaddr *, bool);
38+
extern int smb_send(struct TCP_Server_Info *, struct smb_hdr *,
39+
unsigned int /* length */);
4040
extern unsigned int _GetXid(void);
4141
extern void _FreeXid(unsigned int);
4242
#define GetXid() (int)_GetXid(); cFYI(1,("CIFS VFS: in %s as Xid: %d with uid: %d",__func__, xid,current_fsuid()));

‎fs/cifs/connect.c‎

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,7 @@ cifs_parse_mount_options(char *options, const char *devname,
13541354
}
13551355

13561356
static struct TCP_Server_Info *
1357-
cifs_find_tcp_session(struct sockaddr *addr)
1357+
cifs_find_tcp_session(struct sockaddr_storage *addr)
13581358
{
13591359
struct list_head *tmp;
13601360
struct TCP_Server_Info *server;
@@ -1374,11 +1374,11 @@ cifs_find_tcp_session(struct sockaddr *addr)
13741374
if (server->tcpStatus == CifsNew)
13751375
continue;
13761376

1377-
if (addr->sa_family == AF_INET &&
1377+
if (addr->ss_family == AF_INET &&
13781378
(addr4->sin_addr.s_addr !=
13791379
server->addr.sockAddr.sin_addr.s_addr))
13801380
continue;
1381-
else if (addr->sa_family == AF_INET6 &&
1381+
else if (addr->ss_family == AF_INET6 &&
13821382
memcmp(&server->addr.sockAddr6.sin6_addr,
13831383
&addr6->sin6_addr, sizeof(addr6->sin6_addr)))
13841384
continue;
@@ -1419,12 +1419,12 @@ static struct TCP_Server_Info *
14191419
cifs_get_tcp_session(struct smb_vol *volume_info)
14201420
{
14211421
struct TCP_Server_Info *tcp_ses = NULL;
1422-
struct sockaddr addr;
1422+
struct sockaddr_storage addr;
14231423
struct sockaddr_in *sin_server = (struct sockaddr_in *) &addr;
14241424
struct sockaddr_in6 *sin_server6 = (struct sockaddr_in6 *) &addr;
14251425
int rc;
14261426

1427-
memset(&addr, 0, sizeof(struct sockaddr));
1427+
memset(&addr, 0, sizeof(struct sockaddr_storage));
14281428

14291429
if (volume_info->UNCip && volume_info->UNC) {
14301430
rc = cifs_inet_pton(AF_INET, volume_info->UNCip,
@@ -1435,9 +1435,9 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
14351435
rc = cifs_inet_pton(AF_INET6, volume_info->UNCip,
14361436
&sin_server6->sin6_addr.in6_u);
14371437
if (rc > 0)
1438-
addr.sa_family = AF_INET6;
1438+
addr.ss_family = AF_INET6;
14391439
} else {
1440-
addr.sa_family = AF_INET;
1440+
addr.ss_family = AF_INET;
14411441
}
14421442

14431443
if (rc <= 0) {
@@ -1502,7 +1502,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
15021502
tcp_ses->tcpStatus = CifsNew;
15031503
++tcp_ses->srv_count;
15041504

1505-
if (addr.sa_family == AF_INET6) {
1505+
if (addr.ss_family == AF_INET6) {
15061506
cFYI(1, ("attempting ipv6 connect"));
15071507
/* BB should we allow ipv6 on port 139? */
15081508
/* other OS never observed in Wild doing 139 with v6 */
@@ -1802,7 +1802,7 @@ ipv4_connect(struct TCP_Server_Info *server)
18021802
* user space buffer
18031803
*/
18041804
socket->sk->sk_rcvtimeo = 7 * HZ;
1805-
socket->sk->sk_sndtimeo = 3 * HZ;
1805+
socket->sk->sk_sndtimeo = 5 * HZ;
18061806

18071807
/* make the bufsizes depend on wsize/rsize and max requests */
18081808
if (server->noautotune) {
@@ -1860,9 +1860,7 @@ ipv4_connect(struct TCP_Server_Info *server)
18601860
smb_buf = (struct smb_hdr *)ses_init_buf;
18611861
/* sizeof RFC1002_SESSION_REQUEST with no scope */
18621862
smb_buf->smb_buf_length = 0x81000044;
1863-
rc = smb_send(socket, smb_buf, 0x44,
1864-
(struct sockaddr *) &server->addr.sockAddr,
1865-
server->noblocksnd);
1863+
rc = smb_send(server, smb_buf, 0x44);
18661864
kfree(ses_init_buf);
18671865
msleep(1); /* RFC1001 layer in at least one server
18681866
requires very short break before negprot
@@ -1955,7 +1953,7 @@ ipv6_connect(struct TCP_Server_Info *server)
19551953
* user space buffer
19561954
*/
19571955
socket->sk->sk_rcvtimeo = 7 * HZ;
1958-
socket->sk->sk_sndtimeo = 3 * HZ;
1956+
socket->sk->sk_sndtimeo = 5 * HZ;
19591957
server->ssocket = socket;
19601958

19611959
return rc;

‎fs/cifs/dir.c‎

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ build_path_from_dentry(struct dentry *direntry)
129129
return full_path;
130130
}
131131

132+
static void setup_cifs_dentry(struct cifsTconInfo *tcon,
133+
struct dentry *direntry,
134+
struct inode *newinode)
135+
{
136+
if (tcon->nocase)
137+
direntry->d_op = &cifs_ci_dentry_ops;
138+
else
139+
direntry->d_op = &cifs_dentry_ops;
140+
d_instantiate(direntry, newinode);
141+
}
142+
132143
/* Inode operations in similar order to how they appear in Linux file fs.h */
133144

134145
int
@@ -139,29 +150,31 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
139150
int xid;
140151
int create_options = CREATE_NOT_DIR;
141152
int oplock = 0;
153+
/* BB below access is too much for the mknod to request */
142154
int desiredAccess = GENERIC_READ | GENERIC_WRITE;
143155
__u16 fileHandle;
144156
struct cifs_sb_info *cifs_sb;
145-
struct cifsTconInfo *pTcon;
157+
struct cifsTconInfo *tcon;
146158
char *full_path = NULL;
147159
FILE_ALL_INFO *buf = NULL;
148160
struct inode *newinode = NULL;
149-
struct cifsFileInfo *pCifsFile = NULL;
150161
struct cifsInodeInfo *pCifsInode;
151162
int disposition = FILE_OVERWRITE_IF;
152163
bool write_only = false;
153164

154165
xid = GetXid();
155166

156167
cifs_sb = CIFS_SB(inode->i_sb);
157-
pTcon = cifs_sb->tcon;
168+
tcon = cifs_sb->tcon;
158169

159170
full_path = build_path_from_dentry(direntry);
160171
if (full_path == NULL) {
161172
FreeXid(xid);
162173
return -ENOMEM;
163174
}
164175

176+
mode &= ~current->fs->umask;
177+
165178
if (nd && (nd->flags & LOOKUP_OPEN)) {
166179
int oflags = nd->intent.open.flags;
167180

@@ -196,17 +209,15 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
196209
return -ENOMEM;
197210
}
198211

199-
mode &= ~current->fs->umask;
200-
201212
/*
202213
* if we're not using unix extensions, see if we need to set
203214
* ATTR_READONLY on the create call
204215
*/
205-
if (!pTcon->unix_ext && (mode & S_IWUGO) == 0)
216+
if (!tcon->unix_ext && (mode & S_IWUGO) == 0)
206217
create_options |= CREATE_OPTION_READONLY;
207218

208219
if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS)
209-
rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
220+
rc = CIFSSMBOpen(xid, tcon, full_path, disposition,
210221
desiredAccess, create_options,
211222
&fileHandle, &oplock, buf, cifs_sb->local_nls,
212223
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
@@ -215,7 +226,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
215226

216227
if (rc == -EIO) {
217228
/* old server, retry the open legacy style */
218-
rc = SMBLegacyOpen(xid, pTcon, full_path, disposition,
229+
rc = SMBLegacyOpen(xid, tcon, full_path, disposition,
219230
desiredAccess, create_options,
220231
&fileHandle, &oplock, buf, cifs_sb->local_nls,
221232
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
@@ -225,7 +236,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
225236
} else {
226237
/* If Open reported that we actually created a file
227238
then we now have to set the mode if possible */
228-
if ((pTcon->unix_ext) && (oplock & CIFS_CREATE_ACTION)) {
239+
if ((tcon->unix_ext) && (oplock & CIFS_CREATE_ACTION)) {
229240
struct cifs_unix_set_info_args args = {
230241
.mode = mode,
231242
.ctime = NO_CHANGE_64,
@@ -244,20 +255,20 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
244255
args.uid = NO_CHANGE_64;
245256
args.gid = NO_CHANGE_64;
246257
}
247-
CIFSSMBUnixSetInfo(xid, pTcon, full_path, &args,
258+
CIFSSMBUnixSetInfo(xid, tcon, full_path, &args,
248259
cifs_sb->local_nls,
249260
cifs_sb->mnt_cifs_flags &
250261
CIFS_MOUNT_MAP_SPECIAL_CHR);
251262
} else {
252263
/* BB implement mode setting via Windows security
253264
descriptors e.g. */
254-
/* CIFSSMBWinSetPerms(xid,pTcon,path,mode,-1,-1,nls);*/
265+
/* CIFSSMBWinSetPerms(xid,tcon,path,mode,-1,-1,nls);*/
255266

256267
/* Could set r/o dos attribute if mode & 0222 == 0 */
257268
}
258269

259270
/* server might mask mode so we have to query for it */
260-
if (pTcon->unix_ext)
271+
if (tcon->unix_ext)
261272
rc = cifs_get_inode_info_unix(&newinode, full_path,
262273
inode->i_sb, xid);
263274
else {
@@ -283,22 +294,17 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
283294
}
284295

285296
if (rc != 0) {
286-
cFYI(1,
287-
("Create worked but get_inode_info failed rc = %d",
288-
rc));
289-
} else {
290-
if (pTcon->nocase)
291-
direntry->d_op = &cifs_ci_dentry_ops;
292-
else
293-
direntry->d_op = &cifs_dentry_ops;
294-
d_instantiate(direntry, newinode);
295-
}
297+
cFYI(1, ("Create worked, get_inode_info failed rc = %d",
298+
rc));
299+
} else
300+
setup_cifs_dentry(tcon, direntry, newinode);
301+
296302
if ((nd == NULL /* nfsd case - nfs srv does not set nd */) ||
297303
(!(nd->flags & LOOKUP_OPEN))) {
298304
/* mknod case - do not leave file open */
299-
CIFSSMBClose(xid, pTcon, fileHandle);
305+
CIFSSMBClose(xid, tcon, fileHandle);
300306
} else if (newinode) {
301-
pCifsFile =
307+
struct cifsFileInfo *pCifsFile =
302308
kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
303309

304310
if (pCifsFile == NULL)
@@ -316,7 +322,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
316322
/* set the following in open now
317323
pCifsFile->pfile = file; */
318324
write_lock(&GlobalSMBSeslock);
319-
list_add(&pCifsFile->tlist, &pTcon->openFileList);
325+
list_add(&pCifsFile->tlist, &tcon->openFileList);
320326
pCifsInode = CIFS_I(newinode);
321327
if (pCifsInode) {
322328
/* if readable file instance put first in list*/

‎fs/cifs/inode.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,11 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
12851285
cifsInode = CIFS_I(direntry->d_inode);
12861286
cifsInode->time = 0; /* force revalidate to go get info when
12871287
needed */
1288+
1289+
cifsInode = CIFS_I(inode);
1290+
cifsInode->time = 0; /* force revalidate to get parent dir info
1291+
since cached search results now invalid */
1292+
12881293
direntry->d_inode->i_ctime = inode->i_ctime = inode->i_mtime =
12891294
current_fs_time(inode->i_sb);
12901295

0 commit comments

Comments
 (0)