Ubuntu live patchを導入してみた

Linux

Livepatchとは

Livepatchはその名の通り、Ubuntu(Linux系のos)でapt-get upgradeされた時に、kernelパッチを更新するためにーサーバーを再起動せずに適用できます。

Ubuntu Pro向けなのですが、3ホストまでは無料で利用できるので個人利用をする程度ならちょうど良いです。

live patchの仕組みはこちらのページの図がわかりやすいです。

起動中のkernelにパッチを適用するとなると、実行中のメモリの内容を変更することになってしまうけど、どうやっているのか不思議に思っていました。

上記のように、新たなコードを別のメモリに確保した上で、実行コードをすげ替えてしまうというやり方であれば納得です。

デメリットとしては抽象化のオーバーヘッドが増えるのと、パッチを適用していくとメモリのフラグメンテーションや無駄なメモリアロケーションが増える可能性がありそうです。

また、Livepatch自体も万能ではなくてこの用に抽象化された部分の変更でなければkernelの再実行=OSの再機動が必要になります。詳細

アカウント登録

利用する際に使うtokenはWebサイト上で発行されるのでアカウント登録をしてトークンを取得します。

ユーザ登録後、このページを開くとトークンが表示されます。

設定

Ubuntu 22.04で実行しています。

基本的に、上記のサイトで表示されているコマンドを1発実行すれば完了します。

matsu@dell ~/> sudo pro attach <token>
[sudo] password for matsu: 
Enabling default service esm-apps
Updating package lists
Ubuntu Pro: ESM Apps enabled
Enabling default service esm-infra
Updating package lists
Ubuntu Pro: ESM Infra enabled
Enabling default service livepatch
Installing snapd
Updating package lists
Installing canonical-livepatch snap
Canonical livepatch enabled.
Unable to determine current instance-id
This machine is now attached to 'Ubuntu Pro - free personal subscription'

SERVICE          ENTITLED  STATUS    DESCRIPTION
esm-apps         yes       enabled   Expanded Security Maintenance for Applications
esm-infra        yes       enabled   Expanded Security Maintenance for Infrastructure
livepatch        yes       enabled   Canonical Livepatch service
realtime-kernel  yes       disabled  Ubuntu kernel with PREEMPT_RT patches integrated

NOTICES
Operation in progress: pro attach

Enable services with: pro enable <service>

     Account: [email protected]
Subscription: Ubuntu Pro - free personal subscription

live patchのステータス表示

matsu@dell ~/> sudo ua status
[sudo] password for matsu:
SERVICE          ENTITLED  STATUS    DESCRIPTION
esm-apps         yes       enabled   Expanded Security Maintenance for Applications
esm-infra        yes       enabled   Expanded Security Maintenance for Infrastructure
livepatch        yes       enabled   Canonical Livepatch service
realtime-kernel  yes       disabled  Ubuntu kernel with PREEMPT_RT patches integrated
usg              yes       disabled  Security compliance and audit tools

Enable services with: pro enable <service>

     Account: [email protected]
Subscription: Ubuntu Pro - free personal subscription

livepatchがenabledになっているので設定は完了しているようです。

セキュリティのステータス表示

matsu@dell ~> sudo ua security-status
997 packages installed:
    853 packages from Ubuntu Main/Restricted repository
    101 packages from Ubuntu Universe/Multiverse repository
    25 packages from third parties
    18 packages no longer available for download

To get more information about the packages, run
    pro security-status --help
for a list of available options.

This machine is attached to an Ubuntu Pro subscription.

Main/Restricted packages are receiving security updates from
Ubuntu Pro with 'esm-infra' enabled until 2032.

Universe/Multiverse packages are receiving security updates from
Ubuntu Pro with 'esm-apps' enabled until 2032. You have received 13 security
updates.

考察

この設定が影響しているかどうかわからないのですが、Dockerが調子悪くなりました。。。docker killでコンテナを停止できなくなってしまったりしました。

スタートはできるからまぁ、ギリギリサービスは動くのですが。。。困りものです。

まとめ

  • kernel関連のzero day attackに対して安全に運用できるようになりました。
  • 仮想環境でサービスを運用しているホストに導入すると再機動の回数を減らせて良いです。

コメント