Git Product home page Git Product logo

smack-next's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

smack-next's Issues

SMACK64TRANSMUTE not working with Linux OpenZFS

Distro: Gentoo amd64/hardened/17.1
Kernel: 5.4.97 (All SMACK options enabled)
zfs: 0.8.6

I started working with SMACK a couple days ago and I ran across a bug tonight with the transmute ability.

I ran the procedure found here: https://security.stackexchange.com/questions/141929/linux-kernel-security-module-smack-transmutation-example

This is the log from my test runs:

vm-gentoo-smack / # mkdir /tmp/test   <==(this is a zfs filesystem)
vm-gentoo-smack / # cd /tmp/test
vm-gentoo-smack /tmp/test # chsmack -a dir_label .
vm-gentoo-smack /tmp/test # chsmack .
. access="dir_label"

vm-gentoo-smack /tmp/test # echo "process_label dir_label wx" | smackload
vm-gentoo-smack /tmp/test # echo process_label >/proc/self/attr/current
vm-gentoo-smack /tmp/test # cat /proc/self/attr/current
process_label

vm-gentoo-smack /tmp/test # touch file1
vm-gentoo-smack /tmp/test # mkdir dir1
vm-gentoo-smack /tmp/test # chsmack
dir1 access="_"
file1 access="_"
**** As you can see, it is being set to "floor" instead of "process_label"

**** Now I'll test transmute


vm-gentoo-smack /tmp/test # rm file*
vm-gentoo-smack /tmp/test # rmdir dir*

vm-gentoo-smack /tmp/test # chsmack -t .
vm-gentoo-smack /tmp/test # chsmack .
. access="dir_label" transmute="TRUE"

vm-gentoo-smack /tmp/test # echo "process_label dir_label wxt" | smackload
vm-gentoo-smack /tmp/test # touch file2
vm-gentoo-smack /tmp/test # mkdir dir2
vm-gentoo-smack /tmp/test # chsmack
./dir1 access="_"
./dir2 access="_"
./file1 access="_"
./file2 access="_"
**** As you can see, it is still being set to "floor" instead of transmutating

**** Thinking this may be a ZFS issue, I ran the same tests on a new tmpfs filesystem

vm-gentoo-smack /tmp/test # cd /var/tmp
vm-gentoo-smack /var/tmp # mkdir tmpfs
vm-gentoo-smack /var/tmp # mount -ttmpfs tmpfs tmpfs
vm-gentoo-smack /var/tmp # cd tmpfs
vm-gentoo-smack /var/tmp/tmpfs # df -h .
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           4.9G     0  4.9G   0% /var/tmp/tmpfs

vm-gentoo-smack /var/tmp/tmpfs # mkdir test
vm-gentoo-smack /var/tmp/tmpfs # chsmack -a dir_label test
vm-gentoo-smack /var/tmp/tmpfs # chsmack
./test access="dir_label"

vm-gentoo-smack /var/tmp/tmpfs # cd test
vm-gentoo-smack /var/tmp/tmpfs # echo "process_label dir_label wx" | smackload
vm-gentoo-smack /var/tmp/tmpfs/test # touch file1
vm-gentoo-smack /var/tmp/tmpfs/test # mkdir dir1
vm-gentoo-smack /var/tmp/tmpfs/test # chsmack
./dir1 access="process_label"
./file1 access="process_label"
**** Now it is properly inheriting the "process_label"

**** Test transmutation now

vm-gentoo-smack /var/tmp/tmpfs/test # chsmack -t .
vm-gentoo-smack /var/tmp/tmpfs/test # echo "process_label dir_label wxt" | smackload
vm-gentoo-smack /var/tmp/tmpfs/test # touch file2
vm-gentoo-smack /var/tmp/tmpfs/test # mkdir dir2
vm-gentoo-smack /var/tmp/tmpfs/test # chsmack
./dir2 access="dir_label" transmute="TRUE"
./file2 access="process_label"
**** Transmutation is properly working as well

**** This got me thinking about ZFS and the 3 different settings for 'xattr'
**** In the first case above, it is set to: 'xattr=sa'
**** For this test, I created a new zfs filesystem '/tmp2' and set 'xattr=on'

vm-gentoo-smack /var/tmp/tmpfs/test # cd /
vm-gentoo-smack / # zfs create -oxattr=on zpool/ROOT/tmp2
vm-gentoo-smack / # findmnt tmp2
TARGET SOURCE          FSTYPE OPTIONS
/tmp2  zpool/ROOT/tmp2 zfs    rw,noatime,xattr,posixacl

vm-gentoo-smack / # cd tmp2
vm-gentoo-smack /tmp2 # echo "process_label dir_label wx" | smackload
vm-gentoo-smack /tmp2 # mkdir test
vm-gentoo-smack /tmp2 # cd test
vm-gentoo-smack /tmp2/test # chsmack -a dir_label .
vm-gentoo-smack /tmp2/test # chsmack
vm-gentoo-smack /tmp2/test # chsmack .
. access="dir_label"

vm-gentoo-smack /tmp2/test # touch file1
vm-gentoo-smack /tmp2/test # mkdir dir1
vm-gentoo-smack /tmp2/test # chsmack
./dir1 access="_"
./file1 access="_"

vm-gentoo-smack /tmp2/test # chsmack -t .
vm-gentoo-smack /tmp2/test # echo "process_label dir_label wxt" | smackload
vm-gentoo-smack /tmp2/test # chsmack .
. access="dir_label" transmute="TRUE"

vm-gentoo-smack /tmp2/test # touch file2
vm-gentoo-smack /tmp2/test # mkdir dir2
vm-gentoo-smack /tmp2/test # chsmack .
. access="dir_label" transmute="TRUE"

vm-gentoo-smack /tmp2/test # chsmack
./dir1 access="_"
./dir2 access="_"
./file2 access="_"
./file1 access="_"
****  Same behavior as the first test case above

I looked through the source code, especially around the 'MAY_TRANSMUTE' tests, but nothing jumped out at me that may point to some sort of ZFS weirdness.

Please let me know if there is something I may have overlooked. Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.