public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Luke Kenneth Casson Leighton <lkcl@lkcl.net>
To: Chris Wright <chrisw@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [patch] update: _working_ code to add device+inode check to ipt_owner.c
Date: Thu, 9 Sep 2004 19:10:35 +0100	[thread overview]
Message-ID: <20040909181034.GF10046@lkcl.net> (raw)
In-Reply-To: <20040909091931.K1973@build.pdx.osdl.net>

On Thu, Sep 09, 2004 at 09:19:31AM -0700, Chris Wright wrote:
> * Luke Kenneth Casson Leighton (lkcl@lkcl.net) wrote:
> > wow, gosh, it works.
> > 
> > okay, this is a patch to add support in iptables for per-program
> > firewall filtering.
> > 
> > also included is the patches to iptables-1.2.11.
> > 
> > i have confidence that this patch will provide support for
> > BOTH incoming AND outgoing per-program packet filtering.
> 
> Programs can share a socket.  Incoming is in interrupt context.  You
> have no idea who will be woken up.  How do you handle this?
 
 chris, hi,

 thank you for mentioning this - i can quite cheerfully say
 that i have absolutely no idea what you are referring to, because
 i lack the knowledge on the design / inner workings to be able
 to say, but i am going to attempt to work out what you could
 mean.  please bear with me.

 perhaps you could help guide me through the ipt_owner.c code
 (or point me in the direction of some appropriate notes,
  documentation or prior discussions, or alternatively help
  me out with some keywords to search for).

 i didn't understand why the proscription that ipt_owner not
 be used for INCOMING packets (which someone mentioned to me).

 so if nothing else, like the other ipt_owner things, this patch
 would only be suitable for OUTGOING rules, yes?

 well, that's better than a kick in the teeth - esp. for userspace
 programs.

 doesn't help me with apollon (gift file sharing daemon which is
 kicked off in userspace by apollon client program) but hey.

 anyway.

 so we have, in the completely uncommented code ipt_owner.c, the
 match() function.  it passes in a sk_buff which has some packet
 header structs, a struct sock, which points to a file, which,
 from the usage inside match() shows me that the sk_buff has a
 uid and gid associated with its socket.

 okay, then we come to something like oh i dunno match_pid().

 this calls find_task_by_pid() on the iptables-owner-recorded
 PID.

 then, that task has files (including sockets) associated with it,
 so you have to search through every socket of that thing.  task.
 and you're looking for the file struct of the incoming packet.

 i'm ASSUMING that when you search the task that the task's
 files - (struct ttask_struct*)p)->files - contains AAALLLL
 sockets and files of that task, not just some it feels like.

 am i right about this?


 okay.  what happens for _shared_ sockets.

 under these circumstances... if you only had one rule for one
 PID, and the socket was shared with another PID then... yes, you'd
 end up in a situation where

 in fact, for servers which fork, this would be a problem.

 the task_struct would duplicate the files, you'd end up with a
 different PID...


 ... therefore, _that's_ why ipt_owner is not recommended for use
 with the --pid-owner argument because it's too fluid.

 is this what you are referring to when you say:

	> Programs can share a socket.  Incoming is in interrupt context.  You
	> have no idea who will be woken up.  How do you handle this?

 okay, assuming that this _is_ what you are referring to, i'll describe
 how i BELIEVE my patch to be different, and PLEASE, not least because i
 need to know the answer before i deploy this patch in a live system
 (*gibber*) but also for other people considering using this, please
 correct me on any points i may have got wrong.


 the difference between --pid-owner (IPT_OWNER_PID) and the new patch is
 that when a server forks(), i don't imagine that the mountpoint+inode
 (new IPT_OWNER_DEV+IPT_OWNER_INO) is going to change!

 ... or, and this might be the crux of the matter: when
 sockets are shared (e.g. via servers doing a fork(), is the
 files_struct REALLY duplicated such that the comparison if
 (fckeck_files(files, i) == file) check in match_sid(),
 match_pid(), etc. will FAIL, or are the files_struct entries
 shared between tasks - in particular are they shared between
 tasks that have been fork()ed?

 if they are NOT shared between tasks, then how is it possible
 to ensure that two processes do not attempt to bind to the same
 port number, for example?

 l.
 

  reply	other threads:[~2004-09-09 18:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-09 16:22 [patch] update: _working_ code to add device+inode check to ipt_owner.c Luke Kenneth Casson Leighton
2004-09-09 16:19 ` Chris Wright
2004-09-09 18:10   ` Luke Kenneth Casson Leighton [this message]
2004-09-09 18:48     ` Chris Wright
2004-09-09 21:25       ` Luke Kenneth Casson Leighton
2004-09-09 23:04         ` Chris Wright
2004-09-10  0:08           ` Luke Kenneth Casson Leighton
2004-09-10  0:21             ` Chris Wright
2004-09-10  0:59               ` Luke Kenneth Casson Leighton
2004-09-10  1:08                 ` Chris Wright
2004-09-10  1:34                   ` Luke Kenneth Casson Leighton
2004-09-09 21:38     ` Luke Kenneth Casson Leighton
2004-09-09 23:41       ` Chris Wright
2004-09-10  0:10         ` Luke Kenneth Casson Leighton
2004-09-09 16:29 ` Stephen Smalley
2004-09-09 16:33   ` Stephen Smalley
2004-09-09 17:44   ` Luke Kenneth Casson Leighton

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=20040909181034.GF10046@lkcl.net \
    --to=lkcl@lkcl.net \
    --cc=chrisw@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /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