Commit f242e285 authored by Pavel Shilovsky's avatar Pavel Shilovsky

Bugfixes for 2.6.38

Fix memory over bound bug in cifs_parse_mount_options + stable updates
parent 0f70d52c
...@@ -30,12 +30,13 @@ ...@@ -30,12 +30,13 @@
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/random.h> #include <linux/random.h>
/* Calculate and return the CIFS signature based on the mac key and SMB PDU */ /*
/* the 16 byte signature must be allocated by the caller */ * Calculate and return the CIFS signature based on the mac key and SMB PDU.
/* Note we only use the 1st eight bytes */ * The 16 byte signature must be allocated by the caller. Note we only use the
/* Note that the smb header signature field on input contains the * 1st eight bytes and that the smb header signature field on input contains
sequence number before this function is called */ * the sequence number before this function is called. Also, this function
* should be called with the server->srv_mutex held.
*/
static int cifs_calculate_signature(const struct smb_hdr *cifs_pdu, static int cifs_calculate_signature(const struct smb_hdr *cifs_pdu,
struct TCP_Server_Info *server, char *signature) struct TCP_Server_Info *server, char *signature)
{ {
...@@ -209,8 +210,10 @@ int cifs_verify_signature(struct smb_hdr *cifs_pdu, ...@@ -209,8 +210,10 @@ int cifs_verify_signature(struct smb_hdr *cifs_pdu,
cpu_to_le32(expected_sequence_number); cpu_to_le32(expected_sequence_number);
cifs_pdu->Signature.Sequence.Reserved = 0; cifs_pdu->Signature.Sequence.Reserved = 0;
mutex_lock(&server->srv_mutex);
rc = cifs_calculate_signature(cifs_pdu, server, rc = cifs_calculate_signature(cifs_pdu, server,
what_we_think_sig_should_be); what_we_think_sig_should_be);
mutex_unlock(&server->srv_mutex);
if (rc) if (rc)
return rc; return rc;
......
...@@ -127,6 +127,7 @@ cifs_read_super(struct super_block *sb, void *data, ...@@ -127,6 +127,7 @@ cifs_read_super(struct super_block *sb, void *data,
kfree(cifs_sb); kfree(cifs_sb);
return rc; return rc;
} }
cifs_sb->bdi.ra_pages = default_backing_dev_info.ra_pages;
#ifdef CONFIG_CIFS_DFS_UPCALL #ifdef CONFIG_CIFS_DFS_UPCALL
/* copy mount params to sb for use in submounts */ /* copy mount params to sb for use in submounts */
......
...@@ -809,8 +809,7 @@ static int ...@@ -809,8 +809,7 @@ static int
cifs_parse_mount_options(char *options, const char *devname, cifs_parse_mount_options(char *options, const char *devname,
struct smb_vol *vol) struct smb_vol *vol)
{ {
char *value; char *value, *data, *end;
char *data;
unsigned int temp_len, i, j; unsigned int temp_len, i, j;
char separator[2]; char separator[2];
short int override_uid = -1; short int override_uid = -1;
...@@ -853,6 +852,7 @@ cifs_parse_mount_options(char *options, const char *devname, ...@@ -853,6 +852,7 @@ cifs_parse_mount_options(char *options, const char *devname,
if (!options) if (!options)
return 1; return 1;
end = options + strlen(options);
if (strncmp(options, "sep=", 4) == 0) { if (strncmp(options, "sep=", 4) == 0) {
if (options[4] != 0) { if (options[4] != 0) {
separator[0] = options[4]; separator[0] = options[4];
...@@ -917,6 +917,7 @@ cifs_parse_mount_options(char *options, const char *devname, ...@@ -917,6 +917,7 @@ cifs_parse_mount_options(char *options, const char *devname,
the only illegal character in a password is null */ the only illegal character in a password is null */
if ((value[temp_len] == 0) && if ((value[temp_len] == 0) &&
(value + temp_len < end) &&
(value[temp_len+1] == separator[0])) { (value[temp_len+1] == separator[0])) {
/* reinsert comma */ /* reinsert comma */
value[temp_len] = separator[0]; value[temp_len] = separator[0];
...@@ -2833,7 +2834,7 @@ try_mount_again: ...@@ -2833,7 +2834,7 @@ try_mount_again:
remote_path_check: remote_path_check:
/* check if a whole path (including prepath) is not remote */ /* check if a whole path (including prepath) is not remote */
if (!rc && cifs_sb->prepathlen && tcon) { if (!rc && tcon) {
/* build_path_to_root works only when we have a valid tcon */ /* build_path_to_root works only when we have a valid tcon */
full_path = cifs_build_path_to_root(cifs_sb, tcon); full_path = cifs_build_path_to_root(cifs_sb, tcon);
if (full_path == NULL) { if (full_path == NULL) {
......
...@@ -586,8 +586,10 @@ reopen_error_exit: ...@@ -586,8 +586,10 @@ reopen_error_exit:
int cifs_close(struct inode *inode, struct file *file) int cifs_close(struct inode *inode, struct file *file)
{ {
if (file->private_data != NULL) {
cifsFileInfo_put(file->private_data); cifsFileInfo_put(file->private_data);
file->private_data = NULL; file->private_data = NULL;
}
/* return code from the ->release op is always ignored */ /* return code from the ->release op is always ignored */
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment