Skip to content

Commit 48af05e

Browse files
Paolo 'Blaisorblade' GiarrussoLinus Torvalds
authored andcommitted
[PATCH] uml: fix proc-vs-interrupt context spinlock deadlock
This spinlock can be taken on interrupt too, so spin_lock_irq[save] must be used. However, Documentation/networking/netdevices.txt explains we are called with rtnl_lock() held - so we don't need to care about other concurrent opens. Verified also in LDD3 and by direct checking. Also verified that the network layer (through a state machine) guarantees us that nobody will close the interface while it's being used. Please correct me if I'm wrong. Also, we must check we don't sleep with irqs disabled!!! But anyway, this is not news - we already can't sleep while holding a spinlock. Who says this is guaranted really by the present code? Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Cc: Jeff Dike <jdike@addtoit.com> Cc: Jeff Garzik <jeff@garzik.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 0683750 commit 48af05e

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

‎arch/um/drivers/net_kern.c‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ static int uml_net_open(struct net_device *dev)
114114
struct uml_net_private *lp = dev->priv;
115115
int err;
116116

117-
spin_lock(&lp->lock);
118-
119117
if(lp->fd >= 0){
120118
err = -ENXIO;
121119
goto out;
@@ -149,8 +147,6 @@ static int uml_net_open(struct net_device *dev)
149147
*/
150148
while((err = uml_net_rx(dev)) > 0) ;
151149

152-
spin_unlock(&lp->lock);
153-
154150
spin_lock(&opened_lock);
155151
list_add(&lp->list, &opened);
156152
spin_unlock(&opened_lock);
@@ -160,7 +156,6 @@ static int uml_net_open(struct net_device *dev)
160156
if(lp->close != NULL) (*lp->close)(lp->fd, &lp->user);
161157
lp->fd = -1;
162158
out:
163-
spin_unlock(&lp->lock);
164159
return err;
165160
}
166161

@@ -169,15 +164,12 @@ static int uml_net_close(struct net_device *dev)
169164
struct uml_net_private *lp = dev->priv;
170165

171166
netif_stop_queue(dev);
172-
spin_lock(&lp->lock);
173167

174168
free_irq(dev->irq, dev);
175169
if(lp->close != NULL)
176170
(*lp->close)(lp->fd, &lp->user);
177171
lp->fd = -1;
178172

179-
spin_unlock(&lp->lock);
180-
181173
spin_lock(&opened_lock);
182174
list_del(&lp->list);
183175
spin_unlock(&opened_lock);
@@ -246,9 +238,9 @@ static int uml_net_set_mac(struct net_device *dev, void *addr)
246238
struct uml_net_private *lp = dev->priv;
247239
struct sockaddr *hwaddr = addr;
248240

249-
spin_lock(&lp->lock);
241+
spin_lock_irq(&lp->lock);
250242
set_ether_mac(dev, hwaddr->sa_data);
251-
spin_unlock(&lp->lock);
243+
spin_unlock_irq(&lp->lock);
252244

253245
return(0);
254246
}
@@ -258,7 +250,7 @@ static int uml_net_change_mtu(struct net_device *dev, int new_mtu)
258250
struct uml_net_private *lp = dev->priv;
259251
int err = 0;
260252

261-
spin_lock(&lp->lock);
253+
spin_lock_irq(&lp->lock);
262254

263255
new_mtu = (*lp->set_mtu)(new_mtu, &lp->user);
264256
if(new_mtu < 0){
@@ -269,7 +261,7 @@ static int uml_net_change_mtu(struct net_device *dev, int new_mtu)
269261
dev->mtu = new_mtu;
270262

271263
out:
272-
spin_unlock(&lp->lock);
264+
spin_unlock_irq(&lp->lock);
273265
return err;
274266
}
275267

0 commit comments

Comments
 (0)