Skip to content

dmesg: allow dmesg_t access to init script stream sockets#1137

Merged
pebenito merged 1 commit into
SELinuxProject:mainfrom
sasikuma-qti:main
Jun 3, 2026
Merged

dmesg: allow dmesg_t access to init script stream sockets#1137
pebenito merged 1 commit into
SELinuxProject:mainfrom
sasikuma-qti:main

Conversation

@sasikuma-qti
Copy link
Copy Markdown
Contributor

No description provided.

@thesamesam
Copy link
Copy Markdown
Contributor

What socket exactly is it accessing, and what configuration do you need for it to do that? I haven't observed this and I'm curious as to what it is (this kind of information is very useful when debugging things way down the line too).

@GargiQcom
Copy link
Copy Markdown
Contributor

Command executed from adb shell: adb shell dmesg

Following denials are seen:

`type=AVC msg=audit(1773565011.851:411): avc: denied { ioctl } for pid=4782 comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973 ioctlcmd=0x542a scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0 tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:412): avc: denied { getattr } for pid=4782 comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973 scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0 tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:410): avc: denied { read write } for pid=4782 comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973 scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0 tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:411): avc: denied { ioctl } for pid=4782 comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973 ioctlcmd=0x542a scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0 tclass=unix_stream_socket permissive=1`

@thesamesam
Copy link
Copy Markdown
Contributor

That makes much more sense, thank you! Please include that in the commit message.

@sasikuma-qti
Copy link
Copy Markdown
Contributor Author

That makes much more sense, thank you! Please include that in the commit message.

Updated commit message with the denials.

@thesamesam
Copy link
Copy Markdown
Contributor

Please also include that it was adb shell dmesg too. it's very puzzling otherwise.

@sasikuma-qti
Copy link
Copy Markdown
Contributor Author

Please also include that it was adb shell dmesg too. it's very puzzling otherwise.

Updated the commit message.

@sasikuma-qti
Copy link
Copy Markdown
Contributor Author

@pebenito / @yizhao1 to review further.

@sasikuma-qti
Copy link
Copy Markdown
Contributor Author

@pebenito / @yizhao1 - Gentle reminder. Can you please review this change at the earliest.

@thesamesam
Copy link
Copy Markdown
Contributor

It was a long weekend in the US and UK and it's only been 2 days since your last ping. I'd personally find that excessive on the projects I'm a reviewer for.

sasikuma-qti added a commit to sasikuma-qti/meta-qcom-distro that referenced this pull request May 28, 2026
dmesg was generating AVC denials when interacting with an init-script-owned
UNIX stream socket for operations such as read, write, ioctl, and getattr on
performing `adb shell dmesg`.

Denials:
type=AVC msg=audit(1773565011.851:411): avc: denied { ioctl } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973 ioctlcmd=0x542a
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:412): avc: denied { getattr } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:410): avc: denied { read write } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:411): avc: denied { ioctl } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973 ioctlcmd=0x542a
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

Grant the expected socket access for dmesg_t resolving the AVC denials.

Upstream-Status: Pending [SELinuxProject/refpolicy#1137]

Signed-off-by: Sasi Kumar Maddineni <sasikuma@qti.qualcomm.com>
sasikuma-qti added a commit to sasikuma-qti/meta-qcom-distro that referenced this pull request May 28, 2026
dmesg was generating AVC denials when interacting with an init-script-owned
UNIX stream socket for operations such as read, write, ioctl, and getattr on
performing `adb shell dmesg`.

Denials:
type=AVC msg=audit(1773565011.851:411): avc: denied { ioctl } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973 ioctlcmd=0x542a
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:412): avc: denied { getattr } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:410): avc: denied { read write } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:411): avc: denied { ioctl } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973 ioctlcmd=0x542a
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

Grant the expected socket access for dmesg_t resolving the AVC denials.

Upstream-Status: Pending [SELinuxProject/refpolicy#1137]

Signed-off-by: Sasi Kumar Maddineni <sasikuma@qti.qualcomm.com>
sasikuma-qti added a commit to sasikuma-qti/meta-qcom-distro that referenced this pull request May 29, 2026
dmesg was generating AVC denials when interacting with an init-script-owned
UNIX stream socket for operations such as read, write, ioctl, and getattr on
performing `adb shell dmesg`.

Denials:
type=AVC msg=audit(1773565011.851:411): avc: denied { ioctl } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973 ioctlcmd=0x542a
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:412): avc: denied { getattr } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:410): avc: denied { read write } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:411): avc: denied { ioctl } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973 ioctlcmd=0x542a
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

