Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 36 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,42 @@
<!-- THIS IS AN AUTO-GENERATED FILE by ./tools/gendoc.sh. DO NOT EDIT MANUALLY -->
# Linux Kernel Configs for Popular Distros
![CI status](https://github.com/nyrahul/linux-kernel-configs/actions/workflows/ci-verify.yml/badge.svg)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/nyrahul/linux-kernel-configs?tab=readme-ov-file#contributions-welcome)

There is often a need to check a kernel config and other OS configuration to make a dev/design decision. The question often pops-up, does the popular distributions support the kernel config that the implementation expects? This is an attempt to answer that.

**My specific use-case**:
[KubeArmor](https://github.com/kubearmor/kubearmor) leverages LSMs (Linux Security Modules) and eBPF for in-kernel policy controls. We had to refer to kernel configs for making design/dev decisions regarding whether we can depend on a certain kernel primitive. The boot configs part of this repo helped in making an informed choice.
[KubeArmor](https://kubearmor.io/) leverages LSMs (Linux Security Modules) and eBPF for in-kernel policy controls. We had to refer to kernel configs for making design/dev decisions regarding whether we can depend on a certain kernel primitive. The boot configs part of this repo helped in making an informed choice.

> Note: The lists below are sorted based on kernel version number.


## Distribution Summary

Total Distros: 65

<table>
<tr><th> Kernel Major </th><th>Kernel Arch</th></tr>
<tr><td>

| Kernel Major Ver | Count |
|:----------------:|:-------:|
| >= 6.0 |17|
| >= 5.0 && < 6.0 |28|
| >= 4.0 && < 5.0: |17|
| < 4.0 |3|

</td><td>

| Kernel Arch | Count |
|:-----------:|:-------:|
| x86 |60|
| arm |4|
| powerpc |1|
| unknown |0|

</td></tr></table>

<details><summary><h2>Distribution Details</h2></summary><p>

| Distro | Arch | Kernel | Kernel Config | hostnamectl | os-release |
Expand Down Expand Up @@ -663,17 +691,18 @@ There is often a need to check a kernel config and other OS configuration to mak
<details>
<summary>Adding a new distro</summary>

Use following command to create a Distro/Kernel specific folder with the corresponding markdowns:
ssh/login to the target Linux machine and run:
```
curl -s https://raw.githubusercontent.com/nyrahul/linux-kernel-configs/main/lk-config-get.sh | bash -s
curl -s https://lkc.rjed.in/ | bash -s
```
if `curl` is not available, use `wget` ...
```
wget -q -O- https://raw.githubusercontent.com/nyrahul/linux-kernel-configs/main/lk-config-get.sh | bash -s
wget -q -O- https://lkc.rjed.in/ | bash -s
```
This will create a folder with the name of the distro.

1. Copy the folder to your github fork
2. Run `make`
1. Copy the folder to your `linux-kernel-configs` git repo.
2. Run `make`. This will update the `README.md` file with the distro you added.
3. Raise a PR

</details>
Expand All @@ -687,7 +716,7 @@ Composition means a set of kernel configuration options shown in the context of
To create a new composition:
1. Create a new composition file. Use [tools/compositions/lsm.yaml](tools/compositions/lsm.yaml) as ref.
2. Do a `make`
3. Check if the composition is reflected in the [README.md](README.md)
3. Check if the composition is reflected in the [README.md](README.md).
4. Raise a PR with the changes

</details>
88 changes: 88 additions & 0 deletions tools/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/usr/bin/env bash

YQ=`dirname $0`/yq # Use yq.exe on windows
TMP_OSREL=temporary_osrel.txt
TMP_HOSTCTL=temporary_hostnamectl.txt
TMP_BOOTCFG=temporary_bootconfig.txt

statusline()
{
ORANGE="\033[0;33m"
RED="\033[0;31m"
GREEN="\033[0;32m"
CYAN="\033[0;36m"
NC="\033[0m" # No Color

status=$1
shift
[[ $status == AOK ]] || [[ $status == "0" ]] &&
{
printf "[${GREEN}OK${NC}] $*\n"
return
}
[[ $status == WARN ]] &&
{
printf "[${ORANGE}WARN${NC}] $*\n"
return
}
[[ $status == WAIT ]] &&
{
printf "[${CYAN}..${NC}] $*\r"
return
}
printf "[${RED}FAIL${NC}] $*\n"
exit 1
}

getDistro()
{
if [ -f "$TMP_OSREL" ]; then
. $TMP_OSREL
DISTRO_NAME=$PRETTY_NAME
return
fi
DISTRO_NAME=`grep "Operating System:" $TMP_HOSTCTL | sed 's/.*: //g'`
}

getArchKrnVer()
{
STR=`grep "^#.* Linux.*Kernel Configuration" $TMP_BOOTCFG | head -1 | awk '{print $2,$3}'`
ARCH=${STR/ */}
ARCH=${ARCH/*\//}
KRNVER=${STR/* /}
# KRNVER=${KRNVER/-*/}
}

forEveryPlatform()
{
[[ "$1" == "" ]] && statusline ERR "invalid use of forEveryPlatform"
while read line; do
rm -f $TMP_OSREL $TMP_HOSTCTL $TMP_BOOTCFG
line=`echo $line | sed 's/|/\//g'`
PLATFORM="$line"
PLATFORM_PATH="${line// /%20}"
BOOTCONFIG="$line/bootconfig.md"
[[ ! -f "$BOOTCONFIG" ]] && continue
awk '/\`\`\`/,/\`\`\`/' "$BOOTCONFIG" | grep -v "\`\`\`" > $TMP_BOOTCFG

HOSTNAMECTL="$line/hostnamectl.md"
[[ -f "$HOSTNAMECTL" ]] && awk '/\`\`\`/,/\`\`\`/' "$HOSTNAMECTL" | grep -v "\`\`\`" > $TMP_HOSTCTL
OSREL="$line/os-release.md"
[[ -f "$OSREL" ]] && awk '/\`\`\`/,/\`\`\`/' "$OSREL" | grep -v "\`\`\`" > $TMP_OSREL
[[ ! -f "$TMP_OSREL" ]] && [[ ! -f "$TMP_HOSTCTL" ]] &&
statusline WARN "neither os-release nor hostnamectl found for [$PLATFORM]" && continue

getDistro
getArchKrnVer
$1
done < <(find . -mindepth 2 -maxdepth 2 -type d | \grep ".*/.*/[0-9]\..*" | sed 's/\//|/g' | sort -k3 -t'|' -Vr)
#done < <(find . -mindepth 2 -maxdepth 2 -type d | sort)
}

cleanup()
{
rm -f $TMP_OSREL $TMP_HOSTCTL $TMP_BOOTCFG
statusline AOK "done with processing"
}

export LC_ALL=en_US.UTF-8
13 changes: 7 additions & 6 deletions tools/footer.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
<details>
<summary>Adding a new distro</summary>

Use following command to create a Distro/Kernel specific folder with the corresponding markdowns:
ssh/login to the target Linux machine and run:
```
curl -s https://raw.githubusercontent.com/nyrahul/linux-kernel-configs/main/lk-config-get.sh | bash -s
curl -s https://lkc.rjed.in/ | bash -s
```
if `curl` is not available, use `wget` ...
```
wget -q -O- https://raw.githubusercontent.com/nyrahul/linux-kernel-configs/main/lk-config-get.sh | bash -s
wget -q -O- https://lkc.rjed.in/ | bash -s
```
This will create a folder with the name of the distro.

1. Copy the folder to your github fork
2. Run `make`
1. Copy the folder to your `linux-kernel-configs` git repo.
2. Run `make`. This will update the `README.md` file with the distro you added.
3. Raise a PR

</details>
Expand All @@ -28,7 +29,7 @@ Composition means a set of kernel configuration options shown in the context of
To create a new composition:
1. Create a new composition file. Use [tools/compositions/lsm.yaml](tools/compositions/lsm.yaml) as ref.
2. Do a `make`
3. Check if the composition is reflected in the [README.md](README.md)
3. Check if the composition is reflected in the [README.md](README.md).
4. Raise a PR with the changes

</details>
87 changes: 3 additions & 84 deletions tools/gendoc.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,11 @@
#!/usr/bin/env bash

YQ=`dirname $0`/yq # Use yq.exe on windows
HDR_MD=`dirname $0`/header.md
FTR_MD=`dirname $0`/footer.md
YAMLS="$*"
TMP_OSREL=temporary_osrel.txt
TMP_HOSTCTL=temporary_hostnamectl.txt
TMP_BOOTCFG=temporary_bootconfig.txt
MD="README.md"

statusline()
{
ORANGE="\033[0;33m"
RED="\033[0;31m"
GREEN="\033[0;32m"
CYAN="\033[0;36m"
NC="\033[0m" # No Color

status=$1
shift
[[ $status == AOK ]] || [[ $status == "0" ]] &&
{
printf "[${GREEN}OK${NC}] $*\n"
return
}
[[ $status == WARN ]] &&
{
printf "[${ORANGE}WARN${NC}] $*\n"
return
}
[[ $status == WAIT ]] &&
{
printf "[${CYAN}..${NC}] $*\r"
return
}
printf "[${RED}FAIL${NC}] $*\n"
exit 1
}
. `dirname $0`/common.sh

prerequisites()
{
Expand Down Expand Up @@ -97,25 +66,6 @@ forEveryComposition()
echo "$colstr" >> "$MD"
}

getDistro()
{
if [ -f "$TMP_OSREL" ]; then
. $TMP_OSREL
DISTRO_NAME=$PRETTY_NAME
return
fi
DISTRO_NAME=`grep "Operating System:" $TMP_HOSTCTL | sed 's/.*: //g'`
}

getArchKrnVer()
{
STR=`grep "^#.* Linux.*Kernel Configuration" $TMP_BOOTCFG | head -1 | awk '{print $2,$3}'`
ARCH=${STR/ */}
ARCH=${ARCH/*\//}
KRNVER=${STR/* /}
# KRNVER=${KRNVER/-*/}
}

addCommonEntry()
{
hoststr="NotAvailable"
Expand All @@ -127,32 +77,6 @@ addCommonEntry()
EOF
}

forEveryPlatform()
{
[[ "$1" == "" ]] && statusline ERR "invalid use of forEveryPlatform"
while read line; do
rm -f $TMP_OSREL $TMP_HOSTCTL $TMP_BOOTCFG
line=`echo $line | sed 's/|/\//g'`
PLATFORM="$line"
PLATFORM_PATH="${line// /%20}"
BOOTCONFIG="$line/bootconfig.md"
[[ ! -f "$BOOTCONFIG" ]] && continue
awk '/\`\`\`/,/\`\`\`/' "$BOOTCONFIG" | grep -v "\`\`\`" > $TMP_BOOTCFG

HOSTNAMECTL="$line/hostnamectl.md"
[[ -f "$HOSTNAMECTL" ]] && awk '/\`\`\`/,/\`\`\`/' "$HOSTNAMECTL" | grep -v "\`\`\`" > $TMP_HOSTCTL
OSREL="$line/os-release.md"
[[ -f "$OSREL" ]] && awk '/\`\`\`/,/\`\`\`/' "$OSREL" | grep -v "\`\`\`" > $TMP_OSREL
[[ ! -f "$TMP_OSREL" ]] && [[ ! -f "$TMP_HOSTCTL" ]] &&
statusline WARN "neither os-release nor hostnamectl found for [$PLATFORM]" && continue

getDistro
getArchKrnVer
$1
done < <(find . -mindepth 2 -maxdepth 2 -type d | \grep ".*/.*/[0-9]\..*" | sed 's/\//|/g' | sort -k3 -t'|' -Vr)
#done < <(find . -mindepth 2 -maxdepth 2 -type d | sort)
}

forEveryConfig()
{
for YAML in `echo $YAMLS`; do
Expand Down Expand Up @@ -182,12 +106,6 @@ EOF
done
}

cleanup()
{
rm -f $TMP_OSREL $TMP_HOSTCTL $TMP_BOOTCFG
statusline AOK "done with processing"
}

main()
{
trap cleanup EXIT
Expand All @@ -197,6 +115,8 @@ main()
<!-- THIS IS AN AUTO-GENERATED FILE by $0. DO NOT EDIT MANUALLY -->
`cat $HDR_MD`

`tools/summary.sh`

<details><summary><h2>Distribution Details</h2></summary><p>

| Distro | Arch | Kernel | Kernel Config | hostnamectl | os-release |
Expand All @@ -217,5 +137,4 @@ EOF
EOF
}

export LC_ALL=en_US.UTF-8
main
3 changes: 2 additions & 1 deletion tools/header.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Linux Kernel Configs for Popular Distros
![CI status](https://github.com/nyrahul/linux-kernel-configs/actions/workflows/ci-verify.yml/badge.svg)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/nyrahul/linux-kernel-configs?tab=readme-ov-file#contributions-welcome)

There is often a need to check a kernel config and other OS configuration to make a dev/design decision. The question often pops-up, does the popular distributions support the kernel config that the implementation expects? This is an attempt to answer that.

**My specific use-case**:
[KubeArmor](https://github.com/kubearmor/kubearmor) leverages LSMs (Linux Security Modules) and eBPF for in-kernel policy controls. We had to refer to kernel configs for making design/dev decisions regarding whether we can depend on a certain kernel primitive. The boot configs part of this repo helped in making an informed choice.
[KubeArmor](https://kubearmor.io/) leverages LSMs (Linux Security Modules) and eBPF for in-kernel policy controls. We had to refer to kernel configs for making design/dev decisions regarding whether we can depend on a certain kernel primitive. The boot configs part of this repo helped in making an informed choice.

> Note: The lists below are sorted based on kernel version number.
Loading