Linux X.25 subsystem development
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: Henner Eisen <eis@baty.hanse.de>, "David S. Miller" <davem@redhat.com>
Cc: linux-x25@vger.kernel.org, netdev@oss.sgi.com
Subject: [PATCH] Fix X.25 use after free.
Date: Tue, 5 Aug 2003 15:01:10 -0700	[thread overview]
Message-ID: <20030805150110.0e2753ab.shemminger@osdl.org> (raw)

The conversion from cli/sti to locking in X.25 must not have been tested
on a real SMP with memory debugging enabled.  It OOPS right away if
I do:
	modprobe x25; ifconfig -a

The problem is that it dereferences the socket after it has already been
freed.  The fix for this is to make the call to sock_put, later in
x25_destroy_socket do the free.  Also, need a go to avoid references
in x25_release.

This patch is against 2.6.0-test2.
diff -urNp -X dontdiff net-2.5/net/x25/af_x25.c linux-2.5-net/net/x25/af_x25.c
--- net-2.5/net/x25/af_x25.c	2003-08-01 11:12:02.000000000 -0700
+++ linux-2.5-net/net/x25/af_x25.c	2003-08-05 12:14:42.000000000 -0700
@@ -350,8 +350,11 @@ void x25_destroy_socket(struct sock *sk)
 		sk->sk_timer.function = x25_destroy_timer;
 		sk->sk_timer.data     = (unsigned long)sk;
 		add_timer(&sk->sk_timer);
-	} else
-		sk_free(sk);
+	} else {
+		/* drop last reference so sock_put will free */
+		__sock_put(sk);
+	}
+
 	release_sock(sk);
 	sock_put(sk);
 }
@@ -553,7 +556,7 @@ static int x25_release(struct socket *so
 		case X25_STATE_2:
 			x25_disconnect(sk, 0, 0, 0);
 			x25_destroy_socket(sk);
-			break;
+			goto out;
 
 		case X25_STATE_1:
 		case X25_STATE_3:




             reply	other threads:[~2003-08-05 22:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-05 22:01 Stephen Hemminger [this message]
2003-08-06  0:34 ` [PATCH] Fix X.25 use after free James Morris

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=20030805150110.0e2753ab.shemminger@osdl.org \
    --to=shemminger@osdl.org \
    --cc=davem@redhat.com \
    --cc=eis@baty.hanse.de \
    --cc=linux-x25@vger.kernel.org \
    --cc=netdev@oss.sgi.com \
    /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