linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 net-next] xfrm: Add check to prevent un-complete key manager
       [not found] <1384093556-8987-1-git-send-email-baker.kernel@gmail.com>
@ 2013-11-11  6:39 ` baker.kernel
  2013-11-11  7:11   ` Fan Du
  2013-11-11 19:04   ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: baker.kernel @ 2013-11-11  6:39 UTC (permalink / raw)
  To: davem, herbert, steffen.klassert; +Cc: netdev, linux-kernel, Baker Zhang

From: Baker Zhang <Baker.kernel@gmail.com>

"acquire" and "compile_policy" callbacks are necessary for a key manager.

Signed-off-by: Baker Zhang <Baker.kernel@gmail.com>
---
Thanks for all reply.

V1:
For current kernel source, there is no problem.

In our vpn product, we need a xfrm_km in kernel module
to monitor the xfrm state change.
thus, the 'acquire' and 'compile_policy' may be NULL.

So I think we should do the check before use it. 

V2:
Align the continuation line according the networking coding style.

V3:
Add check to prevent un-complete key manager at register time.

 net/xfrm/xfrm_state.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index b9c3f9e..178283e 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1806,6 +1806,9 @@ static DEFINE_SPINLOCK(xfrm_km_lock);
 
 int xfrm_register_km(struct xfrm_mgr *km)
 {
+	if (km->acquire == NULL || km->compile_policy == NULL)
+		return -EINVAL;
+
 	spin_lock_bh(&xfrm_km_lock);
 	list_add_tail_rcu(&km->list, &xfrm_km_list);
 	spin_unlock_bh(&xfrm_km_lock);
-- 
1.8.3.2


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

* Re: [PATCH v3 net-next] xfrm: Add check to prevent un-complete key manager
  2013-11-11  6:39 ` [PATCH v3 net-next] xfrm: Add check to prevent un-complete key manager baker.kernel
@ 2013-11-11  7:11   ` Fan Du
  2013-11-11 19:04   ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Fan Du @ 2013-11-11  7:11 UTC (permalink / raw)
  To: baker.kernel; +Cc: davem, herbert, steffen.klassert, netdev, linux-kernel



On 2013年11月11日 14:39, baker.kernel@gmail.com wrote:
> From: Baker Zhang<Baker.kernel@gmail.com>
>
> "acquire" and "compile_policy" callbacks are necessary for a key manager.
>
> Signed-off-by: Baker Zhang<Baker.kernel@gmail.com>
> ---
> Thanks for all reply.
>
> V1:
> For current kernel source, there is no problem.
>
> In our vpn product, we need a xfrm_km in kernel module
> to monitor the xfrm state change.
> thus, the 'acquire' and 'compile_policy' may be NULL.
>
> So I think we should do the check before use it.
>
> V2:
> Align the continuation line according the networking coding style.
>
> V3:
> Add check to prevent un-complete key manager at register time.
>
>   net/xfrm/xfrm_state.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
> index b9c3f9e..178283e 100644
> --- a/net/xfrm/xfrm_state.c
> +++ b/net/xfrm/xfrm_state.c
> @@ -1806,6 +1806,9 @@ static DEFINE_SPINLOCK(xfrm_km_lock);
>
>   int xfrm_register_km(struct xfrm_mgr *km)
>   {
> +	if (km->acquire == NULL || km->compile_policy == NULL)

"acquire" is a MUST, "compile_policy" is not a necessity.

 From  the fist commit log, you probably add functionality providing SA state changes
in your private key manager, which current implementation does not. Maybe it's worthwhile
to elaborate the missing functionality than add those checking, because both key manage
(pfkeyv2/netlink) in use has "acquire" and "compile_policy" at the same time.



-- 
浮沉随浪只记今朝笑

--fan

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

* Re: [PATCH v3 net-next] xfrm: Add check to prevent un-complete key manager
  2013-11-11  6:39 ` [PATCH v3 net-next] xfrm: Add check to prevent un-complete key manager baker.kernel
  2013-11-11  7:11   ` Fan Du
@ 2013-11-11 19:04   ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2013-11-11 19:04 UTC (permalink / raw)
  To: baker.kernel; +Cc: herbert, steffen.klassert, netdev, linux-kernel

From: baker.kernel@gmail.com
Date: Mon, 11 Nov 2013 14:39:11 +0800

> +	if (km->acquire == NULL || km->compile_policy == NULL)
> +		return -EINVAL;

There are 7 function pointer methods that must be fully implemented
in an xfrm_mgr object, not just two.

And really we absolutely do not care at all about your out-of-tree
product, it has no bearing upon what should happen here.

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

end of thread, other threads:[~2013-11-11 19:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1384093556-8987-1-git-send-email-baker.kernel@gmail.com>
2013-11-11  6:39 ` [PATCH v3 net-next] xfrm: Add check to prevent un-complete key manager baker.kernel
2013-11-11  7:11   ` Fan Du
2013-11-11 19:04   ` 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).