SELinux-Refpolicy Archive on lore.kernel.org
 help / color / Atom feed
From: Laurent Bigonville <bigon@debian.org>
To: Nicolas Iooss <nicolas.iooss@m4x.org>, selinux-refpolicy@vger.kernel.org
Subject: Re: Permissions in the udevadm_t domain
Date: Mon, 9 Sep 2019 11:18:51 +0200
Message-ID: <9906138d-4c2e-b300-755f-b65629841836@debian.org> (raw)
In-Reply-To: <CAJfZ7=nTK1uO0j7wbevyitrNv_1RYyLpgzMPWjJkM3Mzpcg7ag@mail.gmail.com>

On 7/09/19 15:14, Nicolas Iooss wrote:
> [Adding selinux-refpolicy@vger.kernel.org, which is better suited for
> questions related to refpolicy]
>
> On Sat, Sep 7, 2019 at 12:19 PM Laurent Bigonville <bigon@debian.org> wrote:
> [...]
>> But when
>> looking at the current policy code I'm seeing that udevadm is allowed to
>> delete files/directory/.. in /var/run and I'm wondering why. I've never
>> seen this happening during my (limited) test, an idea?
> Which policy? On my test system based on a lightly-patched refpolicy, I have:
>
> # sesearch -A -s udevadm_t -t var_run_t
> allow udevadm_t var_run_t:dir { getattr open search };
> allow udevadm_t var_run_t:lnk_file { getattr read };

It's the refpolicy, but I meant udev_var_run_t (/var/run/udev) rather 
than var_run_t

# sesearch -A -s udevadm_t -t udev_var_run_t
allow udevadm_t udev_var_run_t:dir { getattr ioctl lock open read 
remove_name rmdir search write };
allow udevadm_t udev_var_run_t:file { getattr unlink };
allow udevadm_t udev_var_run_t:lnk_file { getattr unlink };
allow udevadm_t udev_var_run_t:sock_file { append getattr open write };

>
>> For the later, it seems that the kernel the mode to 400 on some files in
>> /sys (ie. --w------- 1 root root 4096 sep  5 17:06
>> /sys/module/snd_hda_codec_generic/uevent) looking at the code it seems
>> that udev is ready to handle EACCES already, so I was wondering, should
>> we just allow dac_read_search or don't audit dac_read_search (and
>> dac_override as well then)?
> For the record, even with dac_read_search, opening this file fails
> with EACCES, because the kernel did not implement show() on this sysfs
> file (cf. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/module.c?h=v5.2#n1204
> and kernfs_fop_open() in fs/kernfs/file.c). More precisely, openat()
> returns EACCES because kernfs_fop_open() returns this error code when
> trying to open a write-only file for reading. Unfortunately this check
> happens after the capability checks, which is why you got the denials
> for dac_override and dac_read_search.
>
> I do not have an opinion about allowing dac_read_search vs.
> dontaudit-ing dac_read_search and dac_override.
Grift was saying that "the cap_dac_read_search could maybe be 
dontaudited, but then cap_dac_override would have to be dontaudited as 
well. cap_dac_read_search would also be triggered when you run `sudo 
udevadm ...` where pwd or/and oldpwd is ~"

So I guess I will just allow it


      reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <6d208e36-cf81-7fde-2b57-fddf4a529f52@debian.org>
2019-09-07 13:14 ` Nicolas Iooss
2019-09-09  9:18   ` Laurent Bigonville [this message]

Reply instructions:

You may reply publically 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=9906138d-4c2e-b300-755f-b65629841836@debian.org \
    --to=bigon@debian.org \
    --cc=nicolas.iooss@m4x.org \
    --cc=selinux-refpolicy@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-Refpolicy Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/selinux-refpolicy/0 selinux-refpolicy/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-refpolicy selinux-refpolicy/ https://lore.kernel.org/selinux-refpolicy \
		selinux-refpolicy@vger.kernel.org selinux-refpolicy@archiver.kernel.org
	public-inbox-index selinux-refpolicy


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


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