* [IPSEC]: Protect against BHs in xfrm_user_policy()
@ 2005-04-03 16:13 Patrick McHardy
2005-04-04 1:20 ` Herbert Xu
0 siblings, 1 reply; 6+ messages in thread
From: Patrick McHardy @ 2005-04-03 16:13 UTC (permalink / raw)
To: David S. Miller; +Cc: Herbert Xu, netdev
[-- Attachment #1: Type: text/plain, Size: 131 bytes --]
xfrm_user_policy() is called from ip_setsockopt with enabled
BHs, so it needs to protect against them when grabbing
xfrm_km_lock.
[-- Attachment #2: x --]
[-- Type: text/plain, Size: 995 bytes --]
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2005/04/03 17:36:10+02:00 kaber@coreworks.de
# [IPSEC]: Protect against BHs in xfrm_user_policy()
#
# Signed-off-by: Patrick McHardy <kaber@trash.net>
#
# net/xfrm/xfrm_state.c
# 2005/04/03 17:36:00+02:00 kaber@coreworks.de +2 -2
# [IPSEC]: Protect against BHs in xfrm_user_policy()
#
# Signed-off-by: Patrick McHardy <kaber@trash.net>
#
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);
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [IPSEC]: Protect against BHs in xfrm_user_policy()
2005-04-03 16:13 [IPSEC]: Protect against BHs in xfrm_user_policy() Patrick McHardy
@ 2005-04-04 1:20 ` Herbert Xu
2005-04-04 3:47 ` Patrick McHardy
2005-04-04 11:55 ` Herbert Xu
0 siblings, 2 replies; 6+ messages in thread
From: Herbert Xu @ 2005-04-04 1:20 UTC (permalink / raw)
To: Patrick McHardy; +Cc: David S. Miller, netdev
On Sun, Apr 03, 2005 at 06:13:01PM +0200, Patrick McHardy wrote:
>
> # This is a BitKeeper generated diff -Nru style patch.
> #
> # ChangeSet
> # 2005/04/03 17:36:10+02:00 kaber@coreworks.de
> # [IPSEC]: Protect against BHs in xfrm_user_policy()
> #
> # Signed-off-by: Patrick McHardy <kaber@trash.net>
Looks good.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
We want the same thing for km_query, no?
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [IPSEC]: Protect against BHs in xfrm_user_policy()
2005-04-04 1:20 ` Herbert Xu
@ 2005-04-04 3:47 ` Patrick McHardy
2005-04-04 4:06 ` Herbert Xu
2005-04-04 11:55 ` Herbert Xu
1 sibling, 1 reply; 6+ messages in thread
From: Patrick McHardy @ 2005-04-04 3:47 UTC (permalink / raw)
To: Herbert Xu; +Cc: David S. Miller, netdev
On Mon, 4 Apr 2005, Herbert Xu wrote:
> We want the same thing for km_query, no?
In all other places were BHs are not explicitly disabled
but need to be they are already disabled by the caller,
so I left them as they are.
Regards
Patrick
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [IPSEC]: Protect against BHs in xfrm_user_policy()
2005-04-04 3:47 ` Patrick McHardy
@ 2005-04-04 4:06 ` Herbert Xu
0 siblings, 0 replies; 6+ messages in thread
From: Herbert Xu @ 2005-04-04 4:06 UTC (permalink / raw)
To: Patrick McHardy; +Cc: David S. Miller, netdev
On Mon, Apr 04, 2005 at 05:47:44AM +0200, Patrick McHardy wrote:
> On Mon, 4 Apr 2005, Herbert Xu wrote:
> >We want the same thing for km_query, no?
>
> In all other places were BHs are not explicitly disabled
> but need to be they are already disabled by the caller,
> so I left them as they are.
Yes you're right. I missed the spin_lock_bh in xfrm_state_find.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [IPSEC]: Protect against BHs in xfrm_user_policy()
2005-04-04 1:20 ` Herbert Xu
2005-04-04 3:47 ` Patrick McHardy
@ 2005-04-04 11:55 ` Herbert Xu
2005-04-04 17:35 ` David S. Miller
1 sibling, 1 reply; 6+ messages in thread
From: Herbert Xu @ 2005-04-04 11:55 UTC (permalink / raw)
To: Patrick McHardy; +Cc: David S. Miller, netdev
On Mon, Apr 04, 2005 at 11:20:40AM +1000, herbert wrote:
> On Sun, Apr 03, 2005 at 06:13:01PM +0200, Patrick McHardy wrote:
> >
> > # This is a BitKeeper generated diff -Nru style patch.
> > #
> > # ChangeSet
> > # 2005/04/03 17:36:10+02:00 kaber@coreworks.de
> > # [IPSEC]: Protect against BHs in xfrm_user_policy()
> > #
> > # Signed-off-by: Patrick McHardy <kaber@trash.net>
>
> Looks good.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Actually, I now think this patch is unnecessary for mainline.
The read_lock()'s only need to be protected from the write_lock()'s.
Since all the write_lock()'s are made in process context, we don't
need to disable BH on the read_lock()'s.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [IPSEC]: Protect against BHs in xfrm_user_policy()
2005-04-04 11:55 ` Herbert Xu
@ 2005-04-04 17:35 ` David S. Miller
0 siblings, 0 replies; 6+ messages in thread
From: David S. Miller @ 2005-04-04 17:35 UTC (permalink / raw)
To: Herbert Xu; +Cc: kaber, netdev
On Mon, 4 Apr 2005 21:55:08 +1000
Herbert Xu <herbert@gondor.apana.org.au> wrote:
> The read_lock()'s only need to be protected from the write_lock()'s.
>
> Since all the write_lock()'s are made in process context, we don't
> need to disable BH on the read_lock()'s.
This is correct.
It's actually a common technique, only disable IRQ or BH in
the write_locks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-04-04 17:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-03 16:13 [IPSEC]: Protect against BHs in xfrm_user_policy() Patrick McHardy
2005-04-04 1:20 ` Herbert Xu
2005-04-04 3:47 ` Patrick McHardy
2005-04-04 4:06 ` Herbert Xu
2005-04-04 11:55 ` Herbert Xu
2005-04-04 17:35 ` David S. Miller
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).