From b7a10626c8bc88fd097a8bb4486c89558f89320c Mon Sep 17 00:00:00 2001 From: Steve French Date: Sun, 7 Oct 2012 20:00:47 -0500 Subject: [CIFS] WARN_ON_ONCE if kernel_sendmsg() returns -ENOSPC kernel_sendmsg() is less likely to return -ENOSPC and it might be a bug to do so. However, in the past there might have been cases where a -ENOSPC was returned from a low level driver. Add a WARN_ON_ONCE() to ensure that it is safe to assume that -ENOSPC is no longer returned. This -ENOSPC specific handling will be removed once we are sure it is no longer returned. Reviewed-by: Jeff Layton Signed-off-by: Suresh Jayaraman Signed-off-by: Steve French --- fs/cifs/transport.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'fs/cifs') diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 2126ab185045..76d974c952fe 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -183,6 +183,12 @@ smb_send_kvec(struct TCP_Server_Info *server, struct kvec *iov, size_t n_vec, rc = kernel_sendmsg(ssocket, &smb_msg, &iov[first_vec], n_vec - first_vec, remaining); if (rc == -ENOSPC || rc == -EAGAIN) { + /* + * Catch if a low level driver returns -ENOSPC. This + * WARN_ON will be removed by 3.10 if no one reports + * seeing this. + */ + WARN_ON_ONCE(rc == -ENOSPC); i++; if (i >= 14 || (!server->noblocksnd && (i > 2))) { cERROR(1, "sends on sock %p stuck for 15 " -- cgit v1.2.3 From fd3ba42c76d3d4b776120c2b24c1791e7bb3deb1 Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Tue, 7 Aug 2012 04:33:03 -0500 Subject: Convert properly UTF-8 to UTF-16 wchar_t is currently 16bit so converting a utf8 encoded characters not in plane 0 (>= 0x10000) to wchar_t (that is calling char2uni) lead to a -EINVAL return. This patch detect utf8 in cifs_strtoUTF16 and add special code calling utf8s_to_utf16s. Signed-off-by: Frediano Ziglio Acked-by: Jeff Layton Signed-off-by: Steve French --- fs/cifs/cifs_unicode.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'fs/cifs') diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c index 53cf2aabce87..71d5d0a5f6b2 100644 --- a/fs/cifs/cifs_unicode.c +++ b/fs/cifs/cifs_unicode.c @@ -203,6 +203,27 @@ cifs_strtoUTF16(__le16 *to, const char *from, int len, int i; wchar_t wchar_to; /* needed to quiet sparse */ + /* special case for utf8 to handle no plane0 chars */ + if (!strcmp(codepage->charset, "utf8")) { + /* + * convert utf8 -> utf16, we assume we have enough space + * as caller should have assumed conversion does not overflow + * in destination len is length in wchar_t units (16bits) + */ + i = utf8s_to_utf16s(from, len, UTF16_LITTLE_ENDIAN, + (wchar_t *) to, len); + + /* if success terminate and exit */ + if (i >= 0) + goto success; + /* + * if fails fall back to UCS encoding as this + * function should not return negative values + * currently can fail only if source contains + * invalid encoded characters + */ + } + for (i = 0; len && *from; i++, from += charlen, len -= charlen) { charlen = codepage->char2uni(from, len, &wchar_to); if (charlen < 1) { @@ -215,6 +236,7 @@ cifs_strtoUTF16(__le16 *to, const char *from, int len, put_unaligned_le16(wchar_to, &to[i]); } +success: put_unaligned_le16(0, &to[i]); return i; } -- cgit v1.2.3 From 72bd481f860f0125c810bb43d878ce5f9c060c58 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Wed, 3 Oct 2012 16:02:36 -0400 Subject: cifs: reinstate the forcegid option Apparently this was lost when we converted to the standard option parser in 8830d7e07a5e38bc47650a7554b7c1cfd49902bf Cc: Sachin Prabhu Cc: stable@vger.kernel.org # v3.4+ Reported-by: Gregory Lee Bartholomew Signed-off-by: Jeff Layton Signed-off-by: Steve French --- fs/cifs/connect.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'fs/cifs') diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 2fdbe08a7a23..5c670b998ffb 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -67,6 +67,7 @@ enum { /* Mount options that take no arguments */ Opt_user_xattr, Opt_nouser_xattr, Opt_forceuid, Opt_noforceuid, + Opt_forcegid, Opt_noforcegid, Opt_noblocksend, Opt_noautotune, Opt_hard, Opt_soft, Opt_perm, Opt_noperm, Opt_mapchars, Opt_nomapchars, Opt_sfu, @@ -117,6 +118,8 @@ static const match_table_t cifs_mount_option_tokens = { { Opt_nouser_xattr, "nouser_xattr" }, { Opt_forceuid, "forceuid" }, { Opt_noforceuid, "noforceuid" }, + { Opt_forcegid, "forcegid" }, + { Opt_noforcegid, "noforcegid" }, { Opt_noblocksend, "noblocksend" }, { Opt_noautotune, "noautotune" }, { Opt_hard, "hard" }, @@ -1195,6 +1198,12 @@ cifs_parse_mount_options(const char *mountdata, const char *devname, case Opt_noforceuid: override_uid = 0; break; + case Opt_forcegid: + override_gid = 1; + break; + case Opt_noforcegid: + override_gid = 0; + break; case Opt_noblocksend: vol->noblocksnd = 1; break; -- cgit v1.2.3