From: Paul Moore <paul.moore@hp.com>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: linux-security-module@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] LSM: Add security_socket_post_accept() and security_socket_post_recv_datagram().
Date: Thu, 16 Apr 2009 14:23:04 -0400 [thread overview]
Message-ID: <200904161423.04414.paul.moore@hp.com> (raw)
In-Reply-To: <200904150512.n3F5CfDA008806@www262.sakura.ne.jp>
On Wednesday 15 April 2009 01:12:41 am Tetsuo Handa wrote:
> Hello.
>
> Paul Moore wrote:
> > Please submit a patch set that includes both this patch as well as a
> > patch to TOMOYO which makes use of these changes; this way we can
> > properly review your patches in context.
Thank you for sending a patchset with both TOMOYO and LSM/stack changes; this
should give other developers who may not be familiar with TOMOYO a chance to
review your code. My comments/concerns about the LSM changes still stand, if
it is decided to merge these changes I'll be happy to review the TOMOYO
changes further.
> > > + if (!(flags & MSG_PEEK))
> > > + goto no_peek;
> > > + /*
> > > + * If this packet is MSG_PEEK'ed, dequeue it forcibly
> > > + * so that this packet won't prevent the caller from picking up
> > > + * next packet.
> > > + */
> > > + spin_lock_irqsave(&sk->sk_receive_queue.lock, cpu_flags);
> > > + if (skb == skb_peek(&sk->sk_receive_queue)) {
> > > + __skb_unlink(skb, &sk->sk_receive_queue);
> > > + atomic_dec(&skb->users);
> > > + /* Do I have something to do with skb->peeked ? */
> >
> > I don't know but you should find out before this code is merged :)
>
> Q1: Can I use skb_kill_datagram() here?
>
> skb_kill_datagram() uses spin_lock_bh() while __skb_recv_datagram()
> uses spin_lock_irqsave(). Since this codepath is called inside
> __skb_recv_datagram(), I used spin_lock_irqsave() rather than calling
> skb_kill_datagram().
Since __skb_recv_datagram() is already using spin_lock_irqsave() it seems
reasonable to do the same in your changes. As far as skb->peeked is concerned
I don't think it matters much since you are destroying the skb anyway.
> > > +no_peek:
> > > + kfree_skb(skb);
>
> Q2: Do I need to use skb_free_datagram() here rather than kfree_skb()?
>
> In the past ( http://lkml.org/lkml/2007/11/16/406 ), there was no
> difference between skb_free_datagram() and kfree_skb().
>
> | void skb_free_datagram(struct sock *sk, struct sk_buff *skb)
> | {
> | kfree_skb(skb);
> | }
>
> But now (as of 2.6.30-rc2), there is a difference.
>
> | void skb_free_datagram(struct sock *sk, struct sk_buff *skb)
> | {
> | consume_skb(skb);
> | sk_mem_reclaim_partial(sk);
> | }
I don't know for certain, I would have to go look at other users of
skb_free_datagram(), but it does look like using skb_free_datagram() instead
of skb_free() might be preferable.
> Q3: Is __skb_recv_datagram() called from contexts that are not permitted to
> sleep?
>
> If so, TOMOYO has to check whether it is allowed to sleep, for TOMOYO
> will prompt the user "whether to allow App1 to read this datagram or not".
I believe __skb_recv_datagram() is only called via userspace so sleeping
should not be an issue.
> Q4: Is there a way to distinguish requests from userland programs and
> requests from kernel code?
I'm not sure if this is the 100% correct way to do it, but in the past I have
always checked current->mm, for kernel threads this will be NULL.
--
paul moore
linux @ hp
next prev parent reply other threads:[~2009-04-16 18:23 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-14 10:44 [PATCH] LSM: Add security_socket_post_accept() and security_socket_post_recv_datagram() Tetsuo Handa
2009-04-14 22:59 ` Paul Moore
2009-04-15 5:12 ` Tetsuo Handa
2009-04-15 10:51 ` [PATCH 1/2] " Tetsuo Handa
2009-04-15 10:51 ` [PATCH 2/2] tomoyo: Add network access control support Tetsuo Handa
2009-04-16 18:23 ` Paul Moore [this message]
2009-04-18 8:34 ` [PATCH] LSM: Add security_socket_post_accept() and security_socket_post_recv_datagram() Tetsuo Handa
2009-04-20 22:22 ` Paul Moore
2009-04-21 10:54 ` Tetsuo Handa
2009-04-21 10:57 ` David Miller
2009-04-21 11:39 ` Tetsuo Handa
2009-04-21 11:40 ` David Miller
2009-04-21 12:26 ` Tetsuo Handa
2009-04-21 12:37 ` David Miller
2009-04-21 12:52 ` [PATCH] LSM: Add security_socket_post_accept() andsecurity_socket_post_recv_datagram() Tetsuo Handa
2009-04-21 13:04 ` David Miller
2009-04-22 0:55 ` [PATCH] LSM: Add security_socket_post_accept() and security_socket_post_recv_datagram() Tetsuo Handa
2009-04-22 1:14 ` David Miller
2009-04-22 1:49 ` Tetsuo Handa
2009-04-22 4:22 ` David Miller
2009-04-22 5:02 ` Tetsuo Handa
2009-04-22 5:07 ` David Miller
2009-04-22 5:38 ` Tetsuo Handa
2009-04-22 5:52 ` David Miller
2009-04-23 14:00 ` Tetsuo Handa
2009-04-23 14:10 ` David Miller
2009-04-23 14:47 ` Samir Bellabes
2009-04-22 1:52 ` Greg Lindahl
2009-04-22 4:23 ` David Miller
2009-04-22 6:10 ` Greg Lindahl
2009-04-22 6:34 ` David Miller
2009-04-22 6:41 ` Greg Lindahl
2009-04-22 6:46 ` David Miller
2009-04-22 6:54 ` Greg Lindahl
2009-04-22 6:58 ` David Miller
2009-04-22 7:19 ` Tetsuo Handa
2009-04-24 2:07 ` Tetsuo Handa
2009-04-24 4:35 ` David Miller
2009-04-24 4:41 ` David Miller
2009-04-24 4:55 ` Tetsuo Handa
2009-04-24 5:26 ` Tetsuo Handa
2009-04-24 11:40 ` David Miller
2009-04-24 13:57 ` [PATCH] LSM: Add security_socket_post_accept() andsecurity_socket_post_recv_datagram() Tetsuo Handa
2009-04-19 8:03 ` [PATCH v2] LSM: Add security_socket_post_accept() and security_socket_post_recv_datagram() 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=200904161423.04414.paul.moore@hp.com \
--to=paul.moore@hp.com \
--cc=linux-security-module@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.