netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Giuseppe Scrivano <gscrivan@redhat.com>
To: Phil Sutter <phil@nwl.cc>
Cc: netfilter-devel@vger.kernel.org, Florian Westphal <fw@strlen.de>
Subject: Re: [iptables PATCH v2] iptables: accept lock file name at runtime
Date: Fri, 17 Jul 2020 10:18:30 +0200	[thread overview]
Message-ID: <874kq6o8q1.fsf@redhat.com> (raw)
In-Reply-To: <20200716215535.GD23632@orbyte.nwl.cc> (Phil Sutter's message of "Thu, 16 Jul 2020 23:55:35 +0200")

Hi Phil,

thanks for the review.

Phil Sutter <phil@nwl.cc> writes:

> Hi,
>
> On Wed, Jul 15, 2020 at 08:51:52AM +0200, Giuseppe Scrivano wrote:
>> allow users to override at runtime the lock file to use through the
>> XTABLES_LOCKFILE environment variable.
>> 
>> It allows using iptables from a network namespace owned by an user
>> that has no write access to XT_LOCK_NAME (by default under /run), and
>> without setting up a new mount namespace.
>
> This sentence appears overly complicated to me. Isn't the problem just
> that XT_LOCK_NAME may not be writeable? That "user that has no write
> access" is typically root anyway as iptables doesn't support being
> called by non-privileged UIDs.

I'll rephrase it but it is really about the user not having access to the
lock file.

Without involving user namespaces, a simple reproducer for the issue can be:

$ caps="cap_net_admin,cap_net_raw,cap_setpcap,cap_setuid,cap_setgid"
$ capsh --caps="$caps"+eip  --keep=1 --gid=1000 --uid=1000  \
        --addamb="$caps" \
        -- -c "iptables -F ..."

iptables seems to work fine even if the user is not running as root, as
long as enough capabilities are granted.


>> $ XTABLES_LOCKFILE=/tmp/xtables unshare -rn iptables ...
>> 
>> Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
>> ---
>>  iptables/xshared.c | 7 ++++++-
>>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> Could you please update the man page as well? Unless you clarify why
> this should be a hidden feature, of course. :)

sure, I'll send a v3 shortly.

Giuseppe


      reply	other threads:[~2020-07-17  8:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-15  6:51 [iptables PATCH v2] iptables: accept lock file name at runtime Giuseppe Scrivano
2020-07-16 21:55 ` Phil Sutter
2020-07-17  8:18   ` Giuseppe Scrivano [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=874kq6o8q1.fsf@redhat.com \
    --to=gscrivan@redhat.com \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=phil@nwl.cc \
    /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).