SELinux Archive on lore.kernel.org
 help / color / Atom feed
From: Gionatan Danti <g.danti@assyoma.it>
To: Dominick Grift <dominick.grift@defensec.nl>
Cc: "Christian Göttsche" <cgzones@googlemail.com>, selinux@vger.kernel.org
Subject: Re: lnk_file read permission
Date: Fri, 31 Jul 2020 21:37:30 +0200
Message-ID: <bd08eef14271d6a6003bf6ba83ff1904@assyoma.it> (raw)
In-Reply-To: <9f363af014b8670267af982f9d4a6362@assyoma.it>

Il 2020-07-31 19:09 Gionatan Danti ha scritto:
> I did not know that systemd would, with specific settings, create a
> private mysql data dir.
> I would try the var_lib_t approach more widely.
> Thanks.

Mmm, it seems labeling the link as var_lib_t is not always sufficient.
Doing a mongodb test relocation from /var/lib/mongodb to /zzz/mongodb 
the service does not start, even if I can see the link having var_lib_t 
label:

# ls -alZ /var/lib/
...
lrwxrwxrwx. root    root    unconfined_u:object_r:var_lib_t:s0 mongodb 
-> /zzz/mongodb

Indeed, I can see the following in /var/log/audit:

type=AVC msg=audit(1596222151.576:253): avc:  denied  { read } for  
pid=4313 comm="mongod" name="mongodb" dev="dm-0" ino=33673444 
scontext=system_u:system_r:mongod_t:s0 
tcontext=unconfined_u:object_r:var_lib_t:s0 tclass=lnk_file permissive=0

Relabeling the synlink with its "native" label via restorecon -RF 
produce the following:

# ls -alZ /var/lib/
...
lrwxrwxrwx. root    root    system_u:object_r:mongod_var_lib_t:s0 
mongodb -> /zzz/mongodb

But the service again does not start, with the followin logs:

type=AVC msg=audit(1596222240.363:257): avc:  denied  { read } for  
pid=4344 comm="mongod" name="mongodb" dev="dm-0" ino=33673444 
scontext=system_u:system_r:mongod_t:s0 
tcontext=system_u:object_r:mongod_var_lib_t:s0 tclass=lnk_file 
permissive=0

What would be the best approach in this case? I know that one approach 
would be to use a bind mount, but I would like to avoid it because:
a) it has bad filesystem discoverably (you had to search for bind mount 
explicitly, while a symlink is visible even with a simple ls)
b) I need to setup a fcontext <<None>> for the actual dir which is 
bind-mounted (otherwise, a "restorecon -RF /zzz/" will cause issues, by 
relabeling any files with default_t)

I am open to suggestions...
Thanks.

-- 
Danti Gionatan
Supporto Tecnico
Assyoma S.r.l. - www.assyoma.it
email: g.danti@assyoma.it - info@assyoma.it
GPG public key ID: FF5F32A8

  reply index

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-31  9:57 Gionatan Danti
2020-07-31 13:12 ` Stephen Smalley
2020-07-31 16:56   ` Gionatan Danti
2020-07-31 16:25 ` Christian Göttsche
2020-07-31 16:53   ` Dominick Grift
2020-07-31 17:09     ` Gionatan Danti
2020-07-31 19:37       ` Gionatan Danti [this message]
2020-07-31 19:44         ` Dominick Grift
2020-07-31 19:49           ` Gionatan Danti
2020-07-31 17:00   ` Gionatan Danti
2020-07-31 17:45   ` Dominick Grift

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=bd08eef14271d6a6003bf6ba83ff1904@assyoma.it \
    --to=g.danti@assyoma.it \
    --cc=cgzones@googlemail.com \
    --cc=dominick.grift@defensec.nl \
    --cc=selinux@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

SELinux Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/selinux/0 selinux/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 selinux selinux/ https://lore.kernel.org/selinux \
		selinux@vger.kernel.org
	public-inbox-index selinux

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.selinux


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git