From: Paul Moore <paul.moore@hp.com>
To: penguin-kernel@i-love.sakura.ne.jp
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org,
Kentaro Takeda <takedakn@nttdata.co.jp>
Subject: Re: [TOMOYO #5 18/18] LSM expansion for TOMOYO Linux.
Date: Fri, 16 Nov 2007 14:23:27 -0500 [thread overview]
Message-ID: <200711161423.28065.paul.moore@hp.com> (raw)
In-Reply-To: <20071116173529.826621737@I-love.SAKURA.ne.jp>
On Friday 16 November 2007 12:34:57 pm penguin-kernel@i-love.sakura.ne.jp
wrote:
> LSM hooks for network accept and recv:
> * socket_post_accept is modified to return int.
> * post_recv_datagram is added in skb_recv_datagram.
>
> You can try TOMOYO Linux without this patch, but in that case, you
> can't use access control functionality for restricting signal
> transmission and incoming network data.
As discussed a few times before, I'm still not really excited about adding a
new LSM hook in skb_recv_datagram() when we already have hooks to control
locally consumed network traffic. However, I will admit that these existing
hooks do not allow the LSM to block and query userspace for an access
decision like you are trying to do with TOMOYO. I would prefer not to see
this new LSM hook added but I do not have an alternative solution to your
problem so I can't in good conscience completely object to this patch.
Regardless, I have a few comments which are included below ...
> --- linux-2.6-mm.orig/net/core/datagram.c 2007-10-10 05:31:38.000000000
> +0900 +++ linux-2.6-mm/net/core/datagram.c 2007-11-14 15:15:44.000000000
> +0900 @@ -55,6 +55,7 @@
> #include <net/checksum.h>
> #include <net/sock.h>
> #include <net/tcp_states.h>
> +#include <linux/security.h>
>
> /*
> * Is a socket 'connection oriented' ?
> @@ -178,6 +179,27 @@ struct sk_buff *skb_recv_datagram(struct
> } else
> skb = skb_dequeue(&sk->sk_receive_queue);
>
> + error = security_post_recv_datagram(sk, skb, flags);
> + if (error) {
> + unsigned long cpu_flags;
With this patch the 'cpu_flags' variable will be used in two different
if-blocks in this function and declared locally within each block. Please
move the 'cpu_flags' declaration to the top of the function so it only needs
to be declared once.
> +
> + if (!(flags & MSG_PEEK))
> + goto no_peek;
> +
> + spin_lock_irqsave(&sk->sk_receive_queue.lock,
> + cpu_flags);
> + if (skb == skb_peek(&sk->sk_receive_queue)) {
I might be missing something here, but why do you need to do a skb_peek()
again? You already have the skb and the sock, just do the unlink.
> + __skb_unlink(skb,
> + &sk->sk_receive_queue);
> + atomic_dec(&skb->users);
> + }
> + spin_unlock_irqrestore(&sk->sk_receive_queue.lock,
> + cpu_flags);
> +no_peek:
> + skb_free_datagram(sk, skb);
> + goto no_packet;
Two things. First you can probably just call kfree_skb() instead of
skb_free_datagram(). Second, why not move the 'no_peek' code to just
before 'no_packet'?
--
paul moore
linux security @ hp
next prev parent reply other threads:[~2007-11-16 19:31 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-16 17:34 [TOMOYO #5 00/18] TOMOYO Linux - MAC based on process invocation history penguin-kernel
2007-11-16 17:34 ` [TOMOYO #5 01/18] Add struct vfsmount to struct task_struct penguin-kernel
2007-11-16 17:34 ` [TOMOYO #5 02/18] Add wrapper functions for VFS helper functions penguin-kernel
2007-11-16 17:47 ` Trond Myklebust
2007-11-16 18:20 ` [TOMOYO #5 02/18] Add wrapper functions for VFS helperfunctions Tetsuo Handa
2007-11-16 18:33 ` Trond Myklebust
2007-11-17 4:04 ` [TOMOYO #5 02/18] Add wrapper functions for VFShelperfunctions Tetsuo Handa
2007-11-17 4:46 ` Trond Myklebust
2007-11-17 5:23 ` Tetsuo Handa
2007-11-19 12:53 ` [TOMOYO #5 02/18] Add wrapper functions for VFS helper functions Christoph Hellwig
2007-11-19 13:18 ` Tetsuo Handa
2007-11-16 17:34 ` [TOMOYO #5 03/18] Replace VFS with wrapper functions penguin-kernel
2007-11-16 17:34 ` [TOMOYO #5 04/18] Data structures and prototype defitions penguin-kernel
2007-11-16 17:34 ` [TOMOYO #5 05/18] Memory and pathname management functions penguin-kernel
2007-11-16 17:34 ` [TOMOYO #5 06/18] Utility functions and policy manipulation interface penguin-kernel
2007-11-16 17:34 ` [TOMOYO #5 07/18] Domain transition functions penguin-kernel
2007-11-16 17:34 ` [TOMOYO #5 08/18] Auditing interface penguin-kernel
2007-11-16 17:34 ` [TOMOYO #5 09/18] File access control functions penguin-kernel
2007-11-16 17:34 ` [TOMOYO #5 10/18] argv0 check functions penguin-kernel
2007-11-16 17:34 ` [TOMOYO #5 11/18] Network access control functions penguin-kernel
2007-11-16 17:57 ` YOSHIFUJI Hideaki / 吉藤英明
2007-11-16 18:22 ` Tetsuo Handa
2007-11-16 17:34 ` [TOMOYO #5 12/18] Namespace manipulation " penguin-kernel
2007-11-16 17:34 ` [TOMOYO #5 13/18] Signal " penguin-kernel
2007-11-16 17:34 ` [TOMOYO #5 14/18] Capability access " penguin-kernel
2007-11-16 17:34 ` [TOMOYO #5 15/18] LSM adapter functions penguin-kernel
2007-11-16 17:34 ` [TOMOYO #5 16/18] Conditional permission support penguin-kernel
2007-11-16 17:34 ` [TOMOYO #5 17/18] Kconfig and Makefile penguin-kernel
2007-11-16 17:34 ` [TOMOYO #5 18/18] LSM expansion for TOMOYO Linux penguin-kernel
2007-11-16 19:23 ` Paul Moore [this message]
2007-11-17 3:45 ` Tetsuo Handa
2007-11-17 23:09 ` Paul Moore
2007-11-18 4:00 ` Tetsuo Handa
2007-11-19 13:36 ` Paul Moore
2007-11-19 14:29 ` Tetsuo Handa
2007-11-19 15:39 ` Paul Moore
2007-11-20 0:04 ` Tetsuo Handa
2007-11-20 0:52 ` James Morris
2007-11-20 4:50 ` [PATCH] Add packet filtering based on process\'s security context Tetsuo Handa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200711161423.28065.paul.moore@hp.com \
--to=paul.moore@hp.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=takedakn@nttdata.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox