Yocto-5.1.1 (styhead-5.1.1)をUbuntu24.04でビルドしようとしたところ下記のようなエラーが出た。
bitbake core-image-weston
ERROR: User namespaces are not usable by BitBake, possibly due to AppArmor.
See https://discourse.ubuntu.com/t/ubuntu-24-04-lts-noble-numbat-release-notes/39890#unprivileged-user-namespace-restrictions for more information.
Summary: There was 1 ERROR message, returning a non-zero exit code.
記載されているWebページにある情報によると、
Disable this restriction on the entire system for one boot by executing echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns. This setting is lost on reboot. This similar to the previous behaviour, but it does not mitigate against kernel exploits that abuse the unprivileged user namespaces feature.
Disable this restriction using a persistent setting by adding a new file (/etc/sysctl.d/60-apparmor-namespace.conf) with the following contents:
kernel.apparmor_restrict_unprivileged_userns=0
Reboot. This is similar to the previous behaviour, but it does not mitigate against kernel exploits that abuse the unprivileged user namespaces feature.
ということで下記を実行することでエラーは解消された。
$ sudo sysctl kernel.apparmor_restrict_unprivileged_userns=0
kernel.apparmor_restrict_unprivileged_userns = 0
設定をもとに戻す場合は、
sudo sysctl kernel.apparmor_restrict_unprivileged_userns=1
kernel.apparmor_restrict_unprivileged_userns = 1
セキュリティを気にする場合はBitbakeを使わなくなったときに戻したほうがよい。