Grant the expected socket access for dmesg_t resolving the AVC denials.

Upstream-Status: Submitted [SELinuxProject/refpolicy#1137]

Signed-off-by: Sasi Kumar Maddineni <sasikuma@qti.qualcomm.com>
sasikuma-qti added a commit to sasikuma-qti/meta-qcom-distro that referenced this pull request May 29, 2026
dmesg was generating AVC denials when interacting with an init-script-owned
UNIX stream socket for operations such as read, write, ioctl, and getattr on
performing `adb shell dmesg`.

Denials:
type=AVC msg=audit(1773565011.851:411): avc: denied { ioctl } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973 ioctlcmd=0x542a
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:412): avc: denied { getattr } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:410): avc: denied { read write } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:411): avc: denied { ioctl } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973 ioctlcmd=0x542a
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

Grant the expected socket access for dmesg_t resolving the AVC denials.

Upstream-Status: Submitted [SELinuxProject/refpolicy#1137]

Signed-off-by: Sasi Kumar Maddineni <sasikuma@qti.qualcomm.com>
sasikuma-qti added a commit to sasikuma-qti/meta-qcom-distro that referenced this pull request May 29, 2026
dmesg was generating AVC denials when interacting with an init-script-owned
UNIX stream socket for operations such as read, write, ioctl, and getattr on
performing `adb shell dmesg`.

Denials:
type=AVC msg=audit(1773565011.851:411): avc: denied { ioctl } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973 ioctlcmd=0x542a
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:412): avc: denied { getattr } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:410): avc: denied { read write } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:411): avc: denied { ioctl } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973 ioctlcmd=0x542a
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

Grant the expected socket access for dmesg_t resolving the AVC denials.

Upstream-Status: Submitted [SELinuxProject/refpolicy#1137]

Signed-off-by: Sasi Kumar Maddineni <sasikuma@qti.qualcomm.com>
Comment thread policy/modules/admin/dmesg.te Outdated
@WavyEbuilder
Copy link
Copy Markdown
Contributor

As per my comments on the pipewire patch, I don't think this is correct. adb shell is clearly interactive, but for some reason is initrc_t? Which doesn't make sense. I would rather prefer that we add a domain for adb_shell_t and wire that up properly and run in a login domain than doing this, which comes off as a bit of a hack to me. I suspect that this will extent over to various policy modules too, which is not desirable as the ability to talk to unconfined, highly privileged initrc_t processes opens up quite a bit of attack surface.

@sasikuma-qti
Copy link
Copy Markdown
Contributor Author

As per my comments on the pipewire patch, I don't think this is correct. adb shell is clearly interactive, but for some reason is initrc_t? Which doesn't make sense. I would rather prefer that we add a domain for adb_shell_t and wire that up properly and run in a login domain than doing this, which comes off as a bit of a hack to me. I suspect that this will extent over to various policy modules too, which is not desirable as the ability to talk to unconfined, highly privileged initrc_t processes opens up quite a bit of attack surface.

Yes, it will extend to many other policy modules which i am not sure on how to get this validated and reduce the ripple effort of creating a new domain for adb.

dmesg was generating AVC denials when interacting with an init-script-owned
UNIX stream socket for operations such as read, write, ioctl, and getattr on
performing `adb shell dmesg`.

Denials:
type=AVC msg=audit(1773565011.851:411): avc: denied { ioctl } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973 ioctlcmd=0x542a
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:412): avc: denied { getattr } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:410): avc: denied { read write } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

type=AVC msg=audit(1773565011.851:411): avc: denied { ioctl } for pid=4782
comm="dmesg" path="socket:[764973]" dev="sockfs" ino=764973 ioctlcmd=0x542a
scontext=system_u:system_r:dmesg_t:s0 tcontext=system_u:system_r:initrc_t:s0
tclass=unix_stream_socket permissive=1

Grant the expected socket access for dmesg_t resolving the AVC denials.

Signed-off-by: Sasi Kumar Maddineni <quic_sasikuma@quicinc.com>
@pebenito pebenito merged commit ce090e2 into SELinuxProject:main Jun 3, 2026
118 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants