All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Cc: dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 5/5] cifs: handle errors from coalesce_t2
Date: Tue, 26 Apr 2011 08:03:21 -0400	[thread overview]
Message-ID: <1303819401-14789-6-git-send-email-jlayton@redhat.com> (raw)
In-Reply-To: <1303819401-14789-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

cifs_demultiplex_thread calls coalesce_t2 to try and merge follow-on t2
responses into the original mid buffer. coalesce_t2 however can return
errors, but the caller doesn't handle that situation properly. Fix the
thread to treat such a case as it would a malformed packet. Mark the
mid as being malformed and issue the callback.

Cc: stable-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Signed-off-by: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 fs/cifs/connect.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index a2cde4c..d025249 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -629,12 +629,16 @@ incomplete_rcv:
 				isMultiRsp = true;
 				if (mid_entry->resp_buf) {
 					/* merge response - fix up 1st*/
-					if (coalesce_t2(smb_buffer,
-							mid_entry->resp_buf)) {
+					length = coalesce_t2(smb_buffer,
+							mid_entry->resp_buf);
+					if (length > 0) {
+						length = 0;
 						mid_entry->multiRsp = true;
 						break;
 					} else {
-						/* all parts received */
+						/* all parts received or
+						 * packet is malformed
+						 */
 						mid_entry->multiEnd = true;
 						goto multi_t2_fnd;
 					}
-- 
1.7.4.4

  parent reply	other threads:[~2011-04-26 12:03 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-26 12:03 [PATCH 0/5] cifs: fix some bounds checking problems Jeff Layton
     [not found] ` <1303819401-14789-2-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-04-26 14:10   ` [PATCH 1/5] cifs: change bleft in decode_unicode_ssetup back to signed type David Howells
     [not found] ` <1303819401-14789-3-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-04-26 14:11   ` [PATCH 2/5] cifs: check for bytes_remaining going to zero in CIFS_SessSetup David Howells
     [not found] ` <1303819401-14789-4-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-04-26 14:27   ` [PATCH 3/5] cifs: sanitize length checking in coalesce_t2 David Howells
     [not found]     ` <17747.1303828052-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-04-26 16:00       ` Jeff Layton
2011-04-27 12:03       ` [PATCH 3/5] cifs: sanitize length checking in coalesce_t2 (try #2) Jeff Layton
     [not found]     ` <1303905796-28087-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-04-27 16:37       ` David Howells
     [not found]         ` <13543.1303922232-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-04-27 16:43           ` David Howells
2011-04-27 16:43           ` Jeff Layton
2011-04-27 17:31           ` [PATCH] cifs: sanitize length checking in coalesce_t2 (try #3) Jeff Layton
     [not found] ` <1303819401-14789-5-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-04-26 14:39   ` [PATCH 4/5] cifs: refactor mid finding loop in cifs_demultiplex_thread David Howells
2011-05-03  3:44   ` Steve French
     [not found]     ` <BANLkTim4jXoQm47-ecw8r5ftBVGRbA+mKw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-05-03 12:09       ` Jeff Layton
     [not found]         ` <20110503080953.65db9af6-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2011-05-03 14:50           ` Steve French
     [not found] ` <1303819401-14789-6-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-04-26 14:40   ` [PATCH 5/5] cifs: handle errors from coalesce_t2 David Howells
     [not found] ` <1303819401-14789-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-04-26 12:03   ` [PATCH 1/5] cifs: change bleft in decode_unicode_ssetup back to signed type Jeff Layton
2011-04-26 12:03   ` [PATCH 2/5] cifs: check for bytes_remaining going to zero in CIFS_SessSetup Jeff Layton
2011-04-26 12:03   ` [PATCH 3/5] cifs: sanitize length checking in coalesce_t2 Jeff Layton
2011-04-26 12:03   ` [PATCH 4/5] cifs: refactor mid finding loop in cifs_demultiplex_thread Jeff Layton
2011-04-26 12:03   ` Jeff Layton [this message]
2011-04-27 14:17   ` [PATCH 0/5] cifs: fix some bounds checking problems Jeff Layton
     [not found]     ` <20110427101740.32be5c28-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2011-04-27 14:59       ` Steve French
     [not found]         ` <BANLkTiko7K1HJFjAKfRokmFiWk=+rHe0DA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-04-27 15:04           ` Jeff Layton
     [not found]             ` <20110427110404.71b80c29-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2011-04-27 15:06               ` Steve French
     [not found]                 ` <BANLkTinzFc5DgUuG9ohRQNGk12PDO7J-uQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-04-27 15:07                   ` Steve French
     [not found]                     ` <BANLkTikLYQg_zEWS5Joz=7eTj1P_YF6ZzQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-04-27 15:14                       ` Jeff Layton
2011-04-29  5:05   ` Steve French
     [not found]     ` <BANLkTimNseyrXc9ZDz0N4tomRx1oy5P60Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-04-29 10:55       ` Jeff Layton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1303819401-14789-6-git-send-email-jlayton@redhat.com \
    --to=jlayton-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.