Skip to content

Commit

Permalink
i/prompting/constraints: map get-attr and set-attr to read and write (c…
Browse files Browse the repository at this point in the history
…anonical#14142)

* i/prompting/constraints: map get-attr and set-attr to read and write for home interface

Signed-off-by: Oliver Calder <[email protected]>

* s/apparmor/notify: fix comments for AA_MAY_SETATTR and AA_MAY_GETATTR

The `AA_MAY_SETATTR` and `AA_MAY_GETATTR` permissions are checked by the
kernel, and are mapped to by `w` and `r` respectively. These permissions
are not exposed to the user in policy, but they can be included in
notifications from the kernel.

Signed-off-by: Oliver Calder <[email protected]>

---------

Signed-off-by: Oliver Calder <[email protected]>
  • Loading branch information
olivercalder authored Jul 15, 2024
1 parent fc53358 commit 20a6539
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions interfaces/prompting/constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ var (
// and if it does not, it should be interpreted as AA_MAY_READ.
interfaceFilePermissionsMaps = map[string]map[string]notify.FilePermission{
"home": {
"read": notify.AA_MAY_READ,
"write": notify.AA_MAY_WRITE | notify.AA_MAY_APPEND | notify.AA_MAY_CREATE | notify.AA_MAY_DELETE | notify.AA_MAY_RENAME | notify.AA_MAY_CHMOD | notify.AA_MAY_LOCK | notify.AA_MAY_LINK,
"read": notify.AA_MAY_READ | notify.AA_MAY_GETATTR,
"write": notify.AA_MAY_WRITE | notify.AA_MAY_APPEND | notify.AA_MAY_CREATE | notify.AA_MAY_DELETE | notify.AA_MAY_RENAME | notify.AA_MAY_SETATTR | notify.AA_MAY_CHMOD | notify.AA_MAY_LOCK | notify.AA_MAY_LINK,
"execute": notify.AA_MAY_EXEC | notify.AA_EXEC_MMAP,
},
}
Expand Down
10 changes: 5 additions & 5 deletions interfaces/prompting/constraints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ func (s *constraintsSuite) TestAbstractPermissionsFromAppArmorPermissionsUnhappy
},
{
"home",
notify.AA_MAY_GETATTR | notify.AA_MAY_READ,
notify.AA_MAY_GETCRED | notify.AA_MAY_READ,
"cannot map AppArmor permission to abstract permission for the home interface.*",
},
}
Expand All @@ -485,12 +485,12 @@ func (s *constraintsSuite) TestAbstractPermissionsToAppArmorPermissionsHappy(c *
{
"home",
[]string{"read"},
notify.AA_MAY_OPEN | notify.AA_MAY_READ,
notify.AA_MAY_OPEN | notify.AA_MAY_READ | notify.AA_MAY_GETATTR,
},
{
"home",
[]string{"write"},
notify.AA_MAY_OPEN | notify.AA_MAY_WRITE | notify.AA_MAY_APPEND | notify.AA_MAY_CREATE | notify.AA_MAY_DELETE | notify.AA_MAY_RENAME | notify.AA_MAY_CHMOD | notify.AA_MAY_LOCK | notify.AA_MAY_LINK,
notify.AA_MAY_OPEN | notify.AA_MAY_WRITE | notify.AA_MAY_APPEND | notify.AA_MAY_CREATE | notify.AA_MAY_DELETE | notify.AA_MAY_RENAME | notify.AA_MAY_SETATTR | notify.AA_MAY_CHMOD | notify.AA_MAY_LOCK | notify.AA_MAY_LINK,
},
{
"home",
Expand All @@ -500,12 +500,12 @@ func (s *constraintsSuite) TestAbstractPermissionsToAppArmorPermissionsHappy(c *
{
"home",
[]string{"read", "execute"},
notify.AA_MAY_OPEN | notify.AA_MAY_READ | notify.AA_MAY_EXEC | notify.AA_EXEC_MMAP,
notify.AA_MAY_OPEN | notify.AA_MAY_READ | notify.AA_MAY_GETATTR | notify.AA_MAY_EXEC | notify.AA_EXEC_MMAP,
},
{
"home",
[]string{"execute", "write", "read"},
notify.AA_MAY_OPEN | notify.AA_MAY_READ | notify.AA_MAY_EXEC | notify.AA_EXEC_MMAP | notify.AA_MAY_WRITE | notify.AA_MAY_APPEND | notify.AA_MAY_CREATE | notify.AA_MAY_DELETE | notify.AA_MAY_RENAME | notify.AA_MAY_CHMOD | notify.AA_MAY_LOCK | notify.AA_MAY_LINK,
notify.AA_MAY_OPEN | notify.AA_MAY_READ | notify.AA_MAY_GETATTR | notify.AA_MAY_EXEC | notify.AA_EXEC_MMAP | notify.AA_MAY_WRITE | notify.AA_MAY_APPEND | notify.AA_MAY_CREATE | notify.AA_MAY_DELETE | notify.AA_MAY_RENAME | notify.AA_MAY_SETATTR | notify.AA_MAY_CHMOD | notify.AA_MAY_LOCK | notify.AA_MAY_LINK,
},
}
for _, testCase := range cases {
Expand Down
4 changes: 2 additions & 2 deletions sandbox/apparmor/notify/permission.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ const (
AA_MAY_OPEN
// AA_MAY_RENAME implies that a process may rename a file.
AA_MAY_RENAME
// AA_MAY_SETATTR is not checked by the kernel.
// AA_MAY_SETATTR implies that a process may modify file attributes.
AA_MAY_SETATTR
// AA_MAY_GETATTR is not checked by the kernel.
// AA_MAY_GETATTR implies that a process may read file attributes.
AA_MAY_GETATTR
// AA_MAY_SETCRED is not used in the kernel.
AA_MAY_SETCRED
Expand Down

0 comments on commit 20a6539

Please sign in to comment.