netdev
[Top] [All Lists]

[IPSEC]: Protect against BHs in xfrm_user_policy()

To: "David S. Miller" <davem@xxxxxxxxxxxxx>
Subject: [IPSEC]: Protect against BHs in xfrm_user_policy()
From: Patrick McHardy <kaber@xxxxxxxxx>
Date: Sun, 03 Apr 2005 18:13:01 +0200
Cc: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>, netdev <netdev@xxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.6) Gecko/20050324 Debian/1.7.6-1
xfrm_user_policy() is called from ip_setsockopt with enabled
BHs, so it needs to protect against them when grabbing
xfrm_km_lock.

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2005/04/03 17:36:10+02:00 kaber@xxxxxxxxxxxx 
#   [IPSEC]: Protect against BHs in xfrm_user_policy()
#   
#   Signed-off-by: Patrick McHardy <kaber@xxxxxxxxx>
# 
# net/xfrm/xfrm_state.c
#   2005/04/03 17:36:00+02:00 kaber@xxxxxxxxxxxx +2 -2
#   [IPSEC]: Protect against BHs in xfrm_user_policy()
#   
#   Signed-off-by: Patrick McHardy <kaber@xxxxxxxxx>
# 
diff -Nru a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
--- a/net/xfrm/xfrm_state.c     2005-04-03 18:04:38 +02:00
+++ b/net/xfrm/xfrm_state.c     2005-04-03 18:04:38 +02:00
@@ -878,14 +878,14 @@
                goto out;
 
        err = -EINVAL;
-       read_lock(&xfrm_km_lock);
+       read_lock_bh(&xfrm_km_lock);
        list_for_each_entry(km, &xfrm_km_list, list) {
                pol = km->compile_policy(sk->sk_family, optname, data,
                                         optlen, &err);
                if (err >= 0)
                        break;
        }
-       read_unlock(&xfrm_km_lock);
+       read_unlock_bh(&xfrm_km_lock);
 
        if (err >= 0) {
                xfrm_sk_policy_insert(sk, err, pol);
<Prev in Thread] Current Thread [Next in Thread>