Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6

* 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6:
  When verifying the decoded header before decoding the object identifier
  [CIFS] Fix warnings from checkpatch
  [CIFS] Fix improper endian conversion of ACL subauth field
  [CIFS] Fix possible double free if search immediately after search rewind fails
  [CIFS] remove checkpatch warning
  Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
  cifs: assorted endian annotations
  [CIFS] break ATTR_SIZE changes out into their own function
  lockdep: annotate cifs in-kernel sockets
  [CIFS] Fix compiler warning on 64-bit
This commit is contained in:
Linus Torvalds 2008-07-26 12:45:32 -07:00
commit 4b1fefaca9
10 changed files with 410 additions and 518 deletions

View file

@ -400,7 +400,7 @@ asn1_oid_decode(struct asn1_ctx *ctx,
size = eoc - ctx->pointer + 1; size = eoc - ctx->pointer + 1;
/* first subid actually encodes first two subids */ /* first subid actually encodes first two subids */
if (size < 2 || size > ULONG_MAX/sizeof(unsigned long)) if (size < 2 || size > UINT_MAX/sizeof(unsigned long))
return 0; return 0;
*oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC); *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC);
@ -494,7 +494,7 @@ decode_negTokenInit(unsigned char *security_blob, int length,
/* remember to free obj->oid */ /* remember to free obj->oid */
rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag); rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag);
if (rc) { if (rc) {
if ((tag == ASN1_OJI) && (cls == ASN1_PRI)) { if ((tag == ASN1_OJI) && (con == ASN1_PRI)) {
rc = asn1_oid_decode(&ctx, end, &oid, &oidlen); rc = asn1_oid_decode(&ctx, end, &oid, &oidlen);
if (rc) { if (rc) {
rc = compare_oid(oid, oidlen, rc = compare_oid(oid, oidlen,

View file

@ -107,9 +107,7 @@ void cifs_dump_mids(struct TCP_Server_Info *server)
#endif /* CONFIG_CIFS_DEBUG2 */ #endif /* CONFIG_CIFS_DEBUG2 */
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
static int static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
int count, int *eof, void *data)
{ {
struct list_head *tmp; struct list_head *tmp;
struct list_head *tmp1; struct list_head *tmp1;
@ -117,23 +115,13 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
struct cifsSesInfo *ses; struct cifsSesInfo *ses;
struct cifsTconInfo *tcon; struct cifsTconInfo *tcon;
int i; int i;
int length = 0;
char *original_buf = buf;
*beginBuffer = buf + offset; seq_puts(m,
length =
sprintf(buf,
"Display Internal CIFS Data Structures for Debugging\n" "Display Internal CIFS Data Structures for Debugging\n"
"---------------------------------------------------\n"); "---------------------------------------------------\n");
buf += length; seq_printf(m, "CIFS Version %s\n", CIFS_VERSION);
length = sprintf(buf, "CIFS Version %s\n", CIFS_VERSION); seq_printf(m, "Active VFS Requests: %d\n", GlobalTotalActiveXid);
buf += length; seq_printf(m, "Servers:");
length = sprintf(buf,
"Active VFS Requests: %d\n", GlobalTotalActiveXid);
buf += length;
length = sprintf(buf, "Servers:");
buf += length;
i = 0; i = 0;
read_lock(&GlobalSMBSeslock); read_lock(&GlobalSMBSeslock);
@ -142,11 +130,10 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) || if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) ||
(ses->serverNOS == NULL)) { (ses->serverNOS == NULL)) {
buf += sprintf(buf, "\nentry for %s not fully " seq_printf(m, "\nentry for %s not fully "
"displayed\n\t", ses->serverName); "displayed\n\t", ses->serverName);
} else { } else {
length = seq_printf(m,
sprintf(buf,
"\n%d) Name: %s Domain: %s Mounts: %d OS:" "\n%d) Name: %s Domain: %s Mounts: %d OS:"
" %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB" " %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB"
" session status: %d\t", " session status: %d\t",
@ -154,10 +141,9 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
atomic_read(&ses->inUse), atomic_read(&ses->inUse),
ses->serverOS, ses->serverNOS, ses->serverOS, ses->serverNOS,
ses->capabilities, ses->status); ses->capabilities, ses->status);
buf += length;
} }
if (ses->server) { if (ses->server) {
buf += sprintf(buf, "TCP status: %d\n\tLocal Users To " seq_printf(m, "TCP status: %d\n\tLocal Users To "
"Server: %d SecMode: 0x%x Req On Wire: %d", "Server: %d SecMode: 0x%x Req On Wire: %d",
ses->server->tcpStatus, ses->server->tcpStatus,
atomic_read(&ses->server->socketUseCount), atomic_read(&ses->server->socketUseCount),
@ -165,13 +151,12 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
atomic_read(&ses->server->inFlight)); atomic_read(&ses->server->inFlight));
#ifdef CONFIG_CIFS_STATS2 #ifdef CONFIG_CIFS_STATS2
buf += sprintf(buf, " In Send: %d In MaxReq Wait: %d", seq_printf(m, " In Send: %d In MaxReq Wait: %d",
atomic_read(&ses->server->inSend), atomic_read(&ses->server->inSend),
atomic_read(&ses->server->num_waiters)); atomic_read(&ses->server->num_waiters));
#endif #endif
length = sprintf(buf, "\nMIDs:\n"); seq_puts(m, "\nMIDs:\n");
buf += length;
spin_lock(&GlobalMid_Lock); spin_lock(&GlobalMid_Lock);
list_for_each(tmp1, &ses->server->pending_mid_q) { list_for_each(tmp1, &ses->server->pending_mid_q) {
@ -179,7 +164,7 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
mid_q_entry, mid_q_entry,
qhead); qhead);
if (mid_entry) { if (mid_entry) {
length = sprintf(buf, seq_printf(m,
"State: %d com: %d pid:" "State: %d com: %d pid:"
" %d tsk: %p mid %d\n", " %d tsk: %p mid %d\n",
mid_entry->midState, mid_entry->midState,
@ -187,7 +172,6 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
mid_entry->pid, mid_entry->pid,
mid_entry->tsk, mid_entry->tsk,
mid_entry->mid); mid_entry->mid);
buf += length;
} }
} }
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
@ -195,11 +179,9 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
} }
read_unlock(&GlobalSMBSeslock); read_unlock(&GlobalSMBSeslock);
sprintf(buf, "\n"); seq_putc(m, '\n');
buf++;
length = sprintf(buf, "Shares:"); seq_puts(m, "Shares:");
buf += length;
i = 0; i = 0;
read_lock(&GlobalSMBSeslock); read_lock(&GlobalSMBSeslock);
@ -208,62 +190,52 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
i++; i++;
tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
length = sprintf(buf, "\n%d) %s Uses: %d ", i, seq_printf(m, "\n%d) %s Uses: %d ", i,
tcon->treeName, atomic_read(&tcon->useCount)); tcon->treeName, atomic_read(&tcon->useCount));
buf += length;
if (tcon->nativeFileSystem) { if (tcon->nativeFileSystem) {
length = sprintf(buf, "Type: %s ", seq_printf(m, "Type: %s ",
tcon->nativeFileSystem); tcon->nativeFileSystem);
buf += length;
} }
length = sprintf(buf, "DevInfo: 0x%x Attributes: 0x%x" seq_printf(m, "DevInfo: 0x%x Attributes: 0x%x"
"\nPathComponentMax: %d Status: %d", "\nPathComponentMax: %d Status: %d",
le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics), le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics),
le32_to_cpu(tcon->fsAttrInfo.Attributes), le32_to_cpu(tcon->fsAttrInfo.Attributes),
le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength), le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
tcon->tidStatus); tcon->tidStatus);
buf += length;
if (dev_type == FILE_DEVICE_DISK) if (dev_type == FILE_DEVICE_DISK)
length = sprintf(buf, " type: DISK "); seq_puts(m, " type: DISK ");
else if (dev_type == FILE_DEVICE_CD_ROM) else if (dev_type == FILE_DEVICE_CD_ROM)
length = sprintf(buf, " type: CDROM "); seq_puts(m, " type: CDROM ");
else else
length = seq_printf(m, " type: %d ", dev_type);
sprintf(buf, " type: %d ", dev_type);
buf += length; if (tcon->tidStatus == CifsNeedReconnect)
if (tcon->tidStatus == CifsNeedReconnect) { seq_puts(m, "\tDISCONNECTED ");
buf += sprintf(buf, "\tDISCONNECTED ");
length += 14;
}
} }
read_unlock(&GlobalSMBSeslock); read_unlock(&GlobalSMBSeslock);
length = sprintf(buf, "\n"); seq_putc(m, '\n');
buf += length;
/* BB add code to dump additional info such as TCP session info now */ /* BB add code to dump additional info such as TCP session info now */
/* Now calculate total size of returned data */ return 0;
length = buf - original_buf;
if (offset + count >= length)
*eof = 1;
if (length < offset) {
*eof = 1;
return 0;
} else {
length = length - offset;
}
if (length > count)
length = count;
return length;
} }
#ifdef CONFIG_CIFS_STATS static int cifs_debug_data_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, cifs_debug_data_proc_show, NULL);
}
static int static const struct file_operations cifs_debug_data_proc_fops = {
cifs_stats_write(struct file *file, const char __user *buffer, .owner = THIS_MODULE,
unsigned long count, void *data) .open = cifs_debug_data_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#ifdef CONFIG_CIFS_STATS
static ssize_t cifs_stats_proc_write(struct file *file,
const char __user *buffer, size_t count, loff_t *ppos)
{ {
char c; char c;
int rc; int rc;
@ -307,236 +279,132 @@ cifs_stats_write(struct file *file, const char __user *buffer,
return count; return count;
} }
static int static int cifs_stats_proc_show(struct seq_file *m, void *v)
cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
int count, int *eof, void *data)
{ {
int item_length, i, length; int i;
struct list_head *tmp; struct list_head *tmp;
struct cifsTconInfo *tcon; struct cifsTconInfo *tcon;
*beginBuffer = buf + offset; seq_printf(m,
length = sprintf(buf,
"Resources in use\nCIFS Session: %d\n", "Resources in use\nCIFS Session: %d\n",
sesInfoAllocCount.counter); sesInfoAllocCount.counter);
buf += length; seq_printf(m, "Share (unique mount targets): %d\n",
item_length =
sprintf(buf, "Share (unique mount targets): %d\n",
tconInfoAllocCount.counter); tconInfoAllocCount.counter);
length += item_length; seq_printf(m, "SMB Request/Response Buffer: %d Pool size: %d\n",
buf += item_length;
item_length =
sprintf(buf, "SMB Request/Response Buffer: %d Pool size: %d\n",
bufAllocCount.counter, bufAllocCount.counter,
cifs_min_rcv + tcpSesAllocCount.counter); cifs_min_rcv + tcpSesAllocCount.counter);
length += item_length; seq_printf(m, "SMB Small Req/Resp Buffer: %d Pool size: %d\n",
buf += item_length;
item_length =
sprintf(buf, "SMB Small Req/Resp Buffer: %d Pool size: %d\n",
smBufAllocCount.counter, cifs_min_small); smBufAllocCount.counter, cifs_min_small);
length += item_length;
buf += item_length;
#ifdef CONFIG_CIFS_STATS2 #ifdef CONFIG_CIFS_STATS2
item_length = sprintf(buf, "Total Large %d Small %d Allocations\n", seq_printf(m, "Total Large %d Small %d Allocations\n",
atomic_read(&totBufAllocCount), atomic_read(&totBufAllocCount),
atomic_read(&totSmBufAllocCount)); atomic_read(&totSmBufAllocCount));
length += item_length;
buf += item_length;
#endif /* CONFIG_CIFS_STATS2 */ #endif /* CONFIG_CIFS_STATS2 */
item_length = seq_printf(m, "Operations (MIDs): %d\n", midCount.counter);
sprintf(buf, "Operations (MIDs): %d\n", seq_printf(m,
midCount.counter);
length += item_length;
buf += item_length;
item_length = sprintf(buf,
"\n%d session %d share reconnects\n", "\n%d session %d share reconnects\n",
tcpSesReconnectCount.counter, tconInfoReconnectCount.counter); tcpSesReconnectCount.counter, tconInfoReconnectCount.counter);
length += item_length;
buf += item_length;
item_length = sprintf(buf, seq_printf(m,
"Total vfs operations: %d maximum at one time: %d\n", "Total vfs operations: %d maximum at one time: %d\n",
GlobalCurrentXid, GlobalMaxActiveXid); GlobalCurrentXid, GlobalMaxActiveXid);
length += item_length;
buf += item_length;
i = 0; i = 0;
read_lock(&GlobalSMBSeslock); read_lock(&GlobalSMBSeslock);
list_for_each(tmp, &GlobalTreeConnectionList) { list_for_each(tmp, &GlobalTreeConnectionList) {
i++; i++;
tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
item_length = sprintf(buf, "\n%d) %s", i, tcon->treeName); seq_printf(m, "\n%d) %s", i, tcon->treeName);
buf += item_length; if (tcon->tidStatus == CifsNeedReconnect)
length += item_length; seq_puts(m, "\tDISCONNECTED ");
if (tcon->tidStatus == CifsNeedReconnect) { seq_printf(m, "\nSMBs: %d Oplock Breaks: %d",
buf += sprintf(buf, "\tDISCONNECTED ");
length += 14;
}
item_length = sprintf(buf, "\nSMBs: %d Oplock Breaks: %d",
atomic_read(&tcon->num_smbs_sent), atomic_read(&tcon->num_smbs_sent),
atomic_read(&tcon->num_oplock_brks)); atomic_read(&tcon->num_oplock_brks));
buf += item_length; seq_printf(m, "\nReads: %d Bytes: %lld",
length += item_length;
item_length = sprintf(buf, "\nReads: %d Bytes: %lld",
atomic_read(&tcon->num_reads), atomic_read(&tcon->num_reads),
(long long)(tcon->bytes_read)); (long long)(tcon->bytes_read));
buf += item_length; seq_printf(m, "\nWrites: %d Bytes: %lld",
length += item_length;
item_length = sprintf(buf, "\nWrites: %d Bytes: %lld",
atomic_read(&tcon->num_writes), atomic_read(&tcon->num_writes),
(long long)(tcon->bytes_written)); (long long)(tcon->bytes_written));
buf += item_length; seq_printf(m,
length += item_length;
item_length = sprintf(buf,
"\nLocks: %d HardLinks: %d Symlinks: %d", "\nLocks: %d HardLinks: %d Symlinks: %d",
atomic_read(&tcon->num_locks), atomic_read(&tcon->num_locks),
atomic_read(&tcon->num_hardlinks), atomic_read(&tcon->num_hardlinks),
atomic_read(&tcon->num_symlinks)); atomic_read(&tcon->num_symlinks));
buf += item_length;
length += item_length;
item_length = sprintf(buf, "\nOpens: %d Closes: %d Deletes: %d", seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
atomic_read(&tcon->num_opens), atomic_read(&tcon->num_opens),
atomic_read(&tcon->num_closes), atomic_read(&tcon->num_closes),
atomic_read(&tcon->num_deletes)); atomic_read(&tcon->num_deletes));
buf += item_length; seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
length += item_length;
item_length = sprintf(buf, "\nMkdirs: %d Rmdirs: %d",
atomic_read(&tcon->num_mkdirs), atomic_read(&tcon->num_mkdirs),
atomic_read(&tcon->num_rmdirs)); atomic_read(&tcon->num_rmdirs));
buf += item_length; seq_printf(m, "\nRenames: %d T2 Renames %d",
length += item_length;
item_length = sprintf(buf, "\nRenames: %d T2 Renames %d",
atomic_read(&tcon->num_renames), atomic_read(&tcon->num_renames),
atomic_read(&tcon->num_t2renames)); atomic_read(&tcon->num_t2renames));
buf += item_length; seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
length += item_length;
item_length = sprintf(buf, "\nFindFirst: %d FNext %d FClose %d",
atomic_read(&tcon->num_ffirst), atomic_read(&tcon->num_ffirst),
atomic_read(&tcon->num_fnext), atomic_read(&tcon->num_fnext),
atomic_read(&tcon->num_fclose)); atomic_read(&tcon->num_fclose));
buf += item_length;
length += item_length;
} }
read_unlock(&GlobalSMBSeslock); read_unlock(&GlobalSMBSeslock);
buf += sprintf(buf, "\n"); seq_putc(m, '\n');
length++; return 0;
if (offset + count >= length)
*eof = 1;
if (length < offset) {
*eof = 1;
return 0;
} else {
length = length - offset;
}
if (length > count)
length = count;
return length;
} }
static int cifs_stats_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, cifs_stats_proc_show, NULL);
}
static const struct file_operations cifs_stats_proc_fops = {
.owner = THIS_MODULE,
.open = cifs_stats_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.write = cifs_stats_proc_write,
};
#endif /* STATS */ #endif /* STATS */
static struct proc_dir_entry *proc_fs_cifs; static struct proc_dir_entry *proc_fs_cifs;
read_proc_t cifs_txanchor_read; static const struct file_operations cifsFYI_proc_fops;
static read_proc_t cifsFYI_read; static const struct file_operations cifs_oplock_proc_fops;
static write_proc_t cifsFYI_write; static const struct file_operations cifs_lookup_cache_proc_fops;
static read_proc_t oplockEnabled_read; static const struct file_operations traceSMB_proc_fops;
static write_proc_t oplockEnabled_write; static const struct file_operations cifs_multiuser_mount_proc_fops;
static read_proc_t lookupFlag_read; static const struct file_operations cifs_security_flags_proc_fops;
static write_proc_t lookupFlag_write; static const struct file_operations cifs_experimental_proc_fops;
static read_proc_t traceSMB_read; static const struct file_operations cifs_linux_ext_proc_fops;
static write_proc_t traceSMB_write;
static read_proc_t multiuser_mount_read;
static write_proc_t multiuser_mount_write;
static read_proc_t security_flags_read;
static write_proc_t security_flags_write;
/* static read_proc_t ntlmv2_enabled_read;
static write_proc_t ntlmv2_enabled_write;
static read_proc_t packet_signing_enabled_read;
static write_proc_t packet_signing_enabled_write;*/
static read_proc_t experimEnabled_read;
static write_proc_t experimEnabled_write;
static read_proc_t linuxExtensionsEnabled_read;
static write_proc_t linuxExtensionsEnabled_write;
void void
cifs_proc_init(void) cifs_proc_init(void)
{ {
struct proc_dir_entry *pde;
proc_fs_cifs = proc_mkdir("fs/cifs", NULL); proc_fs_cifs = proc_mkdir("fs/cifs", NULL);
if (proc_fs_cifs == NULL) if (proc_fs_cifs == NULL)
return; return;
proc_fs_cifs->owner = THIS_MODULE; proc_fs_cifs->owner = THIS_MODULE;
create_proc_read_entry("DebugData", 0, proc_fs_cifs, proc_create("DebugData", 0, proc_fs_cifs, &cifs_debug_data_proc_fops);
cifs_debug_data_read, NULL);
#ifdef CONFIG_CIFS_STATS #ifdef CONFIG_CIFS_STATS
pde = create_proc_read_entry("Stats", 0, proc_fs_cifs, proc_create("Stats", 0, proc_fs_cifs, &cifs_stats_proc_fops);
cifs_stats_read, NULL);
if (pde)
pde->write_proc = cifs_stats_write;
#endif /* STATS */ #endif /* STATS */
pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs, proc_create("cifsFYI", 0, proc_fs_cifs, &cifsFYI_proc_fops);
cifsFYI_read, NULL); proc_create("traceSMB", 0, proc_fs_cifs, &traceSMB_proc_fops);
if (pde) proc_create("OplockEnabled", 0, proc_fs_cifs, &cifs_oplock_proc_fops);
pde->write_proc = cifsFYI_write; proc_create("Experimental", 0, proc_fs_cifs,
&cifs_experimental_proc_fops);
pde = proc_create("LinuxExtensionsEnabled", 0, proc_fs_cifs,
create_proc_read_entry("traceSMB", 0, proc_fs_cifs, &cifs_linux_ext_proc_fops);
traceSMB_read, NULL); proc_create("MultiuserMount", 0, proc_fs_cifs,
if (pde) &cifs_multiuser_mount_proc_fops);
pde->write_proc = traceSMB_write; proc_create("SecurityFlags", 0, proc_fs_cifs,
&cifs_security_flags_proc_fops);
pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs, proc_create("LookupCacheEnabled", 0, proc_fs_cifs,
oplockEnabled_read, NULL); &cifs_lookup_cache_proc_fops);
if (pde)
pde->write_proc = oplockEnabled_write;
pde = create_proc_read_entry("Experimental", 0, proc_fs_cifs,
experimEnabled_read, NULL);
if (pde)
pde->write_proc = experimEnabled_write;
pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs,
linuxExtensionsEnabled_read, NULL);
if (pde)
pde->write_proc = linuxExtensionsEnabled_write;
pde =
create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs,
multiuser_mount_read, NULL);
if (pde)
pde->write_proc = multiuser_mount_write;
pde =
create_proc_read_entry("SecurityFlags", 0, proc_fs_cifs,
security_flags_read, NULL);
if (pde)
pde->write_proc = security_flags_write;
pde =
create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs,
lookupFlag_read, NULL);
if (pde)
pde->write_proc = lookupFlag_write;
/* pde =
create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs,
ntlmv2_enabled_read, NULL);
if (pde)
pde->write_proc = ntlmv2_enabled_write;
pde =
create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs,
packet_signing_enabled_read, NULL);
if (pde)
pde->write_proc = packet_signing_enabled_write;*/
} }
void void
@ -553,39 +421,26 @@ cifs_proc_clean(void)
#endif #endif
remove_proc_entry("MultiuserMount", proc_fs_cifs); remove_proc_entry("MultiuserMount", proc_fs_cifs);
remove_proc_entry("OplockEnabled", proc_fs_cifs); remove_proc_entry("OplockEnabled", proc_fs_cifs);
/* remove_proc_entry("NTLMV2Enabled",proc_fs_cifs); */
remove_proc_entry("SecurityFlags", proc_fs_cifs); remove_proc_entry("SecurityFlags", proc_fs_cifs);
/* remove_proc_entry("PacketSigningEnabled", proc_fs_cifs); */
remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs); remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs);
remove_proc_entry("Experimental", proc_fs_cifs); remove_proc_entry("Experimental", proc_fs_cifs);
remove_proc_entry("LookupCacheEnabled", proc_fs_cifs); remove_proc_entry("LookupCacheEnabled", proc_fs_cifs);
remove_proc_entry("fs/cifs", NULL); remove_proc_entry("fs/cifs", NULL);
} }
static int static int cifsFYI_proc_show(struct seq_file *m, void *v)
cifsFYI_read(char *page, char **start, off_t off, int count,
int *eof, void *data)
{ {
int len; seq_printf(m, "%d\n", cifsFYI);
return 0;
len = sprintf(page, "%d\n", cifsFYI);
len -= off;
*start = page + off;
if (len > count)
len = count;
else
*eof = 1;
if (len < 0)
len = 0;
return len;
} }
static int
cifsFYI_write(struct file *file, const char __user *buffer, static int cifsFYI_proc_open(struct inode *inode, struct file *file)
unsigned long count, void *data) {
return single_open(file, cifsFYI_proc_show, NULL);
}
static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos)
{ {
char c; char c;
int rc; int rc;
@ -603,30 +458,28 @@ cifsFYI_write(struct file *file, const char __user *buffer,
return count; return count;
} }
static int static const struct file_operations cifsFYI_proc_fops = {
oplockEnabled_read(char *page, char **start, off_t off, .owner = THIS_MODULE,
int count, int *eof, void *data) .open = cifsFYI_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.write = cifsFYI_proc_write,
};
static int cifs_oplock_proc_show(struct seq_file *m, void *v)
{ {
int len; seq_printf(m, "%d\n", oplockEnabled);
return 0;
len = sprintf(page, "%d\n", oplockEnabled);
len -= off;
*start = page + off;
if (len > count)
len = count;
else
*eof = 1;
if (len < 0)
len = 0;
return len;
} }
static int
oplockEnabled_write(struct file *file, const char __user *buffer, static int cifs_oplock_proc_open(struct inode *inode, struct file *file)
unsigned long count, void *data) {
return single_open(file, cifs_oplock_proc_show, NULL);
}
static ssize_t cifs_oplock_proc_write(struct file *file,
const char __user *buffer, size_t count, loff_t *ppos)
{ {
char c; char c;
int rc; int rc;
@ -642,30 +495,28 @@ oplockEnabled_write(struct file *file, const char __user *buffer,
return count; return count;
} }
static int static const struct file_operations cifs_oplock_proc_fops = {
experimEnabled_read(char *page, char **start, off_t off, .owner = THIS_MODULE,
int count, int *eof, void *data) .open = cifs_oplock_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.write = cifs_oplock_proc_write,
};
static int cifs_experimental_proc_show(struct seq_file *m, void *v)
{ {
int len; seq_printf(m, "%d\n", experimEnabled);
return 0;
len = sprintf(page, "%d\n", experimEnabled);
len -= off;
*start = page + off;
if (len > count)
len = count;
else
*eof = 1;
if (len < 0)
len = 0;
return len;
} }
static int
experimEnabled_write(struct file *file, const char __user *buffer, static int cifs_experimental_proc_open(struct inode *inode, struct file *file)
unsigned long count, void *data) {
return single_open(file, cifs_experimental_proc_show, NULL);
}
static ssize_t cifs_experimental_proc_write(struct file *file,
const char __user *buffer, size_t count, loff_t *ppos)
{ {
char c; char c;
int rc; int rc;
@ -683,29 +534,28 @@ experimEnabled_write(struct file *file, const char __user *buffer,
return count; return count;
} }
static int static const struct file_operations cifs_experimental_proc_fops = {
linuxExtensionsEnabled_read(char *page, char **start, off_t off, .owner = THIS_MODULE,
int count, int *eof, void *data) .open = cifs_experimental_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.write = cifs_experimental_proc_write,
};
static int cifs_linux_ext_proc_show(struct seq_file *m, void *v)
{ {
int len; seq_printf(m, "%d\n", linuxExtEnabled);
return 0;
len = sprintf(page, "%d\n", linuxExtEnabled);
len -= off;
*start = page + off;
if (len > count)
len = count;
else
*eof = 1;
if (len < 0)
len = 0;
return len;
} }
static int
linuxExtensionsEnabled_write(struct file *file, const char __user *buffer, static int cifs_linux_ext_proc_open(struct inode *inode, struct file *file)
unsigned long count, void *data) {
return single_open(file, cifs_linux_ext_proc_show, NULL);
}
static ssize_t cifs_linux_ext_proc_write(struct file *file,
const char __user *buffer, size_t count, loff_t *ppos)
{ {
char c; char c;
int rc; int rc;
@ -721,31 +571,28 @@ linuxExtensionsEnabled_write(struct file *file, const char __user *buffer,
return count; return count;
} }
static const struct file_operations cifs_linux_ext_proc_fops = {
.owner = THIS_MODULE,
.open = cifs_linux_ext_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.write = cifs_linux_ext_proc_write,
};
static int static int cifs_lookup_cache_proc_show(struct seq_file *m, void *v)
lookupFlag_read(char *page, char **start, off_t off,
int count, int *eof, void *data)
{ {
int len; seq_printf(m, "%d\n", lookupCacheEnabled);
return 0;
len = sprintf(page, "%d\n", lookupCacheEnabled);
len -= off;
*start = page + off;
if (len > count)
len = count;
else
*eof = 1;
if (len < 0)
len = 0;
return len;
} }
static int
lookupFlag_write(struct file *file, const char __user *buffer, static int cifs_lookup_cache_proc_open(struct inode *inode, struct file *file)
unsigned long count, void *data) {
return single_open(file, cifs_lookup_cache_proc_show, NULL);
}
static ssize_t cifs_lookup_cache_proc_write(struct file *file,
const char __user *buffer, size_t count, loff_t *ppos)
{ {
char c; char c;
int rc; int rc;
@ -760,30 +607,29 @@ lookupFlag_write(struct file *file, const char __user *buffer,
return count; return count;
} }
static int
traceSMB_read(char *page, char **start, off_t off, int count, static const struct file_operations cifs_lookup_cache_proc_fops = {
int *eof, void *data) .owner = THIS_MODULE,
.open = cifs_lookup_cache_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.write = cifs_lookup_cache_proc_write,
};
static int traceSMB_proc_show(struct seq_file *m, void *v)
{ {
int len; seq_printf(m, "%d\n", traceSMB);
return 0;
len = sprintf(page, "%d\n", traceSMB);
len -= off;
*start = page + off;
if (len > count)
len = count;
else
*eof = 1;
if (len < 0)
len = 0;
return len;
} }
static int
traceSMB_write(struct file *file, const char __user *buffer, static int traceSMB_proc_open(struct inode *inode, struct file *file)
unsigned long count, void *data) {
return single_open(file, traceSMB_proc_show, NULL);
}
static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos)
{ {
char c; char c;
int rc; int rc;
@ -799,30 +645,28 @@ traceSMB_write(struct file *file, const char __user *buffer,
return count; return count;
} }
static int static const struct file_operations traceSMB_proc_fops = {
multiuser_mount_read(char *page, char **start, off_t off, .owner = THIS_MODULE,
int count, int *eof, void *data) .open = traceSMB_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.write = traceSMB_proc_write,
};
static int cifs_multiuser_mount_proc_show(struct seq_file *m, void *v)
{ {
int len; seq_printf(m, "%d\n", multiuser_mount);
return 0;
len = sprintf(page, "%d\n", multiuser_mount);
len -= off;
*start = page + off;
if (len > count)
len = count;
else
*eof = 1;
if (len < 0)
len = 0;
return len;
} }
static int
multiuser_mount_write(struct file *file, const char __user *buffer, static int cifs_multiuser_mount_proc_open(struct inode *inode, struct file *fh)
unsigned long count, void *data) {
return single_open(fh, cifs_multiuser_mount_proc_show, NULL);
}
static ssize_t cifs_multiuser_mount_proc_write(struct file *file,
const char __user *buffer, size_t count, loff_t *ppos)
{ {
char c; char c;
int rc; int rc;
@ -838,30 +682,28 @@ multiuser_mount_write(struct file *file, const char __user *buffer,
return count; return count;
} }
static int static const struct file_operations cifs_multiuser_mount_proc_fops = {
security_flags_read(char *page, char **start, off_t off, .owner = THIS_MODULE,
int count, int *eof, void *data) .open = cifs_multiuser_mount_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.write = cifs_multiuser_mount_proc_write,
};
static int cifs_security_flags_proc_show(struct seq_file *m, void *v)
{ {
int len; seq_printf(m, "0x%x\n", extended_security);
return 0;
len = sprintf(page, "0x%x\n", extended_security);
len -= off;
*start = page + off;
if (len > count)
len = count;
else
*eof = 1;
if (len < 0)
len = 0;
return len;
} }
static int
security_flags_write(struct file *file, const char __user *buffer, static int cifs_security_flags_proc_open(struct inode *inode, struct file *file)
unsigned long count, void *data) {
return single_open(file, cifs_security_flags_proc_show, NULL);
}
static ssize_t cifs_security_flags_proc_write(struct file *file,
const char __user *buffer, size_t count, loff_t *ppos)
{ {
unsigned int flags; unsigned int flags;
char flags_string[12]; char flags_string[12];
@ -917,6 +759,15 @@ security_flags_write(struct file *file, const char __user *buffer,
/* BB should we turn on MAY flags for other MUST options? */ /* BB should we turn on MAY flags for other MUST options? */
return count; return count;
} }
static const struct file_operations cifs_security_flags_proc_fops = {
.owner = THIS_MODULE,
.open = cifs_security_flags_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.write = cifs_security_flags_proc_write,
};
#else #else
inline void cifs_proc_init(void) inline void cifs_proc_init(void)
{ {

View file

@ -56,7 +56,7 @@ int match_sid(struct cifs_sid *ctsid)
struct cifs_sid *cwsid; struct cifs_sid *cwsid;
if (!ctsid) if (!ctsid)
return (-1); return -1;
for (i = 0; i < NUM_WK_SIDS; ++i) { for (i = 0; i < NUM_WK_SIDS; ++i) {
cwsid = &(wksidarr[i].cifssid); cwsid = &(wksidarr[i].cifssid);
@ -87,11 +87,11 @@ int match_sid(struct cifs_sid *ctsid)
} }
cFYI(1, ("matching sid: %s\n", wksidarr[i].sidname)); cFYI(1, ("matching sid: %s\n", wksidarr[i].sidname));
return (0); /* sids compare/match */ return 0; /* sids compare/match */
} }
cFYI(1, ("No matching sid")); cFYI(1, ("No matching sid"));
return (-1); return -1;
} }
/* if the two SIDs (roughly equivalent to a UUID for a user or group) are /* if the two SIDs (roughly equivalent to a UUID for a user or group) are
@ -102,16 +102,16 @@ int compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid)
int num_subauth, num_sat, num_saw; int num_subauth, num_sat, num_saw;
if ((!ctsid) || (!cwsid)) if ((!ctsid) || (!cwsid))
return (0); return 0;
/* compare the revision */ /* compare the revision */
if (ctsid->revision != cwsid->revision) if (ctsid->revision != cwsid->revision)
return (0); return 0;
/* compare all of the six auth values */ /* compare all of the six auth values */
for (i = 0; i < 6; ++i) { for (i = 0; i < 6; ++i) {
if (ctsid->authority[i] != cwsid->authority[i]) if (ctsid->authority[i] != cwsid->authority[i])
return (0); return 0;
} }
/* compare all of the subauth values if any */ /* compare all of the subauth values if any */
@ -121,11 +121,11 @@ int compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid)
if (num_subauth) { if (num_subauth) {
for (i = 0; i < num_subauth; ++i) { for (i = 0; i < num_subauth; ++i) {
if (ctsid->sub_auth[i] != cwsid->sub_auth[i]) if (ctsid->sub_auth[i] != cwsid->sub_auth[i])
return (0); return 0;
} }
} }
return (1); /* sids compare/match */ return 1; /* sids compare/match */
} }
@ -169,8 +169,7 @@ static void copy_sec_desc(const struct cifs_ntsd *pntsd,
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
ngroup_sid_ptr->authority[i] = group_sid_ptr->authority[i]; ngroup_sid_ptr->authority[i] = group_sid_ptr->authority[i];
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
ngroup_sid_ptr->sub_auth[i] = ngroup_sid_ptr->sub_auth[i] = group_sid_ptr->sub_auth[i];
cpu_to_le32(group_sid_ptr->sub_auth[i]);
return; return;
} }
@ -285,7 +284,7 @@ static __u16 fill_ace_for_sid(struct cifs_ace *pntace,
size = 1 + 1 + 2 + 4 + 1 + 1 + 6 + (psid->num_subauth * 4); size = 1 + 1 + 2 + 4 + 1 + 1 + 6 + (psid->num_subauth * 4);
pntace->size = cpu_to_le16(size); pntace->size = cpu_to_le16(size);
return (size); return size;
} }
@ -426,7 +425,7 @@ static int set_chmod_dacl(struct cifs_acl *pndacl, struct cifs_sid *pownersid,
pndacl->size = cpu_to_le16(size + sizeof(struct cifs_acl)); pndacl->size = cpu_to_le16(size + sizeof(struct cifs_acl));
pndacl->num_aces = cpu_to_le32(3); pndacl->num_aces = cpu_to_le32(3);
return (0); return 0;
} }
@ -510,7 +509,7 @@ static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len,
sizeof(struct cifs_sid)); */ sizeof(struct cifs_sid)); */
return (0); return 0;
} }
@ -527,7 +526,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd,
struct cifs_acl *ndacl_ptr = NULL; /* no need for SACL ptr */ struct cifs_acl *ndacl_ptr = NULL; /* no need for SACL ptr */
if ((inode == NULL) || (pntsd == NULL) || (pnntsd == NULL)) if ((inode == NULL) || (pntsd == NULL) || (pnntsd == NULL))
return (-EIO); return -EIO;
owner_sid_ptr = (struct cifs_sid *)((char *)pntsd + owner_sid_ptr = (struct cifs_sid *)((char *)pntsd +
le32_to_cpu(pntsd->osidoffset)); le32_to_cpu(pntsd->osidoffset));
@ -550,7 +549,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd,
/* copy security descriptor control portion and owner and group sid */ /* copy security descriptor control portion and owner and group sid */
copy_sec_desc(pntsd, pnntsd, sidsoffset); copy_sec_desc(pntsd, pnntsd, sidsoffset);
return (rc); return rc;
} }
@ -629,11 +628,11 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inode->i_mode)); cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inode->i_mode));
if (!inode) if (!inode)
return (rc); return rc;
sb = inode->i_sb; sb = inode->i_sb;
if (sb == NULL) if (sb == NULL)
return (rc); return rc;
cifs_sb = CIFS_SB(sb); cifs_sb = CIFS_SB(sb);
xid = GetXid(); xid = GetXid();
@ -652,7 +651,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
if (rc != 0) { if (rc != 0) {
cERROR(1, ("Unable to open file to set ACL")); cERROR(1, ("Unable to open file to set ACL"));
FreeXid(xid); FreeXid(xid);
return (rc); return rc;
} }
} }
@ -665,7 +664,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
FreeXid(xid); FreeXid(xid);
return (rc); return rc;
} }
/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ /* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */
@ -715,7 +714,7 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode)
if (!pnntsd) { if (!pnntsd) {
cERROR(1, ("Unable to allocate security descriptor")); cERROR(1, ("Unable to allocate security descriptor"));
kfree(pntsd); kfree(pntsd);
return (-ENOMEM); return -ENOMEM;
} }
rc = build_sec_desc(pntsd, pnntsd, inode, nmode); rc = build_sec_desc(pntsd, pnntsd, inode, nmode);
@ -732,6 +731,6 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode)
kfree(pntsd); kfree(pntsd);
} }
return (rc); return rc;
} }
#endif /* CONFIG_CIFS_EXPERIMENTAL */ #endif /* CONFIG_CIFS_EXPERIMENTAL */

View file

@ -310,9 +310,8 @@ void calc_lanman_hash(struct cifsSesInfo *ses, char *lnm_session_key)
utf8 and other multibyte codepages each need their own strupper utf8 and other multibyte codepages each need their own strupper
function since a byte at a time will ont work. */ function since a byte at a time will ont work. */
for (i = 0; i < CIFS_ENCPWD_SIZE; i++) { for (i = 0; i < CIFS_ENCPWD_SIZE; i++)
password_with_pad[i] = toupper(password_with_pad[i]); password_with_pad[i] = toupper(password_with_pad[i]);
}
SMBencrypt(password_with_pad, ses->server->cryptKey, lnm_session_key); SMBencrypt(password_with_pad, ses->server->cryptKey, lnm_session_key);
/* clear password before we return/free memory */ /* clear password before we return/free memory */

View file

@ -27,7 +27,7 @@
#define MAX_SES_INFO 2 #define MAX_SES_INFO 2
#define MAX_TCON_INFO 4 #define MAX_TCON_INFO 4
#define MAX_TREE_SIZE 2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1 #define MAX_TREE_SIZE (2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1)
#define MAX_SERVER_SIZE 15 #define MAX_SERVER_SIZE 15
#define MAX_SHARE_SIZE 64 /* used to be 20, this should still be enough */ #define MAX_SHARE_SIZE 64 /* used to be 20, this should still be enough */
#define MAX_USERNAME_SIZE 32 /* 32 is to allow for 15 char names + null #define MAX_USERNAME_SIZE 32 /* 32 is to allow for 15 char names + null
@ -537,8 +537,8 @@ require use of the stronger protocol */
#endif /* WEAK_PW_HASH */ #endif /* WEAK_PW_HASH */
#define CIFSSEC_MUST_SEAL 0x40040 /* not supported yet */ #define CIFSSEC_MUST_SEAL 0x40040 /* not supported yet */
#define CIFSSEC_DEF CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 #define CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)
#define CIFSSEC_MAX CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2 #define CIFSSEC_MAX (CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2)
#define CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5) #define CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5)
/* /*
***************************************************************** *****************************************************************

View file

@ -31,7 +31,7 @@
#else #else
#define CIFS_PROT 0 #define CIFS_PROT 0
#endif #endif
#define POSIX_PROT CIFS_PROT+1 #define POSIX_PROT (CIFS_PROT+1)
#define BAD_PROT 0xFFFF #define BAD_PROT 0xFFFF
/* SMB command codes */ /* SMB command codes */
@ -341,7 +341,7 @@
#define CREATE_COMPLETE_IF_OPLK 0x00000100 /* should be zero */ #define CREATE_COMPLETE_IF_OPLK 0x00000100 /* should be zero */
#define CREATE_NO_EA_KNOWLEDGE 0x00000200 #define CREATE_NO_EA_KNOWLEDGE 0x00000200
#define CREATE_EIGHT_DOT_THREE 0x00000400 /* doc says this is obsolete #define CREATE_EIGHT_DOT_THREE 0x00000400 /* doc says this is obsolete
"open for recovery" flag - should "open for recovery" flag should
be zero in any case */ be zero in any case */
#define CREATE_OPEN_FOR_RECOVERY 0x00000400 #define CREATE_OPEN_FOR_RECOVERY 0x00000400
#define CREATE_RANDOM_ACCESS 0x00000800 #define CREATE_RANDOM_ACCESS 0x00000800
@ -414,8 +414,8 @@ struct smb_hdr {
__u8 WordCount; __u8 WordCount;
} __attribute__((packed)); } __attribute__((packed));
/* given a pointer to an smb_hdr retrieve the value of byte count */ /* given a pointer to an smb_hdr retrieve the value of byte count */
#define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount))) #define BCC(smb_var) (*(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount)))
#define BCC_LE(smb_var) ( *(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount))) #define BCC_LE(smb_var) (*(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount)))
/* given a pointer to an smb_hdr retrieve the pointer to the byte area */ /* given a pointer to an smb_hdr retrieve the pointer to the byte area */
#define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount) + 2) #define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount) + 2)

