[PATCH-rt 1/1] Fix spinlock issue in net/core/sock.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Kernel panic's and reboot while doing network operations such ifconfig
and ping on MIPS architecture after RT-patches applied.

In case of CONFIG_PREEMPT_RT, after releasing the lock with
"spin_unlock", context switch might occur before enabling the bottom
half with local_bh_enable and this causes the kernel to panic.
The issue is resolved by releasing the lock afer acquiring the mutex
using spin_unlock_bh.

Tested the fix on MIPS and X86 architecture.

Signed-off-by: Vivek Satpute <vivek@xxxxxxxxxxxxxx>
---
net/core/sock.c |    8 ++++++++
1 file changed, 8 insertions(+)

Index: linux-2.6.28.4/net/core/sock.c
===================================================================
--- linux-2.6.28.4.orig/net/core/sock.c
+++ linux-2.6.28.4/net/core/sock.c
@@ -1752,12 +1752,20 @@ void lock_sock_nested(struct sock *sk, i
 	if (sk->sk_lock.owned)
 		__lock_sock(sk);
 	sk->sk_lock.owned = 1;
+
+#ifndef CONFIG_PREEMPT_RT
 	spin_unlock(&sk->sk_lock.slock);
+#endif
 	/*
 	 * The sk_lock has mutex_lock() semantics here:
 	 */
 	mutex_acquire(&sk->sk_lock.dep_map, subclass, 0, _RET_IP_);
+
+#ifdef CONFIG_PREEMPT_RT
+	spin_unlock_bh(&sk->sk_lock.slock);
+#else
 	local_bh_enable();
+#endif
 }
 
 EXPORT_SYMBOL(lock_sock_nested);




Thanks and Regards,
Vivek Satpute
System Software Engineer
LinSysSoft Technologies, Pune

--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux