Commit 78fc6a9
smack: fix bug: invalid label of unix socket file
According to [1], the label of a UNIX domain socket (UDS)
file (i.e., the filesystem object representing the socket)
is not supposed to participate in Smack security.
To achieve this, [1] labels UDS files with "*"
in smack_d_instantiate().
Before [2], smack_d_instantiate() was responsible
for initializing Smack security for all inodes,
except ones under /proc
[2] imposed the sole responsibility for initializing
inode security for newly created filesystem objects
on smack_inode_init_security().
However, smack_inode_init_security() lacks some logic
present in smack_d_instantiate().
In particular, it does not label UDS files with "*".
This patch adds the missing labeling of UDS files
with "*" to smack_inode_init_security().
Labeling UDS files with "*" in smack_d_instantiate()
still works for stale UDS files that already exist on
disk. Stale UDS files are useless, but I keep labeling
them for consistency and maybe to make easier for user
to delete them.
Compared to [1], this version introduces the following
improvements:
* UDS file label is held inside inode only
and not saved to xattrs.
* relabeling UDS files (setxattr, removexattr, etc.)
is blocked.
[1] 2010-11-24 Casey Schaufler
commit b4e0d5f ("Smack: UDS revision")
[2] 2023-11-16 roberto.sassu
Fixes: e63d86b ("smack: Initialize the in-memory inode in smack_inode_init_security()")
Link: https://lore.kernel.org/linux-security-module/20231116090125.187209-5-roberto.sassu@huaweicloud.com/
Signed-off-by: Konstantin Andreev <andreev@swemel.ru>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>1 parent 69204f6 commit 78fc6a9
2 files changed
Lines changed: 49 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
696 | 696 | | |
697 | 697 | | |
698 | 698 | | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
699 | 704 | | |
700 | 705 | | |
701 | 706 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1020 | 1020 | | |
1021 | 1021 | | |
1022 | 1022 | | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
1023 | 1033 | | |
1024 | 1034 | | |
1025 | 1035 | | |
| |||
1056 | 1066 | | |
1057 | 1067 | | |
1058 | 1068 | | |
1059 | | - | |
1060 | | - | |
1061 | | - | |
1062 | | - | |
1063 | | - | |
| 1069 | + | |
| 1070 | + | |
1064 | 1071 | | |
1065 | 1072 | | |
1066 | | - | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
1067 | 1079 | | |
1068 | 1080 | | |
1069 | 1081 | | |
| |||
1337 | 1349 | | |
1338 | 1350 | | |
1339 | 1351 | | |
| 1352 | + | |
1340 | 1353 | | |
1341 | 1354 | | |
1342 | 1355 | | |
1343 | 1356 | | |
1344 | | - | |
1345 | | - | |
1346 | | - | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
1347 | 1369 | | |
1348 | 1370 | | |
1349 | 1371 | | |
| |||
1353 | 1375 | | |
1354 | 1376 | | |
1355 | 1377 | | |
1356 | | - | |
| 1378 | + | |
1357 | 1379 | | |
1358 | 1380 | | |
1359 | 1381 | | |
| |||
1484 | 1506 | | |
1485 | 1507 | | |
1486 | 1508 | | |
| 1509 | + | |
1487 | 1510 | | |
1488 | 1511 | | |
1489 | | - | |
1490 | | - | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
1491 | 1515 | | |
1492 | | - | |
| 1516 | + | |
| 1517 | + | |
1493 | 1518 | | |
1494 | 1519 | | |
1495 | 1520 | | |
| |||
3607 | 3632 | | |
3608 | 3633 | | |
3609 | 3634 | | |
3610 | | - | |
| 3635 | + | |
3611 | 3636 | | |
3612 | 3637 | | |
3613 | 3638 | | |
| |||
4872 | 4897 | | |
4873 | 4898 | | |
4874 | 4899 | | |
| 4900 | + | |
| 4901 | + | |
| 4902 | + | |
| 4903 | + | |
| 4904 | + | |
4875 | 4905 | | |
4876 | 4906 | | |
4877 | 4907 | | |
| |||
0 commit comments