Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel parameters for systemd-boot #700

Merged
merged 39 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9262da5
systemd-boot kernel parameter
schubi2 Apr 23, 2024
44ab773
Grub2Helper removed
schubi2 Apr 23, 2024
8485cdc
syntax error
schubi2 Apr 23, 2024
da59773
neede require
schubi2 Apr 23, 2024
6b2a0f2
check file exists
schubi2 Apr 23, 2024
fd4d6af
check file exists
schubi2 Apr 23, 2024
72e2371
check file exists
schubi2 Apr 23, 2024
ce138d4
check file exists
schubi2 Apr 23, 2024
f8ec2e7
check file exists
schubi2 Apr 23, 2024
c4b2b54
mitigration
schubi2 Apr 24, 2024
df82d75
syntax fix
schubi2 Apr 24, 2024
126a8ca
syntax fix
schubi2 Apr 24, 2024
dbab4df
syntax fix
schubi2 Apr 24, 2024
4b8fba7
cleanup
schubi2 Apr 24, 2024
3383d4c
Merge branch 'master' into sd_boot_kernel_param
schubi2 Apr 25, 2024
a3b6e12
improved description
schubi2 Apr 25, 2024
0e58f83
rubocop
schubi2 Apr 25, 2024
111c69c
rubocop
schubi2 Apr 25, 2024
22ac8ab
fixed testcase
schubi2 Apr 25, 2024
305ba42
updated testcases
schubi2 Apr 25, 2024
1d7442d
name error
schubi2 Apr 25, 2024
73d5152
fixed testcase
schubi2 Apr 25, 2024
3ec4541
cleanup
schubi2 Apr 25, 2024
092a798
syntax error
schubi2 Apr 25, 2024
612f40f
syntax
schubi2 Apr 25, 2024
ba7c951
syntax
schubi2 Apr 25, 2024
c0af0d6
syntax error
schubi2 Apr 25, 2024
14e8393
additional testcase
schubi2 Apr 26, 2024
1cf70fe
cleanup
schubi2 Apr 26, 2024
db7f337
added more testcases
schubi2 Apr 26, 2024
a3e40b0
packaging
schubi2 Apr 26, 2024
dc66920
adapted suggestions
schubi2 Apr 29, 2024
0033afe
fixed testcases
schubi2 Apr 29, 2024
bc21872
fixed testcase
schubi2 Apr 29, 2024
38d3743
fixed testcase
schubi2 Apr 30, 2024
2bfe9f8
rubocop
schubi2 Apr 30, 2024
aaac87e
rubocop
schubi2 Apr 30, 2024
eb9fc23
rubocop
schubi2 Apr 30, 2024
5784738
not needed requirements
schubi2 Apr 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions package/yast2-bootloader.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Apr 26 13:07:51 UTC 2024 - Stefan Schubert <schubi@suse.com>

- Creating kernel options for systemd-boot. (bsc#1220892)
- 5.0.9

-------------------------------------------------------------------
Fri Apr 5 08:08:09 UTC 2024 - Josef Reidinger <jreidinger@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-bootloader.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-bootloader
Version: 5.0.8
Version: 5.0.9
Release: 0
Summary: YaST2 - Bootloader Configuration
License: GPL-2.0-or-later
Expand Down
106 changes: 106 additions & 0 deletions src/lib/bootloader/generic_widgets.rb
Expand Up @@ -3,6 +3,7 @@
require "yast"

require "bootloader/bootloader_factory"
require "bootloader/cpu_mitigations"

require "cwm/widget"

Expand Down Expand Up @@ -110,4 +111,109 @@ def help
)
end
end

# Represents decision if smt is enabled
class CpuMitigationsWidget < CWM::ComboBox
def initialize
textdomain "bootloader"

super
end

def label
_("CPU Mitigations")
end

def items
::Bootloader::CpuMitigations::ALL.map do |m|
[m.value.to_s, m.to_human_string]
end
end

def help
_(
"<p><b>CPU Mitigations</b><br>\n" \
"The option selects which default settings should be used for CPU \n" \
"side channels mitigations. A highlevel description is on our Technical Information \n" \
"Document TID 7023836. Following options are available:<ul>\n" \
"<li><b>Auto</b>: This option enables all the mitigations needed for your CPU model. \n" \
"This setting can impact performance to some degree, depending on CPU model and \n" \
"workload. It provides all security mitigations, but it does not protect against \n" \
"cross-CPU thread attacks.</li>\n" \
"<li><b>Auto + No SMT</b>: This option enables all the above mitigations in \n" \
"\"Auto\", and also disables Simultaneous Multithreading to avoid \n" \
"side channel attacks across multiple CPU threads. This setting can \n" \
"further impact performance, depending on your \n" \
"workload. This setting provides the full set of available security mitigations.</li>\n" \
"<li><b>Off</b>: All CPU Mitigations are disabled. This setting has no performance \n" \
"impact, but side channel attacks against your CPU are possible, depending on CPU \n" \
"model.</li>\n" \
"<li><b>Manual</b>: This setting does not specify a mitigation level and leaves \n" \
"this to be the kernel default. The administrator can add other mitigations options \n" \
"in the <i>kernel command line</i> widget.\n" \
"All CPU mitigation specific options can be set manually.</li></ul></p>"
)
end

def init
if Bootloader::BootloaderFactory.current.respond_to?(:cpu_mitigations)
self.value = Bootloader::BootloaderFactory.current.cpu_mitigations.value.to_s
else
disable
end
end

def store
return unless enabled?

Bootloader::BootloaderFactory.current.cpu_mitigations =
::Bootloader::CpuMitigations.new(value.to_sym)
end
end

# represents kernel command line
class KernelAppendWidget < CWM::InputField
def initialize
textdomain "bootloader"

super
end

def label
_("O&ptional Kernel Command Line Parameter")
end

def help
_(
"<p><b>Optional Kernel Command Line Parameter</b> lets you define " \
"additional parameters to pass to the kernel.</p>"
)
end

def init
current_bl = ::Bootloader::BootloaderFactory.current
case current_bl
when ::Bootloader::SystemdBoot
self.value = current_bl.kernel_params.serialize.gsub(/mitigations=\S+/, "")
when ::Bootloader::Grub2Base
self.value = current_bl.grub_default.kernel_params.serialize.gsub(/mitigations=\S+/, "")
else
disable
end
end

def store
return unless enabled?

current_bl = ::Bootloader::BootloaderFactory.current
case current_bl
when ::Bootloader::SystemdBoot
current_bl.kernel_params.replace(value)
when ::Bootloader::Grub2Base
current_bl.grub_default.kernel_params.replace(value)
else
log.error("Bootloader type #{current_bl} not found.")
end
end
end
end
90 changes: 0 additions & 90 deletions src/lib/bootloader/grub2_widgets.rb
Expand Up @@ -122,66 +122,6 @@ def store
end
end

# Represents decision if smt is enabled
class CpuMitigationsWidget < CWM::ComboBox
include Grub2Helper

def initialize
textdomain "bootloader"

super
end

def label
_("CPU Mitigations")
end

def items
::Bootloader::CpuMitigations::ALL.map do |m|
[m.value.to_s, m.to_human_string]
end
end

def help
_(
"<p><b>CPU Mitigations</b><br>\n" \
"The option selects which default settings should be used for CPU \n" \
"side channels mitigations. A highlevel description is on our Technical Information \n" \
"Document TID 7023836. Following options are available:<ul>\n" \
"<li><b>Auto</b>: This option enables all the mitigations needed for your CPU model. \n" \
"This setting can impact performance to some degree, depending on CPU model and \n" \
"workload. It provides all security mitigations, but it does not protect against \n" \
"cross-CPU thread attacks.</li>\n" \
"<li><b>Auto + No SMT</b>: This option enables all the above mitigations in \n" \
"\"Auto\", and also disables Simultaneous Multithreading to avoid \n" \
"side channel attacks across multiple CPU threads. This setting can \n" \
"further impact performance, depending on your \n" \
"workload. This setting provides the full set of available security mitigations.</li>\n" \
"<li><b>Off</b>: All CPU Mitigations are disabled. This setting has no performance \n" \
"impact, but side channel attacks against your CPU are possible, depending on CPU \n" \
"model.</li>\n" \
"<li><b>Manual</b>: This setting does not specify a mitigation level and leaves \n" \
"this to be the kernel default. The administrator can add other mitigations options \n" \
"in the <i>kernel command line</i> widget.\n" \
"All CPU mitigation specific options can be set manually.</li></ul></p>"
)
end

def init
if grub2.respond_to?(:cpu_mitigations)
self.value = grub2.cpu_mitigations.value.to_s
else
# do not crash when use no bootloader. This widget is also used in security dialog.
# (bsc#1184968)
disable
end
end

def store
grub2.cpu_mitigations = ::Bootloader::CpuMitigations.new(value.to_sym) if enabled?
end
end

# Represents decision if generic MBR have to be installed on disk
class GenericMBRWidget < CWM::CheckBox
include Grub2Helper
Expand Down Expand Up @@ -268,36 +208,6 @@ def store
end
end

# represents kernel command line
class KernelAppendWidget < CWM::InputField
include Grub2Helper

def initialize
textdomain "bootloader"

super
end

def label
_("O&ptional Kernel Command Line Parameter")
end

def help
_(
"<p><b>Optional Kernel Command Line Parameter</b> lets you define " \
"additional parameters to pass to the kernel.</p>"
)
end

def init
self.value = grub_default.kernel_params.serialize.gsub(/mitigations=\S+/, "")
end

def store
grub_default.kernel_params.replace(value)
end
end

# Represents Protective MBR action
class PMBRWidget < CWM::ComboBox
include Grub2Helper
Expand Down
21 changes: 1 addition & 20 deletions src/lib/bootloader/grub2base.rb
Expand Up @@ -21,7 +21,6 @@
Yast.import "BootStorage"
Yast.import "HTML"
Yast.import "Initrd"
Yast.import "Kernel"
Yast.import "Mode"
Yast.import "Pkg"
Yast.import "Product"
Expand Down Expand Up @@ -381,31 +380,13 @@ def propose_xen_hypervisor
grub_default.xen_hypervisor_params.add_parameter("vga", "gfx-1024x768x16", placer)
end

def propose_resume
swap_parts = Yast::BootStorage.available_swap_partitions
largest_swap_name, lagest_swap_size = (swap_parts.max_by { |_part, size| size } || [])

propose = Yast::Kernel.propose_hibernation? && largest_swap_name

return "" unless propose

if lagest_swap_size < Yast::BootStorage.ram_size
log.info "resume parameter is not added because swap (#{largest_swap_name}) is too small"

return ""
end

# try to use label or udev id for device name... FATE #302219
UdevMapping.to_mountby_device(largest_swap_name)
end

def propose_encrypted
grub_default.cryptodisk.value = !!Yast::BootStorage.encrypted_boot?
end

def propose_grub_default
if grub_default.kernel_params.empty?
kernel_line = Yast::BootArch.DefaultKernelParams(propose_resume)
kernel_line = Yast::BootArch.DefaultKernelParams(Yast::BootStorage.propose_resume)
grub_default.kernel_params.replace(kernel_line)
end
grub_default.gfxmode ||= "auto"
Expand Down