[Bug 1065388] New: apparmor is breaking tool file in lessopen.sh
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388 Bug ID: 1065388 Summary: apparmor is breaking tool file in lessopen.sh Classification: openSUSE Product: openSUSE Tumbleweed Version: Current Hardware: All OS: openSUSE Factory Status: NEW Severity: Major Priority: P5 - None Component: Basesystem Assignee: bnc-team-screening@forge.provo.novell.com Reporter: werner@suse.com QA Contact: qa-bugs@suse.de Found By: --- Blocker: --- Tracing lessopen.sh with export LESS_ADVANCED_PREPROCESSOR=yes shows [...] ++ file -L ./less.1 + type='./less.1: writable, regular file, no read permission' but it should be noether less/less-487> file -L ./less.1 ./less.1: troff or preprocessor input, ASCII text in /etc/apparmor.d/usr.bin.lessopen.sh I found /usr/bin/file rix, but no rule for /usr/bin/file its self! All tools listed in /etc/apparmor.d/usr.bin.lessopen.sh should be able to read files as otherwise nothings goes. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
Dr. Werner Fink
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c1
--- Comment #1 from Dr. Werner Fink
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c2
Christian Boltz
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c3
--- Comment #3 from Dr. Werner Fink
Can you please - switch the profile into complain/learning mode: aa-complain /etc/apparmor.d/usr.bin.lessopen.sh - repeat the previously forbidden/failing things - complain mode means to allow everything and log what would be denied, so everything should work now - attach your /var/log/audit/audit.log (if you don't have auditd running, syslog, journal or dmesg output are alternatives - grep for "apparmor") - finally switch the profile back to enforce mode aa-enforce /etc/apparmor.d/usr.bin.lessopen.sh
As an alternative, you can also run aa-logprof to update the profile yourself. In this case, please tell me which rules you needed to add.
Here we are -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c4
--- Comment #4 from Dr. Werner Fink
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c5
--- Comment #5 from Dr. Werner Fink
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c6
--- Comment #6 from Christian Boltz
in /etc/apparmor.d/usr.bin.lessopen.sh I found
/usr/bin/file rix,
but no rule for /usr/bin/file its self!
The "ix" in the rule means "inherit", so /usr/bin/file will run under the same profile as lessopen.sh. (In reply to Dr. Werner Fink from comment #5)
type=AVC msg=audit(1509089056.461:3242): apparmor="DENIED" operation="sendmsg" profile="/usr/bin/lessopen.sh" pid=11880 comm="file" lport=911 family="inet" sock_type="dgram" protocol=17
... Hmmm ... what does this mean?
Let me guess - you tried to view a file on a NFS share? Ideally this should be hidden in the kernel so that the application doesn't see the network access (because that's on the filesystem level). I know there's an open bugreport about this - I'll check with upstream if/when we can expect a kernel patch. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c7
--- Comment #7 from Dr. Werner Fink
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c8
--- Comment #8 from Dr. Werner Fink
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c9
--- Comment #9 from Dr. Werner Fink
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c10
--- Comment #10 from Dr. Werner Fink
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c11
--- Comment #11 from Dr. Werner Fink
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c12
--- Comment #12 from Dr. Werner Fink
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c13
--- Comment #13 from Dr. Werner Fink
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c14
--- Comment #14 from Christian Boltz
with
network inet dgram, network inet stream, network unix dgram, network unix stream,
the file command returns the corect identifier in both user abd toot case
The two "network unix" streams are only needed until AppArmor 2.11.1 reaches Tumbleweed - there was a a bugfix in apparmor_parser which only showed up in combination with kernel 4.14 rc2 and newer. (Dominique just accepted the staging project, so it should be in one of the next snapshots.) The two "network inet" rules are probably related to NFS - I'm still waiting for an answer from upstream. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c15
--- Comment #15 from Christian Boltz
Any idea which of the "rm" commands in lessopen.sh did this? Checking your (root) bash history for that timestamp might should which file you wanted to
s/might should/should show/
The two "network unix" streams are only needed until AppArmor 2.11.1 reaches Tumbleweed - there was a a bugfix in apparmor_parser which only showed up in
s/only showed up/is only needed/ -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c16
--- Comment #16 from Dr. Werner Fink
... operation="exec" profile="/usr/bin/lessopen.sh" name="/usr/bin/id" pid=32146 comm="lessopen.sh" requested_mask="x" denied_mask="x" fsuid=223 ouid=0
so lessopen.sh wants to execute "id" - but I don't see any "id" call in my Tumbleweed lessopen.sh. Do you have a different lessopen.sh, or am I just blind? (Allowing to run "id" doesn't look like a serious security issue (especially because the profile already allows reading everything including /proc/self/status) - but of course it should only be allowed if it's really needed.)
This id call was added for debugging only as I've checked out which which id for lessopen.sh is used if less is used by root
And finally, there is (before you switched the profile into complain mode):
type=AVC msg=audit(1509081678.576:3010): apparmor="DENIED" operation="unlink" profile="/usr/bin/lessopen.sh" name="/usr/bin/lessopen.sh" pid=30470 comm="rm" requested_mask="d" denied_mask="d" fsuid=0 ouid=0
So for some reason lessopen.sh tried to delete itsself (by calling "rm") this morning :-/ The exact time is: # date -d @1509081678 # the number after msg=audit is the unix timestamp Fr 27. Okt 07:21:18 CEST 2017
Bug in my test code, fixed
(In reply to Dr. Werner Fink from comment #9)
with
network inet dgram, network inet stream, network unix dgram, network unix stream,
the file command returns the corect identifier in both user abd toot case
The two "network unix" streams are only needed until AppArmor 2.11.1 reaches Tumbleweed - there was a a bugfix in apparmor_parser which only showed up in combination with kernel 4.14 rc2 and newer. (Dominique just accepted the staging project, so it should be in one of the next snapshots.)
The two "network inet" rules are probably related to NFS - I'm still waiting for an answer from upstream.
-- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c17
--- Comment #17 from Dr. Werner Fink
As you noticed, groff wants to execute several helper binaries: operation="exec" name="/usr/bin/eqn" comm="groff" operation="exec" name="/usr/bin/grotty" comm="groff" operation="exec" name="/usr/bin/pic" comm="groff" operation="exec" name="/usr/bin/soelim" comm="groff" operation="exec" name="/usr/bin/tbl" comm="groff" operation="exec" name="/usr/bin/troff" comm="groff"
That seems the perfect case or an abstraction .. that is that we migth think about a file gorff below /etc/apparmor.d/abstractions/ which includes those lines? Beside this the line /usr/bin/id mrix, should be removed as this was for debugging only:
All listed binaries somehow belong to groff (according to a quick look at their manpage), so that's fine and means to add the following rules to the profile:
/usr/bin/eqn mrix, /usr/bin/grotty mrix, /usr/bin/id mrix,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/bin/pic mrix, /usr/bin/soelim mrix, /usr/bin/tbl mrix, /usr/bin/troff mrix,
-- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c18
--- Comment #18 from Dr. Werner Fink
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c19
Alberto Planas Dominguez
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c20
Dr. Werner Fink
I filled bsc#1206957 where `less` complains about:
/usr/share/lmod/8.7.15/init/bash: line 57: /usr/bin/readlink: Permission denied /usr/share/lmod/8.7.15/init/bash: line 61: /usr/bin/expr: Permission denied /usr/share/lmod/8.7.15/init/bash: line 62: /usr/bin/basename: Permission denied
At the beginning I thought that this was related with lmod, but after checking the audit log I saw:
type=AVC msg=audit(1673254728.860:235): apparmor="DENIED" operation="exec" profile="/usr/bin/lessopen.sh" name="/usr/bin/readlink" pid=6441 comm="lessopen.sh" requested_mask="x" denied_mask="x" fsuid=1000 ouid=0 type=AVC msg=audit(1673254728.860:236): apparmor="DENIED" operation="exec" profile="/usr/bin/lessopen.sh" name="/usr/bin/expr" pid=6442 comm="lessopen.sh" requested_mask="x" denied_mask="x" fsuid=1000 ouid=0 type=AVC msg=audit(1673254728.860:237): apparmor="DENIED" operation="exec" profile="/usr/bin/lessopen.sh" name="/usr/bin/basename" pid=6443 comm="lessopen.sh" requested_mask="x" denied_mask="x" fsuid=1000 ouid=0
So I wonder if this will require some extension on the lessopen.sh profile?
That looks like a problem with usr merge -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c21
--- Comment #21 from Alberto Planas Dominguez
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c22
--- Comment #22 from Ludwig Nussel
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
Goldwyn Rodrigues
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c23
--- Comment #23 from Christian Boltz
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c24
--- Comment #24 from Dr. Werner Fink
Werner, since the proposed abstraction is quite old, can you please have a quick look at it if the list of helpers is still up-to-date before I finally submit it upstream?
Please replace the /usr/lib/groff/** with /usr/libexec/groff/** in the attachment https://bugzilla.opensuse.org/attachment.cgi?id=746246 -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c25
--- Comment #25 from Dr. Werner Fink
(In reply to Christian Boltz from comment #23)
Werner, since the proposed abstraction is quite old, can you please have a quick look at it if the list of helpers is still up-to-date before I finally submit it upstream?
Please replace the /usr/lib/groff/** with /usr/libexec/groff/** in the attachment https://bugzilla.opensuse.org/attachment.cgi?id=746246
-- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388
http://bugzilla.opensuse.org/show_bug.cgi?id=1065388#c27
--- Comment #27 from OBSbugzilla Bot
participants (2)
-
bugzilla_noreply@novell.com
-
bugzilla_noreply@suse.com