| 1 |
package internal |
| 2 |
|
| 3 |
import ( |
| 4 |
ll "github.com/landlock-lsm/go-landlock/landlock/syscall" |
| 5 |
) |
| 6 |
|
| 7 |
// DetectedABIVersion returns the Landlock ABI version supported by the |
| 8 |
// running kernel, after applying errata-based downgrades. |
| 9 |
// Returns 0 if Landlock is not supported by the kernel. |
| 10 |
func DetectedABIVersion() int { |
| 11 |
v, err := ll.LandlockGetABIVersion() |
| 12 |
if err != nil { |
| 13 |
return 0 |
| 14 |
} |
| 15 |
if v >= 6 { |
| 16 |
// Check that the signal scoping bug is fixed, |
| 17 |
// otherwise downgrade to v5. This should happen only |
| 18 |
// seldomly, as the bugfix was backported to newer |
| 19 |
// versions of the 6.12 LTS kernel. |
| 20 |
errata, err := ll.LandlockGetErrata() |
| 21 |
if err != nil { |
| 22 |
errata = 0 // pretend none fixed |
| 23 |
} |
| 24 |
if (errata & 0x2) == 0 { |
| 25 |
v = 5 |
| 26 |
} |
| 27 |
} |
| 28 |
if v < minimumRequiredABIVersion() { |
| 29 |
return 0 |
| 30 |
} |
| 31 |
return v |
| 32 |
} |