public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Jones <davej@redhat.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] fix use after free in smbfs.
Date: Thu, 7 Jul 2005 14:59:29 -0400	[thread overview]
Message-ID: <20050707185928.GA29413@redhat.com> (raw)

>From code inspection it seems that after freeing 'req', in smb_request()
we continue to dereference it a dozen or so times.

That whole area of code looks suspect.
		...
        smb_lock_server(server);
        if (!(req->rq_flags & SMB_REQ_RECEIVED)) {
            list_del_init(&req->rq_queue);
            smb_rput(req);
        }

smb_rput() also does a list_del_init, but only if its safe
to do so (ie, the refcount has dropped to 0).
To my not-smbfs-savvy eyes, it would seem that we could
potentially nuke the ->rq_queue list, and return from
smb_rput() if the request was still in use. What the rest
of the code does with such a buggered-up request, I've no
idea, but it probably isn't pretty.

Perhaps smb_rput should be taking a pointer to a request that can
be null'd on success ?

Signed-off-by: Dave Jones <davej@redhat.com>

--- linux-2.6.12/fs/smbfs/request.c~	2005-07-07 14:41:11.000000000 -0400
+++ linux-2.6.12/fs/smbfs/request.c	2005-07-07 14:41:22.000000000 -0400
@@ -348,6 +348,7 @@ int smb_add_request(struct smb_request *
 			smb_rput(req);
 		}
 		smb_unlock_server(server);
+		return -EINTR;
 	}
 
 	if (!timeleft) {



Looking further, we do exactly the same thing in smb_request_recv()

        smb_rput(req);
        wake_up_interruptible(&req->rq_wait);
    }

ditto in smbiod.c..

What am I missing here?  smb_rput() -> smb_free_request() does
a kmem_cache_free(req_cachep, req); making further use of that
cache item invalid.

		Dave


                 reply	other threads:[~2005-07-07 19:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20050707185928.GA29413@redhat.com \
    --to=davej@redhat.com \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox