netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfrm: Don't pass current->pid to functions expecting a netlink portid
@ 2012-09-08  6:43 Eric W. Biederman
  2012-09-08  7:03 ` Eric W. Biederman
  0 siblings, 1 reply; 5+ messages in thread
From: Eric W. Biederman @ 2012-09-08  6:43 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Jamal Hadi Salim


km_policy_expired ultimately calls xfrm_exp_policy_notify
which ignores any netlink porrts specified in it's km_event
paramater and simply sends a netlink multicast message.

km_state_expired ultimately calls xfrm_exp_state_notify
which ignores any netlink ports specified in it's km_event
paramater and simply sends a netlink multicast message.

Therefore neither km_policy_expired nor km_state_expired needs the
bogus current->pid value that is currently passed as a netlink port
and a zero can be passed instead, just like all of the other call
sites of km_port_expired and km_state_expired.

Cc: Jamal Hadi Salim <hadi@cyberus.ca>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
 net/xfrm/xfrm_user.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 4801c81..d7bfd27 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1930,7 +1930,7 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
 		// reset the timers here?
 		WARN(1, "Dont know what to do with soft policy expire\n");
 	}
-	km_policy_expired(xp, p->dir, up->hard, current->pid);
+	km_policy_expired(xp, p->dir, up->hard, 0);
 
 out:
 	xfrm_pol_put(xp);
@@ -1958,7 +1958,7 @@ static int xfrm_add_sa_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
 	err = -EINVAL;
 	if (x->km.state != XFRM_STATE_VALID)
 		goto out;
-	km_state_expired(x, ue->hard, current->pid);
+	km_state_expired(x, ue->hard, 0);
 
 	if (ue->hard) {
 		uid_t loginuid = audit_get_loginuid(current);
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] xfrm: Don't pass current->pid to functions expecting a netlink portid
  2012-09-08  6:43 [PATCH] xfrm: Don't pass current->pid to functions expecting a netlink portid Eric W. Biederman
@ 2012-09-08  7:03 ` Eric W. Biederman
  2012-09-08  7:17   ` [PATCH] xfrm: Report user triggered expirations against the users socket Eric W. Biederman
  0 siblings, 1 reply; 5+ messages in thread
From: Eric W. Biederman @ 2012-09-08  7:03 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Jamal Hadi Salim


Ignore this patch.  The issue is real this fix is wrong.

> diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
> index 4801c81..d7bfd27 100644
> --- a/net/xfrm/xfrm_user.c
> +++ b/net/xfrm/xfrm_user.c
> @@ -1930,7 +1930,7 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
>  		// reset the timers here?
>  		WARN(1, "Dont know what to do with soft policy expire\n");
>  	}
> -	km_policy_expired(xp, p->dir, up->hard, current->pid);
> +	km_policy_expired(xp, p->dir, up->hard, 0);
>  
>  out:
>  	xfrm_pol_put(xp);
> @@ -1958,7 +1958,7 @@ static int xfrm_add_sa_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
>  	err = -EINVAL;
>  	if (x->km.state != XFRM_STATE_VALID)
>  		goto out;
> -	km_state_expired(x, ue->hard, current->pid);
> +	km_state_expired(x, ue->hard, 0);
>  
>  	if (ue->hard) {
>  		uid_t loginuid = audit_get_loginuid(current);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] xfrm: Report user triggered expirations against the users socket
  2012-09-08  7:03 ` Eric W. Biederman
@ 2012-09-08  7:17   ` Eric W. Biederman
  2012-09-08 11:48     ` Jamal Hadi Salim
  0 siblings, 1 reply; 5+ messages in thread
From: Eric W. Biederman @ 2012-09-08  7:17 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Jamal Hadi Salim


When a policy expiration is triggered from user space the request
travles through km_policy_expired and ultimately into
xfrm_exp_policy_notify which calls build_polexpire.  build_polexpire
uses the netlink port passed to km_policy_expired as the source port for
the netlink message it builds.

When a state expiration is triggered from user space the request travles
through km_state_expired and ultimately into xfrm_exp_state_notify which
calls build_expire.  build_expire uses the netlink port passed to
km_state_expired as the source port for the netlink message it builds.