View file

@ -686,11 +686,10 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
SecurityBlob, SecurityBlob,
count - 16, count - 16,
&server->secType); &server->secType);
if (rc == 1) { if (rc == 1)
rc = 0; rc = 0;
} else { else
rc = -EINVAL; rc = -EINVAL;
}
} }
} else } else
server->capabilities &= ~CAP_EXTENDED_SECURITY; server->capabilities &= ~CAP_EXTENDED_SECURITY;
@ -3914,7 +3913,10 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
bool is_unicode; bool is_unicode;
struct dfs_referral_level_3 *ref; struct dfs_referral_level_3 *ref;
is_unicode = pSMBr->hdr.Flags2 & SMBFLG2_UNICODE; if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
is_unicode = true;
else
is_unicode = false;
*num_of_nodes = le16_to_cpu(pSMBr->NumberOfReferrals); *num_of_nodes = le16_to_cpu(pSMBr->NumberOfReferrals);
if (*num_of_nodes < 1) { if (*num_of_nodes < 1) {

View file

@ -455,7 +455,7 @@ incomplete_rcv:
/* Note that FC 1001 length is big endian on the wire, /* Note that FC 1001 length is big endian on the wire,
but we convert it here so it is always manipulated but we convert it here so it is always manipulated
as host byte order */ as host byte order */
pdu_length = ntohl(smb_buffer->smb_buf_length); pdu_length = be32_to_cpu((__force __be32)smb_buffer->smb_buf_length);
smb_buffer->smb_buf_length = pdu_length; smb_buffer->smb_buf_length = pdu_length;
cFYI(1, ("rfc1002 length 0x%x", pdu_length+4)); cFYI(1, ("rfc1002 length 0x%x", pdu_length+4));
@ -1461,6 +1461,39 @@ get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, const char *old_path,
return rc; return rc;
} }
#ifdef CONFIG_DEBUG_LOCK_ALLOC
static struct lock_class_key cifs_key[2];
static struct lock_class_key cifs_slock_key[2];
static inline void
cifs_reclassify_socket4(struct socket *sock)
{
struct sock *sk = sock->sk;
BUG_ON(sock_owned_by_user(sk));
sock_lock_init_class_and_name(sk, "slock-AF_INET-CIFS",
&cifs_slock_key[0], "sk_lock-AF_INET-CIFS", &cifs_key[0]);
}
static inline void
cifs_reclassify_socket6(struct socket *sock)
{
struct sock *sk = sock->sk;
BUG_ON(sock_owned_by_user(sk));
sock_lock_init_class_and_name(sk, "slock-AF_INET6-CIFS",
&cifs_slock_key[1], "sk_lock-AF_INET6-CIFS", &cifs_key[1]);
}
#else
static inline void
cifs_reclassify_socket4(struct socket *sock)
{
}
static inline void
cifs_reclassify_socket6(struct socket *sock)
{
}
#endif
/* See RFC1001 section 14 on representation of Netbios names */ /* See RFC1001 section 14 on representation of Netbios names */
static void rfc1002mangle(char *target, char *source, unsigned int length) static void rfc1002mangle(char *target, char *source, unsigned int length)
{ {
@ -1495,6 +1528,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket,
/* BB other socket options to set KEEPALIVE, NODELAY? */ /* BB other socket options to set KEEPALIVE, NODELAY? */
cFYI(1, ("Socket created")); cFYI(1, ("Socket created"));
(*csocket)->sk->sk_allocation = GFP_NOFS; (*csocket)->sk->sk_allocation = GFP_NOFS;
cifs_reclassify_socket4(*csocket);
} }
} }
@ -1627,6 +1661,7 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket)
/* BB other socket options to set KEEPALIVE, NODELAY? */ /* BB other socket options to set KEEPALIVE, NODELAY? */
cFYI(1, ("ipv6 Socket created")); cFYI(1, ("ipv6 Socket created"));
(*csocket)->sk->sk_allocation = GFP_NOFS; (*csocket)->sk->sk_allocation = GFP_NOFS;
cifs_reclassify_socket6(*csocket);
} }
} }

