Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
790fe579
Commit
790fe579
authored
Jul 07, 2007
by
Steve French
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CIFS] more whitespace cleanup
Signed-off-by:
Steve French
<
sfrench@us.ibm.com
>
parent
6dc0f87e
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
544 additions
and
538 deletions
+544
-538
fs/cifs/cifsfs.c
fs/cifs/cifsfs.c
+9
-9
fs/cifs/cifssmb.c
fs/cifs/cifssmb.c
+270
-270
fs/cifs/misc.c
fs/cifs/misc.c
+32
-32
fs/cifs/netmisc.c
fs/cifs/netmisc.c
+9
-9
fs/cifs/readdir.c
fs/cifs/readdir.c
+91
-88
fs/cifs/sess.c
fs/cifs/sess.c
+114
-111
fs/cifs/smbencrypt.c
fs/cifs/smbencrypt.c
+19
-19
No files found.
fs/cifs/cifsfs.c
View file @
790fe579
...
@@ -98,7 +98,7 @@ cifs_read_super(struct super_block *sb, void *data,
...
@@ -98,7 +98,7 @@ cifs_read_super(struct super_block *sb, void *data,
/* BB should we make this contingent on mount parm? */
/* BB should we make this contingent on mount parm? */
sb
->
s_flags
|=
MS_NODIRATIME
|
MS_NOATIME
;
sb
->
s_flags
|=
MS_NODIRATIME
|
MS_NOATIME
;
sb
->
s_fs_info
=
kzalloc
(
sizeof
(
struct
cifs_sb_info
),
GFP_KERNEL
);
sb
->
s_fs_info
=
kzalloc
(
sizeof
(
struct
cifs_sb_info
),
GFP_KERNEL
);
cifs_sb
=
CIFS_SB
(
sb
);
cifs_sb
=
CIFS_SB
(
sb
);
if
(
cifs_sb
==
NULL
)
if
(
cifs_sb
==
NULL
)
return
-
ENOMEM
;
return
-
ENOMEM
;
...
@@ -119,7 +119,8 @@ cifs_read_super(struct super_block *sb, void *data,
...
@@ -119,7 +119,8 @@ cifs_read_super(struct super_block *sb, void *data,
sb
->
s_export_op
=
&
cifs_export_ops
;
sb
->
s_export_op
=
&
cifs_export_ops
;
#endif
/* EXPERIMENTAL */
#endif
/* EXPERIMENTAL */
/* if (cifs_sb->tcon->ses->server->maxBuf > MAX_CIFS_HDR_SIZE + 512)
/* if (cifs_sb->tcon->ses->server->maxBuf > MAX_CIFS_HDR_SIZE + 512)
sb->s_blocksize = cifs_sb->tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; */
sb->s_blocksize =
cifs_sb->tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; */
#ifdef CONFIG_CIFS_QUOTA
#ifdef CONFIG_CIFS_QUOTA
sb
->
s_qcop
=
&
cifs_quotactl_ops
;
sb
->
s_qcop
=
&
cifs_quotactl_ops
;
#endif
#endif
...
@@ -164,7 +165,7 @@ cifs_put_super(struct super_block *sb)
...
@@ -164,7 +165,7 @@ cifs_put_super(struct super_block *sb)
cFYI
(
1
,
(
"In cifs_put_super"
));
cFYI
(
1
,
(
"In cifs_put_super"
));
cifs_sb
=
CIFS_SB
(
sb
);
cifs_sb
=
CIFS_SB
(
sb
);
if
(
cifs_sb
==
NULL
)
{
if
(
cifs_sb
==
NULL
)
{
cFYI
(
1
,(
"Empty cifs superblock info passed to unmount"
));
cFYI
(
1
,
(
"Empty cifs superblock info passed to unmount"
));
return
;
return
;
}
}
rc
=
cifs_umount
(
sb
,
cifs_sb
);
rc
=
cifs_umount
(
sb
,
cifs_sb
);
...
@@ -217,8 +218,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
...
@@ -217,8 +218,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
bypassed it because we detected that this was an older LANMAN sess */
bypassed it because we detected that this was an older LANMAN sess */
if
(
rc
)
if
(
rc
)
rc
=
SMBOldQFSInfo
(
xid
,
pTcon
,
buf
);
rc
=
SMBOldQFSInfo
(
xid
,
pTcon
,
buf
);
/*
/* int f_type;
int f_type;
__fsid_t f_fsid;
__fsid_t f_fsid;
int f_namelen; */
int f_namelen; */
/* BB get from info in tcon struct at mount time call to QFSAttrInfo */
/* BB get from info in tcon struct at mount time call to QFSAttrInfo */
...
...
fs/cifs/cifssmb.c
View file @
790fe579
...
@@ -84,17 +84,17 @@ static struct {
...
@@ -84,17 +84,17 @@ static struct {
/* Mark as invalid, all open files on tree connections since they
/* Mark as invalid, all open files on tree connections since they
were closed when session to server was lost */
were closed when session to server was lost */
static
void
mark_open_files_invalid
(
struct
cifsTconInfo
*
pTcon
)
static
void
mark_open_files_invalid
(
struct
cifsTconInfo
*
pTcon
)
{
{
struct
cifsFileInfo
*
open_file
=
NULL
;
struct
cifsFileInfo
*
open_file
=
NULL
;
struct
list_head
*
tmp
;
struct
list_head
*
tmp
;
struct
list_head
*
tmp1
;
struct
list_head
*
tmp1
;
/* list all files open on tree connection and mark them invalid */
/* list all files open on tree connection and mark them invalid */
write_lock
(
&
GlobalSMBSeslock
);
write_lock
(
&
GlobalSMBSeslock
);
list_for_each_safe
(
tmp
,
tmp1
,
&
pTcon
->
openFileList
)
{
list_for_each_safe
(
tmp
,
tmp1
,
&
pTcon
->
openFileList
)
{
open_file
=
list_entry
(
tmp
,
struct
cifsFileInfo
,
tlist
);
open_file
=
list_entry
(
tmp
,
struct
cifsFileInfo
,
tlist
);
if
(
open_file
)
{
if
(
open_file
)
{
open_file
->
invalidHandle
=
TRUE
;
open_file
->
invalidHandle
=
TRUE
;
}
}
}
}
...
@@ -113,20 +113,20 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
...
@@ -113,20 +113,20 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
/* SMBs NegProt, SessSetup, uLogoff do not have tcon yet so
/* SMBs NegProt, SessSetup, uLogoff do not have tcon yet so
check for tcp and smb session status done differently
check for tcp and smb session status done differently
for those three - in the calling routine */
for those three - in the calling routine */
if
(
tcon
)
{
if
(
tcon
)
{
if
(
tcon
->
tidStatus
==
CifsExiting
)
{
if
(
tcon
->
tidStatus
==
CifsExiting
)
{
/* only tree disconnect, open, and write,
/* only tree disconnect, open, and write,
(and ulogoff which does not have tcon)
(and ulogoff which does not have tcon)
are allowed as we start force umount */
are allowed as we start force umount */
if
((
smb_command
!=
SMB_COM_WRITE_ANDX
)
&&
if
((
smb_command
!=
SMB_COM_WRITE_ANDX
)
&&
(
smb_command
!=
SMB_COM_OPEN_ANDX
)
&&
(
smb_command
!=
SMB_COM_OPEN_ANDX
)
&&
(
smb_command
!=
SMB_COM_TREE_DISCONNECT
))
{
(
smb_command
!=
SMB_COM_TREE_DISCONNECT
))
{
cFYI
(
1
,(
"can not send cmd %d while umounting"
,
cFYI
(
1
,
(
"can not send cmd %d while umounting"
,
smb_command
));
smb_command
));
return
-
ENODEV
;
return
-
ENODEV
;
}
}
}
}
if
((
tcon
->
ses
)
&&
(
tcon
->
ses
->
status
!=
CifsExiting
)
&&
if
((
tcon
->
ses
)
&&
(
tcon
->
ses
->
status
!=
CifsExiting
)
&&
(
tcon
->
ses
->
server
)){
(
tcon
->
ses
->
server
)){
struct
nls_table
*
nls_codepage
;
struct
nls_table
*
nls_codepage
;
/* Give Demultiplex thread up to 10 seconds to
/* Give Demultiplex thread up to 10 seconds to
...
@@ -135,9 +135,9 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
...
@@ -135,9 +135,9 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
while
(
tcon
->
ses
->
server
->
tcpStatus
==
CifsNeedReconnect
)
{
while
(
tcon
->
ses
->
server
->
tcpStatus
==
CifsNeedReconnect
)
{
wait_event_interruptible_timeout
(
tcon
->
ses
->
server
->
response_q
,
wait_event_interruptible_timeout
(
tcon
->
ses
->
server
->
response_q
,
(
tcon
->
ses
->
server
->
tcpStatus
==
CifsGood
),
10
*
HZ
);
(
tcon
->
ses
->
server
->
tcpStatus
==
CifsGood
),
10
*
HZ
);
if
(
tcon
->
ses
->
server
->
tcpStatus
==
CifsNeedReconnect
)
{
if
(
tcon
->
ses
->
server
->
tcpStatus
==
CifsNeedReconnect
)
{
/* on "soft" mounts we wait once */
/* on "soft" mounts we wait once */
if
((
tcon
->
retry
==
FALSE
)
||
if
((
tcon
->
retry
==
FALSE
)
||
(
tcon
->
ses
->
status
==
CifsExiting
))
{
(
tcon
->
ses
->
status
==
CifsExiting
))
{
cFYI
(
1
,(
"gave up waiting on reconnect in smb_init"
));
cFYI
(
1
,(
"gave up waiting on reconnect in smb_init"
));
return
-
EHOSTDOWN
;
return
-
EHOSTDOWN
;
...
@@ -153,10 +153,10 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
...
@@ -153,10 +153,10 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
/* need to prevent multiple threads trying to
/* need to prevent multiple threads trying to
simultaneously reconnect the same SMB session */
simultaneously reconnect the same SMB session */
down
(
&
tcon
->
ses
->
sesSem
);
down
(
&
tcon
->
ses
->
sesSem
);
if
(
tcon
->
ses
->
status
==
CifsNeedReconnect
)
if
(
tcon
->
ses
->
status
==
CifsNeedReconnect
)
rc
=
cifs_setup_session
(
0
,
tcon
->
ses
,
rc
=
cifs_setup_session
(
0
,
tcon
->
ses
,
nls_codepage
);
nls_codepage
);
if
(
!
rc
&&
(
tcon
->
tidStatus
==
CifsNeedReconnect
))
{
if
(
!
rc
&&
(
tcon
->
tidStatus
==
CifsNeedReconnect
))
{
mark_open_files_invalid
(
tcon
);
mark_open_files_invalid
(
tcon
);
rc
=
CIFSTCon
(
0
,
tcon
->
ses
,
tcon
->
treeName
,
rc
=
CIFSTCon
(
0
,
tcon
->
ses
,
tcon
->
treeName
,
tcon
,
nls_codepage
);
tcon
,
nls_codepage
);
...
@@ -170,7 +170,7 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
...
@@ -170,7 +170,7 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
/* BB FIXME add code to check if wsize needs
/* BB FIXME add code to check if wsize needs
update due to negotiated smb buffer size
update due to negotiated smb buffer size
shrinking */
shrinking */
if
(
rc
==
0
)
if
(
rc
==
0
)
atomic_inc
(
&
tconInfoReconnectCount
);
atomic_inc
(
&
tconInfoReconnectCount
);
cFYI
(
1
,
(
"reconnect tcon rc = %d"
,
rc
));
cFYI
(
1
,
(
"reconnect tcon rc = %d"
,
rc
));
...
@@ -200,7 +200,7 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
...
@@ -200,7 +200,7 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
return
-
EIO
;
return
-
EIO
;
}
}
}
}
if
(
rc
)
if
(
rc
)
return
rc
;
return
rc
;
*
request_buf
=
cifs_small_buf_get
();
*
request_buf
=
cifs_small_buf_get
();
...
@@ -211,7 +211,7 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
...
@@ -211,7 +211,7 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
header_assemble
((
struct
smb_hdr
*
)
*
request_buf
,
smb_command
,
tcon
,
wct
);
header_assemble
((
struct
smb_hdr
*
)
*
request_buf
,
smb_command
,
tcon
,
wct
);
if
(
tcon
!=
NULL
)
if
(
tcon
!=
NULL
)
cifs_stats_inc
(
&
tcon
->
num_smbs_sent
);
cifs_stats_inc
(
&
tcon
->
num_smbs_sent
);
return
rc
;
return
rc
;
...
@@ -225,7 +225,7 @@ small_smb_init_no_tc(const int smb_command, const int wct,
...
@@ -225,7 +225,7 @@ small_smb_init_no_tc(const int smb_command, const int wct,
struct
smb_hdr
*
buffer
;
struct
smb_hdr
*
buffer
;
rc
=
small_smb_init
(
smb_command
,
wct
,
NULL
,
request_buf
);
rc
=
small_smb_init
(
smb_command
,
wct
,
NULL
,
request_buf
);
if
(
rc
)
if
(
rc
)
return
rc
;
return
rc
;
buffer
=
(
struct
smb_hdr
*
)
*
request_buf
;
buffer
=
(
struct
smb_hdr
*
)
*
request_buf
;
...
@@ -254,21 +254,21 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
...
@@ -254,21 +254,21 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
/* SMBs NegProt, SessSetup, uLogoff do not have tcon yet so
/* SMBs NegProt, SessSetup, uLogoff do not have tcon yet so
check for tcp and smb session status done differently
check for tcp and smb session status done differently
for those three - in the calling routine */
for those three - in the calling routine */
if
(
tcon
)
{
if
(
tcon
)
{
if
(
tcon
->
tidStatus
==
CifsExiting
)
{
if
(
tcon
->
tidStatus
==
CifsExiting
)
{
/* only tree disconnect, open, and write,
/* only tree disconnect, open, and write,
(and ulogoff which does not have tcon)
(and ulogoff which does not have tcon)
are allowed as we start force umount */
are allowed as we start force umount */
if
((
smb_command
!=
SMB_COM_WRITE_ANDX
)
&&
if
((
smb_command
!=
SMB_COM_WRITE_ANDX
)
&&
(
smb_command
!=
SMB_COM_OPEN_ANDX
)
&&
(
smb_command
!=
SMB_COM_OPEN_ANDX
)
&&
(
smb_command
!=
SMB_COM_TREE_DISCONNECT
))
{
(
smb_command
!=
SMB_COM_TREE_DISCONNECT
))
{
cFYI
(
1
,(
"can not send cmd %d while umounting"
,
cFYI
(
1
,
(
"can not send cmd %d while umounting"
,
smb_command
));
smb_command
));
return
-
ENODEV
;
return
-
ENODEV
;
}
}
}
}
if
((
tcon
->
ses
)
&&
(
tcon
->
ses
->
status
!=
CifsExiting
)
&&
if
((
tcon
->
ses
)
&&
(
tcon
->
ses
->
status
!=
CifsExiting
)
&&
(
tcon
->
ses
->
server
)){
(
tcon
->
ses
->
server
)){
struct
nls_table
*
nls_codepage
;
struct
nls_table
*
nls_codepage
;
/* Give Demultiplex thread up to 10 seconds to
/* Give Demultiplex thread up to 10 seconds to
...
@@ -277,10 +277,10 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
...
@@ -277,10 +277,10 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
while
(
tcon
->
ses
->
server
->
tcpStatus
==
CifsNeedReconnect
)
{
while
(
tcon
->
ses
->
server
->
tcpStatus
==
CifsNeedReconnect
)
{
wait_event_interruptible_timeout
(
tcon
->
ses
->
server
->
response_q
,
wait_event_interruptible_timeout
(
tcon
->
ses
->
server
->
response_q
,
(
tcon
->
ses
->
server
->
tcpStatus
==
CifsGood
),
10
*
HZ
);
(
tcon
->
ses
->
server
->
tcpStatus
==
CifsGood
),
10
*
HZ
);
if
(
tcon
->
ses
->
server
->
tcpStatus
==
if
(
tcon
->
ses
->
server
->
tcpStatus
==
CifsNeedReconnect
)
{
CifsNeedReconnect
)
{
/* on "soft" mounts we wait once */
/* on "soft" mounts we wait once */
if
((
tcon
->
retry
==
FALSE
)
||
if
((
tcon
->
retry
==
FALSE
)
||
(
tcon
->
ses
->
status
==
CifsExiting
))
{
(
tcon
->
ses
->
status
==
CifsExiting
))
{
cFYI
(
1
,(
"gave up waiting on reconnect in smb_init"
));
cFYI
(
1
,(
"gave up waiting on reconnect in smb_init"
));
return
-
EHOSTDOWN
;
return
-
EHOSTDOWN
;
...
@@ -296,10 +296,10 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
...
@@ -296,10 +296,10 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
/* need to prevent multiple threads trying to
/* need to prevent multiple threads trying to
simultaneously reconnect the same SMB session */
simultaneously reconnect the same SMB session */
down
(
&
tcon
->
ses
->
sesSem
);
down
(
&
tcon
->
ses
->
sesSem
);
if
(
tcon
->
ses
->
status
==
CifsNeedReconnect
)
if
(
tcon
->
ses
->
status
==
CifsNeedReconnect
)
rc
=
cifs_setup_session
(
0
,
tcon
->
ses
,
rc
=
cifs_setup_session
(
0
,
tcon
->
ses
,
nls_codepage
);
nls_codepage
);
if
(
!
rc
&&
(
tcon
->
tidStatus
==
CifsNeedReconnect
))
{
if
(
!
rc
&&
(
tcon
->
tidStatus
==
CifsNeedReconnect
))
{
mark_open_files_invalid
(
tcon
);
mark_open_files_invalid
(
tcon
);
rc
=
CIFSTCon
(
0
,
tcon
->
ses
,
tcon
->
treeName
,
rc
=
CIFSTCon
(
0
,
tcon
->
ses
,
tcon
->
treeName
,
tcon
,
nls_codepage
);
tcon
,
nls_codepage
);
...
@@ -313,7 +313,7 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
...
@@ -313,7 +313,7 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
/* BB FIXME add code to check if wsize needs
/* BB FIXME add code to check if wsize needs
update due to negotiated smb buffer size
update due to negotiated smb buffer size
shrinking */
shrinking */
if
(
rc
==
0
)
if
(
rc
==
0
)
atomic_inc
(
&
tconInfoReconnectCount
);
atomic_inc
(
&
tconInfoReconnectCount
);
cFYI
(
1
,
(
"reconnect tcon rc = %d"
,
rc
));
cFYI
(
1
,
(
"reconnect tcon rc = %d"
,
rc
));
...
@@ -343,7 +343,7 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
...
@@ -343,7 +343,7 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
return
-
EIO
;
return
-
EIO
;
}
}
}
}
if
(
rc
)
if
(
rc
)
return
rc
;
return
rc
;
*
request_buf
=
cifs_buf_get
();
*
request_buf
=
cifs_buf_get
();
...
@@ -355,13 +355,13 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
...
@@ -355,13 +355,13 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
/* potential retries of smb operations it turns out we can determine */
/* potential retries of smb operations it turns out we can determine */
/* from the mid flags when the request buffer can be resent without */
/* from the mid flags when the request buffer can be resent without */
/* having to use a second distinct buffer for the response */
/* having to use a second distinct buffer for the response */
if
(
response_buf
)
if
(
response_buf
)
*
response_buf
=
*
request_buf
;
*
response_buf
=
*
request_buf
;
header_assemble
((
struct
smb_hdr
*
)
*
request_buf
,
smb_command
,
tcon
,
header_assemble
((
struct
smb_hdr
*
)
*
request_buf
,
smb_command
,
tcon
,
wct
/*wct */
);
wct
/*wct */
);
if
(
tcon
!=
NULL
)
if
(
tcon
!=
NULL
)
cifs_stats_inc
(
&
tcon
->
num_smbs_sent
);
cifs_stats_inc
(
&
tcon
->
num_smbs_sent
);
return
rc
;
return
rc
;
...
@@ -375,19 +375,19 @@ static int validate_t2(struct smb_t2_rsp * pSMB)
...
@@ -375,19 +375,19 @@ static int validate_t2(struct smb_t2_rsp * pSMB)
/* check for plausible wct, bcc and t2 data and parm sizes */
/* check for plausible wct, bcc and t2 data and parm sizes */
/* check for parm and data offset going beyond end of smb */
/* check for parm and data offset going beyond end of smb */
if
(
pSMB
->
hdr
.
WordCount
>=
10
)
{
if
(
pSMB
->
hdr
.
WordCount
>=
10
)
{
if
((
le16_to_cpu
(
pSMB
->
t2_rsp
.
ParameterOffset
)
<=
1024
)
&&
if
((
le16_to_cpu
(
pSMB
->
t2_rsp
.
ParameterOffset
)
<=
1024
)
&&
(
le16_to_cpu
(
pSMB
->
t2_rsp
.
DataOffset
)
<=
1024
))
{
(
le16_to_cpu
(
pSMB
->
t2_rsp
.
DataOffset
)
<=
1024
))
{
/* check that bcc is at least as big as parms + data */
/* check that bcc is at least as big as parms + data */
/* check that bcc is less than negotiated smb buffer */
/* check that bcc is less than negotiated smb buffer */
total_size
=
le16_to_cpu
(
pSMB
->
t2_rsp
.
ParameterCount
);
total_size
=
le16_to_cpu
(
pSMB
->
t2_rsp
.
ParameterCount
);
if
(
total_size
<
512
)
{
if
(
total_size
<
512
)
{
total_size
+=
le16_to_cpu
(
pSMB
->
t2_rsp
.
DataCount
);
total_size
+=
le16_to_cpu
(
pSMB
->
t2_rsp
.
DataCount
);
/* BCC le converted in SendReceive */
/* BCC le converted in SendReceive */
pBCC
=
(
pSMB
->
hdr
.
WordCount
*
2
)
+
pBCC
=
(
pSMB
->
hdr
.
WordCount
*
2
)
+
sizeof
(
struct
smb_hdr
)
+
sizeof
(
struct
smb_hdr
)
+
(
char
*
)
pSMB
;
(
char
*
)
pSMB
;
if
((
total_size
<=
(
*
(
u16
*
)
pBCC
))
&&
if
((
total_size
<=
(
*
(
u16
*
)
pBCC
))
&&
(
total_size
<
(
total_size
<
CIFSMaxBufSize
+
MAX_CIFS_HDR_SIZE
))
{
CIFSMaxBufSize
+
MAX_CIFS_HDR_SIZE
))
{
return
0
;
return
0
;
...
@@ -413,7 +413,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
...
@@ -413,7 +413,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
unsigned
int
secFlags
;
unsigned
int
secFlags
;
u16
dialect
;
u16
dialect
;
if
(
ses
->
server
)
if
(
ses
->
server
)
server
=
ses
->
server
;
server
=
ses
->
server
;
else
{
else
{
rc
=
-
EIO
;
rc
=
-
EIO
;
...
@@ -425,7 +425,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
...
@@ -425,7 +425,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
return
rc
;
return
rc
;
/* if any of auth flags (ie not sign or seal) are overriden use them */
/* if any of auth flags (ie not sign or seal) are overriden use them */
if
(
ses
->
overrideSecFlg
&
(
~
(
CIFSSEC_MUST_SIGN
|
CIFSSEC_MUST_SEAL
)))
if
(
ses
->
overrideSecFlg
&
(
~
(
CIFSSEC_MUST_SIGN
|
CIFSSEC_MUST_SEAL
)))
secFlags
=
ses
->
overrideSecFlg
;
/* BB FIXME fix sign flags? */
secFlags
=
ses
->
overrideSecFlg
;
/* BB FIXME fix sign flags? */
else
/* if override flags set only sign/seal OR them with global auth */
else
/* if override flags set only sign/seal OR them with global auth */
secFlags
=
extended_security
|
ses
->
overrideSecFlg
;
secFlags
=
extended_security
|
ses
->
overrideSecFlg
;
...
@@ -452,22 +452,22 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
...
@@ -452,22 +452,22 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
goto
neg_err_exit
;
goto
neg_err_exit
;
dialect
=
le16_to_cpu
(
pSMBr
->
DialectIndex
);
dialect
=
le16_to_cpu
(
pSMBr
->
DialectIndex
);
cFYI
(
1
,(
"Dialect: %d"
,
dialect
));
cFYI
(
1
,
(
"Dialect: %d"
,
dialect
));
/* Check wct = 1 error case */
/* Check wct = 1 error case */
if
((
pSMBr
->
hdr
.
WordCount
<
13
)
||
(
dialect
==
BAD_PROT
))
{
if
((
pSMBr
->
hdr
.
WordCount
<
13
)
||
(
dialect
==
BAD_PROT
))
{
/* core returns wct = 1, but we do not ask for core - otherwise
/* core returns wct = 1, but we do not ask for core - otherwise
small wct just comes when dialect index is -1 indicating we
small wct just comes when dialect index is -1 indicating we
could not negotiate a common dialect */
could not negotiate a common dialect */
rc
=
-
EOPNOTSUPP
;
rc
=
-
EOPNOTSUPP
;
goto
neg_err_exit
;
goto
neg_err_exit
;
#ifdef CONFIG_CIFS_WEAK_PW_HASH
#ifdef CONFIG_CIFS_WEAK_PW_HASH
}
else
if
((
pSMBr
->
hdr
.
WordCount
==
13
)
}
else
if
((
pSMBr
->
hdr
.
WordCount
==
13
)
&&
((
dialect
==
LANMAN_PROT
)
&&
((
dialect
==
LANMAN_PROT
)
||
(
dialect
==
LANMAN2_PROT
)))
{
||
(
dialect
==
LANMAN2_PROT
)))
{
__s16
tmp
;
__s16
tmp
;
struct
lanman_neg_rsp
*
rsp
=
(
struct
lanman_neg_rsp
*
)
pSMBr
;
struct
lanman_neg_rsp
*
rsp
=
(
struct
lanman_neg_rsp
*
)
pSMBr
;
if
((
secFlags
&
CIFSSEC_MAY_LANMAN
)
||
if
((
secFlags
&
CIFSSEC_MAY_LANMAN
)
||
(
secFlags
&
CIFSSEC_MAY_PLNTXT
))
(
secFlags
&
CIFSSEC_MAY_PLNTXT
))
server
->
secType
=
LANMAN
;
server
->
secType
=
LANMAN
;
else
{
else
{
...
@@ -483,7 +483,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
...
@@ -483,7 +483,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
GETU32
(
server
->
sessid
)
=
le32_to_cpu
(
rsp
->
SessionKey
);
GETU32
(
server
->
sessid
)
=
le32_to_cpu
(
rsp
->
SessionKey
);
/* even though we do not use raw we might as well set this
/* even though we do not use raw we might as well set this
accurately, in case we ever find a need for it */
accurately, in case we ever find a need for it */
if
((
le16_to_cpu
(
rsp
->
RawMode
)
&
RAW_ENABLE
)
==
RAW_ENABLE
)
{
if
((
le16_to_cpu
(
rsp
->
RawMode
)
&
RAW_ENABLE
)
==
RAW_ENABLE
)
{
server
->
maxRw
=
0xFF00
;
server
->
maxRw
=
0xFF00
;
server
->
capabilities
=
CAP_MPX_MODE
|
CAP_RAW_MODE
;
server
->
capabilities
=
CAP_MPX_MODE
|
CAP_RAW_MODE
;
}
else
{
}
else
{
...
@@ -511,16 +511,16 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
...
@@ -511,16 +511,16 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
seconds
=
val
<
0
?
-
val
:
val
;
seconds
=
val
<
0
?
-
val
:
val
;
result
=
(
seconds
/
MIN_TZ_ADJ
)
*
MIN_TZ_ADJ
;
result
=
(
seconds
/
MIN_TZ_ADJ
)
*
MIN_TZ_ADJ
;
remain
=
seconds
%
MIN_TZ_ADJ
;
remain
=
seconds
%
MIN_TZ_ADJ
;
if
(
remain
>=
(
MIN_TZ_ADJ
/
2
))
if
(
remain
>=
(
MIN_TZ_ADJ
/
2
))
result
+=
MIN_TZ_ADJ
;
result
+=
MIN_TZ_ADJ
;
if
(
val
<
0
)
if
(
val
<
0
)
result
=
-
result
;
result
=
-
result
;
server
->
timeAdj
=
result
;
server
->
timeAdj
=
result
;
}
else
{
}
else
{
server
->
timeAdj
=
(
int
)
tmp
;
server
->
timeAdj
=
(
int
)
tmp
;
server
->
timeAdj
*=
60
;
/* also in seconds */
server
->
timeAdj
*=
60
;
/* also in seconds */
}
}
cFYI
(
1
,(
"server->timeAdj: %d seconds"
,
server
->
timeAdj
));
cFYI
(
1
,
(
"server->timeAdj: %d seconds"
,
server
->
timeAdj
));
/* BB get server time for time conversions and add
/* BB get server time for time conversions and add
...
@@ -535,39 +535,39 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
...
@@ -535,39 +535,39 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
goto
neg_err_exit
;
goto
neg_err_exit
;
}
}
cFYI
(
1
,(
"LANMAN negotiated"
));
cFYI
(
1
,
(
"LANMAN negotiated"
));
/* we will not end up setting signing flags - as no signing
/* we will not end up setting signing flags - as no signing
was in LANMAN and server did not return the flags on */
was in LANMAN and server did not return the flags on */
goto
signing_check
;
goto
signing_check
;
#else
/* weak security disabled */
#else
/* weak security disabled */
}
else
if
(
pSMBr
->
hdr
.
WordCount
==
13
)
{
}
else
if
(
pSMBr
->
hdr
.
WordCount
==
13
)
{
cERROR
(
1
,(
"mount failed, cifs module not built "
cERROR
(
1
,(
"mount failed, cifs module not built "
"with CIFS_WEAK_PW_HASH support"
));
"with CIFS_WEAK_PW_HASH support"
));
rc
=
-
EOPNOTSUPP
;
rc
=
-
EOPNOTSUPP
;
#endif
/* WEAK_PW_HASH */
#endif
/* WEAK_PW_HASH */
goto
neg_err_exit
;
goto
neg_err_exit
;
}
else
if
(
pSMBr
->
hdr
.
WordCount
!=
17
)
{
}
else
if
(
pSMBr
->
hdr
.
WordCount
!=
17
)
{
/* unknown wct */
/* unknown wct */
rc
=
-
EOPNOTSUPP
;
rc
=
-
EOPNOTSUPP
;
goto
neg_err_exit
;
goto
neg_err_exit
;
}
}
/* else wct == 17 NTLM */
/* else wct == 17 NTLM */
server
->
secMode
=
pSMBr
->
SecurityMode
;
server
->
secMode
=
pSMBr
->
SecurityMode
;
if
((
server
->
secMode
&
SECMODE_USER
)
==
0
)
if
((
server
->
secMode
&
SECMODE_USER
)
==
0
)
cFYI
(
1
,(
"share mode security"
));
cFYI
(
1
,
(
"share mode security"
));
if
((
server
->
secMode
&
SECMODE_PW_ENCRYPT
)
==
0
)
if
((
server
->
secMode
&
SECMODE_PW_ENCRYPT
)
==
0
)
#ifdef CONFIG_CIFS_WEAK_PW_HASH
#ifdef CONFIG_CIFS_WEAK_PW_HASH
if
((
secFlags
&
CIFSSEC_MAY_PLNTXT
)
==
0
)
if
((
secFlags
&
CIFSSEC_MAY_PLNTXT
)
==
0
)
#endif
/* CIFS_WEAK_PW_HASH */
#endif
/* CIFS_WEAK_PW_HASH */
cERROR
(
1
,(
"Server requests plain text password"
cERROR
(
1
,(
"Server requests plain text password"
" but client support disabled"
));
" but client support disabled"
));
if
((
secFlags
&
CIFSSEC_MUST_NTLMV2
)
==
CIFSSEC_MUST_NTLMV2
)
if
((
secFlags
&
CIFSSEC_MUST_NTLMV2
)
==
CIFSSEC_MUST_NTLMV2
)
server
->
secType
=
NTLMv2
;
server
->
secType
=
NTLMv2
;
else
if
(
secFlags
&
CIFSSEC_MAY_NTLM
)
else
if
(
secFlags
&
CIFSSEC_MAY_NTLM
)
server
->
secType
=
NTLM
;
server
->
secType
=
NTLM
;
else
if
(
secFlags
&
CIFSSEC_MAY_NTLMV2
)
else
if
(
secFlags
&
CIFSSEC_MAY_NTLMV2
)
server
->
secType
=
NTLMv2
;
server
->
secType
=
NTLMv2
;
/* else krb5 ... any others ... */
/* else krb5 ... any others ... */
...
@@ -620,7 +620,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
...
@@ -620,7 +620,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
SecurityBlob
,
SecurityBlob
,
count
-
16
,
count
-
16
,
&
server
->
secType
);
&
server
->
secType
);
if
(
rc
==
1
)
{
if
(
rc
==
1
)
{
/* BB Need to fill struct for sessetup here */
/* BB Need to fill struct for sessetup here */
rc
=
-
EOPNOTSUPP
;
rc
=
-
EOPNOTSUPP
;
}
else
{
}
else
{
...
@@ -637,7 +637,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
...
@@ -637,7 +637,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
/* MUST_SIGN already includes the MAY_SIGN FLAG
/* MUST_SIGN already includes the MAY_SIGN FLAG
so if this is zero it means that signing is disabled */
so if this is zero it means that signing is disabled */
cFYI
(
1
,
(
"Signing disabled"
));
cFYI
(
1
,
(
"Signing disabled"
));
if
(
server
->
secMode
&
SECMODE_SIGN_REQUIRED
)
if
(
server
->
secMode
&
SECMODE_SIGN_REQUIRED
)
cERROR
(
1
,
(
"Server requires "
cERROR
(
1
,
(
"Server requires "
"/proc/fs/cifs/PacketSigningEnabled "
"/proc/fs/cifs/PacketSigningEnabled "
"to be on"
));
"to be on"
));
...
@@ -655,7 +655,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
...
@@ -655,7 +655,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
server
->
secMode
|=
SECMODE_SIGN_REQUIRED
;
server
->
secMode
|=
SECMODE_SIGN_REQUIRED
;
}
else
{
}
else
{
/* signing optional ie CIFSSEC_MAY_SIGN */
/* signing optional ie CIFSSEC_MAY_SIGN */
if
((
server
->
secMode
&
SECMODE_SIGN_REQUIRED
)
==
0
)
if
((
server
->
secMode
&
SECMODE_SIGN_REQUIRED
)
==
0
)
server
->
secMode
&=
server
->
secMode
&=
~
(
SECMODE_SIGN_ENABLED
|
SECMODE_SIGN_REQUIRED
);
~
(
SECMODE_SIGN_ENABLED
|
SECMODE_SIGN_REQUIRED
);
}
}
...
@@ -663,7 +663,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
...
@@ -663,7 +663,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
neg_err_exit:
neg_err_exit:
cifs_buf_release
(
pSMB
);
cifs_buf_release
(
pSMB
);
cFYI
(
1
,
(
"negprot rc %d"
,
rc
));
cFYI
(
1
,
(
"negprot rc %d"
,
rc
));
return
rc
;
return
rc
;
}
}
...
@@ -696,12 +696,12 @@ CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon)
...
@@ -696,12 +696,12 @@ CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon)
/* No need to return error on this operation if tid invalidated and
/* No need to return error on this operation if tid invalidated and
closed on server already e.g. due to tcp session crashing */
closed on server already e.g. due to tcp session crashing */
if
(
tcon
->
tidStatus
==
CifsNeedReconnect
)
{
if
(
tcon
->
tidStatus
==
CifsNeedReconnect
)
{
up
(
&
tcon
->
tconSem
);
up
(
&
tcon
->
tconSem
);
return
0
;
return
0
;
}
}
if
((
tcon
->
ses
==
NULL
)
||
(
tcon
->
ses
->
server
==
NULL
))
{
if
((
tcon
->
ses
==
NULL
)
||
(
tcon
->
ses
->
server
==
NULL
))
{
up
(
&
tcon
->
tconSem
);
up
(
&
tcon
->
tconSem
);
return
-
EIO
;
return
-
EIO
;
}
}
...
@@ -757,10 +757,10 @@ CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses)
...
@@ -757,10 +757,10 @@ CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses)
smb_buffer_response
=
(
struct
smb_hdr
*
)
pSMB
;
/* BB removeme BB */
smb_buffer_response
=
(
struct
smb_hdr
*
)
pSMB
;
/* BB removeme BB */
if
(
ses
->
server
)
{
if
(
ses
->
server
)
{
pSMB
->
hdr
.
Mid
=
GetNextMid
(
ses
->
server
);
pSMB
->
hdr
.
Mid
=
GetNextMid
(
ses
->
server
);
if
(
ses
->
server
->
secMode
&
if
(
ses
->
server
->
secMode
&
(
SECMODE_SIGN_REQUIRED
|
SECMODE_SIGN_ENABLED
))
(
SECMODE_SIGN_REQUIRED
|
SECMODE_SIGN_ENABLED
))
pSMB
->
hdr
.
Flags2
|=
SMBFLG2_SECURITY_SIGNATURE
;
pSMB
->
hdr
.
Flags2
|=
SMBFLG2_SECURITY_SIGNATURE
;
}
}
...
@@ -999,7 +999,7 @@ CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, __u32 posix_flags,
...
@@ -999,7 +999,7 @@ CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, __u32 posix_flags,
goto
psx_create_err
;
goto
psx_create_err
;
}
}
cFYI
(
1
,(
"copying inode info"
));
cFYI
(
1
,
(
"copying inode info"
));
rc
=
validate_t2
((
struct
smb_t2_rsp
*
)
pSMBr
);
rc
=
validate_t2
((
struct
smb_t2_rsp
*
)
pSMBr
);
if
(
rc
||
(
pSMBr
->
ByteCount
<
sizeof
(
OPEN_PSX_RSP
)))
{
if
(
rc
||
(
pSMBr
->
ByteCount
<
sizeof
(
OPEN_PSX_RSP
)))
{
...
@@ -1012,20 +1012,20 @@ CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, __u32 posix_flags,
...
@@ -1012,20 +1012,20 @@ CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, __u32 posix_flags,
+
le16_to_cpu
(
pSMBr
->
t2
.
DataOffset
));
+
le16_to_cpu
(
pSMBr
->
t2
.
DataOffset
));
*
pOplock
=
le16_to_cpu
(
psx_rsp
->
OplockFlags
);
*
pOplock
=
le16_to_cpu
(
psx_rsp
->
OplockFlags
);
if
(
netfid
)
if
(
netfid
)
*
netfid
=
psx_rsp
->
Fid
;
/* cifs fid stays in le */
*
netfid
=
psx_rsp
->
Fid
;
/* cifs fid stays in le */
/* Let caller know file was created so we can set the mode. */
/* Let caller know file was created so we can set the mode. */
/* Do we care about the CreateAction in any other cases? */
/* Do we care about the CreateAction in any other cases? */
if
(
cpu_to_le32
(
FILE_CREATE
)
==
psx_rsp
->
CreateAction
)
if
(
cpu_to_le32
(
FILE_CREATE
)
==
psx_rsp
->
CreateAction
)
*
pOplock
|=
CIFS_CREATE_ACTION
;
*
pOplock
|=
CIFS_CREATE_ACTION
;
/* check to make sure response data is there */
/* check to make sure response data is there */
if
(
psx_rsp
->
ReturnedLevel
!=
SMB_QUERY_FILE_UNIX_BASIC
)
{
if
(
psx_rsp
->
ReturnedLevel
!=
SMB_QUERY_FILE_UNIX_BASIC
)
{
pRetData
->
Type
=
-
1
;
/* unknown */
pRetData
->
Type
=
-
1
;
/* unknown */
#ifdef CONFIG_CIFS_DEBUG2
#ifdef CONFIG_CIFS_DEBUG2
cFYI
(
1
,(
"unknown type"
));
cFYI
(
1
,
(
"unknown type"
));
#endif
#endif
}
else
{
}
else
{
if
(
pSMBr
->
ByteCount
<
sizeof
(
OPEN_PSX_RSP
)
if
(
pSMBr
->
ByteCount
<
sizeof
(
OPEN_PSX_RSP
)
+
sizeof
(
FILE_UNIX_BASIC_INFO
))
{
+
sizeof
(
FILE_UNIX_BASIC_INFO
))
{
cERROR
(
1
,(
"Open response data too small"
));
cERROR
(
1
,(
"Open response data too small"
));
pRetData
->
Type
=
-
1
;
pRetData
->
Type
=
-
1
;
...
@@ -1072,7 +1072,7 @@ static __u16 convert_disposition(int disposition)
...
@@ -1072,7 +1072,7 @@ static __u16 convert_disposition(int disposition)
ofun
=
SMBOPEN_OCREATE
|
SMBOPEN_OTRUNC
;
ofun
=
SMBOPEN_OCREATE
|
SMBOPEN_OTRUNC
;
break
;
break
;
default:
default:
cFYI
(
1
,
(
"unknown disposition %d"
,
disposition
));
cFYI
(
1
,
(
"unknown disposition %d"
,
disposition
));
ofun
=
SMBOPEN_OAPPEND
;
/* regular open */
ofun
=
SMBOPEN_OAPPEND
;
/* regular open */
}
}
return
ofun
;
return
ofun
;
...
@@ -1131,7 +1131,7 @@ SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon,
...
@@ -1131,7 +1131,7 @@ SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon,
as fifo and server expecting SFU style and
as fifo and server expecting SFU style and
no Unix extensions */
no Unix extensions */
if
(
create_options
&
CREATE_OPTION_SPECIAL
)
if
(
create_options
&
CREATE_OPTION_SPECIAL
)
pSMB
->
FileAttributes
=
cpu_to_le16
(
ATTR_SYSTEM
);
pSMB
->
FileAttributes
=
cpu_to_le16
(
ATTR_SYSTEM
);
else
else
pSMB
->
FileAttributes
=
cpu_to_le16
(
0
/*ATTR_NORMAL*/
);
/* BB FIXME */
pSMB
->
FileAttributes
=
cpu_to_le16
(
0
/*ATTR_NORMAL*/
);
/* BB FIXME */
...
@@ -1167,11 +1167,11 @@ SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon,
...
@@ -1167,11 +1167,11 @@ SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon,
/* Let caller know file was created so we can set the mode. */
/* Let caller know file was created so we can set the mode. */
/* Do we care about the CreateAction in any other cases? */
/* Do we care about the CreateAction in any other cases? */
/* BB FIXME BB */
/* BB FIXME BB */
/* if(cpu_to_le32(FILE_CREATE) == pSMBr->CreateAction)
/* if
(cpu_to_le32(FILE_CREATE) == pSMBr->CreateAction)
*pOplock |= CIFS_CREATE_ACTION; */
*pOplock |= CIFS_CREATE_ACTION; */
/* BB FIXME END */
/* BB FIXME END */
if
(
pfile_info
)
{
if
(
pfile_info
)
{
pfile_info
->
CreationTime
=
0
;
/* BB convert CreateTime*/
pfile_info
->
CreationTime
=
0
;
/* BB convert CreateTime*/
pfile_info
->
LastAccessTime
=
0
;
/* BB fixme */
pfile_info
->
LastAccessTime
=
0
;
/* BB fixme */
pfile_info
->
LastWriteTime
=
0
;
/* BB fixme */
pfile_info
->
LastWriteTime
=
0
;
/* BB fixme */
...
@@ -1239,7 +1239,7 @@ CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
...
@@ -1239,7 +1239,7 @@ CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
/* set file as system file if special file such
/* set file as system file if special file such
as fifo and server expecting SFU style and
as fifo and server expecting SFU style and
no Unix extensions */
no Unix extensions */
if
(
create_options
&
CREATE_OPTION_SPECIAL
)
if
(
create_options
&
CREATE_OPTION_SPECIAL
)
pSMB
->
FileAttributes
=
cpu_to_le32
(
ATTR_SYSTEM
);
pSMB
->
FileAttributes
=
cpu_to_le32
(
ATTR_SYSTEM
);
else
else
pSMB
->
FileAttributes
=
cpu_to_le32
(
ATTR_NORMAL
);
pSMB
->
FileAttributes
=
cpu_to_le32
(
ATTR_NORMAL
);
...
@@ -1277,9 +1277,9 @@ CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
...
@@ -1277,9 +1277,9 @@ CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
*
netfid
=
pSMBr
->
Fid
;
/* cifs fid stays in le */
*
netfid
=
pSMBr
->
Fid
;
/* cifs fid stays in le */
/* Let caller know file was created so we can set the mode. */
/* Let caller know file was created so we can set the mode. */
/* Do we care about the CreateAction in any other cases? */
/* Do we care about the CreateAction in any other cases? */
if
(
cpu_to_le32
(
FILE_CREATE
)
==
pSMBr
->
CreateAction
)
if
(
cpu_to_le32
(
FILE_CREATE
)
==
pSMBr
->
CreateAction
)
*
pOplock
|=
CIFS_CREATE_ACTION
;
*
pOplock
|=
CIFS_CREATE_ACTION
;
if
(
pfile_info
)
{
if
(
pfile_info
)
{
memcpy
((
char
*
)
pfile_info
,(
char
*
)
&
pSMBr
->
CreationTime
,
memcpy
((
char
*
)
pfile_info
,(
char
*
)
&
pSMBr
->
CreationTime
,
36
/* CreationTime to Attributes */
);
36
/* CreationTime to Attributes */
);
/* the file_info buf is endian converted by caller */
/* the file_info buf is endian converted by caller */
...
@@ -1309,8 +1309,8 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,
...
@@ -1309,8 +1309,8 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,
int
resp_buf_type
=
0
;
int
resp_buf_type
=
0
;
struct
kvec
iov
[
1
];
struct
kvec
iov
[
1
];
cFYI
(
1
,
(
"Reading %d bytes on fid %d"
,
count
,
netfid
));
cFYI
(
1
,
(
"Reading %d bytes on fid %d"
,
count
,
netfid
));
if
(
tcon
->
ses
->
capabilities
&
CAP_LARGE_FILES
)
if
(
tcon
->
ses
->
capabilities
&
CAP_LARGE_FILES
)
wct
=
12
;
wct
=
12
;
else
else
wct
=
10
;
/* old style read */
wct
=
10
;
/* old style read */
...
@@ -1327,15 +1327,15 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,
...
@@ -1327,15 +1327,15 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,
pSMB
->
AndXCommand
=
0xFF
;
/* none */
pSMB
->
AndXCommand
=
0xFF
;
/* none */
pSMB
->
Fid
=
netfid
;
pSMB
->
Fid
=
netfid
;
pSMB
->
OffsetLow
=
cpu_to_le32
(
lseek
&
0xFFFFFFFF
);
pSMB
->
OffsetLow
=
cpu_to_le32
(
lseek
&
0xFFFFFFFF
);
if
(
wct
==
12
)
if
(
wct
==
12
)
pSMB
->
OffsetHigh
=
cpu_to_le32
(
lseek
>>
32
);
pSMB
->
OffsetHigh
=
cpu_to_le32
(
lseek
>>
32
);
else
if
((
lseek
>>
32
)
>
0
)
/* can not handle this big offset for old */
else
if
((
lseek
>>
32
)
>
0
)
/* can not handle this big offset for old */
return
-
EIO
;
return
-
EIO
;
pSMB
->
Remaining
=
0
;
pSMB
->
Remaining
=
0
;
pSMB
->
MaxCount
=
cpu_to_le16
(
count
&
0xFFFF
);
pSMB
->
MaxCount
=
cpu_to_le16
(
count
&
0xFFFF
);
pSMB
->
MaxCountHigh
=
cpu_to_le32
(
count
>>
16
);
pSMB
->
MaxCountHigh
=
cpu_to_le32
(
count
>>
16
);
if
(
wct
==
12
)
if
(
wct
==
12
)
pSMB
->
ByteCount
=
0
;
/* no need to do le conversion since 0 */
pSMB
->
ByteCount
=
0
;
/* no need to do le conversion since 0 */
else
{
else
{
/* old style read */
/* old style read */
...
@@ -1368,27 +1368,27 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,
...
@@ -1368,27 +1368,27 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,
}
else
{
}
else
{
pReadData
=
(
char
*
)
(
&
pSMBr
->
hdr
.
Protocol
)
+
pReadData
=
(
char
*
)
(
&
pSMBr
->
hdr
.
Protocol
)
+
le16_to_cpu
(
pSMBr
->
DataOffset
);
le16_to_cpu
(
pSMBr
->
DataOffset
);
/* if(rc = copy_to_user(buf, pReadData, data_length)) {
/* if
(rc = copy_to_user(buf, pReadData, data_length)) {
cERROR(1,("Faulting on read rc = %d",rc));
cERROR(1,("Faulting on read rc = %d",rc));
rc = -EFAULT;
rc = -EFAULT;
}*/
/* can not use copy_to_user when using page cache*/
}*/
/* can not use copy_to_user when using page cache*/
if
(
*
buf
)
if
(
*
buf
)
memcpy
(
*
buf
,
pReadData
,
data_length
);
memcpy
(
*
buf
,
pReadData
,
data_length
);
}
}
}
}
/* cifs_small_buf_release(pSMB); */
/* Freed earlier now in SendReceive2 */
/* cifs_small_buf_release(pSMB); */
/* Freed earlier now in SendReceive2 */
if
(
*
buf
)
{
if
(
*
buf
)
{
if
(
resp_buf_type
==
CIFS_SMALL_BUFFER
)
if
(
resp_buf_type
==
CIFS_SMALL_BUFFER
)
cifs_small_buf_release
(
iov
[
0
].
iov_base
);
cifs_small_buf_release
(
iov
[
0
].
iov_base
);
else
if
(
resp_buf_type
==
CIFS_LARGE_BUFFER
)
else
if
(
resp_buf_type
==
CIFS_LARGE_BUFFER
)
cifs_buf_release
(
iov
[
0
].
iov_base
);
cifs_buf_release
(
iov
[
0
].
iov_base
);
}
else
if
(
resp_buf_type
!=
CIFS_NO_BUFFER
)
{
}
else
if
(
resp_buf_type
!=
CIFS_NO_BUFFER
)
{
/* return buffer to caller to free */
/* return buffer to caller to free */
*
buf
=
iov
[
0
].
iov_base
;
*
buf
=
iov
[
0
].
iov_base
;
if
(
resp_buf_type
==
CIFS_SMALL_BUFFER
)
if
(
resp_buf_type
==
CIFS_SMALL_BUFFER
)
*
pbuf_type
=
CIFS_SMALL_BUFFER
;
*
pbuf_type
=
CIFS_SMALL_BUFFER
;
else
if
(
resp_buf_type
==
CIFS_LARGE_BUFFER
)
else
if
(
resp_buf_type
==
CIFS_LARGE_BUFFER
)
*
pbuf_type
=
CIFS_LARGE_BUFFER
;
*
pbuf_type
=
CIFS_LARGE_BUFFER
;
}
/* else no valid buffer on return - leave as null */
}
/* else no valid buffer on return - leave as null */
...
@@ -1412,10 +1412,10 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
...
@@ -1412,10 +1412,10 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
__u16
byte_count
;
__u16
byte_count
;
/* cFYI(1,("write at %lld %d bytes",offset,count));*/
/* cFYI(1,("write at %lld %d bytes",offset,count));*/
if
(
tcon
->
ses
==
NULL
)
if
(
tcon
->
ses
==
NULL
)
return
-
ECONNABORTED
;
return
-
ECONNABORTED
;
if
(
tcon
->
ses
->
capabilities
&
CAP_LARGE_FILES
)
if
(
tcon
->
ses
->
capabilities
&
CAP_LARGE_FILES
)
wct
=
14
;
wct
=
14
;
else
else
wct
=
12
;
wct
=
12
;
...
@@ -1431,9 +1431,9 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
...
@@ -1431,9 +1431,9 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
pSMB
->
AndXCommand
=
0xFF
;
/* none */
pSMB
->
AndXCommand
=
0xFF
;
/* none */
pSMB
->
Fid
=
netfid
;
pSMB
->
Fid
=
netfid
;
pSMB
->
OffsetLow
=
cpu_to_le32
(
offset
&
0xFFFFFFFF
);
pSMB
->
OffsetLow
=
cpu_to_le32
(
offset
&
0xFFFFFFFF
);
if
(
wct
==
14
)
if
(
wct
==
14
)
pSMB
->
OffsetHigh
=
cpu_to_le32
(
offset
>>
32
);
pSMB
->
OffsetHigh
=
cpu_to_le32
(
offset
>>
32
);
else
if
((
offset
>>
32
)
>
0
)
/* can not handle this big offset for old
*/
else
if
((
offset
>>
32
)
>
0
)
/* can not handle big offset for old srv
*/
return
-
EIO
;
return
-
EIO
;
pSMB
->
Reserved
=
0xFFFFFFFF
;
pSMB
->
Reserved
=
0xFFFFFFFF
;
...
@@ -1444,7 +1444,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
...
@@ -1444,7 +1444,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
can send more if LARGE_WRITE_X capability returned by the server and if
can send more if LARGE_WRITE_X capability returned by the server and if
our buffer is big enough or if we convert to iovecs on socket writes
our buffer is big enough or if we convert to iovecs on socket writes
and eliminate the copy to the CIFS buffer */
and eliminate the copy to the CIFS buffer */
if
(
tcon
->
ses
->
capabilities
&
CAP_LARGE_WRITE_X
)
{
if
(
tcon
->
ses
->
capabilities
&
CAP_LARGE_WRITE_X
)
{
bytes_sent
=
min_t
(
const
unsigned
int
,
CIFSMaxBufSize
,
count
);
bytes_sent
=
min_t
(
const
unsigned
int
,
CIFSMaxBufSize
,
count
);
}
else
{
}
else
{
bytes_sent
=
(
tcon
->
ses
->
server
->
maxBuf
-
MAX_CIFS_HDR_SIZE
)
bytes_sent
=
(
tcon
->
ses
->
server
->
maxBuf
-
MAX_CIFS_HDR_SIZE
)
...
@@ -1455,10 +1455,10 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
...
@@ -1455,10 +1455,10 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
bytes_sent
=
count
;
bytes_sent
=
count
;
pSMB
->
DataOffset
=
pSMB
->
DataOffset
=
cpu_to_le16
(
offsetof
(
struct
smb_com_write_req
,
Data
)
-
4
);
cpu_to_le16
(
offsetof
(
struct
smb_com_write_req
,
Data
)
-
4
);
if
(
buf
)
if
(
buf
)
memcpy
(
pSMB
->
Data
,
buf
,
bytes_sent
);
memcpy
(
pSMB
->
Data
,
buf
,
bytes_sent
);
else
if
(
ubuf
)
{
else
if
(
ubuf
)
{
if
(
copy_from_user
(
pSMB
->
Data
,
ubuf
,
bytes_sent
))
{
if
(
copy_from_user
(
pSMB
->
Data
,
ubuf
,
bytes_sent
))
{
cifs_buf_release
(
pSMB
);
cifs_buf_release
(
pSMB
);
return
-
EFAULT
;
return
-
EFAULT
;
}
}
...
@@ -1467,7 +1467,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
...
@@ -1467,7 +1467,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
cifs_buf_release
(
pSMB
);
cifs_buf_release
(
pSMB
);
return
-
EINVAL
;
return
-
EINVAL
;
}
/* else setting file size with write of zero bytes */
}
/* else setting file size with write of zero bytes */
if
(
wct
==
14
)
if
(
wct
==
14
)
byte_count
=
bytes_sent
+
1
;
/* pad */
byte_count
=
bytes_sent
+
1
;
/* pad */
else
/* wct == 12 */
{
else
/* wct == 12 */
{
byte_count
=
bytes_sent
+
5
;
/* bigger pad, smaller smb hdr */
byte_count
=
bytes_sent
+
5
;
/* bigger pad, smaller smb hdr */
...
@@ -1476,7 +1476,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
...
@@ -1476,7 +1476,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
pSMB
->
DataLengthHigh
=
cpu_to_le16
(
bytes_sent
>>
16
);
pSMB
->
DataLengthHigh
=
cpu_to_le16
(
bytes_sent
>>
16
);
pSMB
->
hdr
.
smb_buf_length
+=
byte_count
;
pSMB
->
hdr
.
smb_buf_length
+=
byte_count
;
if
(
wct
==
14
)
if
(
wct
==
14
)
pSMB
->
ByteCount
=
cpu_to_le16
(
byte_count
);
pSMB
->
ByteCount
=
cpu_to_le16
(
byte_count
);
else
{
/* old style write has byte count 4 bytes earlier so 4 bytes pad */
else
{
/* old style write has byte count 4 bytes earlier so 4 bytes pad */
struct
smb_com_writex_req
*
pSMBW
=
struct
smb_com_writex_req
*
pSMBW
=
...
@@ -1516,9 +1516,9 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
...
@@ -1516,9 +1516,9 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
int
smb_hdr_len
;
int
smb_hdr_len
;
int
resp_buf_type
=
0
;
int
resp_buf_type
=
0
;
cFYI
(
1
,(
"write2 at %lld %d bytes"
,
(
long
long
)
offset
,
count
));
cFYI
(
1
,
(
"write2 at %lld %d bytes"
,
(
long
long
)
offset
,
count
));
if
(
tcon
->
ses
->
capabilities
&
CAP_LARGE_FILES
)
if
(
tcon
->
ses
->
capabilities
&
CAP_LARGE_FILES
)
wct
=
14
;
wct
=
14
;
else
else
wct
=
12
;
wct
=
12
;
...
@@ -1532,9 +1532,9 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
...
@@ -1532,9 +1532,9 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
pSMB
->
AndXCommand
=
0xFF
;
/* none */
pSMB
->
AndXCommand
=
0xFF
;
/* none */
pSMB
->
Fid
=
netfid
;
pSMB
->
Fid
=
netfid
;
pSMB
->
OffsetLow
=
cpu_to_le32
(
offset
&
0xFFFFFFFF
);
pSMB
->
OffsetLow
=
cpu_to_le32
(
offset
&
0xFFFFFFFF
);
if
(
wct
==
14
)
if
(
wct
==
14
)
pSMB
->
OffsetHigh
=
cpu_to_le32
(
offset
>>
32
);
pSMB
->
OffsetHigh
=
cpu_to_le32
(
offset
>>
32
);
else
if
((
offset
>>
32
)
>
0
)
/* can not handle this big offset for old
*/
else
if
((
offset
>>
32
)
>
0
)
/* can not handle big offset for old srv
*/
return
-
EIO
;
return
-
EIO
;
pSMB
->
Reserved
=
0xFFFFFFFF
;
pSMB
->
Reserved
=
0xFFFFFFFF
;
pSMB
->
WriteMode
=
0
;
pSMB
->
WriteMode
=
0
;
...
@@ -1546,11 +1546,11 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
...
@@ -1546,11 +1546,11 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
pSMB
->
DataLengthLow
=
cpu_to_le16
(
count
&
0xFFFF
);
pSMB
->
DataLengthLow
=
cpu_to_le16
(
count
&
0xFFFF
);
pSMB
->
DataLengthHigh
=
cpu_to_le16
(
count
>>
16
);
pSMB
->
DataLengthHigh
=
cpu_to_le16
(
count
>>
16
);
smb_hdr_len
=
pSMB
->
hdr
.
smb_buf_length
+
1
;
/* hdr + 1 byte pad */
smb_hdr_len
=
pSMB
->
hdr
.
smb_buf_length
+
1
;
/* hdr + 1 byte pad */
if
(
wct
==
14
)
if
(
wct
==
14
)
pSMB
->
hdr
.
smb_buf_length
+=
count
+
1
;
pSMB
->
hdr
.
smb_buf_length
+=
count
+
1
;
else
/* wct == 12 */
else
/* wct == 12 */
pSMB
->
hdr
.
smb_buf_length
+=
count
+
5
;
/* smb data starts later */
pSMB
->
hdr
.
smb_buf_length
+=
count
+
5
;
/* smb data starts later */
if
(
wct
==
14
)
if
(
wct
==
14
)
pSMB
->
ByteCount
=
cpu_to_le16
(
count
+
1
);
pSMB
->
ByteCount
=
cpu_to_le16
(
count
+
1
);
else
/* wct == 12 */
/* bigger pad, smaller smb hdr, keep offset ok */
{
else
/* wct == 12 */
/* bigger pad, smaller smb hdr, keep offset ok */
{
struct
smb_com_writex_req
*
pSMBW
=
struct
smb_com_writex_req
*
pSMBW
=
...
@@ -1558,7 +1558,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
...
@@ -1558,7 +1558,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
pSMBW
->
ByteCount
=
cpu_to_le16
(
count
+
5
);
pSMBW
->
ByteCount
=
cpu_to_le16
(
count
+
5
);
}
}
iov
[
0
].
iov_base
=
pSMB
;
iov
[
0
].
iov_base
=
pSMB
;
if
(
wct
==
14
)
if
(
wct
==
14
)
iov
[
0
].
iov_len
=
smb_hdr_len
+
4
;
iov
[
0
].
iov_len
=
smb_hdr_len
+
4
;
else
/* wct == 12 pad bigger by four bytes */
else
/* wct == 12 pad bigger by four bytes */
iov
[
0
].
iov_len
=
smb_hdr_len
+
8
;
iov
[
0
].
iov_len
=
smb_hdr_len
+
8
;
...
@@ -1570,7 +1570,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
...
@@ -1570,7 +1570,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
if
(
rc
)
{
if
(
rc
)
{
cFYI
(
1
,
(
"Send error Write2 = %d"
,
rc
));
cFYI
(
1
,
(
"Send error Write2 = %d"
,
rc
));
*
nbytes
=
0
;
*
nbytes
=
0
;
}
else
if
(
resp_buf_type
==
0
)
{
}
else
if
(
resp_buf_type
==
0
)
{
/* presumably this can not happen, but best to be safe */
/* presumably this can not happen, but best to be safe */
rc
=
-
EIO
;
rc
=
-
EIO
;
*
nbytes
=
0
;
*
nbytes
=
0
;
...
@@ -1582,9 +1582,9 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
...
@@ -1582,9 +1582,9 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
}
}
/* cifs_small_buf_release(pSMB); */
/* Freed earlier now in SendReceive2 */
/* cifs_small_buf_release(pSMB); */
/* Freed earlier now in SendReceive2 */
if
(
resp_buf_type
==
CIFS_SMALL_BUFFER
)
if
(
resp_buf_type
==
CIFS_SMALL_BUFFER
)
cifs_small_buf_release
(
iov
[
0
].
iov_base
);
cifs_small_buf_release
(
iov
[
0
].
iov_base
);
else
if
(
resp_buf_type
==
CIFS_LARGE_BUFFER
)
else
if
(
resp_buf_type
==
CIFS_LARGE_BUFFER
)
cifs_buf_release
(
iov
[
0
].
iov_base
);
cifs_buf_release
(
iov
[
0
].
iov_base
);
/* Note: On -EAGAIN error only caller can retry on handle based calls
/* Note: On -EAGAIN error only caller can retry on handle based calls
...
@@ -1615,7 +1615,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
...
@@ -1615,7 +1615,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
pSMBr
=
(
LOCK_RSP
*
)
pSMB
;
/* BB removeme BB */
pSMBr
=
(
LOCK_RSP
*
)
pSMB
;
/* BB removeme BB */
if
(
lockType
==
LOCKING_ANDX_OPLOCK_RELEASE
)
{
if
(
lockType
==
LOCKING_ANDX_OPLOCK_RELEASE
)
{
timeout
=
-
1
;
/* no response expected */
timeout
=
-
1
;
/* no response expected */
pSMB
->
Timeout
=
0
;
pSMB
->
Timeout
=
0
;
}
else
if
(
waitFlag
==
TRUE
)
{
}
else
if
(
waitFlag
==
TRUE
)
{
...
@@ -1631,7 +1631,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
...
@@ -1631,7 +1631,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
pSMB
->
AndXCommand
=
0xFF
;
/* none */
pSMB
->
AndXCommand
=
0xFF
;
/* none */
pSMB
->
Fid
=
smb_file_id
;
/* netfid stays le */
pSMB
->
Fid
=
smb_file_id
;
/* netfid stays le */
if
((
numLock
!=
0
)
||
(
numUnlock
!=
0
))
{
if
((
numLock
!=
0
)
||
(
numUnlock
!=
0
))
{
pSMB
->
Locks
[
0
].
Pid
=
cpu_to_le16
(
current
->
tgid
);
pSMB
->
Locks
[
0
].
Pid
=
cpu_to_le16
(
current
->
tgid
);
/* BB where to store pid high? */
/* BB where to store pid high? */
pSMB
->
Locks
[
0
].
LengthLow
=
cpu_to_le32
((
u32
)
len
);
pSMB
->
Locks
[
0
].
LengthLow
=
cpu_to_le32
((
u32
)
len
);
...
@@ -1681,7 +1681,7 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
...
@@ -1681,7 +1681,7 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
cFYI
(
1
,
(
"Posix Lock"
));
cFYI
(
1
,
(
"Posix Lock"
));
if
(
pLockData
==
NULL
)
if
(
pLockData
==
NULL
)
return
EINVAL
;
return
EINVAL
;
rc
=
small_smb_init
(
SMB_COM_TRANSACTION2
,
15
,
tcon
,
(
void
**
)
&
pSMB
);
rc
=
small_smb_init
(
SMB_COM_TRANSACTION2
,
15
,
tcon
,
(
void
**
)
&
pSMB
);
...
@@ -1706,7 +1706,7 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
...
@@ -1706,7 +1706,7 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
pSMB
->
MaxDataCount
=
cpu_to_le16
(
1000
);
/* BB find max SMB PDU from sess */
pSMB
->
MaxDataCount
=
cpu_to_le16
(
1000
);
/* BB find max SMB PDU from sess */
pSMB
->
SetupCount
=
1
;
pSMB
->
SetupCount
=
1
;
pSMB
->
Reserved3
=
0
;
pSMB
->
Reserved3
=
0
;
if
(
get_flag
)
if
(
get_flag
)
pSMB
->
SubCommand
=
cpu_to_le16
(
TRANS2_QUERY_FILE_INFORMATION
);
pSMB
->
SubCommand
=
cpu_to_le16
(
TRANS2_QUERY_FILE_INFORMATION
);
else
else
pSMB
->
SubCommand
=
cpu_to_le16
(
TRANS2_SET_FILE_INFORMATION
);
pSMB
->
SubCommand
=
cpu_to_le16
(
TRANS2_SET_FILE_INFORMATION
);
...
@@ -1720,7 +1720,7 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
...
@@ -1720,7 +1720,7 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
(((
char
*
)
&
pSMB
->
hdr
.
Protocol
)
+
offset
);
(((
char
*
)
&
pSMB
->
hdr
.
Protocol
)
+
offset
);
parm_data
->
lock_type
=
cpu_to_le16
(
lock_type
);
parm_data
->
lock_type
=
cpu_to_le16
(
lock_type
);
if
(
waitFlag
)
{
if
(
waitFlag
)
{
timeout
=
3
;
/* blocking operation, no timeout */
timeout
=
3
;
/* blocking operation, no timeout */
parm_data
->
lock_flags
=
cpu_to_le16
(
1
);
parm_data
->
lock_flags
=
cpu_to_le16
(
1
);
pSMB
->
Timeout
=
cpu_to_le32
(
-
1
);
pSMB
->
Timeout
=
cpu_to_le32
(
-
1
);
...
@@ -1757,19 +1757,19 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
...
@@ -1757,19 +1757,19 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
rc
=
-
EIO
;
/* bad smb */
rc
=
-
EIO
;
/* bad smb */
goto
plk_err_exit
;
goto
plk_err_exit
;
}
}
if
(
pLockData
==
NULL
)
{
if
(
pLockData
==
NULL
)
{
rc
=
-
EINVAL
;
rc
=
-
EINVAL
;
goto
plk_err_exit
;
goto
plk_err_exit
;
}
}
data_offset
=
le16_to_cpu
(
pSMBr
->
t2
.
DataOffset
);
data_offset
=
le16_to_cpu
(
pSMBr
->
t2
.
DataOffset
);
data_count
=
le16_to_cpu
(
pSMBr
->
t2
.
DataCount
);
data_count
=
le16_to_cpu
(
pSMBr
->
t2
.
DataCount
);
if
(
data_count
<
sizeof
(
struct
cifs_posix_lock
))
{
if
(
data_count
<
sizeof
(
struct
cifs_posix_lock
))
{
rc
=
-
EIO
;
rc
=
-
EIO
;
goto
plk_err_exit
;
goto
plk_err_exit
;
}
}
parm_data
=
(
struct
cifs_posix_lock
*
)
parm_data
=
(
struct
cifs_posix_lock
*
)
((
char
*
)
&
pSMBr
->
hdr
.
Protocol
+
data_offset
);
((
char
*
)
&
pSMBr
->
hdr
.
Protocol
+
data_offset
);
if
(
parm_data
->
lock_type
==
cpu_to_le16
(
CIFS_UNLCK
))
if
(
parm_data
->
lock_type
==
cpu_to_le16
(
CIFS_UNLCK
))
pLockData
->
fl_type
=
F_UNLCK
;
pLockData
->
fl_type
=
F_UNLCK
;
}
}
...
@@ -1795,7 +1795,7 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id)
...
@@ -1795,7 +1795,7 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id)
/* do not retry on dead session on close */
/* do not retry on dead session on close */
rc
=
small_smb_init
(
SMB_COM_CLOSE
,
3
,
tcon
,
(
void
**
)
&
pSMB
);
rc
=
small_smb_init
(
SMB_COM_CLOSE
,
3
,
tcon
,
(
void
**
)
&
pSMB
);
if
(
rc
==
-
EAGAIN
)
if
(
rc
==
-
EAGAIN
)
return
0
;
return
0
;
if
(
rc
)
if
(
rc
)
return
rc
;
return
rc
;
...
@@ -1809,7 +1809,7 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id)
...
@@ -1809,7 +1809,7 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id)
(
struct
smb_hdr
*
)
pSMBr
,
&
bytes_returned
,
0
);
(
struct
smb_hdr
*
)
pSMBr
,
&
bytes_returned
,
0
);
cifs_stats_inc
(
&
tcon
->
num_closes
);
cifs_stats_inc
(
&
tcon
->
num_closes
);
if
(
rc
)
{
if
(
rc
)
{
if
(
rc
!=
-
EINTR
)
{
if
(
rc
!=
-
EINTR
)
{
/* EINTR is expected when user ctl-c to kill app */
/* EINTR is expected when user ctl-c to kill app */
cERROR
(
1
,
(
"Send error in Close = %d"
,
rc
));
cERROR
(
1
,
(
"Send error in Close = %d"
,
rc
));
}
}
...
@@ -1818,7 +1818,7 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id)
...
@@ -1818,7 +1818,7 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id)
cifs_small_buf_release
(
pSMB
);
cifs_small_buf_release
(
pSMB
);
/* Since session is dead, file will be closed on server already */
/* Since session is dead, file will be closed on server already */
if
(
rc
==
-
EAGAIN
)
if
(
rc
==
-
EAGAIN
)
rc
=
0
;
rc
=
0
;
return
rc
;
return
rc
;
...
@@ -1938,7 +1938,7 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
...
@@ -1938,7 +1938,7 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
rename_info
->
overwrite
=
cpu_to_le32
(
1
);
rename_info
->
overwrite
=
cpu_to_le32
(
1
);
rename_info
->
root_fid
=
0
;
rename_info
->
root_fid
=
0
;
/* unicode only call */
/* unicode only call */
if
(
target_name
==
NULL
)
{
if
(
target_name
==
NULL
)
{
sprintf
(
dummy_string
,
"cifs%x"
,
pSMB
->
hdr
.
Mid
);
sprintf
(
dummy_string
,
"cifs%x"
,
pSMB
->
hdr
.
Mid
);
len_of_str
=
cifsConvertToUCS
((
__le16
*
)
rename_info
->
target_name
,
len_of_str
=
cifsConvertToUCS
((
__le16
*
)
rename_info
->
target_name
,
dummy_string
,
24
,
nls_codepage
,
remap
);
dummy_string
,
24
,
nls_codepage
,
remap
);
...
@@ -1961,7 +1961,7 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
...
@@ -1961,7 +1961,7 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
(
struct
smb_hdr
*
)
pSMBr
,
&
bytes_returned
,
0
);
(
struct
smb_hdr
*
)
pSMBr
,
&
bytes_returned
,
0
);
cifs_stats_inc
(
&
pTcon
->
num_t2renames
);
cifs_stats_inc
(
&
pTcon
->
num_t2renames
);
if
(
rc
)
{
if
(
rc
)
{
cFYI
(
1
,(
"Send error in Rename (by file handle) = %d"
,
rc
));
cFYI
(
1
,
(
"Send error in Rename (by file handle) = %d"
,
rc
));
}
}
cifs_buf_release
(
pSMB
);
cifs_buf_release
(
pSMB
);
...
@@ -2434,7 +2434,7 @@ validate_ntransact(char * buf, char ** ppparm, char ** ppdata,
...
@@ -2434,7 +2434,7 @@ validate_ntransact(char * buf, char ** ppparm, char ** ppdata,
__u32
data_count
,
data_offset
,
parm_count
,
parm_offset
;
__u32
data_count
,
data_offset
,
parm_count
,
parm_offset
;
struct
smb_com_ntransact_rsp
*
pSMBr
;
struct
smb_com_ntransact_rsp
*
pSMBr
;
if
(
buf
==
NULL
)
if
(
buf
==
NULL
)
return
-
EINVAL
;
return
-
EINVAL
;
pSMBr
=
(
struct
smb_com_ntransact_rsp
*
)
buf
;
pSMBr
=
(
struct
smb_com_ntransact_rsp
*
)
buf
;
...
@@ -2453,21 +2453,21 @@ validate_ntransact(char * buf, char ** ppparm, char ** ppdata,
...
@@ -2453,21 +2453,21 @@ validate_ntransact(char * buf, char ** ppparm, char ** ppdata,
*
ppdata
=
(
char
*
)
&
pSMBr
->
hdr
.
Protocol
+
data_offset
;
*
ppdata
=
(
char
*
)
&
pSMBr
->
hdr
.
Protocol
+
data_offset
;
/* should we also check that parm and data areas do not overlap? */
/* should we also check that parm and data areas do not overlap? */
if
(
*
ppparm
>
end_of_smb
)
{
if
(
*
ppparm
>
end_of_smb
)
{
cFYI
(
1
,(
"parms start after end of smb"
));
cFYI
(
1
,
(
"parms start after end of smb"
));
return
-
EINVAL
;
return
-
EINVAL
;
}
else
if
(
parm_count
+
*
ppparm
>
end_of_smb
)
{
}
else
if
(
parm_count
+
*
ppparm
>
end_of_smb
)
{
cFYI
(
1
,(
"parm end after end of smb"
));
cFYI
(
1
,
(
"parm end after end of smb"
));
return
-
EINVAL
;
return
-
EINVAL
;
}
else
if
(
*
ppdata
>
end_of_smb
)
{
}
else
if
(
*
ppdata
>
end_of_smb
)
{
cFYI
(
1
,(
"data starts after end of smb"
));
cFYI
(
1
,
(
"data starts after end of smb"
));
return
-
EINVAL
;
return
-
EINVAL
;
}
else
if
(
data_count
+
*
ppdata
>
end_of_smb
)
{
}
else
if
(
data_count
+
*
ppdata
>
end_of_smb
)
{
cFYI
(
1
,(
"data %p + count %d (%p) ends after end of smb %p start %p"
,
cFYI
(
1
,(
"data %p + count %d (%p) ends after end of smb %p start %p"
,
*
ppdata
,
data_count
,
(
data_count
+
*
ppdata
),
end_of_smb
,
pSMBr
));
/* BB FIXME */
*
ppdata
,
data_count
,
(
data_count
+
*
ppdata
),
end_of_smb
,
pSMBr
));
/* BB FIXME */
return
-
EINVAL
;
return
-
EINVAL
;
}
else
if
(
parm_count
+
data_count
>
pSMBr
->
ByteCount
)
{
}
else
if
(
parm_count
+
data_count
>
pSMBr
->
ByteCount
)
{
cFYI
(
1
,(
"parm count and data count larger than SMB"
));
cFYI
(
1
,
(
"parm count and data count larger than SMB"
));
return
-
EINVAL
;
return
-
EINVAL
;
}
}
return
0
;
return
0
;
...
@@ -2522,18 +2522,18 @@ CIFSSMBQueryReparseLinkInfo(const int xid, struct cifsTconInfo *tcon,
...
@@ -2522,18 +2522,18 @@ CIFSSMBQueryReparseLinkInfo(const int xid, struct cifsTconInfo *tcon,
/* BB also check enough total bytes returned */
/* BB also check enough total bytes returned */
rc
=
-
EIO
;
/* bad smb */
rc
=
-
EIO
;
/* bad smb */
else
{
else
{
if
(
data_count
&&
(
data_count
<
2048
))
{
if
(
data_count
&&
(
data_count
<
2048
))
{
char
*
end_of_smb
=
2
/* sizeof byte count */
+
char
*
end_of_smb
=
2
/* sizeof byte count */
+
pSMBr
->
ByteCount
+
pSMBr
->
ByteCount
+
(
char
*
)
&
pSMBr
->
ByteCount
;
(
char
*
)
&
pSMBr
->
ByteCount
;
struct
reparse_data
*
reparse_buf
=
(
struct
reparse_data
*
)
struct
reparse_data
*
reparse_buf
=
(
struct
reparse_data
*
)
((
char
*
)
&
pSMBr
->
hdr
.
Protocol
+
data_offset
);
((
char
*
)
&
pSMBr
->
hdr
.
Protocol
+
data_offset
);
if
((
char
*
)
reparse_buf
>=
end_of_smb
)
{
if
((
char
*
)
reparse_buf
>=
end_of_smb
)
{
rc
=
-
EIO
;
rc
=
-
EIO
;
goto
qreparse_out
;
goto
qreparse_out
;
}
}
if
((
reparse_buf
->
LinkNamesBuf
+
if
((
reparse_buf
->
LinkNamesBuf
+
reparse_buf
->
TargetNameOffset
+
reparse_buf
->
TargetNameOffset
+
reparse_buf
->
TargetNameLen
)
>
reparse_buf
->
TargetNameLen
)
>
end_of_smb
)
{
end_of_smb
)
{
...
@@ -2602,17 +2602,17 @@ static int cifs_copy_posix_acl(char * trgt,char * src, const int buflen,
...
@@ -2602,17 +2602,17 @@ static int cifs_copy_posix_acl(char * trgt,char * src, const int buflen,
if
(
le16_to_cpu
(
cifs_acl
->
version
)
!=
CIFS_ACL_VERSION
)
if
(
le16_to_cpu
(
cifs_acl
->
version
)
!=
CIFS_ACL_VERSION
)
return
-
EOPNOTSUPP
;
return
-
EOPNOTSUPP
;
if
(
acl_type
&
ACL_TYPE_ACCESS
)
{
if
(
acl_type
&
ACL_TYPE_ACCESS
)
{
count
=
le16_to_cpu
(
cifs_acl
->
access_entry_count
);
count
=
le16_to_cpu
(
cifs_acl
->
access_entry_count
);
pACE
=
&
cifs_acl
->
ace_array
[
0
];
pACE
=
&
cifs_acl
->
ace_array
[
0
];
size
=
sizeof
(
struct
cifs_posix_acl
);
size
=
sizeof
(
struct
cifs_posix_acl
);
size
+=
sizeof
(
struct
cifs_posix_ace
)
*
count
;
size
+=
sizeof
(
struct
cifs_posix_ace
)
*
count
;
/* check if we would go beyond end of SMB */
/* check if we would go beyond end of SMB */
if
(
size_of_data_area
<
size
)
{
if
(
size_of_data_area
<
size
)
{
cFYI
(
1
,(
"bad CIFS POSIX ACL size %d vs. %d"
,
size_of_data_area
,
size
));
cFYI
(
1
,(
"bad CIFS POSIX ACL size %d vs. %d"
,
size_of_data_area
,
size
));
return
-
EINVAL
;
return
-
EINVAL
;
}
}
}
else
if
(
acl_type
&
ACL_TYPE_DEFAULT
)
{
}
else
if
(
acl_type
&
ACL_TYPE_DEFAULT
)
{
count
=
le16_to_cpu
(
cifs_acl
->
access_entry_count
);
count
=
le16_to_cpu
(
cifs_acl
->
access_entry_count
);
size
=
sizeof
(
struct
cifs_posix_acl
);
size
=
sizeof
(
struct
cifs_posix_acl
);
size
+=
sizeof
(
struct
cifs_posix_ace
)
*
count
;
size
+=
sizeof
(
struct
cifs_posix_ace
)
*
count
;
...
@@ -2621,7 +2621,7 @@ static int cifs_copy_posix_acl(char * trgt,char * src, const int buflen,
...
@@ -2621,7 +2621,7 @@ static int cifs_copy_posix_acl(char * trgt,char * src, const int buflen,
count
=
le16_to_cpu
(
cifs_acl
->
default_entry_count
);
count
=
le16_to_cpu
(
cifs_acl
->
default_entry_count
);
size
+=
sizeof
(
struct
cifs_posix_ace
)
*
count
;
size
+=
sizeof
(
struct
cifs_posix_ace
)
*
count
;
/* check if we would go beyond end of SMB */
/* check if we would go beyond end of SMB */
if
(
size_of_data_area
<
size
)
if
(
size_of_data_area
<
size
)
return
-
EINVAL
;
return
-
EINVAL
;
}
else
{
}
else
{
/* illegal type */
/* illegal type */
...
@@ -2629,9 +2629,9 @@ static int cifs_copy_posix_acl(char * trgt,char * src, const int buflen,
...
@@ -2629,9 +2629,9 @@ static int cifs_copy_posix_acl(char * trgt,char * src, const int buflen,
}
}
size
=
posix_acl_xattr_size
(
count
);
size
=
posix_acl_xattr_size
(
count
);
if
((
buflen
==
0
)
||
(
local_acl
==
NULL
))
{
if
((
buflen
==
0
)
||
(
local_acl
==
NULL
))
{
/* used to query ACL EA size */
/* used to query ACL EA size */
}
else
if
(
size
>
buflen
)
{
}
else
if
(
size
>
buflen
)
{
return
-
ERANGE
;
return
-
ERANGE
;
}
else
/* buffer big enough */
{
}
else
/* buffer big enough */
{
local_acl
->
a_version
=
cpu_to_le32
(
POSIX_ACL_XATTR_VERSION
);
local_acl
->
a_version
=
cpu_to_le32
(
POSIX_ACL_XATTR_VERSION
);
...
@@ -2651,7 +2651,7 @@ static __u16 convert_ace_to_cifs_ace(struct cifs_posix_ace * cifs_ace,
...
@@ -2651,7 +2651,7 @@ static __u16 convert_ace_to_cifs_ace(struct cifs_posix_ace * cifs_ace,
cifs_ace
->
cifs_e_perm
=
le16_to_cpu
(
local_ace
->
e_perm
);
cifs_ace
->
cifs_e_perm
=
le16_to_cpu
(
local_ace
->
e_perm
);
cifs_ace
->
cifs_e_tag
=
le16_to_cpu
(
local_ace
->
e_tag
);
cifs_ace
->
cifs_e_tag
=
le16_to_cpu
(
local_ace
->
e_tag
);
/* BB is there a better way to handle the large uid? */
/* BB is there a better way to handle the large uid? */
if
(
local_ace
->
e_id
==
cpu_to_le32
(
-
1
))
{
if
(
local_ace
->
e_id
==
cpu_to_le32
(
-
1
))
{
/* Probably no need to le convert -1 on any arch but can not hurt */
/* Probably no need to le convert -1 on any arch but can not hurt */
cifs_ace
->
cifs_uid
=
cpu_to_le64
(
-
1
);
cifs_ace
->
cifs_uid
=
cpu_to_le64
(
-
1
);
}
else
}
else
...
@@ -2670,21 +2670,21 @@ static __u16 ACL_to_cifs_posix(char * parm_data,const char * pACL,const int bufl
...
@@ -2670,21 +2670,21 @@ static __u16 ACL_to_cifs_posix(char * parm_data,const char * pACL,const int bufl
int
count
;
int
count
;
int
i
;
int
i
;
if
((
buflen
==
0
)
||
(
pACL
==
NULL
)
||
(
cifs_acl
==
NULL
))
if
((
buflen
==
0
)
||
(
pACL
==
NULL
)
||
(
cifs_acl
==
NULL
))
return
0
;
return
0
;
count
=
posix_acl_xattr_count
((
size_t
)
buflen
);
count
=
posix_acl_xattr_count
((
size_t
)
buflen
);
cFYI
(
1
,(
"setting acl with %d entries from buf of length %d and version of %d"
,
cFYI
(
1
,(
"setting acl with %d entries from buf of length %d and version of %d"
,
count
,
buflen
,
le32_to_cpu
(
local_acl
->
a_version
)));
count
,
buflen
,
le32_to_cpu
(
local_acl
->
a_version
)));
if
(
le32_to_cpu
(
local_acl
->
a_version
)
!=
2
)
{
if
(
le32_to_cpu
(
local_acl
->
a_version
)
!=
2
)
{
cFYI
(
1
,(
"unknown POSIX ACL version %d"
,
cFYI
(
1
,(
"unknown POSIX ACL version %d"
,
le32_to_cpu
(
local_acl
->
a_version
)));
le32_to_cpu
(
local_acl
->
a_version
)));
return
0
;
return
0
;
}
}
cifs_acl
->
version
=
cpu_to_le16
(
1
);
cifs_acl
->
version
=
cpu_to_le16
(
1
);
if
(
acl_type
==
ACL_TYPE_ACCESS
)
if
(
acl_type
==
ACL_TYPE_ACCESS
)
cifs_acl
->
access_entry_count
=
cpu_to_le16
(
count
);
cifs_acl
->
access_entry_count
=
cpu_to_le16
(
count
);
else
if
(
acl_type
==
ACL_TYPE_DEFAULT
)
else
if
(
acl_type
==
ACL_TYPE_DEFAULT
)
cifs_acl
->
default_entry_count
=
cpu_to_le16
(
count
);
cifs_acl
->
default_entry_count
=
cpu_to_le16
(
count
);
else
{
else
{
cFYI
(
1
,(
"unknown ACL type %d"
,
acl_type
));
cFYI
(
1
,(
"unknown ACL type %d"
,
acl_type
));
...
@@ -2693,12 +2693,12 @@ static __u16 ACL_to_cifs_posix(char * parm_data,const char * pACL,const int bufl
...
@@ -2693,12 +2693,12 @@ static __u16 ACL_to_cifs_posix(char * parm_data,const char * pACL,const int bufl
for
(
i
=
0
;
i
<
count
;
i
++
)
{
for
(
i
=
0
;
i
<
count
;
i
++
)
{
rc
=
convert_ace_to_cifs_ace
(
&
cifs_acl
->
ace_array
[
i
],
rc
=
convert_ace_to_cifs_ace
(
&
cifs_acl
->
ace_array
[
i
],
&
local_acl
->
a_entries
[
i
]);
&
local_acl
->
a_entries
[
i
]);
if
(
rc
!=
0
)
{
if
(
rc
!=
0
)
{
/* ACE not converted */
/* ACE not converted */
break
;
break
;
}
}
}
}
if
(
rc
==
0
)
{
if
(
rc
==
0
)
{
rc
=
(
__u16
)(
count
*
sizeof
(
struct
cifs_posix_ace
));
rc
=
(
__u16
)(
count
*
sizeof
(
struct
cifs_posix_ace
));
rc
+=
sizeof
(
struct
cifs_posix_acl
);
rc
+=
sizeof
(
struct
cifs_posix_acl
);
/* BB add check to make sure ACL does not overflow SMB */
/* BB add check to make sure ACL does not overflow SMB */
...
@@ -2842,7 +2842,7 @@ CIFSSMBSetPosixACL(const int xid, struct cifsTconInfo *tcon,
...
@@ -2842,7 +2842,7 @@ CIFSSMBSetPosixACL(const int xid, struct cifsTconInfo *tcon,
/* convert to on the wire format for POSIX ACL */
/* convert to on the wire format for POSIX ACL */
data_count
=
ACL_to_cifs_posix
(
parm_data
,
local_acl
,
buflen
,
acl_type
);
data_count
=
ACL_to_cifs_posix
(
parm_data
,
local_acl
,
buflen
,
acl_type
);
if
(
data_count
==
0
)
{
if
(
data_count
==
0
)
{
rc
=
-
EOPNOTSUPP
;
rc
=
-
EOPNOTSUPP
;
goto
setACLerrorExit
;
goto
setACLerrorExit
;
}
}
...
@@ -2883,8 +2883,8 @@ CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon,
...
@@ -2883,8 +2883,8 @@ CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon,
int
bytes_returned
;
int
bytes_returned
;
__u16
params
,
byte_count
;
__u16
params
,
byte_count
;
cFYI
(
1
,
(
"In GetExtAttr"
));
cFYI
(
1
,
(
"In GetExtAttr"
));
if
(
tcon
==
NULL
)
if
(
tcon
==
NULL
)
return
-
ENODEV
;
return
-
ENODEV
;
GetExtAttrRetry:
GetExtAttrRetry:
...
@@ -2934,9 +2934,9 @@ CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon,
...
@@ -2934,9 +2934,9 @@ CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon,
else
{
else
{
__u16
data_offset
=
le16_to_cpu
(
pSMBr
->
t2
.
DataOffset
);
__u16
data_offset
=
le16_to_cpu
(
pSMBr
->
t2
.
DataOffset
);
__u16
count
=
le16_to_cpu
(
pSMBr
->
t2
.
DataCount
);
__u16
count
=
le16_to_cpu
(
pSMBr
->
t2
.
DataCount
);
struct
file_chattr_info
*
pfinfo
;
struct
file_chattr_info
*
pfinfo
;
/* BB Do we need a cast or hash here ? */
/* BB Do we need a cast or hash here ? */
if
(
count
!=
16
)
{
if
(
count
!=
16
)
{
cFYI
(
1
,
(
"Illegal size ret in GetExtAttr"
));
cFYI
(
1
,
(
"Illegal size ret in GetExtAttr"
));
rc
=
-
EIO
;
rc
=
-
EIO
;
goto
GetExtAttrOut
;
goto
GetExtAttrOut
;
...
@@ -2954,7 +2954,6 @@ CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon,
...
@@ -2954,7 +2954,6 @@ CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon,
return
rc
;
return
rc
;
}
}
#endif
/* CONFIG_POSIX */
#endif
/* CONFIG_POSIX */
...
@@ -3017,7 +3016,7 @@ CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid,
...
@@ -3017,7 +3016,7 @@ CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid,
(
char
**
)
&
psec_desc
,
(
char
**
)
&
psec_desc
,
&
parm_len
,
&
data_len
);
&
parm_len
,
&
data_len
);
if
(
rc
)
if
(
rc
)
goto
qsec_out
;
goto
qsec_out
;
pSMBr
=
(
struct
smb_com_ntransact_rsp
*
)
iov
[
0
].
iov_base
;
pSMBr
=
(
struct
smb_com_ntransact_rsp
*
)
iov
[
0
].
iov_base
;
...
@@ -3031,14 +3030,14 @@ CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid,
...
@@ -3031,14 +3030,14 @@ CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid,
/* BB check that data area is minimum length and as big as acl_len */
/* BB check that data area is minimum length and as big as acl_len */
acl_len
=
le32_to_cpu
(
*
(
__le32
*
)
parm
);
acl_len
=
le32_to_cpu
(
*
(
__le32
*
)
parm
);
/* BB check if(acl_len > bufsize) */
/* BB check if
(acl_len > bufsize) */
parse_sec_desc
(
psec_desc
,
acl_len
);
parse_sec_desc
(
psec_desc
,
acl_len
);
}
}
qsec_out:
qsec_out:
if
(
buf_type
==
CIFS_SMALL_BUFFER
)
if
(
buf_type
==
CIFS_SMALL_BUFFER
)
cifs_small_buf_release
(
iov
[
0
].
iov_base
);
cifs_small_buf_release
(
iov
[
0
].
iov_base
);
else
if
(
buf_type
==
CIFS_LARGE_BUFFER
)
else
if
(
buf_type
==
CIFS_LARGE_BUFFER
)
cifs_buf_release
(
iov
[
0
].
iov_base
);
cifs_buf_release
(
iov
[
0
].
iov_base
);
/* cifs_small_buf_release(pSMB); */
/* Freed earlier now in SendReceive2 */
/* cifs_small_buf_release(pSMB); */
/* Freed earlier now in SendReceive2 */
return
rc
;
return
rc
;
...
@@ -3167,7 +3166,7 @@ CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
...
@@ -3167,7 +3166,7 @@ CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
byte_count
=
params
+
1
/* pad */
;
byte_count
=
params
+
1
/* pad */
;
pSMB
->
TotalParameterCount
=
cpu_to_le16
(
params
);
pSMB
->
TotalParameterCount
=
cpu_to_le16
(
params
);
pSMB
->
ParameterCount
=
pSMB
->
TotalParameterCount
;
pSMB
->
ParameterCount
=
pSMB
->
TotalParameterCount
;
if
(
legacy
)
if
(
legacy
)
pSMB
->
InformationLevel
=
cpu_to_le16
(
SMB_INFO_STANDARD
);
pSMB
->
InformationLevel
=
cpu_to_le16
(
SMB_INFO_STANDARD
);
else
else
pSMB
->
InformationLevel
=
cpu_to_le16
(
SMB_QUERY_FILE_ALL_INFO
);
pSMB
->
InformationLevel
=
cpu_to_le16
(
SMB_QUERY_FILE_ALL_INFO
);
...
@@ -3186,14 +3185,15 @@ CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
...
@@ -3186,14 +3185,15 @@ CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
rc
=
-
EIO
;
rc
=
-
EIO
;
else
if
(
!
legacy
&&
(
pSMBr
->
ByteCount
<
40
))
else
if
(
!
legacy
&&
(
pSMBr
->
ByteCount
<
40
))
rc
=
-
EIO
;
/* bad smb */
rc
=
-
EIO
;
/* bad smb */
else
if
(
legacy
&&
(
pSMBr
->
ByteCount
<
24
))
else
if
(
legacy
&&
(
pSMBr
->
ByteCount
<
24
))
rc
=
-
EIO
;
/* 24 or 26 expected but we do not read last field */
rc
=
-
EIO
;
/* 24 or 26 expected but we do not read last field */
else
if
(
pFindData
){
else
if
(
pFindData
){
int
size
;
int
size
;
__u16
data_offset
=
le16_to_cpu
(
pSMBr
->
t2
.
DataOffset
);
__u16
data_offset
=
le16_to_cpu
(
pSMBr
->
t2
.
DataOffset
);
if
(
legacy
)
/* we do not read the last field, EAsize, fortunately
if
(
legacy
)
/* we do not read the last field, EAsize,
since it varies by subdialect and on Set vs. Get, is
fortunately since it varies by subdialect
two bytes or 4 bytes depending but we don't care here */
and on Set vs. Get, is two bytes or 4
bytes depending but we don't care here */
size
=
sizeof
(
FILE_INFO_STANDARD
);
size
=
sizeof
(
FILE_INFO_STANDARD
);
else
else
size
=
sizeof
(
FILE_ALL_INFO
);
size
=
sizeof
(
FILE_ALL_INFO
);
...
@@ -3416,7 +3416,7 @@ CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,
...
@@ -3416,7 +3416,7 @@ CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,
}
else
{
/* BB add check for overrun of SMB buf BB */
}
else
{
/* BB add check for overrun of SMB buf BB */
name_len
=
strnlen
(
searchName
,
PATH_MAX
);
name_len
=
strnlen
(
searchName
,
PATH_MAX
);
/* BB fix here and in unicode clause above ie
/* BB fix here and in unicode clause above ie
if(name_len > buffersize-header)
if
(name_len > buffersize-header)
free buffer exit; BB */
free buffer exit; BB */
strncpy
(
pSMB
->
FileName
,
searchName
,
name_len
);
strncpy
(
pSMB
->
FileName
,
searchName
,
name_len
);
pSMB
->
FileName
[
name_len
]
=
dirsep
;
pSMB
->
FileName
[
name_len
]
=
dirsep
;
...
@@ -3477,7 +3477,7 @@ CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,
...
@@ -3477,7 +3477,7 @@ CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,
}
else
{
/* decode response */
}
else
{
/* decode response */
/* BB remember to free buffer if error BB */
/* BB remember to free buffer if error BB */
rc
=
validate_t2
((
struct
smb_t2_rsp
*
)
pSMBr
);
rc
=
validate_t2
((
struct
smb_t2_rsp
*
)
pSMBr
);
if
(
rc
==
0
)
{
if
(
rc
==
0
)
{
if
(
pSMBr
->
hdr
.
Flags2
&
SMBFLG2_UNICODE
)
if
(
pSMBr
->
hdr
.
Flags2
&
SMBFLG2_UNICODE
)
psrch_inf
->
unicode
=
TRUE
;
psrch_inf
->
unicode
=
TRUE
;
else
else
...
@@ -3491,7 +3491,7 @@ CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,
...
@@ -3491,7 +3491,7 @@ CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,
parms
=
(
T2_FFIRST_RSP_PARMS
*
)((
char
*
)
&
pSMBr
->
hdr
.
Protocol
+
parms
=
(
T2_FFIRST_RSP_PARMS
*
)((
char
*
)
&
pSMBr
->
hdr
.
Protocol
+
le16_to_cpu
(
pSMBr
->
t2
.
ParameterOffset
));
le16_to_cpu
(
pSMBr
->
t2
.
ParameterOffset
));
if
(
parms
->
EndofSearch
)
if
(
parms
->
EndofSearch
)
psrch_inf
->
endOfSearch
=
TRUE
;
psrch_inf
->
endOfSearch
=
TRUE
;
else
else
psrch_inf
->
endOfSearch
=
FALSE
;
psrch_inf
->
endOfSearch
=
FALSE
;
...
@@ -3521,7 +3521,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
...
@@ -3521,7 +3521,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
cFYI
(
1
,
(
"In FindNext"
));
cFYI
(
1
,
(
"In FindNext"
));
if
(
psrch_inf
->
endOfSearch
==
TRUE
)
if
(
psrch_inf
->
endOfSearch
==
TRUE
)
return
-
ENOENT
;
return
-
ENOENT
;
rc
=
smb_init
(
SMB_COM_TRANSACTION2
,
15
,
tcon
,
(
void
**
)
&
pSMB
,
rc
=
smb_init
(
SMB_COM_TRANSACTION2
,
15
,
tcon
,
(
void
**
)
&
pSMB
,
...
@@ -3566,7 +3566,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
...
@@ -3566,7 +3566,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
name_len
=
psrch_inf
->
resume_name_len
;
name_len
=
psrch_inf
->
resume_name_len
;
params
+=
name_len
;
params
+=
name_len
;
if
(
name_len
<
PATH_MAX
)
{
if
(
name_len
<
PATH_MAX
)
{
memcpy
(
pSMB
->
ResumeFileName
,
psrch_inf
->
presume_name
,
name_len
);
memcpy
(
pSMB
->
ResumeFileName
,
psrch_inf
->
presume_name
,
name_len
);
byte_count
+=
name_len
;
byte_count
+=
name_len
;
/* 14 byte parm len above enough for 2 byte null terminator */
/* 14 byte parm len above enough for 2 byte null terminator */
...
@@ -3594,7 +3594,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
...
@@ -3594,7 +3594,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
}
else
{
/* decode response */
}
else
{
/* decode response */
rc
=
validate_t2
((
struct
smb_t2_rsp
*
)
pSMBr
);
rc
=
validate_t2
((
struct
smb_t2_rsp
*
)
pSMBr
);
if
(
rc
==
0
)
{
if
(
rc
==
0
)
{
/* BB fixme add lock for file (srch_info) struct here */
/* BB fixme add lock for file (srch_info) struct here */
if
(
pSMBr
->
hdr
.
Flags2
&
SMBFLG2_UNICODE
)
if
(
pSMBr
->
hdr
.
Flags2
&
SMBFLG2_UNICODE
)
psrch_inf
->
unicode
=
TRUE
;
psrch_inf
->
unicode
=
TRUE
;
...
@@ -3605,7 +3605,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
...
@@ -3605,7 +3605,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
parms
=
(
T2_FNEXT_RSP_PARMS
*
)
response_data
;
parms
=
(
T2_FNEXT_RSP_PARMS
*
)
response_data
;
response_data
=
(
char
*
)
&
pSMBr
->
hdr
.
Protocol
+
response_data
=
(
char
*
)
&
pSMBr
->
hdr
.
Protocol
+
le16_to_cpu
(
pSMBr
->
t2
.
DataOffset
);
le16_to_cpu
(
pSMBr
->
t2
.
DataOffset
);
if
(
psrch_inf
->
smallBuf
)
if
(
psrch_inf
->
smallBuf
)
cifs_small_buf_release
(
cifs_small_buf_release
(
psrch_inf
->
ntwrk_buf_start
);
psrch_inf
->
ntwrk_buf_start
);
else
else
...
@@ -3613,7 +3613,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
...
@@ -3613,7 +3613,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
psrch_inf
->
srch_entries_start
=
response_data
;
psrch_inf
->
srch_entries_start
=
response_data
;
psrch_inf
->
ntwrk_buf_start
=
(
char
*
)
pSMB
;
psrch_inf
->
ntwrk_buf_start
=
(
char
*
)
pSMB
;
psrch_inf
->
smallBuf
=
0
;
psrch_inf
->
smallBuf
=
0
;
if
(
parms
->
EndofSearch
)
if
(
parms
->
EndofSearch
)
psrch_inf
->
endOfSearch
=
TRUE
;
psrch_inf
->
endOfSearch
=
TRUE
;
else
else
psrch_inf
->
endOfSearch
=
FALSE
;
psrch_inf
->
endOfSearch
=
FALSE
;
...
@@ -3653,7 +3653,7 @@ CIFSFindClose(const int xid, struct cifsTconInfo *tcon, const __u16 searchHandle
...
@@ -3653,7 +3653,7 @@ CIFSFindClose(const int xid, struct cifsTconInfo *tcon, const __u16 searchHandle
/* no sense returning error if session restarted
/* no sense returning error if session restarted
as file handle has been closed */
as file handle has been closed */
if
(
rc
==
-
EAGAIN
)
if
(
rc
==
-
EAGAIN
)
return
0
;
return
0
;
if
(
rc
)
if
(
rc
)
return
rc
;
return
rc
;
...
@@ -3689,7 +3689,7 @@ CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon,
...
@@ -3689,7 +3689,7 @@ CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon,
__u16
params
,
byte_count
;
__u16
params
,
byte_count
;
cFYI
(
1
,(
"In GetSrvInodeNum for %s"
,
searchName
));
cFYI
(
1
,(
"In GetSrvInodeNum for %s"
,
searchName
));
if
(
tcon
==
NULL
)
if
(
tcon
==
NULL
)
return
-
ENODEV
;
return
-
ENODEV
;
GetInodeNumberRetry:
GetInodeNumberRetry:
...
@@ -3753,7 +3753,7 @@ CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon,
...
@@ -3753,7 +3753,7 @@ CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon,
__u16
count
=
le16_to_cpu
(
pSMBr
->
t2
.
DataCount
);
__u16
count
=
le16_to_cpu
(
pSMBr
->
t2
.
DataCount
);
struct
file_internal_info
*
pfinfo
;
struct
file_internal_info
*
pfinfo
;
/* BB Do we need a cast or hash here ? */
/* BB Do we need a cast or hash here ? */
if
(
count
<
8
)
{
if
(
count
<
8
)
{
cFYI
(
1
,
(
"Illegal size ret in QryIntrnlInf"
));
cFYI
(
1
,
(
"Illegal size ret in QryIntrnlInf"
));
rc
=
-
EIO
;
rc
=
-
EIO
;
goto
GetInodeNumOut
;
goto
GetInodeNumOut
;
...
@@ -3824,8 +3824,8 @@ CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses,
...
@@ -3824,8 +3824,8 @@ CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses,
strncpy
(
pSMB
->
RequestFileName
,
searchName
,
name_len
);
strncpy
(
pSMB
->
RequestFileName
,
searchName
,
name_len
);
}
}
if
(
ses
->
server
)
{
if
(
ses
->
server
)
{
if
(
ses
->
server
->
secMode
&
if
(
ses
->
server
->
secMode
&
(
SECMODE_SIGN_REQUIRED
|
SECMODE_SIGN_ENABLED
))
(
SECMODE_SIGN_REQUIRED
|
SECMODE_SIGN_ENABLED
))
pSMB
->
hdr
.
Flags2
|=
SMBFLG2_SECURITY_SIGNATURE
;
pSMB
->
hdr
.
Flags2
|=
SMBFLG2_SECURITY_SIGNATURE
;
}
}
...
@@ -3885,7 +3885,7 @@ CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses,
...
@@ -3885,7 +3885,7 @@ CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses,
*
number_of_UNC_in_array
=
le16_to_cpu
(
pSMBr
->
NumberOfReferrals
);
*
number_of_UNC_in_array
=
le16_to_cpu
(
pSMBr
->
NumberOfReferrals
);
/* BB Fix below so can return more than one referral */
/* BB Fix below so can return more than one referral */
if
(
*
number_of_UNC_in_array
>
1
)
if
(
*
number_of_UNC_in_array
>
1
)
*
number_of_UNC_in_array
=
1
;
*
number_of_UNC_in_array
=
1
;
/* get the length of the strings describing refs */
/* get the length of the strings describing refs */
...
@@ -3913,7 +3913,7 @@ CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses,
...
@@ -3913,7 +3913,7 @@ CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses,
/* BB add check for name_len bigger than bcc */
/* BB add check for name_len bigger than bcc */
*
targetUNCs
=
*
targetUNCs
=
kmalloc
(
name_len
+
1
+
(
*
number_of_UNC_in_array
),
GFP_KERNEL
);
kmalloc
(
name_len
+
1
+
(
*
number_of_UNC_in_array
),
GFP_KERNEL
);
if
(
*
targetUNCs
==
NULL
)
{
if
(
*
targetUNCs
==
NULL
)
{
rc
=
-
ENOMEM
;
rc
=
-
ENOMEM
;
goto
GetDFSRefExit
;
goto
GetDFSRefExit
;
}
}
...
@@ -4458,16 +4458,16 @@ CIFSSMBQFSPosixInfo(const int xid, struct cifsTconInfo *tcon,
...
@@ -4458,16 +4458,16 @@ CIFSSMBQFSPosixInfo(const int xid, struct cifsTconInfo *tcon,
le64_to_cpu
(
response_data
->
TotalBlocks
);
le64_to_cpu
(
response_data
->
TotalBlocks
);
FSData
->
f_bfree
=
FSData
->
f_bfree
=
le64_to_cpu
(
response_data
->
BlocksAvail
);
le64_to_cpu
(
response_data
->
BlocksAvail
);
if
(
response_data
->
UserBlocksAvail
==
cpu_to_le64
(
-
1
))
{
if
(
response_data
->
UserBlocksAvail
==
cpu_to_le64
(
-
1
))
{
FSData
->
f_bavail
=
FSData
->
f_bfree
;
FSData
->
f_bavail
=
FSData
->
f_bfree
;
}
else
{
}
else
{
FSData
->
f_bavail
=
FSData
->
f_bavail
=
le64_to_cpu
(
response_data
->
UserBlocksAvail
);
le64_to_cpu
(
response_data
->
UserBlocksAvail
);
}
}
if
(
response_data
->
TotalFileNodes
!=
cpu_to_le64
(
-
1
))
if
(
response_data
->
TotalFileNodes
!=
cpu_to_le64
(
-
1
))
FSData
->
f_files
=
FSData
->
f_files
=
le64_to_cpu
(
response_data
->
TotalFileNodes
);
le64_to_cpu
(
response_data
->
TotalFileNodes
);
if
(
response_data
->
FreeFileNodes
!=
cpu_to_le64
(
-
1
))
if
(
response_data
->
FreeFileNodes
!=
cpu_to_le64
(
-
1
))
FSData
->
f_ffree
=
FSData
->
f_ffree
=
le64_to_cpu
(
response_data
->
FreeFileNodes
);
le64_to_cpu
(
response_data
->
FreeFileNodes
);
}
}
...
@@ -4530,7 +4530,7 @@ CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon, const char *fileName,
...
@@ -4530,7 +4530,7 @@ CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon, const char *fileName,
param_offset
=
offsetof
(
struct
smb_com_transaction2_spi_req
,
param_offset
=
offsetof
(
struct
smb_com_transaction2_spi_req
,
InformationLevel
)
-
4
;
InformationLevel
)
-
4
;
offset
=
param_offset
+
params
;
offset
=
param_offset
+
params
;
if
(
SetAllocation
)
{
if
(
SetAllocation
)
{
if
(
tcon
->
ses
->
capabilities
&
CAP_INFOLEVEL_PASSTHRU
)
if
(
tcon
->
ses
->
capabilities
&
CAP_INFOLEVEL_PASSTHRU
)
pSMB
->
InformationLevel
=
pSMB
->
InformationLevel
=
cpu_to_le16
(
SMB_SET_FILE_ALLOCATION_INFO2
);
cpu_to_le16
(
SMB_SET_FILE_ALLOCATION_INFO2
);
...
@@ -4630,7 +4630,7 @@ CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size,
...
@@ -4630,7 +4630,7 @@ CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size,
pSMB
->
DataOffset
=
cpu_to_le16
(
offset
);
pSMB
->
DataOffset
=
cpu_to_le16
(
offset
);
parm_data
->
FileSize
=
cpu_to_le64
(
size
);
parm_data
->
FileSize
=
cpu_to_le64
(
size
);
pSMB
->
Fid
=
fid
;
pSMB
->
Fid
=
fid
;
if
(
SetAllocation
)
{
if
(
SetAllocation
)
{
if
(
tcon
->
ses
->
capabilities
&
CAP_INFOLEVEL_PASSTHRU
)
if
(
tcon
->
ses
->
capabilities
&
CAP_INFOLEVEL_PASSTHRU
)
pSMB
->
InformationLevel
=
pSMB
->
InformationLevel
=
cpu_to_le16
(
SMB_SET_FILE_ALLOCATION_INFO2
);
cpu_to_le16
(
SMB_SET_FILE_ALLOCATION_INFO2
);
...
@@ -4955,19 +4955,19 @@ CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *tcon,
...
@@ -4955,19 +4955,19 @@ CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *tcon,
data_offset
->
DevMinor
=
cpu_to_le64
(
MINOR
(
device
));
data_offset
->
DevMinor
=
cpu_to_le64
(
MINOR
(
device
));
data_offset
->
Permissions
=
cpu_to_le64
(
mode
);
data_offset
->
Permissions
=
cpu_to_le64
(
mode
);
if
(
S_ISREG
(
mode
))
if
(
S_ISREG
(
mode
))
data_offset
->
Type
=
cpu_to_le32
(
UNIX_FILE
);
data_offset
->
Type
=
cpu_to_le32
(
UNIX_FILE
);
else
if
(
S_ISDIR
(
mode
))
else
if
(
S_ISDIR
(
mode
))
data_offset
->
Type
=
cpu_to_le32
(
UNIX_DIR
);
data_offset
->
Type
=
cpu_to_le32
(
UNIX_DIR
);
else
if
(
S_ISLNK
(
mode
))
else
if
(
S_ISLNK
(
mode
))
data_offset
->
Type
=
cpu_to_le32
(
UNIX_SYMLINK
);
data_offset
->
Type
=
cpu_to_le32
(
UNIX_SYMLINK
);
else
if
(
S_ISCHR
(
mode
))
else
if
(
S_ISCHR
(
mode
))
data_offset
->
Type
=
cpu_to_le32
(
UNIX_CHARDEV
);
data_offset
->
Type
=
cpu_to_le32
(
UNIX_CHARDEV
);
else
if
(
S_ISBLK
(
mode
))
else
if
(
S_ISBLK
(
mode
))
data_offset
->
Type
=
cpu_to_le32
(
UNIX_BLOCKDEV
);
data_offset
->
Type
=
cpu_to_le32
(
UNIX_BLOCKDEV
);
else
if
(
S_ISFIFO
(
mode
))
else
if
(
S_ISFIFO
(
mode
))
data_offset
->
Type
=
cpu_to_le32
(
UNIX_FIFO
);
data_offset
->
Type
=
cpu_to_le32
(
UNIX_FIFO
);
else
if
(
S_ISSOCK
(
mode
))
else
if
(
S_ISSOCK
(
mode
))
data_offset
->
Type
=
cpu_to_le32
(
UNIX_SOCKET
);
data_offset
->
Type
=
cpu_to_le32
(
UNIX_SOCKET
);
...
@@ -5019,7 +5019,7 @@ int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon,
...
@@ -5019,7 +5019,7 @@ int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon,
pSMB
->
SetupCount
=
4
;
/* single byte does not need le conversion */
pSMB
->
SetupCount
=
4
;
/* single byte does not need le conversion */
pSMB
->
SubCommand
=
cpu_to_le16
(
NT_TRANSACT_NOTIFY_CHANGE
);
pSMB
->
SubCommand
=
cpu_to_le16
(
NT_TRANSACT_NOTIFY_CHANGE
);
pSMB
->
ParameterCount
=
pSMB
->
TotalParameterCount
;
pSMB
->
ParameterCount
=
pSMB
->
TotalParameterCount
;
if
(
notify_subdirs
)
if
(
notify_subdirs
)
pSMB
->
WatchTree
=
1
;
/* one byte - no le conversion needed */
pSMB
->
WatchTree
=
1
;
/* one byte - no le conversion needed */
pSMB
->
Reserved2
=
0
;
pSMB
->
Reserved2
=
0
;
pSMB
->
CompletionFilter
=
cpu_to_le32
(
filter
);
pSMB
->
CompletionFilter
=
cpu_to_le32
(
filter
);
...
@@ -5036,7 +5036,7 @@ int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon,
...
@@ -5036,7 +5036,7 @@ int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon,
dnotify_req
=
kmalloc
(
dnotify_req
=
kmalloc
(
sizeof
(
struct
dir_notify_req
),
sizeof
(
struct
dir_notify_req
),
GFP_KERNEL
);
GFP_KERNEL
);
if
(
dnotify_req
)
{
if
(
dnotify_req
)
{
dnotify_req
->
Pid
=
pSMB
->
hdr
.
Pid
;
dnotify_req
->
Pid
=
pSMB
->
hdr
.
Pid
;
dnotify_req
->
PidHigh
=
pSMB
->
hdr
.
PidHigh
;
dnotify_req
->
PidHigh
=
pSMB
->
hdr
.
PidHigh
;
dnotify_req
->
Mid
=
pSMB
->
hdr
.
Mid
;
dnotify_req
->
Mid
=
pSMB
->
hdr
.
Mid
;
...
@@ -5142,13 +5142,13 @@ CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon,
...
@@ -5142,13 +5142,13 @@ CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon,
struct
fealist
*
ea_response_data
;
struct
fealist
*
ea_response_data
;
rc
=
0
;
rc
=
0
;
/* validate_trans2_offsets() */
/* validate_trans2_offsets() */
/* BB
to check if(start of smb + data_offset > &bcc+ bcc)
*/
/* BB
check if start of smb + data_offset > &bcc+ bcc
*/
ea_response_data
=
(
struct
fealist
*
)
ea_response_data
=
(
struct
fealist
*
)
(((
char
*
)
&
pSMBr
->
hdr
.
Protocol
)
+
(((
char
*
)
&
pSMBr
->
hdr
.
Protocol
)
+
data_offset
);
data_offset
);
name_len
=
le32_to_cpu
(
ea_response_data
->
list_len
);
name_len
=
le32_to_cpu
(
ea_response_data
->
list_len
);
cFYI
(
1
,(
"ea length %d"
,
name_len
));
cFYI
(
1
,(
"ea length %d"
,
name_len
));
if
(
name_len
<=
8
)
{
if
(
name_len
<=
8
)
{
/* returned EA size zeroed at top of function */
/* returned EA size zeroed at top of function */
cFYI
(
1
,(
"empty EA list returned from server"
));
cFYI
(
1
,(
"empty EA list returned from server"
));
}
else
{
}
else
{
...
@@ -5163,7 +5163,7 @@ CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon,
...
@@ -5163,7 +5163,7 @@ CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon,
rc
+=
temp_fea
->
name_len
;
rc
+=
temp_fea
->
name_len
;
/* account for prefix user. and trailing null */
/* account for prefix user. and trailing null */
rc
=
rc
+
5
+
1
;
rc
=
rc
+
5
+
1
;
if
(
rc
<
(
int
)
buf_size
)
{
if
(
rc
<
(
int
)
buf_size
)
{
memcpy
(
EAData
,
"user."
,
5
);
memcpy
(
EAData
,
"user."
,
5
);
EAData
+=
5
;
EAData
+=
5
;
memcpy
(
EAData
,
temp_ptr
,
temp_fea
->
name_len
);
memcpy
(
EAData
,
temp_ptr
,
temp_fea
->
name_len
);
...
@@ -5171,7 +5171,7 @@ CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon,
...
@@ -5171,7 +5171,7 @@ CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon,
/* null terminate name */
/* null terminate name */
*
EAData
=
0
;
*
EAData
=
0
;
EAData
=
EAData
+
1
;
EAData
=
EAData
+
1
;
}
else
if
(
buf_size
==
0
)
{
}
else
if
(
buf_size
==
0
)
{
/* skip copy - calc size only */
/* skip copy - calc size only */
}
else
{
}
else
{
/* stop before overrun buffer */
/* stop before overrun buffer */
...
@@ -5285,13 +5285,13 @@ ssize_t CIFSSMBQueryEA(const int xid,struct cifsTconInfo * tcon,
...
@@ -5285,13 +5285,13 @@ ssize_t CIFSSMBQueryEA(const int xid,struct cifsTconInfo * tcon,
struct
fealist
*
ea_response_data
;
struct
fealist
*
ea_response_data
;
rc
=
-
ENODATA
;
rc
=
-
ENODATA
;
/* validate_trans2_offsets() */
/* validate_trans2_offsets() */
/* BB
to check if(start of smb + data_offset > &bcc+ bcc)
*/
/* BB
check if start of smb + data_offset > &bcc+ bcc
*/
ea_response_data
=
(
struct
fealist
*
)
ea_response_data
=
(
struct
fealist
*
)
(((
char
*
)
&
pSMBr
->
hdr
.
Protocol
)
+
(((
char
*
)
&
pSMBr
->
hdr
.
Protocol
)
+
data_offset
);
data_offset
);
name_len
=
le32_to_cpu
(
ea_response_data
->
list_len
);
name_len
=
le32_to_cpu
(
ea_response_data
->
list_len
);
cFYI
(
1
,(
"ea length %d"
,
name_len
));
cFYI
(
1
,(
"ea length %d"
,
name_len
));
if
(
name_len
<=
8
)
{
if
(
name_len
<=
8
)
{
/* returned EA size zeroed at top of function */
/* returned EA size zeroed at top of function */
cFYI
(
1
,(
"empty EA list returned from server"
));
cFYI
(
1
,(
"empty EA list returned from server"
));
}
else
{
}
else
{
...
@@ -5308,18 +5308,18 @@ ssize_t CIFSSMBQueryEA(const int xid,struct cifsTconInfo * tcon,
...
@@ -5308,18 +5308,18 @@ ssize_t CIFSSMBQueryEA(const int xid,struct cifsTconInfo * tcon,
value_len
=
le16_to_cpu
(
temp_fea
->
value_len
);
value_len
=
le16_to_cpu
(
temp_fea
->
value_len
);
/* BB validate that value_len falls within SMB,
/* BB validate that value_len falls within SMB,
even though maximum for name_len is 255 */
even though maximum for name_len is 255 */
if
(
memcmp
(
temp_fea
->
name
,
ea_name
,
if
(
memcmp
(
temp_fea
->
name
,
ea_name
,
temp_fea
->
name_len
)
==
0
)
{
temp_fea
->
name_len
)
==
0
)
{
/* found a match */
/* found a match */
rc
=
value_len
;
rc
=
value_len
;
/* account for prefix user. and trailing null */
/* account for prefix user. and trailing null */
if
(
rc
<=
(
int
)
buf_size
)
{
if
(
rc
<=
(
int
)
buf_size
)
{
memcpy
(
ea_value
,
memcpy
(
ea_value
,
temp_fea
->
name
+
temp_fea
->
name_len
+
1
,
temp_fea
->
name
+
temp_fea
->
name_len
+
1
,
rc
);
rc
);
/* ea values, unlike ea names,
/* ea values, unlike ea names,
are not null terminated */
are not null terminated */
}
else
if
(
buf_size
==
0
)
{
}
else
if
(
buf_size
==
0
)
{
/* skip copy - calc size only */
/* skip copy - calc size only */
}
else
{
}
else
{
/* stop before overrun buffer */
/* stop before overrun buffer */
...
@@ -5387,7 +5387,7 @@ CIFSSMBSetEA(const int xid, struct cifsTconInfo *tcon, const char *fileName,
...
@@ -5387,7 +5387,7 @@ CIFSSMBSetEA(const int xid, struct cifsTconInfo *tcon, const char *fileName,
/* done calculating parms using name_len of file name,
/* done calculating parms using name_len of file name,
now use name_len to calculate length of ea name
now use name_len to calculate length of ea name
we are going to create in the inode xattrs */
we are going to create in the inode xattrs */
if
(
ea_name
==
NULL
)
if
(
ea_name
==
NULL
)
name_len
=
0
;
name_len
=
0
;
else
else
name_len
=
strnlen
(
ea_name
,
255
);
name_len
=
strnlen
(
ea_name
,
255
);
...
@@ -5421,7 +5421,7 @@ CIFSSMBSetEA(const int xid, struct cifsTconInfo *tcon, const char *fileName,
...
@@ -5421,7 +5421,7 @@ CIFSSMBSetEA(const int xid, struct cifsTconInfo *tcon, const char *fileName,
/* we checked above that name len is less than 255 */
/* we checked above that name len is less than 255 */
parm_data
->
list
[
0
].
name_len
=
(
__u8
)
name_len
;
parm_data
->
list
[
0
].
name_len
=
(
__u8
)
name_len
;
/* EA names are always ASCII */
/* EA names are always ASCII */
if
(
ea_name
)
if
(
ea_name
)
strncpy
(
parm_data
->
list
[
0
].
name
,
ea_name
,
name_len
);
strncpy
(
parm_data
->
list
[
0
].
name
,
ea_name
,
name_len
);
parm_data
->
list
[
0
].
name
[
name_len
]
=
0
;
parm_data
->
list
[
0
].
name
[
name_len
]
=
0
;
parm_data
->
list
[
0
].
value_len
=
cpu_to_le16
(
ea_value_len
);
parm_data
->
list
[
0
].
value_len
=
cpu_to_le16
(
ea_value_len
);
...
@@ -5429,8 +5429,8 @@ CIFSSMBSetEA(const int xid, struct cifsTconInfo *tcon, const char *fileName,
...
@@ -5429,8 +5429,8 @@ CIFSSMBSetEA(const int xid, struct cifsTconInfo *tcon, const char *fileName,
we need to ensure that it fits within the smb */
we need to ensure that it fits within the smb */
/*BB add length check that it would fit in negotiated SMB buffer size BB */
/*BB add length check that it would fit in negotiated SMB buffer size BB */
/* if(ea_value_len > buffer_size - 512 (enough for header)) */
/* if
(ea_value_len > buffer_size - 512 (enough for header)) */
if
(
ea_value_len
)
if
(
ea_value_len
)
memcpy
(
parm_data
->
list
[
0
].
name
+
name_len
+
1
,
ea_value
,
ea_value_len
);
memcpy
(
parm_data
->
list
[
0
].
name
+
name_len
+
1
,
ea_value
,
ea_value_len
);
pSMB
->
TotalDataCount
=
pSMB
->
DataCount
;
pSMB
->
TotalDataCount
=
pSMB
->
DataCount
;
...
...
fs/cifs/misc.c
View file @
790fe579
/*
/*
* fs/cifs/misc.c
* fs/cifs/misc.c
*
*
* Copyright (C) International Business Machines Corp., 2002,200
5
* Copyright (C) International Business Machines Corp., 2002,200
7
* Author(s): Steve French (sfrench@us.ibm.com)
* Author(s): Steve French (sfrench@us.ibm.com)
*
*
* This library is free software; you can redistribute it and/or modify
* This library is free software; you can redistribute it and/or modify
...
@@ -49,7 +49,7 @@ _GetXid(void)
...
@@ -49,7 +49,7 @@ _GetXid(void)
GlobalTotalActiveXid
++
;
GlobalTotalActiveXid
++
;
if
(
GlobalTotalActiveXid
>
GlobalMaxActiveXid
)
if
(
GlobalTotalActiveXid
>
GlobalMaxActiveXid
)
GlobalMaxActiveXid
=
GlobalTotalActiveXid
;
/* keep high water mark for number of simultaneous vfs ops in our filesystem */
GlobalMaxActiveXid
=
GlobalTotalActiveXid
;
/* keep high water mark for number of simultaneous vfs ops in our filesystem */
if
(
GlobalTotalActiveXid
>
65000
)
if
(
GlobalTotalActiveXid
>
65000
)
cFYI
(
1
,(
"warning: more than 65000 requests active"
));
cFYI
(
1
,(
"warning: more than 65000 requests active"
));
xid
=
GlobalCurrentXid
++
;
xid
=
GlobalCurrentXid
++
;
spin_unlock
(
&
GlobalMid_Lock
);
spin_unlock
(
&
GlobalMid_Lock
);
...
@@ -60,7 +60,7 @@ void
...
@@ -60,7 +60,7 @@ void
_FreeXid
(
unsigned
int
xid
)
_FreeXid
(
unsigned
int
xid
)
{
{
spin_lock
(
&
GlobalMid_Lock
);
spin_lock
(
&
GlobalMid_Lock
);
/* if(GlobalTotalActiveXid == 0)
/* if
(GlobalTotalActiveXid == 0)
BUG(); */
BUG(); */
GlobalTotalActiveXid
--
;
GlobalTotalActiveXid
--
;
spin_unlock
(
&
GlobalMid_Lock
);
spin_unlock
(
&
GlobalMid_Lock
);
...
@@ -242,7 +242,7 @@ __u16 GetNextMid(struct TCP_Server_Info *server)
...
@@ -242,7 +242,7 @@ __u16 GetNextMid(struct TCP_Server_Info *server)
__u16
last_mid
;
__u16
last_mid
;
int
collision
;
int
collision
;
if
(
server
==
NULL
)
if
(
server
==
NULL
)
return
mid
;
return
mid
;
spin_lock
(
&
GlobalMid_Lock
);
spin_lock
(
&
GlobalMid_Lock
);
...
@@ -260,7 +260,7 @@ __u16 GetNextMid(struct TCP_Server_Info *server)
...
@@ -260,7 +260,7 @@ __u16 GetNextMid(struct TCP_Server_Info *server)
struct
mid_q_entry
*
mid_entry
;
struct
mid_q_entry
*
mid_entry
;
collision
=
0
;
collision
=
0
;
if
(
server
->
CurrentMid
==
0
)
if
(
server
->
CurrentMid
==
0
)
server
->
CurrentMid
++
;
server
->
CurrentMid
++
;
list_for_each
(
tmp
,
&
server
->
pending_mid_q
)
{
list_for_each
(
tmp
,
&
server
->
pending_mid_q
)
{
...
@@ -273,7 +273,7 @@ __u16 GetNextMid(struct TCP_Server_Info *server)
...
@@ -273,7 +273,7 @@ __u16 GetNextMid(struct TCP_Server_Info *server)
break
;
break
;
}
}
}
}
if
(
collision
==
0
)
{
if
(
collision
==
0
)
{
mid
=
server
->
CurrentMid
;
mid
=
server
->
CurrentMid
;
break
;
break
;
}
}
...
@@ -325,7 +325,7 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
...
@@ -325,7 +325,7 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
/* Uid is not converted */
/* Uid is not converted */
buffer
->
Uid
=
treeCon
->
ses
->
Suid
;
buffer
->
Uid
=
treeCon
->
ses
->
Suid
;
buffer
->
Mid
=
GetNextMid
(
treeCon
->
ses
->
server
);
buffer
->
Mid
=
GetNextMid
(
treeCon
->
ses
->
server
);
if
(
multiuser_mount
!=
0
)
{
if
(
multiuser_mount
!=
0
)
{
/* For the multiuser case, there are few obvious technically */
/* For the multiuser case, there are few obvious technically */
/* possible mechanisms to match the local linux user (uid) */
/* possible mechanisms to match the local linux user (uid) */
/* to a valid remote smb user (smb_uid): */
/* to a valid remote smb user (smb_uid): */
...
@@ -350,13 +350,13 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
...
@@ -350,13 +350,13 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
/* BB Add support for establishing new tCon and SMB Session */
/* BB Add support for establishing new tCon and SMB Session */
/* with userid/password pairs found on the smb session */
/* with userid/password pairs found on the smb session */
/* for other target tcp/ip addresses BB */
/* for other target tcp/ip addresses BB */
if
(
current
->
fsuid
!=
treeCon
->
ses
->
linux_uid
)
{
if
(
current
->
fsuid
!=
treeCon
->
ses
->
linux_uid
)
{
cFYI
(
1
,(
"Multiuser mode and UID did not match tcon uid"
));
cFYI
(
1
,(
"Multiuser mode and UID did not match tcon uid"
));
read_lock
(
&
GlobalSMBSeslock
);
read_lock
(
&
GlobalSMBSeslock
);
list_for_each
(
temp_item
,
&
GlobalSMBSessionList
)
{
list_for_each
(
temp_item
,
&
GlobalSMBSessionList
)
{
ses
=
list_entry
(
temp_item
,
struct
cifsSesInfo
,
cifsSessionList
);
ses
=
list_entry
(
temp_item
,
struct
cifsSesInfo
,
cifsSessionList
);
if
(
ses
->
linux_uid
==
current
->
fsuid
)
{
if
(
ses
->
linux_uid
==
current
->
fsuid
)
{
if
(
ses
->
server
==
treeCon
->
ses
->
server
)
{
if
(
ses
->
server
==
treeCon
->
ses
->
server
)
{
cFYI
(
1
,(
"found matching uid substitute right smb_uid"
));
cFYI
(
1
,(
"found matching uid substitute right smb_uid"
));
buffer
->
Uid
=
ses
->
Suid
;
buffer
->
Uid
=
ses
->
Suid
;
break
;
break
;
...
@@ -374,8 +374,8 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
...
@@ -374,8 +374,8 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
buffer
->
Flags2
|=
SMBFLG2_DFS
;
buffer
->
Flags2
|=
SMBFLG2_DFS
;
if
(
treeCon
->
nocase
)
if
(
treeCon
->
nocase
)
buffer
->
Flags
|=
SMBFLG_CASELESS
;
buffer
->
Flags
|=
SMBFLG_CASELESS
;
if
((
treeCon
->
ses
)
&&
(
treeCon
->
ses
->
server
))
if
((
treeCon
->
ses
)
&&
(
treeCon
->
ses
->
server
))
if
(
treeCon
->
ses
->
server
->
secMode
&
if
(
treeCon
->
ses
->
server
->
secMode
&
(
SECMODE_SIGN_REQUIRED
|
SECMODE_SIGN_ENABLED
))
(
SECMODE_SIGN_REQUIRED
|
SECMODE_SIGN_ENABLED
))
buffer
->
Flags2
|=
SMBFLG2_SECURITY_SIGNATURE
;
buffer
->
Flags2
|=
SMBFLG2_SECURITY_SIGNATURE
;
}
}
...
@@ -392,11 +392,11 @@ checkSMBhdr(struct smb_hdr *smb, __u16 mid)
...
@@ -392,11 +392,11 @@ checkSMBhdr(struct smb_hdr *smb, __u16 mid)
and that the message ids match */
and that the message ids match */
if
((
*
(
__le32
*
)
smb
->
Protocol
==
cpu_to_le32
(
0x424d53ff
))
&&
if
((
*
(
__le32
*
)
smb
->
Protocol
==
cpu_to_le32
(
0x424d53ff
))
&&
(
mid
==
smb
->
Mid
))
{
(
mid
==
smb
->
Mid
))
{
if
(
smb
->
Flags
&
SMBFLG_RESPONSE
)
if
(
smb
->
Flags
&
SMBFLG_RESPONSE
)
return
0
;
return
0
;
else
{
else
{
/* only one valid case where server sends us request */
/* only one valid case where server sends us request */
if
(
smb
->
Command
==
SMB_COM_LOCKING_ANDX
)
if
(
smb
->
Command
==
SMB_COM_LOCKING_ANDX
)
return
0
;
return
0
;
else
else
cERROR
(
1
,
(
"Rcvd Request not response"
));
cERROR
(
1
,
(
"Rcvd Request not response"
));
...
@@ -458,16 +458,16 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length)
...
@@ -458,16 +458,16 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length)
return
1
;
return
1
;
clc_len
=
smbCalcSize_LE
(
smb
);
clc_len
=
smbCalcSize_LE
(
smb
);
if
(
4
+
len
!=
length
)
{
if
(
4
+
len
!=
length
)
{
cERROR
(
1
,
(
"Length read does not match RFC1001 length %d"
,
len
));
cERROR
(
1
,
(
"Length read does not match RFC1001 length %d"
,
len
));
return
1
;
return
1
;
}
}
if
(
4
+
len
!=
clc_len
)
{
if
(
4
+
len
!=
clc_len
)
{
/* check if bcc wrapped around for large read responses */
/* check if bcc wrapped around for large read responses */
if
((
len
>
64
*
1024
)
&&
(
len
>
clc_len
))
{
if
((
len
>
64
*
1024
)
&&
(
len
>
clc_len
))
{
/* check if lengths match mod 64K */
/* check if lengths match mod 64K */
if
(((
4
+
len
)
&
0xFFFF
)
==
(
clc_len
&
0xFFFF
))
if
(((
4
+
len
)
&
0xFFFF
)
==
(
clc_len
&
0xFFFF
))
return
0
;
/* bcc wrapped */
return
0
;
/* bcc wrapped */
}
}
cFYI
(
1
,
(
"Calculated size %d vs length %d mismatch for mid %d"
,
cFYI
(
1
,
(
"Calculated size %d vs length %d mismatch for mid %d"
,
...
@@ -483,7 +483,7 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length)
...
@@ -483,7 +483,7 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length)
but server says length is 0x21 bytes too long as if the server
but server says length is 0x21 bytes too long as if the server
forget to reset the smb rfc1001 length when it reset the
forget to reset the smb rfc1001 length when it reset the
wct and bcc to minimum size and drop the t2 parms and data */
wct and bcc to minimum size and drop the t2 parms and data */
if
((
4
+
len
>
clc_len
)
&&
(
len
<=
clc_len
+
512
))
if
((
4
+
len
>
clc_len
)
&&
(
len
<=
clc_len
+
512
))
return
0
;
return
0
;
else
{
else
{
cERROR
(
1
,
(
"RFC1001 size %d bigger than SMB for Mid=%d"
,
cERROR
(
1
,
(
"RFC1001 size %d bigger than SMB for Mid=%d"
,
...
@@ -503,13 +503,13 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
...
@@ -503,13 +503,13 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
struct
cifsFileInfo
*
netfile
;
struct
cifsFileInfo
*
netfile
;
cFYI
(
1
,(
"Checking for oplock break or dnotify response"
));
cFYI
(
1
,(
"Checking for oplock break or dnotify response"
));
if
((
pSMB
->
hdr
.
Command
==
SMB_COM_NT_TRANSACT
)
&&
if
((
pSMB
->
hdr
.
Command
==
SMB_COM_NT_TRANSACT
)
&&
(
pSMB
->
hdr
.
Flags
&
SMBFLG_RESPONSE
))
{
(
pSMB
->
hdr
.
Flags
&
SMBFLG_RESPONSE
))
{
struct
smb_com_transaction_change_notify_rsp
*
pSMBr
=
struct
smb_com_transaction_change_notify_rsp
*
pSMBr
=
(
struct
smb_com_transaction_change_notify_rsp
*
)
buf
;
(
struct
smb_com_transaction_change_notify_rsp
*
)
buf
;
struct
file_notify_information
*
pnotify
;
struct
file_notify_information
*
pnotify
;
__u32
data_offset
=
0
;
__u32
data_offset
=
0
;
if
(
pSMBr
->
ByteCount
>
sizeof
(
struct
file_notify_information
))
{
if
(
pSMBr
->
ByteCount
>
sizeof
(
struct
file_notify_information
))
{
data_offset
=
le32_to_cpu
(
pSMBr
->
DataOffset
);
data_offset
=
le32_to_cpu
(
pSMBr
->
DataOffset
);
pnotify
=
(
struct
file_notify_information
*
)
pnotify
=
(
struct
file_notify_information
*
)
...
@@ -520,15 +520,15 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
...
@@ -520,15 +520,15 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
sizeof(struct smb_hdr)+60); */
sizeof(struct smb_hdr)+60); */
return
TRUE
;
return
TRUE
;
}
}
if
(
pSMBr
->
hdr
.
Status
.
CifsError
)
{
if
(
pSMBr
->
hdr
.
Status
.
CifsError
)
{
cFYI
(
1
,(
"notify err 0x%d"
,
pSMBr
->
hdr
.
Status
.
CifsError
));
cFYI
(
1
,(
"notify err 0x%d"
,
pSMBr
->
hdr
.
Status
.
CifsError
));
return
TRUE
;
return
TRUE
;
}
}
return
FALSE
;
return
FALSE
;
}
}
if
(
pSMB
->
hdr
.
Command
!=
SMB_COM_LOCKING_ANDX
)
if
(
pSMB
->
hdr
.
Command
!=
SMB_COM_LOCKING_ANDX
)
return
FALSE
;
return
FALSE
;
if
(
pSMB
->
hdr
.
Flags
&
SMBFLG_RESPONSE
)
{
if
(
pSMB
->
hdr
.
Flags
&
SMBFLG_RESPONSE
)
{
/* no sense logging error on invalid handle on oplock
/* no sense logging error on invalid handle on oplock
break - harmless race between close request and oplock
break - harmless race between close request and oplock
break response is expected from time to time writing out
break response is expected from time to time writing out
...
@@ -544,11 +544,11 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
...
@@ -544,11 +544,11 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
return
FALSE
;
/* on valid oplock brk we get "request" */
return
FALSE
;
/* on valid oplock brk we get "request" */
}
}
}
}
if
(
pSMB
->
hdr
.
WordCount
!=
8
)
if
(
pSMB
->
hdr
.
WordCount
!=
8
)
return
FALSE
;
return
FALSE
;
cFYI
(
1
,(
" oplock type 0x%d level 0x%d"
,
pSMB
->
LockType
,
pSMB
->
OplockLevel
));
cFYI
(
1
,(
" oplock type 0x%d level 0x%d"
,
pSMB
->
LockType
,
pSMB
->
OplockLevel
));
if
(
!
(
pSMB
->
LockType
&
LOCKING_ANDX_OPLOCK_RELEASE
))
if
(
!
(
pSMB
->
LockType
&
LOCKING_ANDX_OPLOCK_RELEASE
))
return
FALSE
;
return
FALSE
;
/* look up tcon based on tid & uid */
/* look up tcon based on tid & uid */
...
@@ -560,14 +560,14 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
...
@@ -560,14 +560,14 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
list_for_each
(
tmp1
,
&
tcon
->
openFileList
){
list_for_each
(
tmp1
,
&
tcon
->
openFileList
){
netfile
=
list_entry
(
tmp1
,
struct
cifsFileInfo
,
netfile
=
list_entry
(
tmp1
,
struct
cifsFileInfo
,
tlist
);
tlist
);
if
(
pSMB
->
Fid
==
netfile
->
netfid
)
{
if
(
pSMB
->
Fid
==
netfile
->
netfid
)
{
struct
cifsInodeInfo
*
pCifsInode
;
struct
cifsInodeInfo
*
pCifsInode
;
read_unlock
(
&
GlobalSMBSeslock
);
read_unlock
(
&
GlobalSMBSeslock
);
cFYI
(
1
,(
"file id match, oplock break"
));
cFYI
(
1
,(
"file id match, oplock break"
));
pCifsInode
=
pCifsInode
=
CIFS_I
(
netfile
->
pInode
);
CIFS_I
(
netfile
->
pInode
);
pCifsInode
->
clientCanCacheAll
=
FALSE
;
pCifsInode
->
clientCanCacheAll
=
FALSE
;
if
(
pSMB
->
OplockLevel
==
0
)
if
(
pSMB
->
OplockLevel
==
0
)
pCifsInode
->
clientCanCacheRead
pCifsInode
->
clientCanCacheRead
=
FALSE
;
=
FALSE
;
pCifsInode
->
oplockPending
=
TRUE
;
pCifsInode
->
oplockPending
=
TRUE
;
...
@@ -575,7 +575,7 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
...
@@ -575,7 +575,7 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
netfile
->
netfid
,
netfile
->
netfid
,
tcon
);
tcon
);
cFYI
(
1
,(
"about to wake up oplock thd"
));
cFYI
(
1
,(
"about to wake up oplock thd"
));
if
(
oplockThread
)
if
(
oplockThread
)
wake_up_process
(
oplockThread
);
wake_up_process
(
oplockThread
);
return
TRUE
;
return
TRUE
;
}
}
...
@@ -681,7 +681,7 @@ cifs_convertUCSpath(char *target, const __le16 * source, int maxlen,
...
@@ -681,7 +681,7 @@ cifs_convertUCSpath(char *target, const __le16 * source, int maxlen,
default:
default:
len
=
cp
->
uni2char
(
src_char
,
&
target
[
j
],
len
=
cp
->
uni2char
(
src_char
,
&
target
[
j
],
NLS_MAX_CHARSET_SIZE
);
NLS_MAX_CHARSET_SIZE
);
if
(
len
>
0
)
{
if
(
len
>
0
)
{
j
+=
len
;
j
+=
len
;
continue
;
continue
;
}
else
{
}
else
{
...
@@ -690,7 +690,7 @@ cifs_convertUCSpath(char *target, const __le16 * source, int maxlen,
...
@@ -690,7 +690,7 @@ cifs_convertUCSpath(char *target, const __le16 * source, int maxlen,
}
}
j
++
;
j
++
;
/* make sure we do not overrun callers allocated temp buffer */
/* make sure we do not overrun callers allocated temp buffer */
if
(
j
>=
(
2
*
NAME_MAX
))
if
(
j
>=
(
2
*
NAME_MAX
))
break
;
break
;
}
}
cUCS_out:
cUCS_out:
...
@@ -711,7 +711,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen,
...
@@ -711,7 +711,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen,
char
src_char
;
char
src_char
;
__u16
temp
;
__u16
temp
;
if
(
!
mapChars
)
if
(
!
mapChars
)
return
cifs_strtoUCS
(
target
,
source
,
PATH_MAX
,
cp
);
return
cifs_strtoUCS
(
target
,
source
,
PATH_MAX
,
cp
);
for
(
i
=
0
,
j
=
0
;
i
<
maxlen
;
j
++
)
{
for
(
i
=
0
,
j
=
0
;
i
<
maxlen
;
j
++
)
{
...
@@ -749,7 +749,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen,
...
@@ -749,7 +749,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen,
len_remaining
,
&
temp
);
len_remaining
,
&
temp
);
/* if no match, use question mark, which
/* if no match, use question mark, which
at least in some cases servers as wild card */
at least in some cases servers as wild card */
if
(
charlen
<
1
)
{
if
(
charlen
<
1
)
{
target
[
j
]
=
cpu_to_le16
(
0x003f
);
target
[
j
]
=
cpu_to_le16
(
0x003f
);
charlen
=
1
;
charlen
=
1
;
}
else
}
else
...
...
fs/cifs/netmisc.c
View file @
790fe579
...
@@ -140,9 +140,9 @@ cifs_inet_pton(int address_family, char *cp,void *dst)
...
@@ -140,9 +140,9 @@ cifs_inet_pton(int address_family, char *cp,void *dst)
/* calculate length by finding first slash or NULL */
/* calculate length by finding first slash or NULL */
/* BB Should we convert '/' slash to '\' here since it seems already done
/* BB Should we convert '/' slash to '\' here since it seems already done
before this */
before this */
if
(
address_family
==
AF_INET
)
{
if
(
address_family
==
AF_INET
)
{
ret
=
in4_pton
(
cp
,
-
1
/* len */
,
dst
,
'\\'
,
NULL
);
ret
=
in4_pton
(
cp
,
-
1
/* len */
,
dst
,
'\\'
,
NULL
);
}
else
if
(
address_family
==
AF_INET6
)
{
}
else
if
(
address_family
==
AF_INET6
)
{
ret
=
in6_pton
(
cp
,
-
1
/* len */
,
dst
,
'\\'
,
NULL
);
ret
=
in6_pton
(
cp
,
-
1
/* len */
,
dst
,
'\\'
,
NULL
);
}
}
#ifdef CONFIG_CIFS_DEBUG2
#ifdef CONFIG_CIFS_DEBUG2
...
@@ -773,7 +773,7 @@ map_smb_to_linux_error(struct smb_hdr *smb)
...
@@ -773,7 +773,7 @@ map_smb_to_linux_error(struct smb_hdr *smb)
if
(
smb
->
Flags2
&
SMBFLG2_ERR_STATUS
)
{
if
(
smb
->
Flags2
&
SMBFLG2_ERR_STATUS
)
{
/* translate the newer STATUS codes to old style errors and then to POSIX errors */
/* translate the newer STATUS codes to old style errors and then to POSIX errors */
__u32
err
=
le32_to_cpu
(
smb
->
Status
.
CifsError
);
__u32
err
=
le32_to_cpu
(
smb
->
Status
.
CifsError
);
if
(
cifsFYI
&
CIFS_RC
)
if
(
cifsFYI
&
CIFS_RC
)
cifs_print_status
(
err
);
cifs_print_status
(
err
);
ntstatus_to_dos
(
err
,
&
smberrclass
,
&
smberrcode
);
ntstatus_to_dos
(
err
,
&
smberrclass
,
&
smberrcode
);
}
else
{
}
else
{
...
@@ -889,15 +889,15 @@ struct timespec cnvrtDosUnixTm(__u16 date, __u16 time)
...
@@ -889,15 +889,15 @@ struct timespec cnvrtDosUnixTm(__u16 date, __u16 time)
sec
=
2
*
st
->
TwoSeconds
;
sec
=
2
*
st
->
TwoSeconds
;
min
=
st
->
Minutes
;
min
=
st
->
Minutes
;
if
((
sec
>
59
)
||
(
min
>
59
))
if
((
sec
>
59
)
||
(
min
>
59
))
cERROR
(
1
,(
"illegal time min %d sec %d"
,
min
,
sec
));
cERROR
(
1
,(
"illegal time min %d sec %d"
,
min
,
sec
));
sec
+=
(
min
*
60
);
sec
+=
(
min
*
60
);
sec
+=
60
*
60
*
st
->
Hours
;
sec
+=
60
*
60
*
st
->
Hours
;
if
(
st
->
Hours
>
24
)
if
(
st
->
Hours
>
24
)
cERROR
(
1
,(
"illegal hours %d"
,
st
->
Hours
));
cERROR
(
1
,(
"illegal hours %d"
,
st
->
Hours
));
days
=
sd
->
Day
;
days
=
sd
->
Day
;
month
=
sd
->
Month
;
month
=
sd
->
Month
;
if
((
days
>
31
)
||
(
month
>
12
))
if
((
days
>
31
)
||
(
month
>
12
))
cERROR
(
1
,(
"illegal date, month %d day: %d"
,
month
,
days
));
cERROR
(
1
,(
"illegal date, month %d day: %d"
,
month
,
days
));
month
-=
1
;
month
-=
1
;
days
+=
total_days_of_prev_months
[
month
];
days
+=
total_days_of_prev_months
[
month
];
...
@@ -911,11 +911,11 @@ struct timespec cnvrtDosUnixTm(__u16 date, __u16 time)
...
@@ -911,11 +911,11 @@ struct timespec cnvrtDosUnixTm(__u16 date, __u16 time)
consider 2 special case years, ie the years 2000 and 2100, and only
consider 2 special case years, ie the years 2000 and 2100, and only
adjust for the lack of leap year for the year 2100, as 2000 was a
adjust for the lack of leap year for the year 2100, as 2000 was a
leap year (divisable by 400) */
leap year (divisable by 400) */
if
(
year
>=
120
)
/* the year 2100 */
if
(
year
>=
120
)
/* the year 2100 */
days
=
days
-
1
;
/* do not count leap year for the year 2100 */
days
=
days
-
1
;
/* do not count leap year for the year 2100 */
/* adjust for leap year where we are still before leap day */
/* adjust for leap year where we are still before leap day */
if
(
year
!=
120
)
if
(
year
!=
120
)
days
-=
((
year
&
0x03
)
==
0
)
&&
(
month
<
2
?
1
:
0
);
days
-=
((
year
&
0x03
)
==
0
)
&&
(
month
<
2
?
1
:
0
);
sec
+=
24
*
60
*
60
*
days
;
sec
+=
24
*
60
*
60
*
days
;
...
...
fs/cifs/readdir.c
View file @
790fe579
...
@@ -110,7 +110,7 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
...
@@ -110,7 +110,7 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
return
rc
;
return
rc
;
}
}
static
void
AdjustForTZ
(
struct
cifsTconInfo
*
tcon
,
struct
inode
*
inode
)
static
void
AdjustForTZ
(
struct
cifsTconInfo
*
tcon
,
struct
inode
*
inode
)
{
{
if
((
tcon
)
&&
(
tcon
->
ses
)
&&
(
tcon
->
ses
->
server
))
{
if
((
tcon
)
&&
(
tcon
->
ses
)
&&
(
tcon
->
ses
->
server
))
{
inode
->
i_ctime
.
tv_sec
+=
tcon
->
ses
->
server
->
timeAdj
;
inode
->
i_ctime
.
tv_sec
+=
tcon
->
ses
->
server
->
timeAdj
;
...
@@ -122,7 +122,7 @@ static void AdjustForTZ(struct cifsTconInfo * tcon, struct inode * inode)
...
@@ -122,7 +122,7 @@ static void AdjustForTZ(struct cifsTconInfo * tcon, struct inode * inode)
static
void
fill_in_inode
(
struct
inode
*
tmp_inode
,
int
new_buf_type
,
static
void
fill_in_inode
(
struct
inode
*
tmp_inode
,
int
new_buf_type
,
char
*
buf
,
int
*
pobject_type
,
int
isNewInode
)
char
*
buf
,
int
*
pobject_type
,
int
isNewInode
)
{
{
loff_t
local_size
;
loff_t
local_size
;
struct
timespec
local_mtime
;
struct
timespec
local_mtime
;
...
@@ -354,7 +354,7 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
...
@@ -354,7 +354,7 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
/* safest to just call it a file */
/* safest to just call it a file */
*
pobject_type
=
DT_REG
;
*
pobject_type
=
DT_REG
;
tmp_inode
->
i_mode
|=
S_IFREG
;
tmp_inode
->
i_mode
|=
S_IFREG
;
cFYI
(
1
,
(
"unknown inode type %d"
,
type
));
cFYI
(
1
,
(
"unknown inode type %d"
,
type
));
}
}
if
(
cifs_sb
->
mnt_cifs_flags
&
CIFS_MOUNT_OVERR_UID
)
if
(
cifs_sb
->
mnt_cifs_flags
&
CIFS_MOUNT_OVERR_UID
)
...
@@ -401,8 +401,9 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
...
@@ -401,8 +401,9 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
tmp_inode
->
i_data
.
a_ops
=
&
cifs_addr_ops
;
tmp_inode
->
i_data
.
a_ops
=
&
cifs_addr_ops
;
if
(
isNewInode
)
if
(
isNewInode
)
return
;
/* No sense invalidating pages for new inode since we
return
;
/* No sense invalidating pages for new inode
have not started caching readahead file data yet */
since we have not started caching readahead
file data for it yet */
if
(
timespec_equal
(
&
tmp_inode
->
i_mtime
,
&
local_mtime
)
&&
if
(
timespec_equal
(
&
tmp_inode
->
i_mtime
,
&
local_mtime
)
&&
(
local_size
==
tmp_inode
->
i_size
))
{
(
local_size
==
tmp_inode
->
i_size
))
{
...
@@ -500,7 +501,7 @@ static int cifs_unicode_bytelen(char *str)
...
@@ -500,7 +501,7 @@ static int cifs_unicode_bytelen(char *str)
if
(
ustr
[
len
]
==
0
)
if
(
ustr
[
len
]
==
0
)
return
len
<<
1
;
return
len
<<
1
;
}
}
cFYI
(
1
,(
"Unicode string longer than PATH_MAX found"
));
cFYI
(
1
,
(
"Unicode string longer than PATH_MAX found"
));
return
len
<<
1
;
return
len
<<
1
;
}
}
...
@@ -517,7 +518,7 @@ static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level)
...
@@ -517,7 +518,7 @@ static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level)
pfData
->
FileNameLength
;
pfData
->
FileNameLength
;
}
else
}
else
new_entry
=
old_entry
+
le32_to_cpu
(
pDirInfo
->
NextEntryOffset
);
new_entry
=
old_entry
+
le32_to_cpu
(
pDirInfo
->
NextEntryOffset
);
cFYI
(
1
,
(
"new entry %p old entry %p"
,
new_entry
,
old_entry
));
cFYI
(
1
,
(
"new entry %p old entry %p"
,
new_entry
,
old_entry
));
/* validate that new_entry is not past end of SMB */
/* validate that new_entry is not past end of SMB */
if
(
new_entry
>=
end_of_smb
)
{
if
(
new_entry
>=
end_of_smb
)
{
cERROR
(
1
,
cERROR
(
1
,
...
@@ -583,7 +584,8 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
...
@@ -583,7 +584,8 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
filename
=
&
pFindData
->
FileName
[
0
];
filename
=
&
pFindData
->
FileName
[
0
];
len
=
pFindData
->
FileNameLength
;
len
=
pFindData
->
FileNameLength
;
}
else
{
}
else
{
cFYI
(
1
,(
"Unknown findfirst level %d"
,
cfile
->
srch_inf
.
info_level
));
cFYI
(
1
,
(
"Unknown findfirst level %d"
,
cfile
->
srch_inf
.
info_level
));
}
}
if
(
filename
)
{
if
(
filename
)
{
...
@@ -604,7 +606,7 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
...
@@ -604,7 +606,7 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
if
(
filename
[
0
]
==
'.'
)
if
(
filename
[
0
]
==
'.'
)
rc
=
1
;
rc
=
1
;
}
else
if
(
len
==
2
)
{
}
else
if
(
len
==
2
)
{
if
((
filename
[
0
]
==
'.'
)
&&
(
filename
[
1
]
==
'.'
))
if
((
filename
[
0
]
==
'.'
)
&&
(
filename
[
1
]
==
'.'
))
rc
=
2
;
rc
=
2
;
}
}
}
}
...
@@ -665,13 +667,13 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
...
@@ -665,13 +667,13 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
is_dir_changed
(
file
))
||
is_dir_changed
(
file
))
||
(
index_to_find
<
first_entry_in_buffer
))
{
(
index_to_find
<
first_entry_in_buffer
))
{
/* close and restart search */
/* close and restart search */
cFYI
(
1
,(
"search backing up - close and restart search"
));
cFYI
(
1
,
(
"search backing up - close and restart search"
));
cifsFile
->
invalidHandle
=
TRUE
;
cifsFile
->
invalidHandle
=
TRUE
;
CIFSFindClose
(
xid
,
pTcon
,
cifsFile
->
netfid
);
CIFSFindClose
(
xid
,
pTcon
,
cifsFile
->
netfid
);
kfree
(
cifsFile
->
search_resume_name
);
kfree
(
cifsFile
->
search_resume_name
);
cifsFile
->
search_resume_name
=
NULL
;
cifsFile
->
search_resume_name
=
NULL
;
if
(
cifsFile
->
srch_inf
.
ntwrk_buf_start
)
{
if
(
cifsFile
->
srch_inf
.
ntwrk_buf_start
)
{
cFYI
(
1
,(
"freeing SMB ff cache buf on search rewind"
));
cFYI
(
1
,
(
"freeing SMB ff cache buf on search rewind"
));
if
(
cifsFile
->
srch_inf
.
smallBuf
)
if
(
cifsFile
->
srch_inf
.
smallBuf
)
cifs_small_buf_release
(
cifsFile
->
srch_inf
.
cifs_small_buf_release
(
cifsFile
->
srch_inf
.
ntwrk_buf_start
);
ntwrk_buf_start
);
...
@@ -681,14 +683,15 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
...
@@ -681,14 +683,15 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
}
}
rc
=
initiate_cifs_search
(
xid
,
file
);
rc
=
initiate_cifs_search
(
xid
,
file
);
if
(
rc
)
{
if
(
rc
)
{
cFYI
(
1
,(
"error %d reinitiating a search on rewind"
,
rc
));
cFYI
(
1
,
(
"error %d reinitiating a search on rewind"
,
rc
));
return
rc
;
return
rc
;
}
}
}
}
while
((
index_to_find
>=
cifsFile
->
srch_inf
.
index_of_last_entry
)
&&
while
((
index_to_find
>=
cifsFile
->
srch_inf
.
index_of_last_entry
)
&&
(
rc
==
0
)
&&
(
cifsFile
->
srch_inf
.
endOfSearch
==
FALSE
)){
(
rc
==
0
)
&&
(
cifsFile
->
srch_inf
.
endOfSearch
==
FALSE
)){
cFYI
(
1
,
(
"calling findnext2"
));
cFYI
(
1
,
(
"calling findnext2"
));
rc
=
CIFSFindNext
(
xid
,
pTcon
,
cifsFile
->
netfid
,
rc
=
CIFSFindNext
(
xid
,
pTcon
,
cifsFile
->
netfid
,
&
cifsFile
->
srch_inf
);
&
cifsFile
->
srch_inf
);
if
(
rc
)
if
(
rc
)
...
@@ -707,14 +710,14 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
...
@@ -707,14 +710,14 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
first_entry_in_buffer
=
cifsFile
->
srch_inf
.
index_of_last_entry
first_entry_in_buffer
=
cifsFile
->
srch_inf
.
index_of_last_entry
-
cifsFile
->
srch_inf
.
entries_in_buffer
;
-
cifsFile
->
srch_inf
.
entries_in_buffer
;
pos_in_buf
=
index_to_find
-
first_entry_in_buffer
;
pos_in_buf
=
index_to_find
-
first_entry_in_buffer
;
cFYI
(
1
,
(
"found entry - pos_in_buf %d"
,
pos_in_buf
));
cFYI
(
1
,
(
"found entry - pos_in_buf %d"
,
pos_in_buf
));
for
(
i
=
0
;(
i
<
(
pos_in_buf
))
&&
(
current_entry
!=
NULL
);
i
++
)
{
for
(
i
=
0
;(
i
<
(
pos_in_buf
))
&&
(
current_entry
!=
NULL
);
i
++
)
{
/* go entry by entry figuring out which is first */
/* go entry by entry figuring out which is first */
current_entry
=
nxt_dir_entry
(
current_entry
,
end_of_smb
,
current_entry
=
nxt_dir_entry
(
current_entry
,
end_of_smb
,
cifsFile
->
srch_inf
.
info_level
);
cifsFile
->
srch_inf
.
info_level
);
}
}
if
((
current_entry
==
NULL
)
&&
(
i
<
pos_in_buf
))
{
if
((
current_entry
==
NULL
)
&&
(
i
<
pos_in_buf
))
{
/* BB fixme - check if we should flag this error */
/* BB fixme - check if we should flag this error */
cERROR
(
1
,(
"reached end of buf searching for pos in buf"
cERROR
(
1
,(
"reached end of buf searching for pos in buf"
" %d index to find %lld rc %d"
,
" %d index to find %lld rc %d"
,
...
@@ -723,12 +726,12 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
...
@@ -723,12 +726,12 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
rc
=
0
;
rc
=
0
;
*
ppCurrentEntry
=
current_entry
;
*
ppCurrentEntry
=
current_entry
;
}
else
{
}
else
{
cFYI
(
1
,(
"index not in buffer - could not findnext into it"
));
cFYI
(
1
,
(
"index not in buffer - could not findnext into it"
));
return
0
;
return
0
;
}
}
if
(
pos_in_buf
>=
cifsFile
->
srch_inf
.
entries_in_buffer
)
{
if
(
pos_in_buf
>=
cifsFile
->
srch_inf
.
entries_in_buffer
)
{
cFYI
(
1
,
(
"can not return entries pos_in_buf beyond last entry
"
));
cFYI
(
1
,
(
"can not return entries pos_in_buf beyond last
"
));
*
num_to_ret
=
0
;
*
num_to_ret
=
0
;
}
else
}
else
*
num_to_ret
=
cifsFile
->
srch_inf
.
entries_in_buffer
-
pos_in_buf
;
*
num_to_ret
=
cifsFile
->
srch_inf
.
entries_in_buffer
-
pos_in_buf
;
...
@@ -748,11 +751,11 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
...
@@ -748,11 +751,11 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
*
pinum
=
0
;
*
pinum
=
0
;
if
(
level
==
SMB_FIND_FILE_UNIX
)
{
if
(
level
==
SMB_FIND_FILE_UNIX
)
{
FILE_UNIX_INFO
*
pFindData
=
(
FILE_UNIX_INFO
*
)
current_entry
;
FILE_UNIX_INFO
*
pFindData
=
(
FILE_UNIX_INFO
*
)
current_entry
;
filename
=
&
pFindData
->
FileName
[
0
];
filename
=
&
pFindData
->
FileName
[
0
];
if
(
unicode
)
{
if
(
unicode
)
{
len
=
cifs_unicode_bytelen
(
filename
);
len
=
cifs_unicode_bytelen
(
filename
);
}
else
{
}
else
{
/* BB should we make this strnlen of PATH_MAX? */
/* BB should we make this strnlen of PATH_MAX? */
...
@@ -760,49 +763,49 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
...
@@ -760,49 +763,49 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
}
}
/* BB fixme - hash low and high 32 bits if not 64 bit arch BB fixme */
/* BB fixme - hash low and high 32 bits if not 64 bit arch BB fixme */
if
(
cifs_sb
->
mnt_cifs_flags
&
CIFS_MOUNT_SERVER_INUM
)
if
(
cifs_sb
->
mnt_cifs_flags
&
CIFS_MOUNT_SERVER_INUM
)
*
pinum
=
pFindData
->
UniqueId
;
*
pinum
=
pFindData
->
UniqueId
;
}
else
if
(
level
==
SMB_FIND_FILE_DIRECTORY_INFO
)
{
}
else
if
(
level
==
SMB_FIND_FILE_DIRECTORY_INFO
)
{
FILE_DIRECTORY_INFO
*
pFindData
=
FILE_DIRECTORY_INFO
*
pFindData
=
(
FILE_DIRECTORY_INFO
*
)
current_entry
;
(
FILE_DIRECTORY_INFO
*
)
current_entry
;
filename
=
&
pFindData
->
FileName
[
0
];
filename
=
&
pFindData
->
FileName
[
0
];
len
=
le32_to_cpu
(
pFindData
->
FileNameLength
);
len
=
le32_to_cpu
(
pFindData
->
FileNameLength
);
}
else
if
(
level
==
SMB_FIND_FILE_FULL_DIRECTORY_INFO
)
{
}
else
if
(
level
==
SMB_FIND_FILE_FULL_DIRECTORY_INFO
)
{
FILE_FULL_DIRECTORY_INFO
*
pFindData
=
FILE_FULL_DIRECTORY_INFO
*
pFindData
=
(
FILE_FULL_DIRECTORY_INFO
*
)
current_entry
;
(
FILE_FULL_DIRECTORY_INFO
*
)
current_entry
;
filename
=
&
pFindData
->
FileName
[
0
];
filename
=
&
pFindData
->
FileName
[
0
];
len
=
le32_to_cpu
(
pFindData
->
FileNameLength
);
len
=
le32_to_cpu
(
pFindData
->
FileNameLength
);
}
else
if
(
level
==
SMB_FIND_FILE_ID_FULL_DIR_INFO
)
{
}
else
if
(
level
==
SMB_FIND_FILE_ID_FULL_DIR_INFO
)
{
SEARCH_ID_FULL_DIR_INFO
*
pFindData
=
SEARCH_ID_FULL_DIR_INFO
*
pFindData
=
(
SEARCH_ID_FULL_DIR_INFO
*
)
current_entry
;
(
SEARCH_ID_FULL_DIR_INFO
*
)
current_entry
;
filename
=
&
pFindData
->
FileName
[
0
];
filename
=
&
pFindData
->
FileName
[
0
];
len
=
le32_to_cpu
(
pFindData
->
FileNameLength
);
len
=
le32_to_cpu
(
pFindData
->
FileNameLength
);
*
pinum
=
pFindData
->
UniqueId
;
*
pinum
=
pFindData
->
UniqueId
;
}
else
if
(
level
==
SMB_FIND_FILE_BOTH_DIRECTORY_INFO
)
{
}
else
if
(
level
==
SMB_FIND_FILE_BOTH_DIRECTORY_INFO
)
{
FILE_BOTH_DIRECTORY_INFO
*
pFindData
=
FILE_BOTH_DIRECTORY_INFO
*
pFindData
=
(
FILE_BOTH_DIRECTORY_INFO
*
)
current_entry
;
(
FILE_BOTH_DIRECTORY_INFO
*
)
current_entry
;
filename
=
&
pFindData
->
FileName
[
0
];
filename
=
&
pFindData
->
FileName
[
0
];
len
=
le32_to_cpu
(
pFindData
->
FileNameLength
);
len
=
le32_to_cpu
(
pFindData
->
FileNameLength
);
}
else
if
(
level
==
SMB_FIND_FILE_INFO_STANDARD
)
{
}
else
if
(
level
==
SMB_FIND_FILE_INFO_STANDARD
)
{
FIND_FILE_STANDARD_INFO
*
pFindData
=
FIND_FILE_STANDARD_INFO
*
pFindData
=
(
FIND_FILE_STANDARD_INFO
*
)
current_entry
;
(
FIND_FILE_STANDARD_INFO
*
)
current_entry
;
filename
=
&
pFindData
->
FileName
[
0
];
filename
=
&
pFindData
->
FileName
[
0
];
/* one byte length, no name conversion */
/* one byte length, no name conversion */
len
=
(
unsigned
int
)
pFindData
->
FileNameLength
;
len
=
(
unsigned
int
)
pFindData
->
FileNameLength
;
}
else
{
}
else
{
cFYI
(
1
,
(
"Unknown findfirst level %d"
,
level
));
cFYI
(
1
,
(
"Unknown findfirst level %d"
,
level
));
return
-
EINVAL
;
return
-
EINVAL
;
}
}
if
(
len
>
max_len
)
{
if
(
len
>
max_len
)
{
cERROR
(
1
,(
"bad search response length %d past smb end"
,
len
));
cERROR
(
1
,(
"bad search response length %d past smb end"
,
len
));
return
-
EINVAL
;
return
-
EINVAL
;
}
}
if
(
unicode
)
{
if
(
unicode
)
{
/* BB fixme - test with long names */
/* BB fixme - test with long names */
/* Note converted filename can be longer than in unicode */
/* Note converted filename can be longer than in unicode */
if
(
cifs_sb
->
mnt_cifs_flags
&
CIFS_MOUNT_MAP_SPECIAL_CHR
)
if
(
cifs_sb
->
mnt_cifs_flags
&
CIFS_MOUNT_MAP_SPECIAL_CHR
)
pqst
->
len
=
cifs_convertUCSpath
((
char
*
)
pqst
->
name
,
pqst
->
len
=
cifs_convertUCSpath
((
char
*
)
pqst
->
name
,
(
__le16
*
)
filename
,
len
/
2
,
nlt
);
(
__le16
*
)
filename
,
len
/
2
,
nlt
);
else
else
...
@@ -813,7 +816,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
...
@@ -813,7 +816,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
pqst
->
len
=
len
;
pqst
->
len
=
len
;
}
}
pqst
->
hash
=
full_name_hash
(
pqst
->
name
,
pqst
->
len
);
pqst
->
hash
=
full_name_hash
(
pqst
->
name
,
pqst
->
len
);
/* cFYI(1,("filldir on %s",pqst->name)); */
/* cFYI(1,
("filldir on %s",pqst->name)); */
return
rc
;
return
rc
;
}
}
...
@@ -832,17 +835,17 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
...
@@ -832,17 +835,17 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
/* get filename and len into qstring */
/* get filename and len into qstring */
/* get dentry */
/* get dentry */
/* decide whether to create and populate ionde */
/* decide whether to create and populate ionde */
if
((
direntry
==
NULL
)
||
(
file
==
NULL
))
if
((
direntry
==
NULL
)
||
(
file
==
NULL
))
return
-
EINVAL
;
return
-
EINVAL
;
pCifsF
=
file
->
private_data
;
pCifsF
=
file
->
private_data
;
if
((
scratch_buf
==
NULL
)
||
(
pfindEntry
==
NULL
)
||
(
pCifsF
==
NULL
))
if
((
scratch_buf
==
NULL
)
||
(
pfindEntry
==
NULL
)
||
(
pCifsF
==
NULL
))
return
-
ENOENT
;
return
-
ENOENT
;
rc
=
cifs_entry_is_dot
(
pfindEntry
,
pCifsF
);
rc
=
cifs_entry_is_dot
(
pfindEntry
,
pCifsF
);
/* skip . and .. since we added them first */
/* skip . and .. since we added them first */
if
(
rc
!=
0
)
if
(
rc
!=
0
)
return
0
;
return
0
;
cifs_sb
=
CIFS_SB
(
file
->
f_path
.
dentry
->
d_sb
);
cifs_sb
=
CIFS_SB
(
file
->
f_path
.
dentry
->
d_sb
);
...
@@ -854,16 +857,16 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
...
@@ -854,16 +857,16 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
max_len
,
max_len
,
&
inum
/* returned */
);
&
inum
/* returned */
);
if
(
rc
)
if
(
rc
)
return
rc
;
return
rc
;
rc
=
construct_dentry
(
&
qstring
,
file
,
&
tmp_inode
,
&
tmp_dentry
);
rc
=
construct_dentry
(
&
qstring
,
file
,
&
tmp_inode
,
&
tmp_dentry
);
if
((
tmp_inode
==
NULL
)
||
(
tmp_dentry
==
NULL
))
if
((
tmp_inode
==
NULL
)
||
(
tmp_dentry
==
NULL
))
return
-
ENOMEM
;
return
-
ENOMEM
;
if
(
rc
)
{
if
(
rc
)
{
/* inode created, we need to hash it with right inode number */
/* inode created, we need to hash it with right inode number */
if
(
inum
!=
0
)
{
if
(
inum
!=
0
)
{
/* BB fixme - hash the 2 32 quantities bits together if necessary BB */
/* BB fixme - hash the 2 32 quantities bits together if necessary BB */
tmp_inode
->
i_ino
=
inum
;
tmp_inode
->
i_ino
=
inum
;
}
}
...
@@ -873,27 +876,27 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
...
@@ -873,27 +876,27 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
/* we pass in rc below, indicating whether it is a new inode,
/* we pass in rc below, indicating whether it is a new inode,
so we can figure out whether to invalidate the inode cached
so we can figure out whether to invalidate the inode cached
data if the file has changed */
data if the file has changed */
if
(
pCifsF
->
srch_inf
.
info_level
==
SMB_FIND_FILE_UNIX
)
if
(
pCifsF
->
srch_inf
.
info_level
==
SMB_FIND_FILE_UNIX
)
unix_fill_in_inode
(
tmp_inode
,
unix_fill_in_inode
(
tmp_inode
,
(
FILE_UNIX_INFO
*
)
pfindEntry
,
(
FILE_UNIX_INFO
*
)
pfindEntry
,
&
obj_type
,
rc
);
&
obj_type
,
rc
);
else
if
(
pCifsF
->
srch_inf
.
info_level
==
SMB_FIND_FILE_INFO_STANDARD
)
else
if
(
pCifsF
->
srch_inf
.
info_level
==
SMB_FIND_FILE_INFO_STANDARD
)
fill_in_inode
(
tmp_inode
,
0
/* old level 1 buffer type */
,
fill_in_inode
(
tmp_inode
,
0
/* old level 1 buffer type */
,
pfindEntry
,
&
obj_type
,
rc
);
pfindEntry
,
&
obj_type
,
rc
);
else
else
fill_in_inode
(
tmp_inode
,
1
/* NT */
,
pfindEntry
,
&
obj_type
,
rc
);
fill_in_inode
(
tmp_inode
,
1
/* NT */
,
pfindEntry
,
&
obj_type
,
rc
);
if
(
rc
)
/* new inode - needs to be tied to dentry */
{
if
(
rc
)
/* new inode - needs to be tied to dentry */
{
d_instantiate
(
tmp_dentry
,
tmp_inode
);
d_instantiate
(
tmp_dentry
,
tmp_inode
);
if
(
rc
==
2
)
if
(
rc
==
2
)
d_rehash
(
tmp_dentry
);
d_rehash
(
tmp_dentry
);
}
}
rc
=
filldir
(
direntry
,
qstring
.
name
,
qstring
.
len
,
file
->
f_pos
,
rc
=
filldir
(
direntry
,
qstring
.
name
,
qstring
.
len
,
file
->
f_pos
,
tmp_inode
->
i_ino
,
obj_type
);
tmp_inode
->
i_ino
,
obj_type
);
if
(
rc
)
{
if
(
rc
)
{
cFYI
(
1
,
(
"filldir rc = %d"
,
rc
));
cFYI
(
1
,
(
"filldir rc = %d"
,
rc
));
/* we can not return filldir errors to the caller
/* we can not return filldir errors to the caller
since they are "normal" when the stat blocksize
since they are "normal" when the stat blocksize
is too small - we return remapped error instead */
is too small - we return remapped error instead */
...
@@ -912,47 +915,47 @@ static int cifs_save_resume_key(const char *current_entry,
...
@@ -912,47 +915,47 @@ static int cifs_save_resume_key(const char *current_entry,
__u16
level
;
__u16
level
;
char
*
filename
;
char
*
filename
;
if
((
cifsFile
==
NULL
)
||
(
current_entry
==
NULL
))
if
((
cifsFile
==
NULL
)
||
(
current_entry
==
NULL
))
return
-
EINVAL
;
return
-
EINVAL
;
level
=
cifsFile
->
srch_inf
.
info_level
;
level
=
cifsFile
->
srch_inf
.
info_level
;
if
(
level
==
SMB_FIND_FILE_UNIX
)
{
if
(
level
==
SMB_FIND_FILE_UNIX
)
{
FILE_UNIX_INFO
*
pFindData
=
(
FILE_UNIX_INFO
*
)
current_entry
;
FILE_UNIX_INFO
*
pFindData
=
(
FILE_UNIX_INFO
*
)
current_entry
;
filename
=
&
pFindData
->
FileName
[
0
];
filename
=
&
pFindData
->
FileName
[
0
];
if
(
cifsFile
->
srch_inf
.
unicode
)
{
if
(
cifsFile
->
srch_inf
.
unicode
)
{
len
=
cifs_unicode_bytelen
(
filename
);
len
=
cifs_unicode_bytelen
(
filename
);
}
else
{
}
else
{
/* BB should we make this strnlen of PATH_MAX? */
/* BB should we make this strnlen of PATH_MAX? */
len
=
strnlen
(
filename
,
PATH_MAX
);
len
=
strnlen
(
filename
,
PATH_MAX
);
}
}
cifsFile
->
srch_inf
.
resume_key
=
pFindData
->
ResumeKey
;
cifsFile
->
srch_inf
.
resume_key
=
pFindData
->
ResumeKey
;
}
else
if
(
level
==
SMB_FIND_FILE_DIRECTORY_INFO
)
{
}
else
if
(
level
==
SMB_FIND_FILE_DIRECTORY_INFO
)
{
FILE_DIRECTORY_INFO
*
pFindData
=
FILE_DIRECTORY_INFO
*
pFindData
=
(
FILE_DIRECTORY_INFO
*
)
current_entry
;
(
FILE_DIRECTORY_INFO
*
)
current_entry
;
filename
=
&
pFindData
->
FileName
[
0
];
filename
=
&
pFindData
->
FileName
[
0
];
len
=
le32_to_cpu
(
pFindData
->
FileNameLength
);
len
=
le32_to_cpu
(
pFindData
->
FileNameLength
);
cifsFile
->
srch_inf
.
resume_key
=
pFindData
->
FileIndex
;
cifsFile
->
srch_inf
.
resume_key
=
pFindData
->
FileIndex
;
}
else
if
(
level
==
SMB_FIND_FILE_FULL_DIRECTORY_INFO
)
{
}
else
if
(
level
==
SMB_FIND_FILE_FULL_DIRECTORY_INFO
)
{
FILE_FULL_DIRECTORY_INFO
*
pFindData
=
FILE_FULL_DIRECTORY_INFO
*
pFindData
=
(
FILE_FULL_DIRECTORY_INFO
*
)
current_entry
;
(
FILE_FULL_DIRECTORY_INFO
*
)
current_entry
;
filename
=
&
pFindData
->
FileName
[
0
];
filename
=
&
pFindData
->
FileName
[
0
];
len
=
le32_to_cpu
(
pFindData
->
FileNameLength
);
len
=
le32_to_cpu
(
pFindData
->
FileNameLength
);
cifsFile
->
srch_inf
.
resume_key
=
pFindData
->
FileIndex
;
cifsFile
->
srch_inf
.
resume_key
=
pFindData
->
FileIndex
;
}
else
if
(
level
==
SMB_FIND_FILE_ID_FULL_DIR_INFO
)
{
}
else
if
(
level
==
SMB_FIND_FILE_ID_FULL_DIR_INFO
)
{
SEARCH_ID_FULL_DIR_INFO
*
pFindData
=
SEARCH_ID_FULL_DIR_INFO
*
pFindData
=
(
SEARCH_ID_FULL_DIR_INFO
*
)
current_entry
;
(
SEARCH_ID_FULL_DIR_INFO
*
)
current_entry
;
filename
=
&
pFindData
->
FileName
[
0
];
filename
=
&
pFindData
->
FileName
[
0
];
len
=
le32_to_cpu
(
pFindData
->
FileNameLength
);
len
=
le32_to_cpu
(
pFindData
->
FileNameLength
);
cifsFile
->
srch_inf
.
resume_key
=
pFindData
->
FileIndex
;
cifsFile
->
srch_inf
.
resume_key
=
pFindData
->
FileIndex
;
}
else
if
(
level
==
SMB_FIND_FILE_BOTH_DIRECTORY_INFO
)
{
}
else
if
(
level
==
SMB_FIND_FILE_BOTH_DIRECTORY_INFO
)
{
FILE_BOTH_DIRECTORY_INFO
*
pFindData
=
FILE_BOTH_DIRECTORY_INFO
*
pFindData
=
(
FILE_BOTH_DIRECTORY_INFO
*
)
current_entry
;
(
FILE_BOTH_DIRECTORY_INFO
*
)
current_entry
;
filename
=
&
pFindData
->
FileName
[
0
];
filename
=
&
pFindData
->
FileName
[
0
];
len
=
le32_to_cpu
(
pFindData
->
FileNameLength
);
len
=
le32_to_cpu
(
pFindData
->
FileNameLength
);
cifsFile
->
srch_inf
.
resume_key
=
pFindData
->
FileIndex
;
cifsFile
->
srch_inf
.
resume_key
=
pFindData
->
FileIndex
;
}
else
if
(
level
==
SMB_FIND_FILE_INFO_STANDARD
)
{
}
else
if
(
level
==
SMB_FIND_FILE_INFO_STANDARD
)
{
FIND_FILE_STANDARD_INFO
*
pFindData
=
FIND_FILE_STANDARD_INFO
*
pFindData
=
(
FIND_FILE_STANDARD_INFO
*
)
current_entry
;
(
FIND_FILE_STANDARD_INFO
*
)
current_entry
;
filename
=
&
pFindData
->
FileName
[
0
];
filename
=
&
pFindData
->
FileName
[
0
];
...
@@ -960,7 +963,7 @@ static int cifs_save_resume_key(const char *current_entry,
...
@@ -960,7 +963,7 @@ static int cifs_save_resume_key(const char *current_entry,
len
=
(
unsigned
int
)
pFindData
->
FileNameLength
;
len
=
(
unsigned
int
)
pFindData
->
FileNameLength
;
cifsFile
->
srch_inf
.
resume_key
=
pFindData
->
ResumeKey
;
cifsFile
->
srch_inf
.
resume_key
=
pFindData
->
ResumeKey
;
}
else
{
}
else
{
cFYI
(
1
,
(
"Unknown findfirst level %d"
,
level
));
cFYI
(
1
,
(
"Unknown findfirst level %d"
,
level
));
return
-
EINVAL
;
return
-
EINVAL
;
}
}
cifsFile
->
srch_inf
.
resume_name_len
=
len
;
cifsFile
->
srch_inf
.
resume_name_len
=
len
;
...
@@ -985,7 +988,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
...
@@ -985,7 +988,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
cifs_sb
=
CIFS_SB
(
file
->
f_path
.
dentry
->
d_sb
);
cifs_sb
=
CIFS_SB
(
file
->
f_path
.
dentry
->
d_sb
);
pTcon
=
cifs_sb
->
tcon
;
pTcon
=
cifs_sb
->
tcon
;
if
(
pTcon
==
NULL
)
if
(
pTcon
==
NULL
)
return
-
EINVAL
;
return
-
EINVAL
;
switch
((
int
)
file
->
f_pos
)
{
switch
((
int
)
file
->
f_pos
)
{
...
@@ -1011,22 +1014,22 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
...
@@ -1011,22 +1014,22 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
if it before then restart search
if it before then restart search
if after then keep searching till find it */
if after then keep searching till find it */
if
(
file
->
private_data
==
NULL
)
{
if
(
file
->
private_data
==
NULL
)
{
rc
=
initiate_cifs_search
(
xid
,
file
);
rc
=
initiate_cifs_search
(
xid
,
file
);
cFYI
(
1
,
(
"initiate cifs search rc %d"
,
rc
));
cFYI
(
1
,
(
"initiate cifs search rc %d"
,
rc
));
if
(
rc
)
{
if
(
rc
)
{
FreeXid
(
xid
);
FreeXid
(
xid
);
return
rc
;
return
rc
;
}
}
}
}
if
(
file
->
private_data
==
NULL
)
{
if
(
file
->
private_data
==
NULL
)
{
rc
=
-
EINVAL
;
rc
=
-
EINVAL
;
FreeXid
(
xid
);
FreeXid
(
xid
);
return
rc
;
return
rc
;
}
}
cifsFile
=
file
->
private_data
;
cifsFile
=
file
->
private_data
;
if
(
cifsFile
->
srch_inf
.
endOfSearch
)
{
if
(
cifsFile
->
srch_inf
.
endOfSearch
)
{
if
(
cifsFile
->
srch_inf
.
emptyDir
)
{
if
(
cifsFile
->
srch_inf
.
emptyDir
)
{
cFYI
(
1
,
(
"End of search, empty dir"
));
cFYI
(
1
,
(
"End of search, empty dir"
));
rc
=
0
;
rc
=
0
;
break
;
break
;
...
@@ -1040,17 +1043,17 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
...
@@ -1040,17 +1043,17 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
rc
=
find_cifs_entry
(
xid
,
pTcon
,
file
,
rc
=
find_cifs_entry
(
xid
,
pTcon
,
file
,
&
current_entry
,
&
num_to_fill
);
&
current_entry
,
&
num_to_fill
);
if
(
rc
)
{
if
(
rc
)
{
cFYI
(
1
,
(
"fce error %d"
,
rc
));
cFYI
(
1
,
(
"fce error %d"
,
rc
));
goto
rddir2_exit
;
goto
rddir2_exit
;
}
else
if
(
current_entry
!=
NULL
)
{
}
else
if
(
current_entry
!=
NULL
)
{
cFYI
(
1
,
(
"entry %lld found"
,
file
->
f_pos
));
cFYI
(
1
,
(
"entry %lld found"
,
file
->
f_pos
));
}
else
{
}
else
{
cFYI
(
1
,(
"could not find entry"
));
cFYI
(
1
,
(
"could not find entry"
));
goto
rddir2_exit
;
goto
rddir2_exit
;
}
}
cFYI
(
1
,(
"loop through %d times filling dir for net buf %p"
,
cFYI
(
1
,
(
"loop through %d times filling dir for net buf %p"
,
num_to_fill
,
cifsFile
->
srch_inf
.
ntwrk_buf_start
));
num_to_fill
,
cifsFile
->
srch_inf
.
ntwrk_buf_start
));
max_len
=
smbCalcSize
((
struct
smb_hdr
*
)
max_len
=
smbCalcSize
((
struct
smb_hdr
*
)
cifsFile
->
srch_inf
.
ntwrk_buf_start
);
cifsFile
->
srch_inf
.
ntwrk_buf_start
);
end_of_smb
=
cifsFile
->
srch_inf
.
ntwrk_buf_start
+
max_len
;
end_of_smb
=
cifsFile
->
srch_inf
.
ntwrk_buf_start
+
max_len
;
...
@@ -1060,8 +1063,8 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
...
@@ -1060,8 +1063,8 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
such multibyte target UTF-8 characters. cifs_unicode.c,
such multibyte target UTF-8 characters. cifs_unicode.c,
which actually does the conversion, has the same limit */
which actually does the conversion, has the same limit */
tmp_buf
=
kmalloc
((
2
*
NAME_MAX
)
+
4
,
GFP_KERNEL
);
tmp_buf
=
kmalloc
((
2
*
NAME_MAX
)
+
4
,
GFP_KERNEL
);
for
(
i
=
0
;(
i
<
num_to_fill
)
&&
(
rc
==
0
);
i
++
)
{
for
(
i
=
0
;
(
i
<
num_to_fill
)
&&
(
rc
==
0
);
i
++
)
{
if
(
current_entry
==
NULL
)
{
if
(
current_entry
==
NULL
)
{
/* evaluate whether this case is an error */
/* evaluate whether this case is an error */
cERROR
(
1
,(
"past end of SMB num to fill %d i %d"
,
cERROR
(
1
,(
"past end of SMB num to fill %d i %d"
,
num_to_fill
,
i
));
num_to_fill
,
i
));
...
@@ -1071,17 +1074,17 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
...
@@ -1071,17 +1074,17 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
we want to check for that here? */
we want to check for that here? */
rc
=
cifs_filldir
(
current_entry
,
file
,
rc
=
cifs_filldir
(
current_entry
,
file
,
filldir
,
direntry
,
tmp_buf
,
max_len
);
filldir
,
direntry
,
tmp_buf
,
max_len
);
if
(
rc
==
-
EOVERFLOW
)
{
if
(
rc
==
-
EOVERFLOW
)
{
rc
=
0
;
rc
=
0
;
break
;
break
;
}
}
file
->
f_pos
++
;
file
->
f_pos
++
;
if
(
file
->
f_pos
==
if
(
file
->
f_pos
==
cifsFile
->
srch_inf
.
index_of_last_entry
)
{
cifsFile
->
srch_inf
.
index_of_last_entry
)
{
cFYI
(
1
,(
"last entry in buf at pos %lld %s"
,
cFYI
(
1
,
(
"last entry in buf at pos %lld %s"
,
file
->
f_pos
,
tmp_buf
));
file
->
f_pos
,
tmp_buf
));
cifs_save_resume_key
(
current_entry
,
cifsFile
);
cifs_save_resume_key
(
current_entry
,
cifsFile
);
break
;
break
;
}
else
}
else
current_entry
=
current_entry
=
...
...
fs/cifs/sess.c
View file @
790fe579
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* SMB/CIFS session setup handling routines
* SMB/CIFS session setup handling routines
*
*
* Copyright (c) International Business Machines Corp., 2006
* Copyright (c) International Business Machines Corp., 2006
, 2007
* Author(s): Steve French (sfrench@us.ibm.com)
* Author(s): Steve French (sfrench@us.ibm.com)
*
*
* This library is free software; you can redistribute it and/or modify
* This library is free software; you can redistribute it and/or modify
...
@@ -51,7 +51,8 @@ static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB)
...
@@ -51,7 +51,8 @@ static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB)
capabilities
=
CAP_LARGE_FILES
|
CAP_NT_SMBS
|
CAP_LEVEL_II_OPLOCKS
|
capabilities
=
CAP_LARGE_FILES
|
CAP_NT_SMBS
|
CAP_LEVEL_II_OPLOCKS
|
CAP_LARGE_WRITE_X
|
CAP_LARGE_READ_X
;
CAP_LARGE_WRITE_X
|
CAP_LARGE_READ_X
;
if
(
ses
->
server
->
secMode
&
(
SECMODE_SIGN_REQUIRED
|
SECMODE_SIGN_ENABLED
))
if
(
ses
->
server
->
secMode
&
(
SECMODE_SIGN_REQUIRED
|
SECMODE_SIGN_ENABLED
))
pSMB
->
req
.
hdr
.
Flags2
|=
SMBFLG2_SECURITY_SIGNATURE
;
pSMB
->
req
.
hdr
.
Flags2
|=
SMBFLG2_SECURITY_SIGNATURE
;
if
(
ses
->
capabilities
&
CAP_UNICODE
)
{
if
(
ses
->
capabilities
&
CAP_UNICODE
)
{
...
@@ -75,9 +76,9 @@ static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB)
...
@@ -75,9 +76,9 @@ static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB)
}
}
static
void
unicode_ssetup_strings
(
char
**
pbcc_area
,
struct
cifsSesInfo
*
ses
,
static
void
unicode_ssetup_strings
(
char
**
pbcc_area
,
struct
cifsSesInfo
*
ses
,
const
struct
nls_table
*
nls_cp
)
const
struct
nls_table
*
nls_cp
)
{
{
char
*
bcc_ptr
=
*
pbcc_area
;
char
*
bcc_ptr
=
*
pbcc_area
;
int
bytes_ret
=
0
;
int
bytes_ret
=
0
;
/* BB FIXME add check that strings total less
/* BB FIXME add check that strings total less
...
@@ -89,7 +90,7 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
...
@@ -89,7 +90,7 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
bcc_ptr++;
bcc_ptr++;
} */
} */
/* copy user */
/* copy user */
if
(
ses
->
userName
==
NULL
)
{
if
(
ses
->
userName
==
NULL
)
{
/* null user mount */
/* null user mount */
*
bcc_ptr
=
0
;
*
bcc_ptr
=
0
;
*
(
bcc_ptr
+
1
)
=
0
;
*
(
bcc_ptr
+
1
)
=
0
;
...
@@ -100,7 +101,7 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
...
@@ -100,7 +101,7 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
bcc_ptr
+=
2
*
bytes_ret
;
bcc_ptr
+=
2
*
bytes_ret
;
bcc_ptr
+=
2
;
/* account for null termination */
bcc_ptr
+=
2
;
/* account for null termination */
/* copy domain */
/* copy domain */
if
(
ses
->
domainName
==
NULL
)
{
if
(
ses
->
domainName
==
NULL
)
{
/* Sending null domain better than using a bogus domain name (as
/* Sending null domain better than using a bogus domain name (as
we did briefly in 2.6.18) since server will use its default */
we did briefly in 2.6.18) since server will use its default */
*
bcc_ptr
=
0
;
*
bcc_ptr
=
0
;
...
@@ -130,14 +131,14 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
...
@@ -130,14 +131,14 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
}
}
static
void
ascii_ssetup_strings
(
char
**
pbcc_area
,
struct
cifsSesInfo
*
ses
,
static
void
ascii_ssetup_strings
(
char
**
pbcc_area
,
struct
cifsSesInfo
*
ses
,
const
struct
nls_table
*
nls_cp
)
const
struct
nls_table
*
nls_cp
)
{
{
char
*
bcc_ptr
=
*
pbcc_area
;
char
*
bcc_ptr
=
*
pbcc_area
;
/* copy user */
/* copy user */
/* BB what about null user mounts - check that we do this BB */
/* BB what about null user mounts - check that we do this BB */
/* copy user */
/* copy user */
if
(
ses
->
userName
==
NULL
)
{
if
(
ses
->
userName
==
NULL
)
{
/* BB what about null user mounts - check that we do this BB */
/* BB what about null user mounts - check that we do this BB */
}
else
{
/* 300 should be long enough for any conceivable user name */
}
else
{
/* 300 should be long enough for any conceivable user name */
strncpy
(
bcc_ptr
,
ses
->
userName
,
300
);
strncpy
(
bcc_ptr
,
ses
->
userName
,
300
);
...
@@ -149,7 +150,7 @@ static void ascii_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
...
@@ -149,7 +150,7 @@ static void ascii_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
/* copy domain */
/* copy domain */
if
(
ses
->
domainName
!=
NULL
)
{
if
(
ses
->
domainName
!=
NULL
)
{
strncpy
(
bcc_ptr
,
ses
->
domainName
,
256
);
strncpy
(
bcc_ptr
,
ses
->
domainName
,
256
);
bcc_ptr
+=
strnlen
(
ses
->
domainName
,
256
);
bcc_ptr
+=
strnlen
(
ses
->
domainName
,
256
);
}
/* else we will send a null domain name
}
/* else we will send a null domain name
...
@@ -170,16 +171,17 @@ static void ascii_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
...
@@ -170,16 +171,17 @@ static void ascii_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
*
pbcc_area
=
bcc_ptr
;
*
pbcc_area
=
bcc_ptr
;
}
}
static
int
decode_unicode_ssetup
(
char
**
pbcc_area
,
int
bleft
,
struct
cifsSesInfo
*
ses
,
static
int
decode_unicode_ssetup
(
char
**
pbcc_area
,
int
bleft
,
const
struct
nls_table
*
nls_cp
)
struct
cifsSesInfo
*
ses
,
const
struct
nls_table
*
nls_cp
)
{
{
int
rc
=
0
;
int
rc
=
0
;
int
words_left
,
len
;
int
words_left
,
len
;
char
*
data
=
*
pbcc_area
;
char
*
data
=
*
pbcc_area
;
cFYI
(
1
,
(
"bleft %d"
,
bleft
));
cFYI
(
1
,
(
"bleft %d"
,
bleft
));
/* SMB header is unaligned, so cifs servers word align start of
/* SMB header is unaligned, so cifs servers word align start of
...
@@ -198,14 +200,14 @@ static int decode_unicode_ssetup(char ** pbcc_area, int bleft, struct cifsSesInf
...
@@ -198,14 +200,14 @@ static int decode_unicode_ssetup(char ** pbcc_area, int bleft, struct cifsSesInf
/* We look for obvious messed up bcc or strings in response so we do not go off
/* We look for obvious messed up bcc or strings in response so we do not go off
the end since (at least) WIN2K and Windows XP have a major bug in not null
the end since (at least) WIN2K and Windows XP have a major bug in not null
terminating last Unicode string in response */
terminating last Unicode string in response */
if
(
len
>=
words_left
)
if
(
len
>=
words_left
)
return
rc
;
return
rc
;
if
(
ses
->
serverOS
)
if
(
ses
->
serverOS
)
kfree
(
ses
->
serverOS
);
kfree
(
ses
->
serverOS
);
/* UTF-8 string will not grow more than four times as big as UCS-16 */
/* UTF-8 string will not grow more than four times as big as UCS-16 */
ses
->
serverOS
=
kzalloc
(
4
*
len
,
GFP_KERNEL
);
ses
->
serverOS
=
kzalloc
(
4
*
len
,
GFP_KERNEL
);
if
(
ses
->
serverOS
!=
NULL
)
{
if
(
ses
->
serverOS
!=
NULL
)
{
cifs_strfromUCS_le
(
ses
->
serverOS
,
(
__le16
*
)
data
,
len
,
cifs_strfromUCS_le
(
ses
->
serverOS
,
(
__le16
*
)
data
,
len
,
nls_cp
);
nls_cp
);
}
}
...
@@ -215,17 +217,17 @@ static int decode_unicode_ssetup(char ** pbcc_area, int bleft, struct cifsSesInf
...
@@ -215,17 +217,17 @@ static int decode_unicode_ssetup(char ** pbcc_area, int bleft, struct cifsSesInf
/* save off server network operating system */
/* save off server network operating system */
len
=
UniStrnlen
((
wchar_t
*
)
data
,
words_left
);
len
=
UniStrnlen
((
wchar_t
*
)
data
,
words_left
);
if
(
len
>=
words_left
)
if
(
len
>=
words_left
)
return
rc
;
return
rc
;
if
(
ses
->
serverNOS
)
if
(
ses
->
serverNOS
)
kfree
(
ses
->
serverNOS
);
kfree
(
ses
->
serverNOS
);
ses
->
serverNOS
=
kzalloc
(
4
*
len
,
GFP_KERNEL
);
/* BB this is wrong length FIXME BB */
ses
->
serverNOS
=
kzalloc
(
4
*
len
,
GFP_KERNEL
);
/* BB this is wrong length FIXME BB */
if
(
ses
->
serverNOS
!=
NULL
)
{
if
(
ses
->
serverNOS
!=
NULL
)
{
cifs_strfromUCS_le
(
ses
->
serverNOS
,
(
__le16
*
)
data
,
len
,
cifs_strfromUCS_le
(
ses
->
serverNOS
,
(
__le16
*
)
data
,
len
,
nls_cp
);
nls_cp
);
if
(
strncmp
(
ses
->
serverNOS
,
"NT LAN Manager 4"
,
16
)
==
0
)
{
if
(
strncmp
(
ses
->
serverNOS
,
"NT LAN Manager 4"
,
16
)
==
0
)
{
cFYI
(
1
,(
"NT4 server"
));
cFYI
(
1
,
(
"NT4 server"
));
ses
->
flags
|=
CIFS_SES_NT4
;
ses
->
flags
|=
CIFS_SES_NT4
;
}
}
}
}
...
@@ -235,13 +237,13 @@ static int decode_unicode_ssetup(char ** pbcc_area, int bleft, struct cifsSesInf
...
@@ -235,13 +237,13 @@ static int decode_unicode_ssetup(char ** pbcc_area, int bleft, struct cifsSesInf
/* save off server domain */
/* save off server domain */
len
=
UniStrnlen
((
wchar_t
*
)
data
,
words_left
);
len
=
UniStrnlen
((
wchar_t
*
)
data
,
words_left
);
if
(
len
>
words_left
)
if
(
len
>
words_left
)
return
rc
;
return
rc
;
if
(
ses
->
serverDomain
)
if
(
ses
->
serverDomain
)
kfree
(
ses
->
serverDomain
);
kfree
(
ses
->
serverDomain
);
ses
->
serverDomain
=
kzalloc
(
2
*
(
len
+
1
),
GFP_KERNEL
);
/* BB FIXME wrong length */
ses
->
serverDomain
=
kzalloc
(
2
*
(
len
+
1
),
GFP_KERNEL
);
/* BB FIXME wrong length */
if
(
ses
->
serverDomain
!=
NULL
)
{
if
(
ses
->
serverDomain
!=
NULL
)
{
cifs_strfromUCS_le
(
ses
->
serverDomain
,
(
__le16
*
)
data
,
len
,
cifs_strfromUCS_le
(
ses
->
serverDomain
,
(
__le16
*
)
data
,
len
,
nls_cp
);
nls_cp
);
ses
->
serverDomain
[
2
*
len
]
=
0
;
ses
->
serverDomain
[
2
*
len
]
=
0
;
...
@@ -250,32 +252,33 @@ static int decode_unicode_ssetup(char ** pbcc_area, int bleft, struct cifsSesInf
...
@@ -250,32 +252,33 @@ static int decode_unicode_ssetup(char ** pbcc_area, int bleft, struct cifsSesInf
data
+=
2
*
(
len
+
1
);
data
+=
2
*
(
len
+
1
);
words_left
-=
len
+
1
;
words_left
-=
len
+
1
;
cFYI
(
1
,
(
"words left: %d"
,
words_left
));
cFYI
(
1
,
(
"words left: %d"
,
words_left
));
return
rc
;
return
rc
;
}
}
static
int
decode_ascii_ssetup
(
char
**
pbcc_area
,
int
bleft
,
struct
cifsSesInfo
*
ses
,
static
int
decode_ascii_ssetup
(
char
**
pbcc_area
,
int
bleft
,
const
struct
nls_table
*
nls_cp
)
struct
cifsSesInfo
*
ses
,
const
struct
nls_table
*
nls_cp
)
{
{
int
rc
=
0
;
int
rc
=
0
;
int
len
;
int
len
;
char
*
bcc_ptr
=
*
pbcc_area
;
char
*
bcc_ptr
=
*
pbcc_area
;
cFYI
(
1
,(
"decode sessetup ascii. bleft %d"
,
bleft
));
cFYI
(
1
,
(
"decode sessetup ascii. bleft %d"
,
bleft
));
len
=
strnlen
(
bcc_ptr
,
bleft
);
len
=
strnlen
(
bcc_ptr
,
bleft
);
if
(
len
>=
bleft
)
if
(
len
>=
bleft
)
return
rc
;
return
rc
;
if
(
ses
->
serverOS
)
if
(
ses
->
serverOS
)
kfree
(
ses
->
serverOS
);
kfree
(
ses
->
serverOS
);
ses
->
serverOS
=
kzalloc
(
len
+
1
,
GFP_KERNEL
);
ses
->
serverOS
=
kzalloc
(
len
+
1
,
GFP_KERNEL
);
if
(
ses
->
serverOS
)
if
(
ses
->
serverOS
)
strncpy
(
ses
->
serverOS
,
bcc_ptr
,
len
);
strncpy
(
ses
->
serverOS
,
bcc_ptr
,
len
);
if
(
strncmp
(
ses
->
serverOS
,
"OS/2"
,
4
)
==
0
)
{
if
(
strncmp
(
ses
->
serverOS
,
"OS/2"
,
4
)
==
0
)
{
cFYI
(
1
,(
"OS/2 server"
));
cFYI
(
1
,
(
"OS/2 server"
));
ses
->
flags
|=
CIFS_SES_OS2
;
ses
->
flags
|=
CIFS_SES_OS2
;
}
}
...
@@ -283,21 +286,21 @@ static int decode_ascii_ssetup(char ** pbcc_area, int bleft, struct cifsSesInfo
...
@@ -283,21 +286,21 @@ static int decode_ascii_ssetup(char ** pbcc_area, int bleft, struct cifsSesInfo
bleft
-=
len
+
1
;
bleft
-=
len
+
1
;
len
=
strnlen
(
bcc_ptr
,
bleft
);
len
=
strnlen
(
bcc_ptr
,
bleft
);
if
(
len
>=
bleft
)
if
(
len
>=
bleft
)
return
rc
;
return
rc
;
if
(
ses
->
serverNOS
)
if
(
ses
->
serverNOS
)
kfree
(
ses
->
serverNOS
);
kfree
(
ses
->
serverNOS
);
ses
->
serverNOS
=
kzalloc
(
len
+
1
,
GFP_KERNEL
);
ses
->
serverNOS
=
kzalloc
(
len
+
1
,
GFP_KERNEL
);
if
(
ses
->
serverNOS
)
if
(
ses
->
serverNOS
)
strncpy
(
ses
->
serverNOS
,
bcc_ptr
,
len
);
strncpy
(
ses
->
serverNOS
,
bcc_ptr
,
len
);
bcc_ptr
+=
len
+
1
;
bcc_ptr
+=
len
+
1
;
bleft
-=
len
+
1
;
bleft
-=
len
+
1
;
len
=
strnlen
(
bcc_ptr
,
bleft
);
len
=
strnlen
(
bcc_ptr
,
bleft
);
if
(
len
>
bleft
)
if
(
len
>
bleft
)
return
rc
;
return
rc
;
/* No domain field in LANMAN case. Domain is
/* No domain field in LANMAN case. Domain is
...
@@ -305,7 +308,7 @@ static int decode_ascii_ssetup(char ** pbcc_area, int bleft, struct cifsSesInfo
...
@@ -305,7 +308,7 @@ static int decode_ascii_ssetup(char ** pbcc_area, int bleft, struct cifsSesInfo
/* BB For newer servers which do not support Unicode,
/* BB For newer servers which do not support Unicode,
but thus do return domain here we could add parsing
but thus do return domain here we could add parsing
for it later, but it is not very important */
for it later, but it is not very important */
cFYI
(
1
,
(
"ascii: bytes left %d"
,
bleft
));
cFYI
(
1
,
(
"ascii: bytes left %d"
,
bleft
));
return
rc
;
return
rc
;
}
}
...
@@ -328,13 +331,13 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
...
@@ -328,13 +331,13 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
__u16
action
;
__u16
action
;
int
bytes_remaining
;
int
bytes_remaining
;
if
(
ses
==
NULL
)
if
(
ses
==
NULL
)
return
-
EINVAL
;
return
-
EINVAL
;
type
=
ses
->
server
->
secType
;
type
=
ses
->
server
->
secType
;
cFYI
(
1
,
(
"sess setup type %d"
,
type
));
cFYI
(
1
,
(
"sess setup type %d"
,
type
));
if
(
type
==
LANMAN
)
{
if
(
type
==
LANMAN
)
{
#ifndef CONFIG_CIFS_WEAK_PW_HASH
#ifndef CONFIG_CIFS_WEAK_PW_HASH
/* LANMAN and plaintext are less secure and off by default.
/* LANMAN and plaintext are less secure and off by default.
So we make this explicitly be turned on in kconfig (in the
So we make this explicitly be turned on in kconfig (in the
...
@@ -344,15 +347,15 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
...
@@ -344,15 +347,15 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
return
-
EOPNOTSUPP
;
return
-
EOPNOTSUPP
;
#endif
#endif
wct
=
10
;
/* lanman 2 style sessionsetup */
wct
=
10
;
/* lanman 2 style sessionsetup */
}
else
if
((
type
==
NTLM
)
||
(
type
==
NTLMv2
))
{
}
else
if
((
type
==
NTLM
)
||
(
type
==
NTLMv2
))
{
/* For NTLMv2 failures eventually may need to retry NTLM */
/* For NTLMv2 failures eventually may need to retry NTLM */
wct
=
13
;
/* old style NTLM sessionsetup */
wct
=
13
;
/* old style NTLM sessionsetup */
}
else
/* same size
for
negotiate or auth, NTLMSSP or extended security */
}
else
/* same size
:
negotiate or auth, NTLMSSP or extended security */
wct
=
12
;
wct
=
12
;
rc
=
small_smb_init_no_tc
(
SMB_COM_SESSION_SETUP_ANDX
,
wct
,
ses
,
rc
=
small_smb_init_no_tc
(
SMB_COM_SESSION_SETUP_ANDX
,
wct
,
ses
,
(
void
**
)
&
smb_buf
);
(
void
**
)
&
smb_buf
);
if
(
rc
)
if
(
rc
)
return
rc
;
return
rc
;
pSMB
=
(
SESSION_SETUP_ANDX
*
)
smb_buf
;
pSMB
=
(
SESSION_SETUP_ANDX
*
)
smb_buf
;
...
@@ -373,7 +376,7 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
...
@@ -373,7 +376,7 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
ses
->
flags
&=
~
CIFS_SES_LANMAN
;
ses
->
flags
&=
~
CIFS_SES_LANMAN
;
if
(
type
==
LANMAN
)
{
if
(
type
==
LANMAN
)
{
#ifdef CONFIG_CIFS_WEAK_PW_HASH
#ifdef CONFIG_CIFS_WEAK_PW_HASH
char
lnm_session_key
[
CIFS_SESS_KEY_SIZE
];
char
lnm_session_key
[
CIFS_SESS_KEY_SIZE
];
...
@@ -397,7 +400,7 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
...
@@ -397,7 +400,7 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
changed to do higher than lanman dialect and
changed to do higher than lanman dialect and
we reconnected would we ever calc signing_key? */
we reconnected would we ever calc signing_key? */
cFYI
(
1
,(
"Negotiating LANMAN setting up strings"
));
cFYI
(
1
,
(
"Negotiating LANMAN setting up strings"
));
/* Unicode not allowed for LANMAN dialects */
/* Unicode not allowed for LANMAN dialects */
ascii_ssetup_strings
(
&
bcc_ptr
,
ses
,
nls_cp
);
ascii_ssetup_strings
(
&
bcc_ptr
,
ses
,
nls_cp
);
#endif
#endif
...
@@ -414,17 +417,17 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
...
@@ -414,17 +417,17 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
SMBNTencrypt
(
ses
->
password
,
ses
->
server
->
cryptKey
,
SMBNTencrypt
(
ses
->
password
,
ses
->
server
->
cryptKey
,
ntlm_session_key
);
ntlm_session_key
);
if
(
first_time
)
/* should this be moved into common code
if
(
first_time
)
/* should this be moved into common code
with similar ntlmv2 path? */
with similar ntlmv2 path? */
cifs_calculate_mac_key
(
ses
->
server
->
mac_signing_key
,
cifs_calculate_mac_key
(
ses
->
server
->
mac_signing_key
,
ntlm_session_key
,
ses
->
password
);
ntlm_session_key
,
ses
->
password
);
/* copy session key */
/* copy session key */
memcpy
(
bcc_ptr
,
(
char
*
)
ntlm_session_key
,
CIFS_SESS_KEY_SIZE
);
memcpy
(
bcc_ptr
,
(
char
*
)
ntlm_session_key
,
CIFS_SESS_KEY_SIZE
);
bcc_ptr
+=
CIFS_SESS_KEY_SIZE
;
bcc_ptr
+=
CIFS_SESS_KEY_SIZE
;
memcpy
(
bcc_ptr
,
(
char
*
)
ntlm_session_key
,
CIFS_SESS_KEY_SIZE
);
memcpy
(
bcc_ptr
,
(
char
*
)
ntlm_session_key
,
CIFS_SESS_KEY_SIZE
);
bcc_ptr
+=
CIFS_SESS_KEY_SIZE
;
bcc_ptr
+=
CIFS_SESS_KEY_SIZE
;
if
(
ses
->
capabilities
&
CAP_UNICODE
)
{
if
(
ses
->
capabilities
&
CAP_UNICODE
)
{
/* unicode strings must be word aligned */
/* unicode strings must be word aligned */
if
(
iov
[
0
].
iov_len
%
2
)
{
if
(
iov
[
0
].
iov_len
%
2
)
{
*
bcc_ptr
=
0
;
*
bcc_ptr
=
0
;
...
@@ -434,13 +437,13 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
...
@@ -434,13 +437,13 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
}
else
}
else
ascii_ssetup_strings
(
&
bcc_ptr
,
ses
,
nls_cp
);
ascii_ssetup_strings
(
&
bcc_ptr
,
ses
,
nls_cp
);
}
else
if
(
type
==
NTLMv2
)
{
}
else
if
(
type
==
NTLMv2
)
{
char
*
v2_sess_key
=
char
*
v2_sess_key
=
kmalloc
(
sizeof
(
struct
ntlmv2_resp
),
GFP_KERNEL
);
kmalloc
(
sizeof
(
struct
ntlmv2_resp
),
GFP_KERNEL
);
/* BB FIXME change all users of v2_sess_key to
/* BB FIXME change all users of v2_sess_key to
struct ntlmv2_resp */
struct ntlmv2_resp */
if
(
v2_sess_key
==
NULL
)
{
if
(
v2_sess_key
==
NULL
)
{
cifs_small_buf_release
(
smb_buf
);
cifs_small_buf_release
(
smb_buf
);
return
-
ENOMEM
;
return
-
ENOMEM
;
}
}
...
@@ -456,7 +459,7 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
...
@@ -456,7 +459,7 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
/* calculate session key */
/* calculate session key */
setup_ntlmv2_rsp
(
ses
,
v2_sess_key
,
nls_cp
);
setup_ntlmv2_rsp
(
ses
,
v2_sess_key
,
nls_cp
);
if
(
first_time
)
/* should this be moved into common code
if
(
first_time
)
/* should this be moved into common code
with similar ntlmv2 path? */
with similar ntlmv2 path? */
/* cifs_calculate_ntlmv2_mac_key(ses->server->mac_signing_key,
/* cifs_calculate_ntlmv2_mac_key(ses->server->mac_signing_key,
response BB FIXME, v2_sess_key); */
response BB FIXME, v2_sess_key); */
...
@@ -468,8 +471,8 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
...
@@ -468,8 +471,8 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
memcpy
(
bcc_ptr
,
(
char
*
)
v2_sess_key
,
sizeof
(
struct
ntlmv2_resp
));
memcpy
(
bcc_ptr
,
(
char
*
)
v2_sess_key
,
sizeof
(
struct
ntlmv2_resp
));
bcc_ptr
+=
sizeof
(
struct
ntlmv2_resp
);
bcc_ptr
+=
sizeof
(
struct
ntlmv2_resp
);
kfree
(
v2_sess_key
);
kfree
(
v2_sess_key
);
if
(
ses
->
capabilities
&
CAP_UNICODE
)
{
if
(
ses
->
capabilities
&
CAP_UNICODE
)
{
if
(
iov
[
0
].
iov_len
%
2
)
{
if
(
iov
[
0
].
iov_len
%
2
)
{
*
bcc_ptr
=
0
;
*
bcc_ptr
=
0
;
}
bcc_ptr
++
;
}
bcc_ptr
++
;
unicode_ssetup_strings
(
&
bcc_ptr
,
ses
,
nls_cp
);
unicode_ssetup_strings
(
&
bcc_ptr
,
ses
,
nls_cp
);
...
@@ -492,16 +495,16 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
...
@@ -492,16 +495,16 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
rc
=
SendReceive2
(
xid
,
ses
,
iov
,
2
/* num_iovecs */
,
&
resp_buf_type
,
0
);
rc
=
SendReceive2
(
xid
,
ses
,
iov
,
2
/* num_iovecs */
,
&
resp_buf_type
,
0
);
/* SMB request buf freed in SendReceive2 */
/* SMB request buf freed in SendReceive2 */
cFYI
(
1
,
(
"ssetup rc from sendrecv2 is %d"
,
rc
));
cFYI
(
1
,
(
"ssetup rc from sendrecv2 is %d"
,
rc
));
if
(
rc
)
if
(
rc
)
goto
ssetup_exit
;
goto
ssetup_exit
;
pSMB
=
(
SESSION_SETUP_ANDX
*
)
iov
[
0
].
iov_base
;
pSMB
=
(
SESSION_SETUP_ANDX
*
)
iov
[
0
].
iov_base
;
smb_buf
=
(
struct
smb_hdr
*
)
iov
[
0
].
iov_base
;
smb_buf
=
(
struct
smb_hdr
*
)
iov
[
0
].
iov_base
;
if
((
smb_buf
->
WordCount
!=
3
)
&&
(
smb_buf
->
WordCount
!=
4
))
{
if
((
smb_buf
->
WordCount
!=
3
)
&&
(
smb_buf
->
WordCount
!=
4
))
{
rc
=
-
EIO
;
rc
=
-
EIO
;
cERROR
(
1
,(
"bad word count %d"
,
smb_buf
->
WordCount
));
cERROR
(
1
,
(
"bad word count %d"
,
smb_buf
->
WordCount
));
goto
ssetup_exit
;
goto
ssetup_exit
;
}
}
action
=
le16_to_cpu
(
pSMB
->
resp
.
Action
);
action
=
le16_to_cpu
(
pSMB
->
resp
.
Action
);
...
@@ -514,12 +517,12 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
...
@@ -514,12 +517,12 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
bytes_remaining
=
BCC
(
smb_buf
);
bytes_remaining
=
BCC
(
smb_buf
);
bcc_ptr
=
pByteArea
(
smb_buf
);
bcc_ptr
=
pByteArea
(
smb_buf
);
if
(
smb_buf
->
WordCount
==
4
)
{
if
(
smb_buf
->
WordCount
==
4
)
{
__u16
blob_len
;
__u16
blob_len
;
blob_len
=
le16_to_cpu
(
pSMB
->
resp
.
SecurityBlobLength
);
blob_len
=
le16_to_cpu
(
pSMB
->
resp
.
SecurityBlobLength
);
bcc_ptr
+=
blob_len
;
bcc_ptr
+=
blob_len
;
if
(
blob_len
>
bytes_remaining
)
{
if
(
blob_len
>
bytes_remaining
)
{
cERROR
(
1
,(
"bad security blob length %d"
,
blob_len
));
cERROR
(
1
,
(
"bad security blob length %d"
,
blob_len
));
rc
=
-
EINVAL
;
rc
=
-
EINVAL
;
goto
ssetup_exit
;
goto
ssetup_exit
;
}
}
...
@@ -527,7 +530,7 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
...
@@ -527,7 +530,7 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
}
}
/* BB check if Unicode and decode strings */
/* BB check if Unicode and decode strings */
if
(
smb_buf
->
Flags2
&
SMBFLG2_UNICODE
)
if
(
smb_buf
->
Flags2
&
SMBFLG2_UNICODE
)
rc
=
decode_unicode_ssetup
(
&
bcc_ptr
,
bytes_remaining
,
rc
=
decode_unicode_ssetup
(
&
bcc_ptr
,
bytes_remaining
,
ses
,
nls_cp
);
ses
,
nls_cp
);
else
else
...
@@ -535,10 +538,10 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
...
@@ -535,10 +538,10 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
ssetup_exit:
ssetup_exit:
kfree
(
str_area
);
kfree
(
str_area
);
if
(
resp_buf_type
==
CIFS_SMALL_BUFFER
)
{
if
(
resp_buf_type
==
CIFS_SMALL_BUFFER
)
{
cFYI
(
1
,(
"ssetup freeing small buf %p"
,
iov
[
0
].
iov_base
));
cFYI
(
1
,
(
"ssetup freeing small buf %p"
,
iov
[
0
].
iov_base
));
cifs_small_buf_release
(
iov
[
0
].
iov_base
);
cifs_small_buf_release
(
iov
[
0
].
iov_base
);
}
else
if
(
resp_buf_type
==
CIFS_LARGE_BUFFER
)
}
else
if
(
resp_buf_type
==
CIFS_LARGE_BUFFER
)
cifs_buf_release
(
iov
[
0
].
iov_base
);
cifs_buf_release
(
iov
[
0
].
iov_base
);
return
rc
;
return
rc
;
...
...
fs/cifs/smbencrypt.c
View file @
790fe579
...
@@ -74,8 +74,8 @@ SMBencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24)
...
@@ -74,8 +74,8 @@ SMBencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24)
SMBOWFencrypt
(
p21
,
c8
,
p24
);
SMBOWFencrypt
(
p21
,
c8
,
p24
);
memset
(
p14
,
0
,
15
);
memset
(
p14
,
0
,
15
);
memset
(
p21
,
0
,
21
);
memset
(
p21
,
0
,
21
);
}
}
/* Routines for Windows NT MD4 Hash functions. */
/* Routines for Windows NT MD4 Hash functions. */
...
@@ -97,7 +97,7 @@ _my_wcslen(__u16 * str)
...
@@ -97,7 +97,7 @@ _my_wcslen(__u16 * str)
static
int
static
int
_my_mbstowcs
(
__u16
*
dst
,
const
unsigned
char
*
src
,
int
len
)
_my_mbstowcs
(
__u16
*
dst
,
const
unsigned
char
*
src
,
int
len
)
{
/*
not a very good conversion routine - change/fix */
{
/* BB
not a very good conversion routine - change/fix */
int
i
;
int
i
;
__u16
val
;
__u16
val
;
...
@@ -123,7 +123,7 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16)
...
@@ -123,7 +123,7 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16)
__u16
wpwd
[
129
];
__u16
wpwd
[
129
];
/* Password cannot be longer than 128 characters */
/* Password cannot be longer than 128 characters */
if
(
passwd
)
{
if
(
passwd
)
{
len
=
strlen
((
char
*
)
passwd
);
len
=
strlen
((
char
*
)
passwd
);
if
(
len
>
128
)
{
if
(
len
>
128
)
{
len
=
128
;
len
=
128
;
...
@@ -138,7 +138,7 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16)
...
@@ -138,7 +138,7 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16)
len
=
_my_wcslen
(
wpwd
)
*
sizeof
(
__u16
);
len
=
_my_wcslen
(
wpwd
)
*
sizeof
(
__u16
);
mdfour
(
p16
,
(
unsigned
char
*
)
wpwd
,
len
);
mdfour
(
p16
,
(
unsigned
char
*
)
wpwd
,
len
);
memset
(
wpwd
,
0
,
129
*
2
);
memset
(
wpwd
,
0
,
129
*
2
);
}
}
#if 0 /* currently unused */
#if 0 /* currently unused */
...
@@ -184,8 +184,8 @@ ntv2_owf_gen(const unsigned char owf[16], const char *user_n,
...
@@ -184,8 +184,8 @@ ntv2_owf_gen(const unsigned char owf[16], const char *user_n,
struct HMACMD5Context ctx;
struct HMACMD5Context ctx;
/* might as well do one alloc to hold both (user_u and dom_u) */
/* might as well do one alloc to hold both (user_u and dom_u) */
user_u = kmalloc(2048 * sizeof(wchar_t),
GFP_KERNEL);
user_u = kmalloc(2048 * sizeof(wchar_t),
GFP_KERNEL);
if(user_u == NULL)
if
(user_u == NULL)
return;
return;
dom_u = user_u + 1024;
dom_u = user_u + 1024;
...
@@ -256,8 +256,8 @@ SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24)
...
@@ -256,8 +256,8 @@ SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24)
#if 0
#if 0
static void
static void
SMBOWFencrypt_ntv2(const unsigned char kr[16],
SMBOWFencrypt_ntv2(const unsigned char kr[16],
const struct data_blob *
srv_chal,
const struct data_blob *
srv_chal,
const struct data_blob *
cli_chal, unsigned char resp_buf[16])
const struct data_blob *
cli_chal, unsigned char resp_buf[16])
{
{
struct HMACMD5Context ctx;
struct HMACMD5Context ctx;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment