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
Kirill Smelkov
linux
Commits
e637fa3a
Commit
e637fa3a
authored
Oct 12, 2003
by
Steve French
Browse files
Options
Browse Files
Download
Plain Diff
Merge
bk://linux.bkbits.net/linux-2.5
into hostme.bitkeeper.com:/repos/c/cifs/linux-2.5cifs
parents
6ab5c9ad
bc27a5b4
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
313 additions
and
162 deletions
+313
-162
fs/cifs/AUTHORS
fs/cifs/AUTHORS
+1
-0
fs/cifs/CHANGES
fs/cifs/CHANGES
+17
-0
fs/cifs/README
fs/cifs/README
+7
-0
fs/cifs/cifs_debug.c
fs/cifs/cifs_debug.c
+5
-3
fs/cifs/cifsencrypt.c
fs/cifs/cifsencrypt.c
+3
-3
fs/cifs/cifsfs.c
fs/cifs/cifsfs.c
+14
-16
fs/cifs/cifsglob.h
fs/cifs/cifsglob.h
+24
-3
fs/cifs/cifssmb.c
fs/cifs/cifssmb.c
+1
-0
fs/cifs/connect.c
fs/cifs/connect.c
+58
-5
fs/cifs/dir.c
fs/cifs/dir.c
+2
-0
fs/cifs/file.c
fs/cifs/file.c
+163
-31
fs/cifs/misc.c
fs/cifs/misc.c
+7
-7
fs/cifs/smbdes.c
fs/cifs/smbdes.c
+1
-39
fs/cifs/smbencrypt.c
fs/cifs/smbencrypt.c
+0
-43
fs/cifs/transport.c
fs/cifs/transport.c
+10
-12
No files found.
fs/cifs/AUTHORS
View file @
e637fa3a
...
...
@@ -20,6 +20,7 @@ Patch Contributors
Zwane Mwaikambo
Andi Kleen
Amrut Joshi
Shobhit Dayal
Test case and Bug Report contributors
-------------------------------------
...
...
fs/cifs/CHANGES
View file @
e637fa3a
Version 0.94
------------
Fix to list processing in reopen_files. Fix reconnection when server hung
but tcpip session still alive.
Version 0.93
------------
Add missing mount options including iocharset. SMP fixes in write and open.
Fix errors in reconnecting after TCP session failure. Fix module unloading
of default nls codepage
Version 0.92
------------
Active smb transactions should never go negative (fix double FreeXid). Fix
list processing in file routines. Check return code on kmalloc in open.
Fix spinlock usage for SMP.
Version 0.91
------------
Fix oops in reopen_files when invalid dentry. drop dentry on server rename
...
...
fs/cifs/README
View file @
e637fa3a
...
...
@@ -127,6 +127,13 @@ A partial list of the supported mount options follows:
this overrides the default mode for directory inodes.
port attempt to contact the server on this tcp port, before
trying the usual ports (port 445, then 139).
iocharset Codepage used to convert local path names to and from
Unicode. Unicode is used by default for network path
names if the server supports it. If iocharset is
not specified then the nls_default specified
during the local client kernel build will be used.
If server does not support Unicode, this parameter is
unused.
rsize default read size
wsize default write size
rw mount the network share read-write (note that the
...
...
fs/cifs/cifs_debug.c
View file @
e637fa3a
/*
* fs/cifs_debug.c
*
* Copyright (
c) International Business Machines Corp., 2000,2002
* Copyright (
C) International Business Machines Corp., 2000,2003
*
* Modified by Steve French (sfrench@us.ibm.com)
*
...
...
@@ -84,12 +84,12 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
ses
=
list_entry
(
tmp
,
struct
cifsSesInfo
,
cifsSessionList
);
length
=
sprintf
(
buf
,
"
\n
%d) Name: %s Domain: %s Mounts: %d ServerOS: %s
ServerNOS: %s
\n
\t
Capabilities: 0x%x"
,
"
\n
%d) Name: %s Domain: %s Mounts: %d ServerOS: %s
\n\t
ServerNOS: %s
\t
Capabilities: 0x%x"
,
i
,
ses
->
serverName
,
ses
->
serverDomain
,
atomic_read
(
&
ses
->
inUse
),
ses
->
serverOS
,
ses
->
serverNOS
,
ses
->
capabilities
);
buf
+=
length
;
if
(
ses
->
server
)
buf
+=
sprintf
(
buf
,
"
\t
Local Users To Same Server: %d SecMode: 0x%x"
,
buf
+=
sprintf
(
buf
,
"
\
n\
t
Local Users To Same Server: %d SecMode: 0x%x"
,
atomic_read
(
&
ses
->
server
->
socketUseCount
),
ses
->
server
->
secMode
);
}
read_unlock
(
&
GlobalSMBSeslock
);
...
...
@@ -123,6 +123,8 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
sprintf
(
buf
,
" type: %d "
,
tcon
->
fsDevInfo
.
DeviceType
);
buf
+=
length
;
if
(
tcon
->
tidStatus
==
CifsNeedReconnect
)
buf
+=
sprintf
(
buf
,
"
\t
DISCONNECTED "
);
}
read_unlock
(
&
GlobalSMBSeslock
);
length
=
sprintf
(
buf
,
"
\n
"
);
...
...
fs/cifs/cifsencrypt.c
View file @
e637fa3a
/*
* fs/cifs/cifsencrypt.c
*
* Copyright (
c
) International Business Machines Corp., 2003
* Copyright (
C
) International Business Machines Corp., 2003
* Author(s): Steve French (sfrench@us.ibm.com)
*
* This library is free software; you can redistribute it and/or modify
...
...
@@ -64,13 +64,13 @@ int cifs_sign_smb(struct smb_hdr * cifs_pdu, struct cifsSesInfo * ses,
if
((
le32_to_cpu
(
cifs_pdu
->
Flags2
)
&
SMBFLG2_SECURITY_SIGNATURE
)
==
0
)
return
rc
;
write
_lock
(
&
GlobalMid_Lock
);
spin
_lock
(
&
GlobalMid_Lock
);
cifs_pdu
->
Signature
.
Sequence
.
SequenceNumber
=
cpu_to_le32
(
ses
->
sequence_number
);
cifs_pdu
->
Signature
.
Sequence
.
Reserved
=
0
;
*
pexpected_response_sequence_number
=
ses
->
sequence_number
++
;
ses
->
sequence_number
++
;
write
_unlock
(
&
GlobalMid_Lock
);
spin
_unlock
(
&
GlobalMid_Lock
);
rc
=
cifs_calculate_signature
(
cifs_pdu
,
ses
->
mac_signing_key
,
smb_signature
);
if
(
rc
)
...
...
fs/cifs/cifsfs.c
View file @
e637fa3a
/*
* fs/cifs/cifsfs.c
*
* Copyright (
c) International Business Machines Corp., 2002
* Copyright (
C) International Business Machines Corp., 2002,2003
* Author(s): Steve French (sfrench@us.ibm.com)
*
* Common Internet FileSystem (CIFS) client
...
...
@@ -81,7 +81,6 @@ cifs_read_super(struct super_block *sb, void *data,
cifs_sb
=
CIFS_SB
(
sb
);
if
(
cifs_sb
==
NULL
)
return
-
ENOMEM
;
cifs_sb
->
local_nls
=
load_nls_default
();
/* needed for ASCII cp to Unicode converts */
rc
=
cifs_mount
(
sb
,
cifs_sb
,
data
,
devname
);
...
...
@@ -571,8 +570,6 @@ cifs_destroy_mids(void)
static
int
cifs_oplock_thread
(
void
*
dummyarg
)
{
struct
list_head
*
tmp
;
struct
list_head
*
tmp1
;
struct
oplock_q_entry
*
oplock_item
;
struct
cifsTconInfo
*
pTcon
;
struct
inode
*
inode
;
...
...
@@ -585,19 +582,22 @@ static int cifs_oplock_thread(void * dummyarg)
oplockThread
=
current
;
do
{
set_current_state
(
TASK_INTERRUPTIBLE
);
schedule_timeout
(
100
*
HZ
);
/* BB add missing code */
write_lock
(
&
GlobalMid_Lock
);
list_for_each_safe
(
tmp
,
tmp1
,
&
GlobalOplock_Q
)
{
oplock_item
=
list_entry
(
tmp
,
struct
oplock_q_entry
,
qhead
);
schedule_timeout
(
39
*
HZ
);
spin_lock
(
&
GlobalMid_Lock
);
if
(
list_empty
(
&
GlobalOplock_Q
))
{
spin_unlock
(
&
GlobalMid_Lock
);
schedule_timeout
(
39
*
HZ
);
}
else
{
oplock_item
=
list_entry
(
GlobalOplock_Q
.
next
,
struct
oplock_q_entry
,
qhead
);
if
(
oplock_item
)
{
pTcon
=
oplock_item
->
tcon
;
inode
=
oplock_item
->
pinode
;
netfid
=
oplock_item
->
netfid
;
spin_unlock
(
&
GlobalMid_Lock
);
DeleteOplockQEntry
(
oplock_item
);
write_unlock
(
&
GlobalMid_Lock
);
if
(
S_ISREG
(
inode
->
i_mode
))
if
(
S_ISREG
(
inode
->
i_mode
))
rc
=
filemap_fdatawrite
(
inode
->
i_mapping
);
else
rc
=
0
;
...
...
@@ -609,11 +609,9 @@ static int cifs_oplock_thread(void * dummyarg)
0
,
LOCKING_ANDX_OPLOCK_RELEASE
,
0
/* wait flag */
);
cFYI
(
1
,(
"Oplock release rc = %d "
,
rc
));
write_lock
(
&
GlobalMid_Lock
);
}
else
break
;
spin_unlock
(
&
GlobalMid_Lock
)
;
}
write_unlock
(
&
GlobalMid_Lock
);
}
while
(
!
signal_pending
(
current
));
complete_and_exit
(
&
cifs_oplock_exited
,
0
);
}
...
...
@@ -640,7 +638,7 @@ init_cifs(void)
GlobalTotalActiveXid
=
0
;
GlobalMaxActiveXid
=
0
;
GlobalSMBSeslock
=
RW_LOCK_UNLOCKED
;
GlobalMid_Lock
=
RW
_LOCK_UNLOCKED
;
GlobalMid_Lock
=
SPIN
_LOCK_UNLOCKED
;
rc
=
cifs_init_inodecache
();
if
(
!
rc
)
{
...
...
fs/cifs/cifsglob.h
View file @
e637fa3a
/*
* fs/cifs/cifsglob.h
*
* Copyright (
c) International Business Machines Corp., 2002
* Copyright (
C) International Business Machines Corp., 2002,2003
* Author(s): Steve French (sfrench@us.ibm.com)
*
* This library is free software; you can redistribute it and/or modify
...
...
@@ -212,6 +212,7 @@ struct cifsFileInfo {
int
endOfSearch
:
1
;
/* we have reached end of search */
int
closePend
:
1
;
/* file is marked to close */
int
emptyDir
:
1
;
int
invalidHandle
:
1
;
/* file closed via session abend */
char
*
search_resume_name
;
unsigned
int
resume_name_length
;
__u32
resume_key
;
...
...
@@ -294,7 +295,27 @@ struct servers_not_supported { /* @z4a */
* following to be declared.
*/
/* BB Every global should have an associated mutex for safe update BB */
/****************************************************************************
* Locking notes. All updates to global variables and lists should be
* protected by spinlocks or semaphores.
*
* Spinlocks
* ---------
* GlobalMid_Lock protects:
* list operations on pending_mid_q and oplockQ
* updates to XID counters, multiplex id and SMB sequence numbers
* GlobalSMBSesLock protects:
* list operations on tcp and SMB session lists and tCon lists
* f_owner.lock protects certain per file struct operations
* mapping->page_lock protects certain per page operations
*
* Semaphores
* ----------
* sesSem operations on smb session
* tconSem operations on tree connection
* i_sem inode operations
*
****************************************************************************/
#ifdef DECLARE_GLOBALS_HERE
#define GLOBAL_EXTERN
...
...
@@ -327,7 +348,7 @@ GLOBAL_EXTERN struct list_head GlobalOplock_Q;
GLOBAL_EXTERN
unsigned
int
GlobalCurrentXid
;
/* protected by GlobalMid_Sem */
GLOBAL_EXTERN
unsigned
int
GlobalTotalActiveXid
;
/* prot by GlobalMid_Sem */
GLOBAL_EXTERN
unsigned
int
GlobalMaxActiveXid
;
/* prot by GlobalMid_Sem */
GLOBAL_EXTERN
rw
lock_t
GlobalMid_Lock
;
/* protects above and list operations */
GLOBAL_EXTERN
spin
lock_t
GlobalMid_Lock
;
/* protects above and list operations */
/* on midQ entries */
GLOBAL_EXTERN
char
Local_System_Name
[
15
];
...
...
fs/cifs/cifssmb.c
View file @
e637fa3a
...
...
@@ -62,6 +62,7 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
if
(
!
rc
)
reopen_files
(
tcon
,
nls_codepage
);
}
unload_nls
(
nls_codepage
);
}
}
if
(
rc
)
...
...
fs/cifs/connect.c
View file @
e637fa3a
/*
* fs/cifs/connect.c
*
* Copyright (
c) International Business Machines Corp., 2002
* Copyright (
C) International Business Machines Corp., 2002,2003
* Author(s): Steve French (sfrench@us.ibm.com)
*
* This library is free software; you can redistribute it and/or modify
...
...
@@ -52,6 +52,8 @@ struct smb_vol {
char
*
domainname
;
char
*
UNC
;
char
*
UNCip
;
char
*
iocharset
;
/* local code page for mapping to and from Unicode */
char
*
source_rfc1001_name
;
/* netbios name of client */
uid_t
linux_uid
;
gid_t
linux_gid
;
mode_t
file_mode
;
...
...
@@ -59,6 +61,7 @@ struct smb_vol {
int
rw
;
unsigned
int
rsize
;
unsigned
int
wsize
;
unsigned
int
sockopt
;
unsigned
short
int
port
;
};
...
...
@@ -182,7 +185,12 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
sizeof
(
struct
smb_hdr
)
-
1
/* RFC1001 header and SMB header */
,
MSG_PEEK
/* flags see socket.h */
);
if
(
length
<
0
)
{
if
(
server
->
tcpStatus
==
CifsNeedReconnect
)
{
cFYI
(
1
,(
"Reconnecting after server stopped responding"
));
cifs_reconnect
(
server
);
csocket
=
server
->
ssocket
;
continue
;
}
else
if
(
length
<
0
)
{
if
(
length
==
-
ECONNRESET
)
{
cERROR
(
1
,
(
"Connection reset by peer "
));
cifs_reconnect
(
server
);
...
...
@@ -272,7 +280,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
}
task_to_wake
=
NULL
;
read
_lock
(
&
GlobalMid_Lock
);
spin
_lock
(
&
GlobalMid_Lock
);
list_for_each
(
tmp
,
&
server
->
pending_mid_q
)
{
mid_entry
=
list_entry
(
tmp
,
struct
mid_q_entry
,
...
...
@@ -288,7 +296,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
MID_RESPONSE_RECEIVED
;
}
}
read
_unlock
(
&
GlobalMid_Lock
);
spin
_unlock
(
&
GlobalMid_Lock
);
if
(
task_to_wake
)
{
smb_buffer
=
NULL
;
/* will be freed by users thread after he is done */
wake_up_process
(
task_to_wake
);
...
...
@@ -432,6 +440,20 @@ parse_mount_options(char *options, const char *devname, struct smb_vol *vol)
printk
(
KERN_WARNING
"CIFS: domain name too long
\n
"
);
return
1
;
}
}
else
if
(
strnicmp
(
data
,
"iocharset"
,
9
)
==
0
)
{
if
(
!
value
||
!*
value
)
{
printk
(
KERN_WARNING
"CIFS: invalid iocharset specified
\n
"
);
return
1
;
/* needs_arg; */
}
if
(
strnlen
(
value
,
65
)
<
65
)
{
if
(
strnicmp
(
value
,
"default"
,
7
))
vol
->
iocharset
=
value
;
/* if iocharset not set load_nls_default used by caller */
cFYI
(
1
,
(
"iocharset set to %s"
,
value
));
}
else
{
printk
(
KERN_WARNING
"CIFS: iocharset name too long.
\n
"
);
return
1
;
}
}
else
if
(
strnicmp
(
data
,
"uid"
,
3
)
==
0
)
{
if
(
value
&&
*
value
)
{
vol
->
linux_uid
=
...
...
@@ -467,6 +489,19 @@ parse_mount_options(char *options, const char *devname, struct smb_vol *vol)
vol
->
wsize
=
simple_strtoul
(
value
,
&
value
,
0
);
}
}
else
if
(
strnicmp
(
data
,
"sockopt"
,
5
)
==
0
)
{
if
(
value
&&
*
value
)
{
vol
->
sockopt
=
simple_strtoul
(
value
,
&
value
,
0
);
}
}
else
if
(
strnicmp
(
data
,
"netbiosname"
,
4
)
==
0
)
{
if
(
!
value
||
!*
value
)
{
vol
->
source_rfc1001_name
=
NULL
;
}
else
if
(
strnlen
(
value
,
17
)
<
17
)
{
vol
->
source_rfc1001_name
=
value
;
}
else
{
printk
(
KERN_WARNING
"CIFS: netbiosname too long (more than 15)
\n
"
);
}
}
else
if
(
strnicmp
(
data
,
"version"
,
3
)
==
0
)
{
/* ignore */
}
else
if
(
strnicmp
(
data
,
"rw"
,
2
)
==
0
)
{
...
...
@@ -728,8 +763,13 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket)
*
csocket
=
NULL
;
return
rc
;
}
else
{
/* BB other socket options to set KEEPALIVE, timeouts? NODELAY? */
/* BB other socket options to set KEEPALIVE, NODELAY? */
struct
timeval
tval
;
tval
.
tv_sec
=
10
;
cFYI
(
1
,(
"Socket created"
));
sock_setsockopt
(
*
csocket
,
SOL_SOCKET
,
SO_RCVTIMEO
,
(
char
*
)
&
tval
,
sizeof
(
struct
timeval
));
}
}
...
...
@@ -863,6 +903,19 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
return
-
EINVAL
;
}
/* this is needed for ASCII cp to Unicode converts */
if
(
volume_info
.
iocharset
==
NULL
)
{
cifs_sb
->
local_nls
=
load_nls_default
();
/* load_nls_default can not return null */
}
else
{
cifs_sb
->
local_nls
=
load_nls
(
volume_info
.
iocharset
);
if
(
cifs_sb
->
local_nls
==
NULL
)
{
cERROR
(
1
,(
"CIFS mount error: iocharset %s not found"
,
volume_info
.
iocharset
));
FreeXid
(
xid
);
return
-
ELIBACC
;
}
}
existingCifsSes
=
find_tcp_session
(
sin_server
.
sin_addr
.
s_addr
,
volume_info
.
username
,
&
srvTcp
);
...
...
fs/cifs/dir.c
View file @
e637fa3a
...
...
@@ -218,6 +218,8 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
pCifsFile
->
netfid
=
fileHandle
;
pCifsFile
->
pid
=
current
->
tgid
;
pCifsFile
->
pInode
=
newinode
;
pCifsFile
->
invalidHandle
=
FALSE
;
pCifsFile
->
closePend
=
FALSE
;
/* pCifsFile->pfile = file; */
/* put in at open time */
write_lock
(
&
GlobalSMBSeslock
);
list_add
(
&
pCifsFile
->
tlist
,
&
pTcon
->
openFileList
);
...
...
fs/cifs/file.c
View file @
e637fa3a
This diff is collapsed.
Click to expand it.
fs/cifs/misc.c
View file @
e637fa3a
/*
* fs/cifs/misc.c
*
* Copyright (
c
) International Business Machines Corp., 2002,2003
* Copyright (
C
) International Business Machines Corp., 2002,2003
* Author(s): Steve French (sfrench@us.ibm.com)
*
* This library is free software; you can redistribute it and/or modify
...
...
@@ -42,23 +42,23 @@ _GetXid(void)
{
unsigned
int
xid
;
write
_lock
(
&
GlobalMid_Lock
);
spin
_lock
(
&
GlobalMid_Lock
);
GlobalTotalActiveXid
++
;
if
(
GlobalTotalActiveXid
>
GlobalMaxActiveXid
)
GlobalMaxActiveXid
=
GlobalTotalActiveXid
;
/* keep high water mark for number of simultaneous vfs ops in our filesystem */
xid
=
GlobalCurrentXid
++
;
write
_unlock
(
&
GlobalMid_Lock
);
spin
_unlock
(
&
GlobalMid_Lock
);
return
xid
;
}
void
_FreeXid
(
unsigned
int
xid
)
{
write
_lock
(
&
GlobalMid_Lock
);
spin
_lock
(
&
GlobalMid_Lock
);
/* if(GlobalTotalActiveXid == 0)
BUG(); */
GlobalTotalActiveXid
--
;
write
_unlock
(
&
GlobalMid_Lock
);
spin
_unlock
(
&
GlobalMid_Lock
);
}
struct
cifsSesInfo
*
...
...
@@ -217,10 +217,10 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
buffer
->
Pid
=
tmp
&
0xFFFF
;
tmp
>>=
16
;
buffer
->
PidHigh
=
tmp
&
0xFFFF
;
write
_lock
(
&
GlobalMid_Lock
);
spin
_lock
(
&
GlobalMid_Lock
);
GlobalMid
++
;
buffer
->
Mid
=
GlobalMid
;
write
_unlock
(
&
GlobalMid_Lock
);
spin
_unlock
(
&
GlobalMid_Lock
);
if
(
treeCon
)
{
buffer
->
Tid
=
treeCon
->
tid
;
if
(
treeCon
->
ses
)
{
...
...
fs/cifs/smbdes.c
View file @
e637fa3a
...
...
@@ -6,7 +6,7 @@
SMB authentication protocol
Copyright (C) Andrew Tridgell 1998
Modified by Steve French (sfrench@us.ibm.com) 2002
Modified by Steve French (sfrench@us.ibm.com) 2002
,2003
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -376,41 +376,3 @@ cred_hash3(unsigned char *out, unsigned char *in, unsigned char *key, int forw)
key2
[
0
]
=
key
[
7
];
smbhash
(
out
+
8
,
in
+
8
,
key2
,
forw
);
}
void
SamOEMhash
(
unsigned
char
*
data
,
unsigned
char
*
key
,
int
val
)
{
unsigned
char
s_box
[
256
];
unsigned
char
index_i
=
0
;
unsigned
char
index_j
=
0
;
unsigned
char
j
=
0
;
int
ind
;
for
(
ind
=
0
;
ind
<
256
;
ind
++
)
{
s_box
[
ind
]
=
(
unsigned
char
)
ind
;
}
for
(
ind
=
0
;
ind
<
256
;
ind
++
)
{
unsigned
char
tc
;
j
+=
(
s_box
[
ind
]
+
key
[
ind
%
16
]);
tc
=
s_box
[
ind
];
s_box
[
ind
]
=
s_box
[
j
];
s_box
[
j
]
=
tc
;
}
for
(
ind
=
0
;
ind
<
val
;
ind
++
)
{
unsigned
char
tc
;
unsigned
char
t
;
index_i
++
;
index_j
+=
s_box
[
index_i
];
tc
=
s_box
[
index_i
];
s_box
[
index_i
]
=
s_box
[
index_j
];
s_box
[
index_j
]
=
tc
;
t
=
s_box
[
index_i
]
+
s_box
[
index_j
];
data
[
ind
]
=
data
[
ind
]
^
s_box
[
t
];
}
}
fs/cifs/smbencrypt.c
View file @
e637fa3a
...
...
@@ -63,7 +63,6 @@ void cred_hash1(unsigned char *out, unsigned char *in, unsigned char *key);
void
cred_hash2
(
unsigned
char
*
out
,
unsigned
char
*
in
,
unsigned
char
*
key
);
void
cred_hash3
(
unsigned
char
*
out
,
unsigned
char
*
in
,
unsigned
char
*
key
,
int
forw
);
void
SamOEMhash
(
unsigned
char
*
data
,
unsigned
char
*
key
,
int
val
);
/*The following definitions come from libsmb/smbencrypt.c */
...
...
@@ -75,8 +74,6 @@ void SMBOWFencrypt(unsigned char passwd[16], unsigned char *c8,
void
NTLMSSPOWFencrypt
(
unsigned
char
passwd
[
8
],
unsigned
char
*
ntlmchalresp
,
unsigned
char
p24
[
24
]);
void
SMBNTencrypt
(
unsigned
char
*
passwd
,
unsigned
char
*
c8
,
unsigned
char
*
p24
);
int
make_oem_passwd_hash
(
char
data
[
516
],
const
char
*
passwd
,
unsigned
char
old_pw_hash
[
16
],
int
unicode
);
int
decode_pw_buffer
(
char
in_buffer
[
516
],
char
*
new_pwrd
,
int
new_pwrd_size
,
__u32
*
new_pw_len
);
...
...
@@ -346,46 +343,6 @@ static struct data_blob LMv2_generate_response(const unsigned char ntlm_v2_hash[
return
final_response
;
}
int
make_oem_passwd_hash
(
char
data
[
516
],
const
char
*
passwd
,
unsigned
char
old_pw_hash
[
16
],
int
unicode
)
{
int
new_pw_len
=
strlen
(
passwd
)
*
(
unicode
?
2
:
1
);
if
(
new_pw_len
>
512
)
{
cERROR
(
1
,
(
"CIFS make_oem_passwd_hash: new password is too long."
));
return
FALSE
;
}
/*
* Now setup the data area.
* We need to generate a random fill
* for this area to make it harder to
* decrypt. JRA.
*
*/
get_random_bytes
(
data
,
sizeof
(
data
));
if
(
unicode
)
{
/* Note that passwd should be in DOS oem character set. */
/* dos_struni2( &data[512 - new_pw_len], passwd, 512); */
cifs_strtoUCS
((
wchar_t
*
)
&
data
[
512
-
new_pw_len
],
passwd
,
512
,
/* struct nls_table */
load_nls_default
());
/* BB call unload_nls now or get nls differntly */
}
else
{
/* Note that passwd should be in DOS oem character set. */
strcpy
(
&
data
[
512
-
new_pw_len
],
passwd
);
}
SIVAL
(
data
,
512
,
new_pw_len
);
#ifdef DEBUG_PASSWORD
DEBUG
(
100
,
(
"make_oem_passwd_hash
\n
"
));
dump_data
(
100
,
data
,
516
);
#endif
SamOEMhash
((
unsigned
char
*
)
data
,
(
unsigned
char
*
)
old_pw_hash
,
516
);
return
TRUE
;
}
void
SMBsesskeygen_ntv2
(
const
unsigned
char
kr
[
16
],
const
unsigned
char
*
nt_resp
,
__u8
sess_key
[
16
])
...
...
fs/cifs/transport.c
View file @
e637fa3a
/*
* fs/cifs/transport.c
*
* Copyright (
c) International Business Machines Corp., 2002
* Copyright (
C) International Business Machines Corp., 2002,2003
* Author(s): Steve French (sfrench@us.ibm.com)
*
* This library is free software; you can redistribute it and/or modify
...
...
@@ -39,7 +39,6 @@ AllocMidQEntry(struct smb_hdr *smb_buffer, struct cifsSesInfo *ses)
struct
mid_q_entry
*
temp
;
int
timeout
=
10
*
HZ
;
/* BB add spinlock to protect midq for each session BB */
if
(
ses
==
NULL
)
{
cERROR
(
1
,
(
"Null session passed in to AllocMidQEntry "
));
return
NULL
;
...
...
@@ -72,11 +71,11 @@ AllocMidQEntry(struct smb_hdr *smb_buffer, struct cifsSesInfo *ses)
}
if
(
ses
->
server
->
tcpStatus
==
CifsGood
)
{
write
_lock
(
&
GlobalMid_Lock
);
spin
_lock
(
&
GlobalMid_Lock
);
list_add_tail
(
&
temp
->
qhead
,
&
ses
->
server
->
pending_mid_q
);
atomic_inc
(
&
midCount
);
temp
->
midState
=
MID_REQUEST_ALLOCATED
;
write
_unlock
(
&
GlobalMid_Lock
);
spin
_unlock
(
&
GlobalMid_Lock
);
}
else
{
cERROR
(
1
,(
"Need to reconnect after session died to server"
));
if
(
temp
)
...
...
@@ -89,12 +88,11 @@ AllocMidQEntry(struct smb_hdr *smb_buffer, struct cifsSesInfo *ses)
void
DeleteMidQEntry
(
struct
mid_q_entry
*
midEntry
)
{
/* BB add spinlock to protect midq for each session BB */
write_lock
(
&
GlobalMid_Lock
);
spin_lock
(
&
GlobalMid_Lock
);
midEntry
->
midState
=
MID_FREE
;
list_del
(
&
midEntry
->
qhead
);
atomic_dec
(
&
midCount
);
write
_unlock
(
&
GlobalMid_Lock
);
spin
_unlock
(
&
GlobalMid_Lock
);
buf_release
(
midEntry
->
resp_buf
);
kmem_cache_free
(
cifs_mid_cachep
,
midEntry
);
}
...
...
@@ -115,9 +113,9 @@ AllocOplockQEntry(struct inode * pinode, __u16 fid, struct cifsTconInfo * tcon)
temp
->
pinode
=
pinode
;
temp
->
tcon
=
tcon
;
temp
->
netfid
=
fid
;
write
_lock
(
&
GlobalMid_Lock
);
spin
_lock
(
&
GlobalMid_Lock
);
list_add_tail
(
&
temp
->
qhead
,
&
GlobalOplock_Q
);
write
_unlock
(
&
GlobalMid_Lock
);
spin
_unlock
(
&
GlobalMid_Lock
);
}
return
temp
;
...
...
@@ -125,11 +123,10 @@ AllocOplockQEntry(struct inode * pinode, __u16 fid, struct cifsTconInfo * tcon)
void
DeleteOplockQEntry
(
struct
oplock_q_entry
*
oplockEntry
)
{
/* BB add spinlock to protect midq for each session BB */
write_lock
(
&
GlobalMid_Lock
);
spin_lock
(
&
GlobalMid_Lock
);
/* should we check if list empty first? */
list_del
(
&
oplockEntry
->
qhead
);
write
_unlock
(
&
GlobalMid_Lock
);
spin
_unlock
(
&
GlobalMid_Lock
);
kmem_cache_free
(
cifs_oplock_cachep
,
oplockEntry
);
}
...
...
@@ -240,6 +237,7 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses,
else
{
cFYI
(
1
,(
"No response buffer"
));
DeleteMidQEntry
(
midQ
);
ses
->
server
->
tcpStatus
=
CifsNeedReconnect
;
return
-
EIO
;
}
}
...
...
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