View file

@ -1413,6 +1413,82 @@ out_busy:
return -ETXTBSY; return -ETXTBSY;
} }
static int
cifs_set_file_size(struct inode *inode, struct iattr *attrs,
int xid, char *full_path)
{
int rc;
struct cifsFileInfo *open_file;
struct cifsInodeInfo *cifsInode = CIFS_I(inode);
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
struct cifsTconInfo *pTcon = cifs_sb->tcon;
/*
* To avoid spurious oplock breaks from server, in the case of
* inodes that we already have open, avoid doing path based
* setting of file size if we can do it by handle.
* This keeps our caching token (oplock) and avoids timeouts
* when the local oplock break takes longer to flush
* writebehind data than the SMB timeout for the SetPathInfo
* request would allow
*/
open_file = find_writable_file(cifsInode);
if (open_file) {
__u16 nfid = open_file->netfid;
__u32 npid = open_file->pid;
rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, nfid,
npid, false);
atomic_dec(&open_file->wrtPending);
cFYI(1, ("SetFSize for attrs rc = %d", rc));
if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
unsigned int bytes_written;
rc = CIFSSMBWrite(xid, pTcon, nfid, 0, attrs->ia_size,
&bytes_written, NULL, NULL, 1);
cFYI(1, ("Wrt seteof rc %d", rc));
}
} else
rc = -EINVAL;
if (rc != 0) {
/* Set file size by pathname rather than by handle
either because no valid, writeable file handle for
it was found or because there was an error setting
it by handle */
rc = CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size,
false, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc));
if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
__u16 netfid;
int oplock = 0;
rc = SMBLegacyOpen(xid, pTcon, full_path,
FILE_OPEN, GENERIC_WRITE,
CREATE_NOT_DIR, &netfid, &oplock, NULL,
cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc == 0) {
unsigned int bytes_written;
rc = CIFSSMBWrite(xid, pTcon, netfid, 0,
attrs->ia_size,
&bytes_written, NULL,
NULL, 1);
cFYI(1, ("wrt seteof rc %d", rc));
CIFSSMBClose(xid, pTcon, netfid);
}
}
}
if (rc == 0) {
rc = cifs_vmtruncate(inode, attrs->ia_size);
cifs_truncate_page(inode->i_mapping, inode->i_size);
}
return rc;
}
int cifs_setattr(struct dentry *direntry, struct iattr *attrs) int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
{ {
int xid; int xid;
@ -1420,7 +1496,6 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
struct cifsTconInfo *pTcon; struct cifsTconInfo *pTcon;
char *full_path = NULL; char *full_path = NULL;
int rc = -EACCES; int rc = -EACCES;
struct cifsFileInfo *open_file = NULL;
FILE_BASIC_INFO time_buf; FILE_BASIC_INFO time_buf;
bool set_time = false; bool set_time = false;
bool set_dosattr = false; bool set_dosattr = false;
@ -1472,78 +1547,8 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
} }
if (attrs->ia_valid & ATTR_SIZE) { if (attrs->ia_valid & ATTR_SIZE) {
/* To avoid spurious oplock breaks from server, in the case of rc = cifs_set_file_size(inode, attrs, xid, full_path);
inodes that we already have open, avoid doing path based if (rc != 0)
setting of file size if we can do it by handle.
This keeps our caching token (oplock) and avoids timeouts
when the local oplock break takes longer to flush
writebehind data than the SMB timeout for the SetPathInfo
request would allow */
open_file = find_writable_file(cifsInode);
if (open_file) {
__u16 nfid = open_file->netfid;
__u32 npid = open_file->pid;
rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size,
nfid, npid, false);
atomic_dec(&open_file->wrtPending);
cFYI(1, ("SetFSize for attrs rc = %d", rc));
if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
unsigned int bytes_written;
rc = CIFSSMBWrite(xid, pTcon,
nfid, 0, attrs->ia_size,
&bytes_written, NULL, NULL,
1 /* 45 seconds */);
cFYI(1, ("Wrt seteof rc %d", rc));
}
} else
rc = -EINVAL;
if (rc != 0) {
/* Set file size by pathname rather than by handle
either because no valid, writeable file handle for
it was found or because there was an error setting
it by handle */
rc = CIFSSMBSetEOF(xid, pTcon, full_path,
attrs->ia_size, false,
cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc));
if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
__u16 netfid;
int oplock = 0;
rc = SMBLegacyOpen(xid, pTcon, full_path,
FILE_OPEN, GENERIC_WRITE,
CREATE_NOT_DIR, &netfid, &oplock,
NULL, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc == 0) {
unsigned int bytes_written;
rc = CIFSSMBWrite(xid, pTcon,
netfid, 0,
attrs->ia_size,
&bytes_written, NULL,
NULL, 1 /* 45 sec */);
cFYI(1, ("wrt seteof rc %d", rc));
CIFSSMBClose(xid, pTcon, netfid);
}
}
}
/* Server is ok setting allocation size implicitly - no need
to call:
CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size, true,
cifs_sb->local_nls);
*/
if (rc == 0) {
rc = cifs_vmtruncate(inode, attrs->ia_size);
cifs_truncate_page(inode->i_mapping, inode->i_size);
} else
goto cifs_setattr_exit; goto cifs_setattr_exit;
} }

View file

@ -690,6 +690,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
else else
cifs_buf_release(cifsFile->srch_inf. cifs_buf_release(cifsFile->srch_inf.
ntwrk_buf_start); ntwrk_buf_start);
cifsFile->srch_inf.ntwrk_buf_start = NULL;
} }
rc = initiate_cifs_search(xid, file); rc = initiate_cifs_search(xid, file);
if (rc) { if (rc) {