Pass nlh->nlmsg_pid from the user generated netlink message that
requested the expiration to km_policy_expired and km_state_expired
instead of current->pid which is not a netlink port number.

Cc: Jamal Hadi Salim <hadi@cyberus.ca>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
 net/xfrm/xfrm_user.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 4801c81..c1fbdbf 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1930,7 +1930,7 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
 		// reset the timers here?
 		WARN(1, "Dont know what to do with soft policy expire\n");
 	}
-	km_policy_expired(xp, p->dir, up->hard, current->pid);
+	km_policy_expired(xp, p->dir, up->hard, nlh->nlmsg_pid);
 
 out:
 	xfrm_pol_put(xp);
@@ -1958,7 +1958,7 @@ static int xfrm_add_sa_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
 	err = -EINVAL;
 	if (x->km.state != XFRM_STATE_VALID)
 		goto out;
-	km_state_expired(x, ue->hard, current->pid);
+	km_state_expired(x, ue->hard, nlh->nlmsg_pid);
 
 	if (ue->hard) {
 		uid_t loginuid = audit_get_loginuid(current);
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] xfrm: Report user triggered expirations against the users socket
  2012-09-08  7:17   ` [PATCH] xfrm: Report user triggered expirations against the users socket Eric W. Biederman
@ 2012-09-08 11:48     ` Jamal Hadi Salim
  2012-09-10 19:34       ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Jamal Hadi Salim @ 2012-09-08 11:48 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: David Miller, netdev, Jamal Hadi Salim

On 12-09-08 03:17 AM, Eric W. Biederman wrote:
> When a policy expiration is triggered from user space the request
> travles through km_policy_expired and ultimately into
> xfrm_exp_policy_notify which calls build_polexpire.  build_polexpire
> uses the netlink port passed to km_policy_expired as the source port for
> the netlink message it builds.
>
> When a state expiration is triggered from user space the request travles
> through km_state_expired and ultimately into xfrm_exp_state_notify which
> calls build_expire.  build_expire uses the netlink port passed to
> km_state_expired as the source port for the netlink message it builds.
>
> Pass nlh->nlmsg_pid from the user generated netlink message that
> requested the expiration to km_policy_expired and km_state_expired
> instead of current->pid which is not a netlink port number.
>
> Cc: Jamal Hadi Salim <hadi@cyberus.ca>
> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
>

I suppose.
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>


cheers,
jamal

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] xfrm: Report user triggered expirations against the users socket
  2012-09-08 11:48     ` Jamal Hadi Salim
@ 2012-09-10 19:34       ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2012-09-10 19:34 UTC (permalink / raw)
  To: jhs; +Cc: ebiederm, netdev, hadi

From: Jamal Hadi Salim <jhs@mojatatu.com>
Date: Sat, 08 Sep 2012 07:48:14 -0400

> On 12-09-08 03:17 AM, Eric W. Biederman wrote:
>> When a policy expiration is triggered from user space the request
>> travles through km_policy_expired and ultimately into
>> xfrm_exp_policy_notify which calls build_polexpire.  build_polexpire
>> uses the netlink port passed to km_policy_expired as the source port
>> for
>> the netlink message it builds.
>>
>> When a state expiration is triggered from user space the request
>> travles
>> through km_state_expired and ultimately into xfrm_exp_state_notify
>> which
>> calls build_expire.  build_expire uses the netlink port passed to
>> km_state_expired as the source port for the netlink message it builds.
>>
>> Pass nlh->nlmsg_pid from the user generated netlink message that
>> requested the expiration to km_policy_expired and km_state_expired
>> instead of current->pid which is not a netlink port number.
>>
>> Cc: Jamal Hadi Salim <hadi@cyberus.ca>
>> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
>>
> 
> I suppose.
> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>

Applied to net-next, thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-09-10 19:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-08  6:43 [PATCH] xfrm: Don't pass current->pid to functions expecting a netlink portid Eric W. Biederman
2012-09-08  7:03 ` Eric W. Biederman
2012-09-08  7:17   ` [PATCH] xfrm: Report user triggered expirations against the users socket Eric W. Biederman
2012-09-08 11:48     ` Jamal Hadi Salim
2012-09-10 19:34       ` David 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).