From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: "Luis R. Rodriguez" <mcgrof@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
davem@davemloft.net, daniel@iogearbox.net,
torvalds@linux-foundation.org, gregkh@linuxfoundation.org,
luto@amacapital.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel-team@fb.com,
Juergen Gross <jgross@suse.com>, Eric Paris <eparis@redhat.com>,
Matthew Auld <matthew.auld@intel.com>,
Josh Triplett <josh@joshtriplett.org>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Chris Wilson <chris@chris-wilson.co.uk>,
Stephen Smalley <sds@tycho.nsa.gov>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Mimi Zohar <zohar@linux.vnet.ibm.com>,
David Howells <dhowells@redhat.com>,
Kees Cook <keescook@chromium.org>,
Andrew Morton <akpm@linux-foundation.org>,
Dominik Brodowski <linux@dominikbrodowski.net>,
Hugh Dickins <hughd@google.com>, Jann Horn <jannh@google.com>,
Jani Nikula <jani.nikula@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
David Airlie <airlied@linux.ie>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Linux FS Devel <linux-fsdevel@vger.kernel.org>,
pjones@redhat.com, Michael Matz <matz@suse.de>,
mjg59@google.com,
linux-security-module <linux-security-module@vger.kernel.org>,
linux-integrity@vger.kernel.org
Subject: Re: [PATCH v2 net-next 2/4] net: add skeleton of bpfilter kernel module
Date: Tue, 8 May 2018 19:29:29 -0700 [thread overview]
Message-ID: <20180509022928.elyxj6mohm2jud56@ast-mbp> (raw)
In-Reply-To: <20180507185124.GA18195@wotan.suse.de>
On Mon, May 07, 2018 at 06:51:24PM +0000, Luis R. Rodriguez wrote:
> > Notice that _binary_net_bpfilter_bpfilter_umh_start - end
> > is placed into .init.rodata section, so it's freed as soon as __init
> > function of bpfilter.ko is finished.
> > As part of __init the bpfilter.ko does first request/reply action
> > via two unix pipe provided by fork_usermode_blob() helper to
> > make sure that umh is healthy. If not it will kill it via pid.
>
> It does this very fast, right away. On a really slow system how are you sure
> that this won't race and the execution of the check happens early on prior to
> letting the actual setup trigger? After all, we're calling the userpsace
> process in async mode. We could preempt it now.
I don't see an issue.
the kernel synchronously writes into a pipe. User space process reads.
Exactly the same as coredump logic with pipes.
> > +# a bit of elf magic to convert bpfilter_umh binary into a binary blob
> > +# inside bpfilter_umh.o elf file referenced by
> > +# _binary_net_bpfilter_bpfilter_umh_start symbol
> > +# which bpfilter_kern.c passes further into umh blob loader at run-time
> > +quiet_cmd_copy_umh = GEN $@
> > + cmd_copy_umh = echo ':' > $(obj)/.bpfilter_umh.o.cmd; \
> > + $(OBJCOPY) -I binary -O $(CONFIG_OUTPUT_FORMAT) \
> > + -B `$(OBJDUMP) -f $<|grep architecture|cut -d, -f1|cut -d' ' -f2` \
> > + --rename-section .data=.init.rodata $< $@
>
> Cool, but so our expectation is that the compiler sets this symbol, how
> are we sure it will always be set?
Compiler doesn't set it. objcopy does.
> > +
> > + if (__bpfilter_process_sockopt(NULL, 0, 0, 0, 0) != 0) {
>
> See, here, what if the userspace process gets preemtped and we run this
> check afterwards? Is that possible?
User space is a normal task. It can sleep and can be single stepped with GDB.
prev parent reply other threads:[~2018-05-09 2:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20180503043604.1604587-1-ast@kernel.org>
[not found] ` <20180503043604.1604587-2-ast@kernel.org>
2018-05-04 19:56 ` [PATCH v2 net-next 1/4] umh: introduce fork_usermode_blob() helper Luis R. Rodriguez
2018-05-05 1:37 ` Alexei Starovoitov
2018-05-07 18:39 ` Luis R. Rodriguez
2018-05-09 2:25 ` Alexei Starovoitov
2018-05-10 22:27 ` Kees Cook
2018-05-10 23:16 ` Alexei Starovoitov
[not found] ` <20180503043604.1604587-3-ast@kernel.org>
2018-05-07 18:51 ` [PATCH v2 net-next 2/4] net: add skeleton of bpfilter kernel module Luis R. Rodriguez
2018-05-09 2:29 ` Alexei Starovoitov [this message]
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=20180509022928.elyxj6mohm2jud56@ast-mbp \
--to=alexei.starovoitov@gmail.com \
--cc=airlied@linux.ie \
--cc=akpm@linux-foundation.org \
--cc=ast@kernel.org \
--cc=chris@chris-wilson.co.uk \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=ebiederm@xmission.com \
--cc=eparis@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=hughd@google.com \
--cc=jani.nikula@linux.intel.com \
--cc=jannh@google.com \
--cc=jgross@suse.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=josh@joshtriplett.org \
--cc=keescook@chromium.org \
--cc=kernel-team@fb.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=linux@dominikbrodowski.net \
--cc=luto@amacapital.net \
--cc=matthew.auld@intel.com \
--cc=matz@suse.de \
--cc=mcgrof@kernel.org \
--cc=mjg59@google.com \
--cc=netdev@vger.kernel.org \
--cc=pjones@redhat.com \
--cc=rjw@rjwysocki.net \
--cc=rodrigo.vivi@intel.com \
--cc=sds@tycho.nsa.gov \
--cc=torvalds@linux-foundation.org \
--cc=zohar@linux.vnet.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).