netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ralf Baechle DL5RB <ralf@linux-mips.org>
To: netdev@oss.sgi.com, linux-hams@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>
Subject: [PATCH] Fix ax25_get_socket locking
Date: Mon, 14 Mar 2005 08:37:44 +0000	[thread overview]
Message-ID: <20050314083744.GA12765@linux-mips.org> (raw)

In an attempt to return a locked socket ax25_get_socket() was calling
lock_sock() with a spinlock held, bad idea.  Making matters worse it's
only user is running in bottom half context resulting in a potencial
attempt to sleep in bottom half context, so fix the locking there as well.

Index: bk-afu/net/ax25/ax25_in.c
===================================================================
--- bk-afu.orig/net/ax25/ax25_in.c	2005-03-14 00:20:42.153164936 +0000
+++ bk-afu/net/ax25/ax25_in.c	2005-03-14 00:21:07.469316296 +0000
@@ -275,6 +275,7 @@
 			/* Now find a suitable dgram socket */
 			sk = ax25_get_socket(&dest, &src, SOCK_DGRAM);
 			if (sk != NULL) {
+				bh_lock_sock(sk);
 				if (atomic_read(&sk->sk_rmem_alloc) >=
 				    sk->sk_rcvbuf) {
 					kfree_skb(skb);
@@ -286,7 +287,8 @@
 					if (sock_queue_rcv_skb(sk, skb) != 0)
 						kfree_skb(skb);
 				}
-				release_sock(sk);
+				bh_unlock_sock(sk);
+				sock_put(sk);
 			} else {
 				kfree_skb(skb);
 			}
Index: bk-afu/net/ax25/af_ax25.c
===================================================================
--- bk-afu.orig/net/ax25/af_ax25.c	2005-03-14 00:21:03.757880520 +0000
+++ bk-afu/net/ax25/af_ax25.c	2005-03-14 00:21:07.471315992 +0000
@@ -180,8 +180,7 @@
 		    !ax25cmp(&s->dest_addr, dest_addr) &&
 		    s->sk->sk_type == type) {
 			sk = s->sk;
-			/* XXX Sleeps with spinlock held, use refcounts instead. XXX */
-			lock_sock(sk);
+			sock_hold(sk);
 			break;
 		}
 	}

             reply	other threads:[~2005-03-14  8:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-14  8:37 Ralf Baechle DL5RB [this message]
2005-03-15  5:30 ` [PATCH] Fix ax25_get_socket locking David S. Miller

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=20050314083744.GA12765@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=davem@davemloft.net \
    --cc=linux-hams@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;
as well as URLs for NNTP newsgroup(s).