aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/cifsfs.c14
-rw-r--r--fs/cifs/cifsfs.h2
-rw-r--r--fs/cifs/cifssmb.c30
-rw-r--r--fs/cifs/connect.c132
-rw-r--r--fs/cifs/dir.c17
-rw-r--r--fs/cifs/file.c13
-rw-r--r--fs/cifs/netmisc.c3
7 files changed, 89 insertions, 122 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index d34212822444..ca6a3796a33b 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -370,13 +370,13 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
370 (int)(srcaddr->sa_family)); 370 (int)(srcaddr->sa_family));
371 } 371 }
372 372
373 seq_printf(s, ",uid=%d", cifs_sb->mnt_uid); 373 seq_printf(s, ",uid=%u", cifs_sb->mnt_uid);
374 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) 374 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)
375 seq_printf(s, ",forceuid"); 375 seq_printf(s, ",forceuid");
376 else 376 else
377 seq_printf(s, ",noforceuid"); 377 seq_printf(s, ",noforceuid");
378 378
379 seq_printf(s, ",gid=%d", cifs_sb->mnt_gid); 379 seq_printf(s, ",gid=%u", cifs_sb->mnt_gid);
380 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) 380 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)
381 seq_printf(s, ",forcegid"); 381 seq_printf(s, ",forcegid");
382 else 382 else
@@ -434,11 +434,15 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
434 seq_printf(s, ",noperm"); 434 seq_printf(s, ",noperm");
435 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) 435 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO)
436 seq_printf(s, ",strictcache"); 436 seq_printf(s, ",strictcache");
437 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPUID)
438 seq_printf(s, ",backupuid=%u", cifs_sb->mnt_backupuid);
439 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPGID)
440 seq_printf(s, ",backupgid=%u", cifs_sb->mnt_backupgid);
437 441
438 seq_printf(s, ",rsize=%d", cifs_sb->rsize); 442 seq_printf(s, ",rsize=%u", cifs_sb->rsize);
439 seq_printf(s, ",wsize=%d", cifs_sb->wsize); 443 seq_printf(s, ",wsize=%u", cifs_sb->wsize);
440 /* convert actimeo and display it in seconds */ 444 /* convert actimeo and display it in seconds */
441 seq_printf(s, ",actimeo=%lu", cifs_sb->actimeo / HZ); 445 seq_printf(s, ",actimeo=%lu", cifs_sb->actimeo / HZ);
442 446
443 return 0; 447 return 0;
444} 448}
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index d1389bb33ceb..65365358c976 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -125,5 +125,5 @@ extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
125extern const struct export_operations cifs_export_ops; 125extern const struct export_operations cifs_export_ops;
126#endif /* CONFIG_CIFS_NFSD_EXPORT */ 126#endif /* CONFIG_CIFS_NFSD_EXPORT */
127 127
128#define CIFS_VERSION "1.77" 128#define CIFS_VERSION "1.78"
129#endif /* _CIFSFS_H */ 129#endif /* _CIFSFS_H */
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 8fecc99be344..da2f5446fa7a 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -3892,13 +3892,12 @@ CIFSSMBSetCIFSACL(const int xid, struct cifs_tcon *tcon, __u16 fid,
3892 int rc = 0; 3892 int rc = 0;
3893 int bytes_returned = 0; 3893 int bytes_returned = 0;
3894 SET_SEC_DESC_REQ *pSMB = NULL; 3894 SET_SEC_DESC_REQ *pSMB = NULL;
3895 NTRANSACT_RSP *pSMBr = NULL; 3895 void *pSMBr;
3896 3896
3897setCifsAclRetry: 3897setCifsAclRetry:
3898 rc = smb_init(SMB_COM_NT_TRANSACT, 19, tcon, (void **) &pSMB, 3898 rc = smb_init(SMB_COM_NT_TRANSACT, 19, tcon, (void **) &pSMB, &pSMBr);
3899 (void **) &pSMBr);
3900 if (rc) 3899 if (rc)
3901 return (rc); 3900 return rc;
3902 3901
3903 pSMB->MaxSetupCount = 0; 3902 pSMB->MaxSetupCount = 0;
3904 pSMB->Reserved = 0; 3903 pSMB->Reserved = 0;
@@ -3926,9 +3925,8 @@ setCifsAclRetry:
3926 pSMB->AclFlags = cpu_to_le32(aclflag); 3925 pSMB->AclFlags = cpu_to_le32(aclflag);
3927 3926
3928 if (pntsd && acllen) { 3927 if (pntsd && acllen) {
3929 memcpy((char *) &pSMBr->hdr.Protocol + data_offset, 3928 memcpy((char *)pSMBr + offsetof(struct smb_hdr, Protocol) +
3930 (char *) pntsd, 3929 data_offset, pntsd, acllen);
3931 acllen);
3932 inc_rfc1001_len(pSMB, byte_count + data_count); 3930 inc_rfc1001_len(pSMB, byte_count + data_count);
3933 } else 3931 } else
3934 inc_rfc1001_len(pSMB, byte_count); 3932 inc_rfc1001_len(pSMB, byte_count);
@@ -4846,8 +4844,12 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
4846 max_len = data_end - temp; 4844 max_len = data_end - temp;
4847 node->node_name = cifs_strndup_from_utf16(temp, max_len, 4845 node->node_name = cifs_strndup_from_utf16(temp, max_len,
4848 is_unicode, nls_codepage); 4846 is_unicode, nls_codepage);
4849 if (!node->node_name) 4847 if (!node->node_name) {
4850 rc = -ENOMEM; 4848 rc = -ENOMEM;
4849 goto parse_DFS_referrals_exit;
4850 }
4851
4852 ref++;
4851 } 4853 }
4852 4854
4853parse_DFS_referrals_exit: 4855parse_DFS_referrals_exit:
@@ -5708,7 +5710,8 @@ CIFSSMBSetFileInfo(const int xid, struct cifs_tcon *tcon,
5708 param_offset = offsetof(struct smb_com_transaction2_sfi_req, Fid) - 4; 5710 param_offset = offsetof(struct smb_com_transaction2_sfi_req, Fid) - 4;
5709 offset = param_offset + params; 5711 offset = param_offset + params;
5710 5712
5711 data_offset = (char *) (&pSMB->hdr.Protocol) + offset; 5713 data_offset = (char *)pSMB +
5714 offsetof(struct smb_hdr, Protocol) + offset;
5712 5715
5713 count = sizeof(FILE_BASIC_INFO); 5716 count = sizeof(FILE_BASIC_INFO);
5714 pSMB->MaxParameterCount = cpu_to_le16(2); 5717 pSMB->MaxParameterCount = cpu_to_le16(2);
@@ -5977,7 +5980,7 @@ CIFSSMBUnixSetFileInfo(const int xid, struct cifs_tcon *tcon,
5977 u16 fid, u32 pid_of_opener) 5980 u16 fid, u32 pid_of_opener)
5978{ 5981{
5979 struct smb_com_transaction2_sfi_req *pSMB = NULL; 5982 struct smb_com_transaction2_sfi_req *pSMB = NULL;
5980 FILE_UNIX_BASIC_INFO *data_offset; 5983 char *data_offset;
5981 int rc = 0; 5984 int rc = 0;
5982 u16 params, param_offset, offset, byte_count, count; 5985 u16 params, param_offset, offset, byte_count, count;
5983 5986
@@ -5999,8 +6002,9 @@ CIFSSMBUnixSetFileInfo(const int xid, struct cifs_tcon *tcon,
5999 param_offset = offsetof(struct smb_com_transaction2_sfi_req, Fid) - 4; 6002 param_offset = offsetof(struct smb_com_transaction2_sfi_req, Fid) - 4;
6000 offset = param_offset + params; 6003 offset = param_offset + params;
6001 6004
6002 data_offset = (FILE_UNIX_BASIC_INFO *) 6005 data_offset = (char *)pSMB +
6003 ((char *)(&pSMB->hdr.Protocol) + offset); 6006 offsetof(struct smb_hdr, Protocol) + offset;
6007
6004 count = sizeof(FILE_UNIX_BASIC_INFO); 6008 count = sizeof(FILE_UNIX_BASIC_INFO);
6005 6009
6006 pSMB->MaxParameterCount = cpu_to_le16(2); 6010 pSMB->MaxParameterCount = cpu_to_le16(2);
@@ -6022,7 +6026,7 @@ CIFSSMBUnixSetFileInfo(const int xid, struct cifs_tcon *tcon,
6022 inc_rfc1001_len(pSMB, byte_count); 6026 inc_rfc1001_len(pSMB, byte_count);
6023 pSMB->ByteCount = cpu_to_le16(byte_count); 6027 pSMB->ByteCount = cpu_to_le16(byte_count);
6024 6028
6025 cifs_fill_unix_set_info(data_offset, args); 6029 cifs_fill_unix_set_info((FILE_UNIX_BASIC_INFO *)data_offset, args);
6026 6030
6027 rc = SendReceiveNoRsp(xid, tcon->ses, (char *) pSMB, 0); 6031 rc = SendReceiveNoRsp(xid, tcon->ses, (char *) pSMB, 0);
6028 if (rc) 6032 if (rc)
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 302a15c505a9..5dcc55197fb3 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -109,6 +109,8 @@ enum {
109 109
110 /* Options which could be blank */ 110 /* Options which could be blank */
111 Opt_blank_pass, 111 Opt_blank_pass,
112 Opt_blank_user,
113 Opt_blank_ip,
112 114
113 Opt_err 115 Opt_err
114}; 116};
@@ -183,11 +185,15 @@ static const match_table_t cifs_mount_option_tokens = {
183 { Opt_wsize, "wsize=%s" }, 185 { Opt_wsize, "wsize=%s" },
184 { Opt_actimeo, "actimeo=%s" }, 186 { Opt_actimeo, "actimeo=%s" },
185 187
188 { Opt_blank_user, "user=" },
189 { Opt_blank_user, "username=" },
186 { Opt_user, "user=%s" }, 190 { Opt_user, "user=%s" },
187 { Opt_user, "username=%s" }, 191 { Opt_user, "username=%s" },
188 { Opt_blank_pass, "pass=" }, 192 { Opt_blank_pass, "pass=" },
189 { Opt_pass, "pass=%s" }, 193 { Opt_pass, "pass=%s" },
190 { Opt_pass, "password=%s" }, 194 { Opt_pass, "password=%s" },
195 { Opt_blank_ip, "ip=" },
196 { Opt_blank_ip, "addr=" },
191 { Opt_ip, "ip=%s" }, 197 { Opt_ip, "ip=%s" },
192 { Opt_ip, "addr=%s" }, 198 { Opt_ip, "addr=%s" },
193 { Opt_unc, "unc=%s" }, 199 { Opt_unc, "unc=%s" },
@@ -209,6 +215,8 @@ static const match_table_t cifs_mount_option_tokens = {
209 215
210 { Opt_ignore, "cred" }, 216 { Opt_ignore, "cred" },
211 { Opt_ignore, "credentials" }, 217 { Opt_ignore, "credentials" },
218 { Opt_ignore, "cred=%s" },
219 { Opt_ignore, "credentials=%s" },
212 { Opt_ignore, "guest" }, 220 { Opt_ignore, "guest" },
213 { Opt_ignore, "rw" }, 221 { Opt_ignore, "rw" },
214 { Opt_ignore, "ro" }, 222 { Opt_ignore, "ro" },
@@ -1117,7 +1125,7 @@ static int get_option_ul(substring_t args[], unsigned long *option)
1117 string = match_strdup(args); 1125 string = match_strdup(args);
1118 if (string == NULL) 1126 if (string == NULL)
1119 return -ENOMEM; 1127 return -ENOMEM;
1120 rc = kstrtoul(string, 10, option); 1128 rc = kstrtoul(string, 0, option);
1121 kfree(string); 1129 kfree(string);
1122 1130
1123 return rc; 1131 return rc;
@@ -1534,15 +1542,17 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1534 1542
1535 /* String Arguments */ 1543 /* String Arguments */
1536 1544
1545 case Opt_blank_user:
1546 /* null user, ie. anonymous authentication */
1547 vol->nullauth = 1;
1548 vol->username = NULL;
1549 break;
1537 case Opt_user: 1550 case Opt_user:
1538 string = match_strdup(args); 1551 string = match_strdup(args);
1539 if (string == NULL) 1552 if (string == NULL)
1540 goto out_nomem; 1553 goto out_nomem;
1541 1554
1542 if (!*string) { 1555 if (strnlen(string, MAX_USERNAME_SIZE) >
1543 /* null user, ie. anonymous authentication */
1544 vol->nullauth = 1;
1545 } else if (strnlen(string, MAX_USERNAME_SIZE) >
1546 MAX_USERNAME_SIZE) { 1556 MAX_USERNAME_SIZE) {
1547 printk(KERN_WARNING "CIFS: username too long\n"); 1557 printk(KERN_WARNING "CIFS: username too long\n");
1548 goto cifs_parse_mount_err; 1558 goto cifs_parse_mount_err;
@@ -1565,8 +1575,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1565 1575
1566 /* Obtain the value string */ 1576 /* Obtain the value string */
1567 value = strchr(data, '='); 1577 value = strchr(data, '=');
1568 if (value != NULL) 1578 value++;
1569 *value++ = '\0';
1570 1579
1571 /* Set tmp_end to end of the string */ 1580 /* Set tmp_end to end of the string */
1572 tmp_end = (char *) value + strlen(value); 1581 tmp_end = (char *) value + strlen(value);
@@ -1612,14 +1621,15 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1612 } 1621 }
1613 vol->password[j] = '\0'; 1622 vol->password[j] = '\0';
1614 break; 1623 break;
1624 case Opt_blank_ip:
1625 vol->UNCip = NULL;
1626 break;
1615 case Opt_ip: 1627 case Opt_ip:
1616 string = match_strdup(args); 1628 string = match_strdup(args);
1617 if (string == NULL) 1629 if (string == NULL)
1618 goto out_nomem; 1630 goto out_nomem;
1619 1631
1620 if (!*string) { 1632 if (strnlen(string, INET6_ADDRSTRLEN) >
1621 vol->UNCip = NULL;
1622 } else if (strnlen(string, INET6_ADDRSTRLEN) >
1623 INET6_ADDRSTRLEN) { 1633 INET6_ADDRSTRLEN) {
1624 printk(KERN_WARNING "CIFS: ip address " 1634 printk(KERN_WARNING "CIFS: ip address "
1625 "too long\n"); 1635 "too long\n");
@@ -1637,18 +1647,19 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1637 if (string == NULL) 1647 if (string == NULL)
1638 goto out_nomem; 1648 goto out_nomem;
1639 1649
1640 if (!*string) {
1641 printk(KERN_WARNING "CIFS: invalid path to "
1642 "network resource\n");
1643 goto cifs_parse_mount_err;
1644 }
1645
1646 temp_len = strnlen(string, 300); 1650 temp_len = strnlen(string, 300);
1647 if (temp_len == 300) { 1651 if (temp_len == 300) {
1648 printk(KERN_WARNING "CIFS: UNC name too long\n"); 1652 printk(KERN_WARNING "CIFS: UNC name too long\n");
1649 goto cifs_parse_mount_err; 1653 goto cifs_parse_mount_err;
1650 } 1654 }
1651 1655
1656 vol->UNC = kmalloc(temp_len+1, GFP_KERNEL);
1657 if (vol->UNC == NULL) {
1658 printk(KERN_WARNING "CIFS: no memory for UNC\n");
1659 goto cifs_parse_mount_err;
1660 }
1661 strcpy(vol->UNC, string);
1662
1652 if (strncmp(string, "//", 2) == 0) { 1663 if (strncmp(string, "//", 2) == 0) {
1653 vol->UNC[0] = '\\'; 1664 vol->UNC[0] = '\\';
1654 vol->UNC[1] = '\\'; 1665 vol->UNC[1] = '\\';
@@ -1658,24 +1669,13 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1658 goto cifs_parse_mount_err; 1669 goto cifs_parse_mount_err;
1659 } 1670 }
1660 1671
1661 vol->UNC = kmalloc(temp_len+1, GFP_KERNEL);
1662 if (vol->UNC == NULL) {
1663 printk(KERN_WARNING "CIFS: no memory "
1664 "for UNC\n");
1665 goto cifs_parse_mount_err;
1666 }
1667 strcpy(vol->UNC, string);
1668 break; 1672 break;
1669 case Opt_domain: 1673 case Opt_domain:
1670 string = match_strdup(args); 1674 string = match_strdup(args);
1671 if (string == NULL) 1675 if (string == NULL)
1672 goto out_nomem; 1676 goto out_nomem;
1673 1677
1674 if (!*string) { 1678 if (strnlen(string, 256) == 256) {
1675 printk(KERN_WARNING "CIFS: invalid domain"
1676 " name\n");
1677 goto cifs_parse_mount_err;
1678 } else if (strnlen(string, 256) == 256) {
1679 printk(KERN_WARNING "CIFS: domain name too" 1679 printk(KERN_WARNING "CIFS: domain name too"
1680 " long\n"); 1680 " long\n");
1681 goto cifs_parse_mount_err; 1681 goto cifs_parse_mount_err;
@@ -1694,11 +1694,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1694 if (string == NULL) 1694 if (string == NULL)
1695 goto out_nomem; 1695 goto out_nomem;
1696 1696
1697 if (!*string) { 1697 if (!cifs_convert_address(
1698 printk(KERN_WARNING "CIFS: srcaddr value not"
1699 " specified\n");
1700 goto cifs_parse_mount_err;
1701 } else if (!cifs_convert_address(
1702 (struct sockaddr *)&vol->srcaddr, 1698 (struct sockaddr *)&vol->srcaddr,
1703 string, strlen(string))) { 1699 string, strlen(string))) {
1704 printk(KERN_WARNING "CIFS: Could not parse" 1700 printk(KERN_WARNING "CIFS: Could not parse"
@@ -1711,11 +1707,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1711 if (string == NULL) 1707 if (string == NULL)
1712 goto out_nomem; 1708 goto out_nomem;
1713 1709
1714 if (!*string) {
1715 printk(KERN_WARNING "CIFS: Invalid path"
1716 " prefix\n");
1717 goto cifs_parse_mount_err;
1718 }
1719 temp_len = strnlen(string, 1024); 1710 temp_len = strnlen(string, 1024);
1720 if (string[0] != '/') 1711 if (string[0] != '/')
1721 temp_len++; /* missing leading slash */ 1712 temp_len++; /* missing leading slash */
@@ -1743,11 +1734,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1743 if (string == NULL) 1734 if (string == NULL)
1744 goto out_nomem; 1735 goto out_nomem;
1745 1736
1746 if (!*string) { 1737 if (strnlen(string, 1024) >= 65) {
1747 printk(KERN_WARNING "CIFS: Invalid iocharset"
1748 " specified\n");
1749 goto cifs_parse_mount_err;
1750 } else if (strnlen(string, 1024) >= 65) {
1751 printk(KERN_WARNING "CIFS: iocharset name " 1738 printk(KERN_WARNING "CIFS: iocharset name "
1752 "too long.\n"); 1739 "too long.\n");
1753 goto cifs_parse_mount_err; 1740 goto cifs_parse_mount_err;
@@ -1772,11 +1759,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1772 if (string == NULL) 1759 if (string == NULL)
1773 goto out_nomem; 1760 goto out_nomem;
1774 1761
1775 if (!*string) {
1776 printk(KERN_WARNING "CIFS: No socket option"
1777 " specified\n");
1778 goto cifs_parse_mount_err;
1779 }
1780 if (strnicmp(string, "TCP_NODELAY", 11) == 0) 1762 if (strnicmp(string, "TCP_NODELAY", 11) == 0)
1781 vol->sockopt_tcp_nodelay = 1; 1763 vol->sockopt_tcp_nodelay = 1;
1782 break; 1764 break;
@@ -1785,12 +1767,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1785 if (string == NULL) 1767 if (string == NULL)
1786 goto out_nomem; 1768 goto out_nomem;
1787 1769
1788 if (!*string) {
1789 printk(KERN_WARNING "CIFS: Invalid (empty)"
1790 " netbiosname\n");
1791 break;
1792 }
1793
1794 memset(vol->source_rfc1001_name, 0x20, 1770 memset(vol->source_rfc1001_name, 0x20,
1795 RFC1001_NAME_LEN); 1771 RFC1001_NAME_LEN);
1796 /* 1772 /*
@@ -1818,11 +1794,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1818 if (string == NULL) 1794 if (string == NULL)
1819 goto out_nomem; 1795 goto out_nomem;
1820 1796
1821 if (!*string) {
1822 printk(KERN_WARNING "CIFS: Empty server"
1823 " netbiosname specified\n");
1824 break;
1825 }
1826 /* last byte, type, is 0x20 for servr type */ 1797 /* last byte, type, is 0x20 for servr type */
1827 memset(vol->target_rfc1001_name, 0x20, 1798 memset(vol->target_rfc1001_name, 0x20,
1828 RFC1001_NAME_LEN_WITH_NULL); 1799 RFC1001_NAME_LEN_WITH_NULL);
@@ -1849,12 +1820,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1849 if (string == NULL) 1820 if (string == NULL)
1850 goto out_nomem; 1821 goto out_nomem;
1851 1822
1852 if (!*string) {
1853 cERROR(1, "no protocol version specified"
1854 " after vers= mount option");
1855 goto cifs_parse_mount_err;
1856 }
1857
1858 if (strnicmp(string, "cifs", 4) == 0 || 1823 if (strnicmp(string, "cifs", 4) == 0 ||
1859 strnicmp(string, "1", 1) == 0) { 1824 strnicmp(string, "1", 1) == 0) {
1860 /* This is the default */ 1825 /* This is the default */
@@ -1869,12 +1834,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1869 if (string == NULL) 1834 if (string == NULL)
1870 goto out_nomem; 1835 goto out_nomem;
1871 1836
1872 if (!*string) {
1873 printk(KERN_WARNING "CIFS: no security flavor"
1874 " specified\n");
1875 break;
1876 }
1877
1878 if (cifs_parse_security_flavors(string, vol) != 0) 1837 if (cifs_parse_security_flavors(string, vol) != 0)
1879 goto cifs_parse_mount_err; 1838 goto cifs_parse_mount_err;
1880 break; 1839 break;
@@ -2226,6 +2185,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
2226 tcp_ses->session_estab = false; 2185 tcp_ses->session_estab = false;
2227 tcp_ses->sequence_number = 0; 2186 tcp_ses->sequence_number = 0;
2228 tcp_ses->lstrp = jiffies; 2187 tcp_ses->lstrp = jiffies;
2188 spin_lock_init(&tcp_ses->req_lock);
2229 INIT_LIST_HEAD(&tcp_ses->tcp_ses_list); 2189 INIT_LIST_HEAD(&tcp_ses->tcp_ses_list);
2230 INIT_LIST_HEAD(&tcp_ses->smb_ses_list); 2190 INIT_LIST_HEAD(&tcp_ses->smb_ses_list);
2231 INIT_DELAYED_WORK(&tcp_ses->echo, cifs_echo_request); 2191 INIT_DELAYED_WORK(&tcp_ses->echo, cifs_echo_request);
@@ -3271,10 +3231,6 @@ void cifs_setup_cifs_sb(struct smb_vol *pvolume_info,
3271 3231
3272 cifs_sb->mnt_uid = pvolume_info->linux_uid; 3232 cifs_sb->mnt_uid = pvolume_info->linux_uid;
3273 cifs_sb->mnt_gid = pvolume_info->linux_gid; 3233 cifs_sb->mnt_gid = pvolume_info->linux_gid;
3274 if (pvolume_info->backupuid_specified)
3275 cifs_sb->mnt_backupuid = pvolume_info->backupuid;
3276 if (pvolume_info->backupgid_specified)
3277 cifs_sb->mnt_backupgid = pvolume_info->backupgid;
3278 cifs_sb->mnt_file_mode = pvolume_info->file_mode; 3234 cifs_sb->mnt_file_mode = pvolume_info->file_mode;
3279 cifs_sb->mnt_dir_mode = pvolume_info->dir_mode; 3235 cifs_sb->mnt_dir_mode = pvolume_info->dir_mode;
3280 cFYI(1, "file mode: 0x%hx dir mode: 0x%hx", 3236 cFYI(1, "file mode: 0x%hx dir mode: 0x%hx",
@@ -3305,10 +3261,14 @@ void cifs_setup_cifs_sb(struct smb_vol *pvolume_info,
3305 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_RWPIDFORWARD; 3261 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_RWPIDFORWARD;
3306 if (pvolume_info->cifs_acl) 3262 if (pvolume_info->cifs_acl)
3307 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL; 3263 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL;
3308 if (pvolume_info->backupuid_specified) 3264 if (pvolume_info->backupuid_specified) {
3309 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_BACKUPUID; 3265 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_BACKUPUID;
3310 if (pvolume_info->backupgid_specified) 3266 cifs_sb->mnt_backupuid = pvolume_info->backupuid;
3267 }
3268 if (pvolume_info->backupgid_specified) {
3311 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_BACKUPGID; 3269 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_BACKUPGID;
3270 cifs_sb->mnt_backupgid = pvolume_info->backupgid;
3271 }
3312 if (pvolume_info->override_uid) 3272 if (pvolume_info->override_uid)
3313 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_UID; 3273 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_UID;
3314 if (pvolume_info->override_gid) 3274 if (pvolume_info->override_gid)
@@ -3657,22 +3617,6 @@ cifs_get_volume_info(char *mount_data, const char *devname)
3657 return volume_info; 3617 return volume_info;
3658} 3618}
3659 3619
3660/* make sure ra_pages is a multiple of rsize */
3661static inline unsigned int
3662cifs_ra_pages(struct cifs_sb_info *cifs_sb)
3663{
3664 unsigned int reads;
3665 unsigned int rsize_pages = cifs_sb->rsize / PAGE_CACHE_SIZE;
3666
3667 if (rsize_pages >= default_backing_dev_info.ra_pages)
3668 return default_backing_dev_info.ra_pages;
3669 else if (rsize_pages == 0)
3670 return rsize_pages;
3671
3672 reads = default_backing_dev_info.ra_pages / rsize_pages;
3673 return reads * rsize_pages;
3674}
3675
3676int 3620int
3677cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info) 3621cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info)
3678{ 3622{
@@ -3760,7 +3704,7 @@ try_mount_again:
3760 cifs_sb->rsize = cifs_negotiate_rsize(tcon, volume_info); 3704 cifs_sb->rsize = cifs_negotiate_rsize(tcon, volume_info);
3761 3705
3762 /* tune readahead according to rsize */ 3706 /* tune readahead according to rsize */
3763 cifs_sb->bdi.ra_pages = cifs_ra_pages(cifs_sb); 3707 cifs_sb->bdi.ra_pages = cifs_sb->rsize / PAGE_CACHE_SIZE;
3764 3708
3765remote_path_check: 3709remote_path_check:
3766#ifdef CONFIG_CIFS_DFS_UPCALL 3710#ifdef CONFIG_CIFS_DFS_UPCALL
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index d172c8ed9017..ec4e9a2a12f8 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -668,12 +668,19 @@ cifs_d_revalidate(struct dentry *direntry, struct nameidata *nd)
668 return 0; 668 return 0;
669 else { 669 else {
670 /* 670 /*
671 * Forcibly invalidate automounting directory inodes 671 * If the inode wasn't known to be a dfs entry when
672 * (remote DFS directories) so to have them 672 * the dentry was instantiated, such as when created
673 * instantiated again for automount 673 * via ->readdir(), it needs to be set now since the
674 * attributes will have been updated by
675 * cifs_revalidate_dentry().
674 */ 676 */
675 if (IS_AUTOMOUNT(direntry->d_inode)) 677 if (IS_AUTOMOUNT(direntry->d_inode) &&
676 return 0; 678 !(direntry->d_flags & DCACHE_NEED_AUTOMOUNT)) {
679 spin_lock(&direntry->d_lock);
680 direntry->d_flags |= DCACHE_NEED_AUTOMOUNT;
681 spin_unlock(&direntry->d_lock);
682 }
683
677 return 1; 684 return 1;
678 } 685 }
679 } 686 }
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 460d87b7cda0..81725e9286e9 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -835,13 +835,21 @@ cifs_posix_lock_set(struct file *file, struct file_lock *flock)
835 if ((flock->fl_flags & FL_POSIX) == 0) 835 if ((flock->fl_flags & FL_POSIX) == 0)
836 return rc; 836 return rc;
837 837
838try_again:
838 mutex_lock(&cinode->lock_mutex); 839 mutex_lock(&cinode->lock_mutex);
839 if (!cinode->can_cache_brlcks) { 840 if (!cinode->can_cache_brlcks) {
840 mutex_unlock(&cinode->lock_mutex); 841 mutex_unlock(&cinode->lock_mutex);
841 return rc; 842 return rc;
842 } 843 }
843 rc = posix_lock_file_wait(file, flock); 844
845 rc = posix_lock_file(file, flock, NULL);
844 mutex_unlock(&cinode->lock_mutex); 846 mutex_unlock(&cinode->lock_mutex);
847 if (rc == FILE_LOCK_DEFERRED) {
848 rc = wait_event_interruptible(flock->fl_wait, !flock->fl_next);
849 if (!rc)
850 goto try_again;
851 locks_delete_block(flock);
852 }
845 return rc; 853 return rc;
846} 854}
847 855
@@ -2170,7 +2178,7 @@ cifs_iovec_write(struct file *file, const struct iovec *iov,
2170 unsigned long nr_pages, i; 2178 unsigned long nr_pages, i;
2171 size_t copied, len, cur_len; 2179 size_t copied, len, cur_len;
2172 ssize_t total_written = 0; 2180 ssize_t total_written = 0;
2173 loff_t offset = *poffset; 2181 loff_t offset;
2174 struct iov_iter it; 2182 struct iov_iter it;
2175 struct cifsFileInfo *open_file; 2183 struct cifsFileInfo *open_file;
2176 struct cifs_tcon *tcon; 2184 struct cifs_tcon *tcon;
@@ -2192,6 +2200,7 @@ cifs_iovec_write(struct file *file, const struct iovec *iov,
2192 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 2200 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
2193 open_file = file->private_data; 2201 open_file = file->private_data;
2194 tcon = tlink_tcon(open_file->tlink); 2202 tcon = tlink_tcon(open_file->tlink);
2203 offset = *poffset;
2195 2204
2196 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) 2205 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD)
2197 pid = open_file->pid; 2206 pid = open_file->pid;
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
index dd23a321bdda..581c225f7f50 100644
--- a/fs/cifs/netmisc.c
+++ b/fs/cifs/netmisc.c
@@ -197,8 +197,7 @@ cifs_convert_address(struct sockaddr *dst, const char *src, int len)
197 memcpy(scope_id, pct + 1, slen); 197 memcpy(scope_id, pct + 1, slen);
198 scope_id[slen] = '\0'; 198 scope_id[slen] = '\0';
199 199
200 rc = strict_strtoul(scope_id, 0, 200 rc = kstrtouint(scope_id, 0, &s6->sin6_scope_id);
201 (unsigned long *)&s6->sin6_scope_id);
202 rc = (rc == 0) ? 1 : 0; 201 rc = (rc == 0) ? 1 : 0;
203 } 202 }
204 203