Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 911146 - sec-policy/apparmor-profiles-3.1.4: zgrep profile causes permission denied in zgrep with app-alternatives/gzip
Summary: sec-policy/apparmor-profiles-3.1.4: zgrep profile causes permission denied in...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: The Gentoo Linux Hardened Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-07-24 16:28 UTC by Jonas Rakebrandt
Modified: 2025-01-27 21:58 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonas Rakebrandt 2023-07-24 16:28:49 UTC
Executing zgrep gives a "permission denied" error when running with apparmor enabled.
Logs show that apparmor denies execution of /usr/bin/pigz or /usr/bin/gzip-reference (depending on USE choice in app-alternatives/gzip) because the allowed /usr/bin/gzip is just a symlink to the alternatives.

Reproducible: Always

Steps to Reproduce:
1. Have an apparmor-enabled system
2. Try to use zgrep (e.g. zgrep HZ /proc/config.gz)
Actual Results:  
zgrep fails with "permission denied"

Expected Results:  
zgrep returns the results
Comment 1 Thomas Schneider 2023-09-06 14:31:04 UTC
Workaround:

# cat /etc/apparmor.d/local/zgrep
# Site-specific additions and overrides for 'zgrep'
/bin/gzip-reference Cx -> helper,
/bin/grep Cx -> helper

Depending on /usr merge or app-alternatives/gzip choice, adjust the paths as needed and reload the profile afterwards.
Comment 2 bpholman5 2025-01-27 21:58:05 UTC
Confirming this issue:

- using 1.13-r1
- this is observed on a merged-usr system
- installed from binhost


Reproducible: Always

Steps to Reproduce:
1. Start with a merged-usr system
2. Install gzip from a binhost
3. Attempt to zgrep a gzip archive (/proc/config.gz in my case)
Actual Results:  
```
# zgrep INOTIFY /proc/config.gz
/usr/sbin/zgrep: line 254: /usr/sbin/gzip: Permission denied
# ls -la /usr/sbin/zgrep
-rwxr-xr-x 1 root root 8204 Aug 18 18:07 /usr/sbin/zgrep
# ls -la /usr/sbin/gzip
lrwxrwxrwx 1 root root 14 Apr 16  2024 /usr/sbin/gzip -> gzip-reference
# ls -la /usr/sbin/gzip-reference
-rwxr-xr-x 1 root root 97352 Aug 18 18:07 /usr/sbin/gzip-reference
```

Expected Results:  
CONFIG_INOTIFY_USER=y

Similar to Thomas's workaround:
```
/usr/bin/gzip-reference Cx -> helper,
```

The current profile already contains grep in the apparmor profile so only adding gzip-reference is required.