Kernel lockdown
Subsystems (64)
cover Kernel lockdown
These patches provide a facility by which a variety of avenues by which userspace can feasibly modify the running kernel image can be locked down. These include:
(*) No unsigned modules and no modules for which can't validate the
signature.
(*) No use of ioperm(), iopl() and no writing to /dev/port.
(*) No writing to /dev/mem or /dev/kmem.
(*) No hibernation.
(*) Restrict PCI BAR access.
(*) Restrict MSR access.
(*) No kexec_load().
(*) Certain ACPI restrictions.
(*) Restrict debugfs interface to ASUS WMI.
The lock-down can be configured to be triggered by the EFI secure boot status, provided the shim isn't insecure. The lock-down can be lifted by typing SysRq+x on a keyboard attached to the system.
The patches can be found here also:
http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/log/?h=keys-lockdown
They are dependent for some EFI definitions on the keys-uefi branch.
David
---
Dave Young (1):
Copy secure_boot flag in boot params across kexec reboot
David Howells (3):
Add the ability to lock down access to the running kernel image
efi: Get the secure boot status
efi: Lock down the kernel if booted in secure boot mode
Josh Boyer (4):
efi: Disable secure boot if shim is in insecure mode
efi: Add EFI_SECURE_BOOT bit
hibernate: Disable when the kernel is locked down
acpi: Ignore acpi_rsdp kernel param when the kernel has been locked down
Kyle McMartin (1):
Add a sysrq option to exit secure boot mode
Matthew Garrett (7):
kexec: Disable at runtime if the kernel is locked down
PCI: Lock down BAR access when the kernel is locked down
x86: Lock down IO port access when the kernel is locked down
ACPI: Limit access to custom_method when the kernel is locked down
asus-wmi: Restrict debugfs interface when the kernel is locked down Restrict /dev/mem and /dev/kmem when the kernel is locked down
x86: Restrict MSR access when the kernel is locked down
Documentation/x86/zero-page.txt | 2 + arch/x86/Kconfig | 22 ++++++++++++++ arch/x86/boot/compressed/eboot.c | 53 +++++++++++++++++++++++++++++++++ arch/x86/include/uapi/asm/bootparam.h | 3 +- arch/x86/kernel/ioport.c | 5 ++- arch/x86/kernel/kexec-bzimage64.c | 1 + arch/x86/kernel/msr.c | 8 +++++ arch/x86/kernel/setup.c | 39 ++++++++++++++++++++++++ drivers/acpi/custom_method.c | 3 ++ drivers/acpi/osl.c | 3 +- drivers/char/mem.c | 10 ++++++ drivers/input/misc/uinput.c | 1 + drivers/pci/pci-sysfs.c | 10 ++++++ drivers/pci/proc.c | 9 +++++- drivers/pci/syscall.c | 3 +- drivers/platform/x86/asus-wmi.c | 9 ++++++ drivers/tty/sysrq.c | 19 ++++++++---- include/linux/efi.h | 1 + include/linux/input.h | 5 +++ include/linux/security.h | 16 ++++++++++ include/linux/sysrq.h | 8 ++++- kernel/debug/kdb/kdb_main.c | 2 + kernel/kexec.c | 8 +++++ kernel/module.c | 2 + kernel/power/hibernate.c | 3 +- security/Kconfig | 16 +++++++++- security/Makefile | 3 ++ security/lock_down.c | 40 +++++++++++++++++++++++++ 28 files changed, 287 insertions(+), 17 deletions(-) create mode 100644 security/lock_down.c
PATCH 1/16 Add the ability to lock down access to the running kernel image
Provide a single call to allow kernel code to determine whether the system should be locked down, thereby disallowing various accesses that might allow the running kernel image to be changed including the loading of modules that aren't validly signed with a key we recognise, fiddling with MSR registers and disallowing hibernation,
---
include/linux/security.h | 16 ++++++++++++++++ security/Kconfig | 16 +++++++++++++++- security/Makefile | 3 +++ security/lock_down.c | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 security/lock_down.c
include/linux/security.h +16 -0
@@ -1685,5 +1685,21 @@ static inline void free_secdata(void *secdata) { }#endif /* CONFIG_SECURITY */ +#ifdef CONFIG_LOCK_DOWN_KERNEL +extern void lock_kernel_down (void ); +extern bool kernel_is_locked_down (void ); +#ifdef CONFIG_ALLOW_LOCKDOWN_LIFT +extern void lift_kernel_lockdown (void ); +#endif +#else +static inline void lock_kernel_down (void ) +{ +} +static inline bool kernel_is_locked_down (void ) +{ +return false; +} +#endif +#endif /* ! __LINUX_SECURITY_H */
security/Kconfig +15 -1
@@ -158,6 +158,21 @@ config HARDENED_USERCOPY_PAGESPAN been removed. This config is intended to be used only while trying to find such users. +config LOCK_DOWN_KERNEL + bool "Allow the kernel to be 'locked down'" + help + Allow the kernel to be locked down under certain circumstances, for + instance if UEFI secure boot is enabled. Locking down the kernel + turns off various features that might otherwise allow access to the + kernel image (eg. setting MSR registers). + +config ALLOW_LOCKDOWN_LIFT + bool + help + Allow the lockdown on a kernel to be lifted, thereby restoring the + ability of userspace to access the kernel image (eg. by SysRq+x under + x86). + source security/selinux/Kconfig source security/smack/Kconfig source security/tomoyo/Kconfig
@@ -205,4 +220,3 @@ config DEFAULT_SECURITY default "" if DEFAULT_SECURITY_DAC endmenu -
security/Makefile +3 -0
@@ -29,3 +29,6 @@ obj-$(CONFIG_CGROUP_DEVICE) += device_cgroup.o # Object integrity file lists subdir-$(CONFIG_INTEGRITY) += integrity obj-$(CONFIG_INTEGRITY) += integrity/ + +# Allow the kernel to be locked down +obj-$(CONFIG_LOCK_DOWN_KERNEL) += lock_down.o
security/lock_down.c new file +40 -0
@@ -0,0 +1,40 @@ +/* Lock down the kernel +* +* Copyright (C) 2016 Red Hat, Inc. All Rights Reserved. +* Written by David Howells ([email protected]) +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public Licence +* as published by the Free Software Foundation; either version +* 2 of the Licence, or (at your option) any later version. +*/ + +#include <linux/security.h> +#include <linux/export.h> + +static __read_mostly bool kernel_locked_down; + +/* +* Put the kernel into lock-down mode. +*/ +void lock_kernel_down (void ) +{ + kernel_locked_down = true; +} + +/* +* Take the kernel out of lockdown mode. +*/ +void lift_kernel_lockdown (void ) +{ + kernel_locked_down = false; +} + +/** +* kernel_is_locked_down - Find out if the kernel is locked down +*/ +bool kernel_is_locked_down (void ) +{ +return kernel_locked_down; +} +EXPORT_SYMBOL (kernel_locked_down);
Borislav Petkov
maintainerRe: [PATCH 01/16] Add the ability to lock down access to the running kernel image
Quoted 8 lines · David Howells
Provide a single call to allow kernel code to determine whether the system should be locked down, thereby disallowing various accesses that might allow the running kernel image to be changed including the loading of modules that aren't validly signed with a key we recognise, fiddling with MSR registers and disallowing hibernation,
Signed-off-by David Howells <[email protected]>---
...
security/lock_down.c line 40
Quoted 8 lines
security/lock_down.c new file +8
-0+/** +* kernel_is_locked_down - Find out if the kernel is locked down +*/ +bool kernel_is_locked_down (void ) +{ +return kernel_locked_down; +} +EXPORT_SYMBOL (kernel_locked_down);
Surely
EXPORT_SYMBOL(kernel_is_locked_down);
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Re: [PATCH 01/16] Add the ability to lock down access to the running kernel image
Quoted 5 lines · Borislav Petkov
Quoted 1 line
+EXPORT_SYMBOL(kernel_locked_down);
Surely
EXPORT_SYMBOL(kernel_is_locked_down);
Sorry, yes. Obviously it won't cause a compilation error...
David
Re: [PATCH 01/16] Add the ability to lock down access to the running kernel image
In reply to David HowellsHi!
Quoted 3 lines
allow the running kernel image to be changed including the loading of modules that aren't validly signed with a key we recognise, fiddling with MSR registers and disallowing hibernation,
"." at EOL.
security/Kconfig config HARDENED_USERCOPY_PAGESPAN · line 162
Quoted 6 lines
security/Kconfig +2
-0@@ -158,6 +158,21 @@ config HARDENED_USERCOPY_PAGESPAN been removed. This config is intended to be used only while trying to find such users. +config LOCK_DOWN_KERNEL + bool "Allow the kernel to be 'locked down'"
Locked down, or 'locked down' ? :-).
security/Kconfig config HARDENED_USERCOPY_PAGESPAN · line 167
Quoted 5 lines
security/Kconfig +5
-0+ help + Allow the kernel to be locked down under certain circumstances, for + instance if UEFI secure boot is enabled. Locking down the kernel + turns off various features that might otherwise allow access to the + kernel image (eg. setting MSR registers).
I'd add something that clarifies it is "running" kernel image.
security/Kconfig config HARDENED_USERCOPY_PAGESPAN · line 170
Quoted 2 lines
security/Kconfig +2
-0+config ALLOW_LOCKDOWN_LIFT + bool
Don't you need to add 'bool "something"' so that user can actually select this?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH 01/16] Add the ability to lock down access to the running kernel image
Quoted 5 lines · Pavel Machek
security/Kconfig config HARDENED_USERCOPY_PAGESPAN · line 170
Quoted 2 lines
security/Kconfig +2
-0+config ALLOW_LOCKDOWN_LIFT + boolDon't you need to add 'bool "something"' so that user can actually select this?
No - see patch 6. This option merely makes the function available. Actually, I haven't done it quite right: the function in the .c file should be conditionalised too.
David
PATCH 2/16 efi: Get the secure boot status
In reply to David HowellsGet the firmware's secure-boot status in the kernel boot wrapper and stash it somewhere that the main kernel image can find.
---
Documentation/x86/zero-page.txt | 2 ++ arch/x86/boot/compressed/eboot.c | 35 +++++++++++++++++++++++++++++++++ arch/x86/include/uapi/asm/bootparam.h | 3 ++- 3 files changed, 39 insertions(+), 1 deletion(-)
Documentation/x86/zero-page.txt +2 -0
@@ -31,6 +31,8 @@ Offset Proto Name Meaning 1E9/001 ALL eddbuf_entries Number of entries in eddbuf (below) 1EA/001 ALL edd_mbr_sig_buf_entries Number of entries in edd_mbr_sig_buffer (below) +1EB/001 ALL kbd_status Numlock is enabled +1EC/001 ALL secure_boot Secure boot is enabled in the firmware 1EF/001 ALL sentinel Used to detect broken bootloaders 290/040 ALL edd_mbr_sig_buffer EDD MBR signatures 2D0/A00 ALL e820_map E820 memory map table
arch/x86/boot/compressed/eboot.c +35 -0
@@ -12,6 +12,7 @@#include <asm/efi.h> #include <asm/setup.h> #include <asm/desc.h> +#include <asm/bootparam_utils.h> #include "../string.h" #include "eboot.h"
@@ -537,6 +538,36 @@ static void setup_efi_pci(struct boot_params *params)efi_call_early (free_pool, pci_handle); } +static int get_secure_boot (void ) +{ +u8 sb, setup; +unsigned long datasize =sizeof (sb); +efi_guid_t var_guid =EFI_GLOBAL_VARIABLE_GUID ; +efi_status_t status; + + status = efi_early->call ((unsigned long )sys_table->runtime->get_variable, +L"SecureBoot" , &var_guid,NULL , &datasize, &sb); + +if (status !=EFI_SUCCESS ) +return 0 ; + +if (sb ==0 ) +return 0 ; + + + status = efi_early->call ((unsigned long )sys_table->runtime->get_variable, +L"SetupMode" , &var_guid,NULL , &datasize, + &setup); + +if (status !=EFI_SUCCESS ) +return 0 ; + +if (setup ==1 ) +return 0 ; + +return 1 ; +} +static efi_status_t setup_uga32 (void **uga_handle,unsigned long size,u32 *width,u32 *height) {
@@ -1094,6 +1125,10 @@ struct boot_params *efi_main(struct efi_config *c,else setup_boot_services32 (efi_early); +sanitize_boot_params (boot_params); + + boot_params->secure_boot =get_secure_boot (); +setup_graphics (boot_params);setup_efi_pci (boot_params);
arch/x86/include/uapi/asm/bootparam.h +2 -1
@@ -134,7 +134,8 @@ struct boot_params {__u8 eddbuf_entries;/* 0x1e9 */ __u8 edd_mbr_sig_buf_entries;/* 0x1ea */ __u8 kbd_status;/* 0x1eb */ -__u8 _pad5[3 ];/* 0x1ec */ +__u8 secure_boot;/* 0x1ec */ +__u8 _pad5[2 ];/* 0x1ed */ /* * The sentinel is set to a nonzero value (0xff) in header.S. *
Re: [PATCH 02/16] efi: Get the secure boot status
Quoted 38 lines · David Howells
Get the firmware's secure-boot status in the kernel boot wrapper and stash it somewhere that the main kernel image can find.
Signed-off-by Matthew Garrett <[email protected]>Signed-off-by David Howells <[email protected]>---
Documentation/x86/zero-page.txt | 2 ++ arch/x86/boot/compressed/eboot.c | 35 +++++++++++++++++++++++++++++++++ arch/x86/include/uapi/asm/bootparam.h | 3 ++- 3 files changed, 39 insertions(+), 1 deletion(-)Documentation/x86/zero-page.txt +2
-0@@ -31,6 +31,8 @@ Offset Proto Name Meaning 1E9/001 ALL eddbuf_entries Number of entries in eddbuf (below) 1EA/001 ALL edd_mbr_sig_buf_entries Number of entries in edd_mbr_sig_buffer (below) +1EB/001 ALL kbd_status Numlock is enabled +1EC/001 ALL secure_boot Secure boot is enabled in the firmware 1EF/001 ALL sentinel Used to detect broken bootloaders 290/040 ALL edd_mbr_sig_buffer EDD MBR signatures 2D0/A00 ALL e820_map E820 memory map tablearch/x86/boot/compressed/eboot.c +1
-0@@ -12,6 +12,7 @@#include <asm/efi.h> #include <asm/setup.h> #include <asm/desc.h> +#include <asm/bootparam_utils.h> #include "../string.h" #include "eboot.h"
arch/x86/boot/compressed/eboot.c static void setup_efi_pci(struct boot_params *params) · line 542
Quoted 5 lines
arch/x86/boot/compressed/eboot.c +2
-0@@ -537,6 +538,36 @@ static void setup_efi_pci(struct boot_params *params)efi_call_early (free_pool, pci_handle); } +static int get_secure_boot (void ) +{
This function is very similar to the existing efi_get_secureboot() in drivers/firmware/efi/libstub/arm-stub.c.
Please avoid adding more duplicate code to the EFI stub and try to reuse the existing code.
I suggest moving the existing efi_get_secureboot() to a new file drivers/firmware/efi/libstub/secureboot.c which gets linked into libstub, perhaps dependent on a new config option.
arch/x86/boot/compressed/eboot.c static void setup_efi_pci(struct boot_params *params) · line 549
Quoted 7 lines
arch/x86/boot/compressed/eboot.c +7
-0+u8 sb, setup; +unsigned long datasize =sizeof (sb); +efi_guid_t var_guid =EFI_GLOBAL_VARIABLE_GUID ; +efi_status_t status; + + status = efi_early->call ((unsigned long )sys_table->runtime->get_variable, +L"SecureBoot" , &var_guid,NULL , &datasize, &sb);
This doesn't work in mixed mode.
We already have the efi_call_early() macro to call boot services in a manner that works across all arches and bitness variants.
In 4.10 there will be an efi_call_proto() macro to allow the same for protocol calls:
http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?h=efi/core&id=3552fdf29f01
I suggest adding an efi_call_runtime() macro for arch- and bitness- agnostic runtime services calls, like this:
#define efi_call_runtime(f, ...) \ __efi_early()->call(efi_table_attr(efi_runtime_services, f, \ __efi_early()->runtime_services), __VA_ARGS__)
For this to work you need to add a runtime_services attribute to struct efi_config, this requires modifying head_32.S and head_64.S, use commit 0a637ee61247 ("x86/efi: Allow invocation of arbitrary boot services") as a template.
If you define corresponding efi_call_runtime() macros for ARM, you should indeed be able to share this function across arches.
Thanks,
Lukas
Quoted 50 lines
arch/x86/boot/compressed/eboot.c +25
-0+ +if (status !=EFI_SUCCESS ) +return 0 ; + +if (sb ==0 ) +return 0 ; + + + status = efi_early->call ((unsigned long )sys_table->runtime->get_variable, +L"SetupMode" , &var_guid,NULL , &datasize, + &setup); + +if (status !=EFI_SUCCESS ) +return 0 ; + +if (setup ==1 ) +return 0 ; + +return 1 ; +} +static efi_status_t setup_uga32 (void **uga_handle,unsigned long size,u32 *width,u32 *height) {@@ -1094,6 +1125,10 @@ struct boot_params *efi_main(struct efi_config *c,else setup_boot_services32 (efi_early); +sanitize_boot_params (boot_params); + + boot_params->secure_boot =get_secure_boot (); +setup_graphics (boot_params);setup_efi_pci (boot_params);arch/x86/include/uapi/asm/bootparam.h +2
-1@@ -134,7 +134,8 @@ struct boot_params {__u8 eddbuf_entries;/* 0x1e9 */ __u8 edd_mbr_sig_buf_entries;/* 0x1ea */ __u8 kbd_status;/* 0x1eb */ -__u8 _pad5[3 ];/* 0x1ec */ +__u8 secure_boot;/* 0x1ec */ +__u8 _pad5[2 ];/* 0x1ed */ /* * The sentinel is set to a nonzero value (0xff) in header.S. *
Re: [PATCH 02/16] efi: Get the secure boot status
Hi Lukas,
Looking in efi_get_secureboot(), is there a reason:
efi_guid_t var_guid = EFI_GLOBAL_VARIABLE_GUID;
isn't static const?
David
Re: [PATCH 02/16] efi: Get the secure boot status
(+ Linn)
Quoted 8 lines · David Howells
Hi Lukas,
Looking in
efi_get_secureboot(), is there a reason:efi_guid_t var_guid = EFI_GLOBAL_VARIABLE_GUID;isn't static const?
Not a good one, no. It used to be static const, but for some reason, commit 30d7bf034c03 ("efi/arm64: Check SetupMode when determining Secure Boot status") removed the static and the const (and I reviewed it and did not complain AFAIR)
I'll gladly take a patch that reinstates that, though.
Re: [PATCH 02/16] efi: Get the secure boot status
Quoted 4 lines · Ard Biesheuvel
Quoted 4 lines
Looking in
efi_get_secureboot(), is there a reason:efi_guid_t var_guid = EFI_GLOBAL_VARIABLE_GUID;
Quoted 8 lines
Quoted 2 lines
isn't static const?
Not a good one, no. It used to be static const, but for some reason, commit
30d7bf034c03("efi/arm64: Check SetupMode when determining Secure Boot status") removed the static and the const (and I reviewed it and did not complain AFAIR)
I'll gladly take a patch that reinstates that, though.
Also, is there a reason that:
typedef efi_status_t efi_get_variable_t (efi_char16_t *name, efi_guid_t *vendor, u32 *attr,
unsigned long *data_size, void *data);
Doesn't have const name and vendor?
David
Re: [PATCH 02/16] efi: Get the secure boot status
Quoted 15 lines · David Howells
Quoted 4 lines · Ard Biesheuvel
Quoted 4 lines
Looking in
efi_get_secureboot(), is there a reason:efi_guid_t var_guid = EFI_GLOBAL_VARIABLE_GUID;Quoted 8 lines
Quoted 2 lines
isn't static const?
Not a good one, no. It used to be static const, but for some reason, commit
30d7bf034c03("efi/arm64: Check SetupMode when determining Secure Boot status") removed the static and the const (and I reviewed it and did not complain AFAIR)
I'll gladly take a patch that reinstates that, though.
Quoted 7 lines
Also, is there a reason that:
typedef
efi_status_tefi_get_variable_t(efi_char16_t*name,efi_guid_t*vendor, u32 *attr,unsigned long *data_size, void *data);Doesn't have const name and vendor?
Yes, but not a good one either.
Sadly, the prototypes in the UEFI spec completely ignore constness, and these definitions are intended to be identical to the ones in the spec. This also means, for instance, that most UEFI firmwares stores these kinds of GUIDs in read-write memory, which is a potential goldmine for hackers, given how GUIDs are UEFI's duct tape, i.e., keeping the world together.
Re: [PATCH 02/16] efi: Get the secure boot status
Quoted 21 lines · Ard Biesheuvel
Quoted 13 lines · David Howells
Quoted 11 lines · Ard Biesheuvel
Quoted 5 lines
Looking in
efi_get_secureboot(), is there a reason:efi_guid_t var_guid = EFI_GLOBAL_VARIABLE_GUID;isn't static const?
Not a good one, no. It used to be static const, but for some reason, commit
30d7bf034c03("efi/arm64: Check SetupMode when determining Secure Boot status") removed the static and the const (and I reviewed it and did not complain AFAIR)
I'll gladly take a patch that reinstates that, though.Quoted 6 lines
Also, is there a reason that:
typedef
efi_status_tefi_get_variable_t(efi_char16_t*name,efi_guid_t*vendor, u32 *attr,unsigned long *data_size, void *data);Doesn't have const name and vendor?
Quoted 8 lines
Yes, but not a good one either.
Sadly, the prototypes in the UEFI spec completely ignore constness, and these definitions are intended to be identical to the ones in the spec. This also means, for instance, that most UEFI firmwares stores these kinds of GUIDs in read-write memory, which is a potential goldmine for hackers, given how GUIDs are UEFI's duct tape, i.e., keeping the world together.
But the spec declares these two parameters as "IN", so it would seem legal to declare them const, no?
Incidentally I've already prepared commits a couple of days ago to change the GUID declarations to const everywhere and also change the get_variable prototype, I was planning to submit them for 4.11... :-)
Thanks,
Lukas
Re: [PATCH 02/16] efi: Get the secure boot status
Quoted 34 lines · Lukas Wunner
Quoted 23 lines · Ard Biesheuvel
Quoted 14 lines · David Howells
Quoted 11 lines · Ard Biesheuvel
Quoted 5 lines
Looking in
efi_get_secureboot(), is there a reason:efi_guid_t var_guid = EFI_GLOBAL_VARIABLE_GUID;isn't static const?
Not a good one, no. It used to be static const, but for some reason, commit
30d7bf034c03("efi/arm64: Check SetupMode when determining Secure Boot status") removed the static and the const (and I reviewed it and did not complain AFAIR)
I'll gladly take a patch that reinstates that, though.Quoted 6 lines
Also, is there a reason that:
typedef
efi_status_tefi_get_variable_t(efi_char16_t*name,efi_guid_t*vendor, u32 *attr,unsigned long *data_size, void *data);Doesn't have const name and vendor?
Quoted 8 lines
Yes, but not a good one either.
Sadly, the prototypes in the UEFI spec completely ignore constness, and these definitions are intended to be identical to the ones in the spec. This also means, for instance, that most UEFI firmwares stores these kinds of GUIDs in read-write memory, which is a potential goldmine for hackers, given how GUIDs are UEFI's duct tape, i.e., keeping the world together.
Quoted 3 lines
But the spec declares these two parameters as "IN", so it would seem legal to declare them const, no?
Good point.
Quoted 4 lines
Incidentally I've already prepared commits a couple of days ago to change the GUID declarations to const everywhere and also change the
get_variableprototype, I was planning to submit them for 4.11... :-)
I would like to take those, provided that they only modify IN pointer arguments.
Re: [PATCH 02/16] efi: Get the secure boot status
In reply to Lukas WunnerQuoted 14 lines · Lukas Wunner
We already have the
efi_call_early()macro to call boot services in a manner that works across all arches and bitness variants.In 4.10 there will be an
efi_call_proto()macro to allow the same for protocol calls:
http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?h=efi/core&id=3552fdf29f01I suggest adding an
efi_call_runtime()macro for arch- and bitness- agnostic runtime services calls, like this:#define efi_call_runtime(f, ...) \ __efi_early()->call(efi_table_attr(efi_runtime_services, f, \ __efi_early()->runtime_services), __VA_ARGS__)
Quoted 7 lines
For this to work you need to add a
runtime_servicesattribute to structefi_config, this requires modifyinghead_32.Sandhead_64.S, use commit0a637ee61247("x86/efi: Allow invocation of arbitrary boot services") as a template.If you define corresponding
efi_call_runtime()macros for ARM, you should indeed be able to share this function across arches.
I'm not sure why I need to do this if I replace get_secure_boot() from my patch with a call to efi_get_secureboot().
David
Re: [PATCH 02/16] efi: Get the secure boot status
Quoted 20 lines · David Howells
Quoted 19 lines · Lukas Wunner
We already have the
efi_call_early()macro to call boot services in a manner that works across all arches and bitness variants.In 4.10 there will be an
efi_call_proto()macro to allow the same for protocol calls:
http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?h=efi/core&id=3552fdf29f01I suggest adding an
efi_call_runtime()macro for arch- and bitness- agnostic runtime services calls, like this:#define efi_call_runtime(f, ...) \ __efi_early()->call(efi_table_attr(efi_runtime_services, f, \ __efi_early()->runtime_services), __VA_ARGS__)For this to work you need to add a
runtime_servicesattribute to structefi_config, this requires modifyinghead_32.Sandhead_64.S, use commit0a637ee61247("x86/efi: Allow invocation of arbitrary boot services") as a template.
Quoted 5 lines
Quoted 2 lines
If you define corresponding
efi_call_runtime()macros for ARM, you should indeed be able to share this function across arches.I'm not sure why I need to do this if I replace
get_secure_boot()from my patch with a call toefi_get_secureboot().
You need to do this to make the code run correctly in mixed mode (64 bit CPU, but 32-bit EFI).
This dereferences efi_system_table_t *sys_table_arg as well as efi_runtime_services_t *runtime:
efi_get_variable_t *f_getvar = sys_table_arg->runtime->get_variable;
The problem is that efi_system_table_t and efi_runtime_services_t uses 64-bit wide elements when compiled on 64-bit (unsigned long or void *). They need to be cast to efi_system_table_32_t and efi_runtime_services_32_t at runtime if EFI is 32-bit.
The efi_call_early() and efi_call_proto() macros do this automatically. I suggest that you add efi_call_runtime() for symmetry.
Thanks,
Lukas
PATCH 1/6 x86/efi: Allow invocation of arbitrary runtime services
In reply to Lukas WunnerProvide the ability to perform mixed-mode runtime service calls for x86 in the same way that commit 0a637ee61247bd4bed9b2a07568ef7a1cfc76187 provides the ability to invoke arbitrary boot services.
---
arch/x86/boot/compressed/eboot.c | 1 + arch/x86/boot/compressed/head_32.S | 6 +++--- arch/x86/boot/compressed/head_64.S | 8 ++++---- arch/x86/include/asm/efi.h | 5 +++++ 4 files changed, 13 insertions(+), 7 deletions(-)
arch/x86/boot/compressed/eboot.c +1 -0
@@ -32,6 +32,7 @@ static void setup_boot_services##bits(struct efi_config *c) \ \ table = (typeof (table ))sys_table; \ \ + c->runtime_services = table->runtime; \ c->boot_services = table->boottime; \ c->text_output = table->con_out; \ }
arch/x86/boot/compressed/head_32.S +3 -3
@@ -82,7 +82,7 @@ ENTRY(efi_pe_entry) /* Relocate efi_config->call() */ leal efi32_config(%esi), %eax - add %esi, 32(%eax) + add %esi, 40(%eax) pushl %eax call make_boot_params
@@ -108,7 +108,7 @@ ENTRY(efi32_stub_entry) /* Relocate efi_config->call() */ leal efi32_config(%esi), %eax - add %esi, 32(%eax) + add %esi, 40(%eax) pushl %eax 2: call efi_main
@@ -264,7 +264,7 @@ relocated: #ifdef CONFIG_EFI_STUB .data efi32_config: - .fill 4,8,0 + .fill 5,8,0 .long efi_call_phys .long 0 .byte 0
arch/x86/boot/compressed/head_64.S +4 -4
@@ -265,7 +265,7 @@ ENTRY(efi_pe_entry) /* * Relocate efi_config->call(). */ - addq %rbp, efi64_config+32(%rip) + addq %rbp, efi64_config+40(%rip) movq %rax, %rdi call make_boot_params
@@ -285,7 +285,7 @@ handover_entry: * Relocate efi_config->call(). */ movq efi_config(%rip), %rax - addq %rbp, 32(%rax) + addq %rbp, 40(%rax) 2: movq efi_config(%rip), %rdi call efi_main
@@ -457,14 +457,14 @@ efi_config: #ifdef CONFIG_EFI_MIXED .global efi32_config efi32_config: - .fill 4,8,0 + .fill 5,8,0 .quad efi64_thunk .byte 0 #endif .global efi64_config efi64_config: - .fill 4,8,0 + .fill 5,8,0 .quad efi_call .byte 1 #endif /* CONFIG_EFI_STUB */
arch/x86/include/asm/efi.h +5 -0
@@ -191,6 +191,7 @@ static inline efi_status_t efi_thunk_set_virtual_address_map(struct efi_config {u64 image_handle;u64 table; +u64 runtime_services;u64 boot_services;u64 text_output;efi_status_t (*call)(unsigned long , ...);
@@ -226,6 +227,10 @@ static inline bool efi_is_64bit(void)#define __efi_call_early (f, ...) \ __efi_early()->call((unsigned long)f, __VA_ARGS__); +#define efi_call_runtime (f, ...) \ + __efi_early()->call(efi_table_attr(efi_runtime_services, f, \ + __efi_early()->runtime_services), __VA_ARGS__) +extern bool efi_reboot_required (void );#else
Re: [PATCH 1/6] x86/efi: Allow invocation of arbitrary runtime services
Quoted 2 lines · David Howells
Provide the ability to perform mixed-mode runtime service calls for x86 in the same way that commit
0a637ee61247bd4bed9b2a07568ef7a1cfc76187provides
Small nit, checkpatch usually complains that this should be written as 12-character SHA-1 followed by the commit subject, i.e.
0a637ee61247 ("x86/efi: Allow invocation of arbitrary boot services")
Other than that LGTM. Same for patch 2 of this series.
Thanks,
Lukas
Quoted 118 lines
the ability to invoke arbitrary boot services.
Suggested-by Lukas Wunner <[email protected]>Signed-off-by David Howells <[email protected]>---
arch/x86/boot/compressed/eboot.c | 1 + arch/x86/boot/compressed/head_32.S | 6 +++--- arch/x86/boot/compressed/head_64.S | 8 ++++---- arch/x86/include/asm/efi.h | 5 +++++ 4 files changed, 13 insertions(+), 7 deletions(-)arch/x86/boot/compressed/eboot.c +1
-0@@ -32,6 +32,7 @@ static void setup_boot_services##bits(struct efi_config *c) \ \ table = (typeof (table ))sys_table; \ \ + c->runtime_services = table->runtime; \ c->boot_services = table->boottime; \ c->text_output = table->con_out; \ }arch/x86/boot/compressed/head_32.S +3
-3@@ -82,7 +82,7 @@ ENTRY(efi_pe_entry) /* Relocate efi_config->call() */ leal efi32_config(%esi), %eax - add %esi, 32(%eax) + add %esi, 40(%eax) pushl %eax call make_boot_params@@ -108,7 +108,7 @@ ENTRY(efi32_stub_entry) /* Relocate efi_config->call() */ leal efi32_config(%esi), %eax - add %esi, 32(%eax) + add %esi, 40(%eax) pushl %eax 2: call efi_main@@ -264,7 +264,7 @@ relocated: #ifdef CONFIG_EFI_STUB .data efi32_config: - .fill 4,8,0 + .fill 5,8,0 .long efi_call_phys .long 0 .byte 0arch/x86/boot/compressed/head_64.S +4
-4@@ -265,7 +265,7 @@ ENTRY(efi_pe_entry) /* * Relocate efi_config->call(). */ - addq %rbp, efi64_config+32(%rip) + addq %rbp, efi64_config+40(%rip) movq %rax, %rdi call make_boot_params@@ -285,7 +285,7 @@ handover_entry: * Relocate efi_config->call(). */ movq efi_config(%rip), %rax - addq %rbp, 32(%rax) + addq %rbp, 40(%rax) 2: movq efi_config(%rip), %rdi call efi_main@@ -457,14 +457,14 @@ efi_config: #ifdef CONFIG_EFI_MIXED .global efi32_config efi32_config: - .fill 4,8,0 + .fill 5,8,0 .quad efi64_thunk .byte 0 #endif .global efi64_config efi64_config: - .fill 4,8,0 + .fill 5,8,0 .quad efi_call .byte 1 #endif /* CONFIG_EFI_STUB */arch/x86/include/asm/efi.h +5
-0@@ -191,6 +191,7 @@ static inline efi_status_t efi_thunk_set_virtual_address_map(struct efi_config {u64 image_handle;u64 table; +u64 runtime_services;u64 boot_services;u64 text_output;efi_status_t (*call)(unsigned long , ...);@@ -226,6 +227,10 @@ static inline bool efi_is_64bit(void)#define __efi_call_early (f, ...) \ __efi_early()->call((unsigned long)f, __VA_ARGS__); +#define efi_call_runtime (f, ...) \ + __efi_early()->call(efi_table_attr(efi_runtime_services, f, \ + __efi_early()->runtime_services), __VA_ARGS__) +extern bool efi_reboot_required (void );#else
Re: [PATCH 1/6] x86/efi: Allow invocation of arbitrary runtime services
Quoted 4 lines · Lukas Wunner
Small nit, checkpatch usually complains that this should be written as 12-character SHA-1 followed by the commit subject, i.e.
0a637ee61247("x86/efi: Allow invocation of arbitrary boot services")
In this case, checkpatch is wrong.
David
Re: [PATCH 1/6] x86/efi: Allow invocation of arbitrary runtime services
Quoted 8 lines · David Howells
Quoted 4 lines · Lukas Wunner
Small nit, checkpatch usually complains that this should be written as 12-character SHA-1 followed by the commit subject, i.e.
0a637ee61247("x86/efi: Allow invocation of arbitrary boot services")In this case, checkpatch is wrong.
Why do you think so?
Re: [PATCH 1/6] x86/efi: Allow invocation of arbitrary runtime services
Quoted 8 lines · Joe Perches
Quoted 6 lines
Quoted 4 lines
Small nit, checkpatch usually complains that this should be written as 12-character SHA-1 followed by the commit subject, i.e.
0a637ee61247("x86/efi: Allow invocation of arbitrary boot services")In this case, checkpatch is wrong.
Why do you think so?
Actually, checkpatch doesn't complain about embedded commit IDs anymore, so in that case, it's just about acceptable.
Apart from that, I think we should put in the full SHA-1 commit. The probability of a collision in a 12-digit hex number for the >5,000,000 commits just in Linus's tree is currently at ~4.5% and gradually increasing. Add in all the commits in not-yet-upstreamed trees - which might be another million commits, say - then we're over 6%..
Oh, yes, and speaking of checkpatch, can you make it so that if it sees:
commit 12345...
Author: foo <foo@bar>
Date: blah
Subject line
Description lines
...
...
...
...
Signed-off-by-and-suchline-lines
diff ...
with the all description indented by 4 spaces, then assume that it's the output of git show and not give the warnings about signed-off-by and other things being indented?
David
Re: [PATCH 1/6] x86/efi: Allow invocation of arbitrary runtime services
Quoted 5 lines · David Howells
Quoted 3 lines · Joe Perches
Quoted 3 lines
Quoted 3 lines
Small nit, checkpatch usually complains that this should be written as 12-character SHA-1 followed by the commit subject, i.e.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
0a637ee61247("x86/efi: Allow invocation of arbitrary boot services")In this case, checkpatch is wrong.
Why do you think so?
Actually, checkpatch doesn't complain about embedded commit IDs anymore, so in that case, it's just about acceptable.
checkpatch still emits warnings about the format of commmit IDs.
What version of checkpatch are yuu using?
Quoted 5 lines
Apart from that, I think we should put in the full SHA-1 commit. The probability of a collision in a 12-digit hex number for the >5,000,000 commits just in Linus's tree is currently at ~4.5% and gradually increasing. Add in all the commits in not-yet-upstreamed trees - which might be another million commits, say - then we're over 6%..
Umm, no, that's not correct.
SHA-1 lengths of 12 are unique for quite awhile yet.
https://blog.cuviper.com/2013/11/10/how-short-can-git-abbreviate/
Using Linus' tree today, from commit 3b404a519815 the current output of the git-uniq-abbrev script is:
$ git-uniq-abbrev 5048673 objects 4: 5048673 / 65536 5: 5007413 / 998721 6: 1312496 / 623343 7: 94487 / 47089 8: 6163 / 3081 9: 416 / 208 10: 28 / 14 11: 4 / 2 12: 0 / 0 d597639e2036f04f0226761e2d818b31f2db7820 d597639e203a100156501df8a0756fd09573e2de ef91b6e893a00d903400f8e1303efc4d52b710af ef91b6e893afc4c4ca488453ea9f19ced5fa5861
Quoted 16 lines
Oh, yes, and speaking of checkpatch, can you make it so that if it sees:
commit 12345...
Author: foo <foo@bar>
Date: blahSubject line Description lines ... ... ... ... Signed-off-by-and-suchline-lines
Quoted 5 lines
diff ...
with the all description indented by 4 spaces, then assume that it's the output of git show and not give the warnings about signed-off-by and other things being indented?
No. Use --format=email as appropriate instead.
Re: [PATCH 1/6] x86/efi: Allow invocation of arbitrary runtime services
Quoted 4 lines · Joe Perches
Umm, no, that's not correct.
SHA-1 lengths of 12 are unique for quite awhile yet.https://blog.cuviper.com/2013/11/10/how-short-can-git-abbreviate/
The article says:
1.9% at 12
which is for 3253824 objects (I get 1.86%).
However, that was three years ago, and we now have over five million objects, so the collision possibility is 4.5% now.
If we add another 2 million over the next three years, then the probability will be over 8% then.
I've attached my spreadsheet for you to have a look at.
Quoted 1 line
No. Use --format=email as appropriate instead.
Fix checkpatch. This is an entirely reasonable supposition.
David
Re: [PATCH 1/6] x86/efi: Allow invocation of arbitrary runtime services
Quoted 16 lines · David Howells
Quoted 4 lines · Joe Perches
Umm, no, that's not correct.
SHA-1 lengths of 12 are unique for quite awhile yet.https://blog.cuviper.com/2013/11/10/how-short-can-git-abbreviate/
The article says:
1.9% at 12which is for 3253824 objects (I get 1.86%).
However, that was three years ago, and we now have over five million objects, so the collision possibility is 4.5% now.
Quoted 8 lines
If we add another 2 million over the next three years, then the probability will be over 8% then.
I've attached my spreadsheet for you to have a look at.
Quoted 1 line
No. Use --format=email as appropriate instead.
Fix checkpatch. This is an entirely reasonable supposition.
No. There's nothing to fix there IMO.
Of course you are welcome to submit patches.
PATCH 2/6 arm/efi: Allow invocation of arbitrary runtime services
In reply to Lukas WunnerProvide the ability to perform mixed-mode runtime service calls for arm in the same way that commit 0a637ee61247bd4bed9b2a07568ef7a1cfc76187 provides the ability to invoke arbitrary boot services.
---
arch/arm/include/asm/efi.h | 1 + arch/arm64/include/asm/efi.h | 1 + 2 files changed, 2 insertions(+)
arch/arm/include/asm/efi.h +1 -0
@@ -55,6 +55,7 @@ void efi_virtmap_unload(void);#define efi_call_early (f, ...) sys_table_arg->boottime->f(__VA_ARGS__)#define __efi_call_early (f, ...) f(__VA_ARGS__) +#define efi_call_runtime (f, ...) sys_table_arg->runtime->f(__VA_ARGS__)#define efi_is_64bit () (false)#define efi_call_proto (protocol, f, instance, ...) \
arch/arm64/include/asm/efi.h +1 -0
@@ -49,6 +49,7 @@ int efi_set_mapping_permissions(struct mm_struct *mm, efi_memory_desc_t *md);#define efi_call_early (f, ...) sys_table_arg->boottime->f(__VA_ARGS__)#define __efi_call_early (f, ...) f(__VA_ARGS__) +#define efi_call_runtime (f, ...) sys_table_arg->runtime->f(__VA_ARGS__)#define efi_is_64bit () (true)#define efi_call_proto (protocol, f, instance, ...) \
PATCH 3/6 efi: Add SHIM and image security database GUID definitions
In reply to Lukas WunnerAdd the definitions for shim and image security database, both of which are used widely in various Linux distros.
---
include/linux/efi.h | 3 +++ 1 file changed, 3 insertions(+)
include/linux/efi.h +3 -0
@@ -610,6 +610,9 @@ void efi_native_runtime_setup(void);#define EFI_CONSOLE_OUT_DEVICE_GUID EFI_GUID(0xd3b36f2c, 0xd551, 0x11d4, 0x9a, 0x46, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)#define APPLE_PROPERTIES_PROTOCOL_GUID EFI_GUID(0x91bd12fe, 0xf6c3, 0x44fb, 0xa5, 0xb7, 0x51, 0x22, 0xab, 0x30, 0x3a, 0xe0) +#define EFI_IMAGE_SECURITY_DATABASE_GUID EFI_GUID(0xd719b2cb, 0x3d3a, 0x4596, 0xa3, 0xbc, 0xda, 0xd0, 0x0e, 0x67, 0x65, 0x6f) +#define EFI_SHIM_LOCK_GUID EFI_GUID(0x605dab50, 0xe046, 0x4300, 0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23) +/* * This GUID is used to pass to the kernel proper the struct screen_info * structure that was populated by the stub based on the GOP protocol instance
PATCH 4/6 efi: Get the secure boot status
In reply to Lukas WunnerGet the firmware's secure-boot status in the kernel boot wrapper and stash it somewhere that the main kernel image can find.
---
Documentation/x86/zero-page.txt | 2 + arch/x86/boot/compressed/eboot.c | 5 ++ arch/x86/include/uapi/asm/bootparam.h | 3 + drivers/firmware/efi/libstub/Makefile | 2 - drivers/firmware/efi/libstub/arm-stub.c | 46 -------------------- drivers/firmware/efi/libstub/secureboot.c | 66 +++++++++++++++++++++++++++++ include/linux/efi.h | 2 + 7 files changed, 78 insertions(+), 48 deletions(-) create mode 100644 drivers/firmware/efi/libstub/secureboot.c
Documentation/x86/zero-page.txt +2 -0
@@ -31,6 +31,8 @@ Offset Proto Name Meaning 1E9/001 ALL eddbuf_entries Number of entries in eddbuf (below) 1EA/001 ALL edd_mbr_sig_buf_entries Number of entries in edd_mbr_sig_buffer (below) +1EB/001 ALL kbd_status Numlock is enabled +1EC/001 ALL secure_boot Secure boot is enabled in the firmware 1EF/001 ALL sentinel Used to detect broken bootloaders 290/040 ALL edd_mbr_sig_buffer EDD MBR signatures 2D0/A00 ALL e820_map E820 memory map table
arch/x86/boot/compressed/eboot.c +5 -0
@@ -12,6 +12,7 @@#include <asm/efi.h> #include <asm/setup.h> #include <asm/desc.h> +#include <asm/bootparam_utils.h> #include "../string.h" #include "eboot.h"
@@ -1158,6 +1159,10 @@ struct boot_params *efi_main(struct efi_config *c,else setup_boot_services32 (efi_early); +sanitize_boot_params (boot_params); + + boot_params->secure_boot =efi_get_secureboot (); +setup_graphics (boot_params);setup_efi_pci (boot_params);
arch/x86/include/uapi/asm/bootparam.h +2 -1
@@ -135,7 +135,8 @@ struct boot_params {__u8 eddbuf_entries;/* 0x1e9 */ __u8 edd_mbr_sig_buf_entries;/* 0x1ea */ __u8 kbd_status;/* 0x1eb */ -__u8 _pad5[3 ];/* 0x1ec */ +__u8 secure_boot;/* 0x1ec */ +__u8 _pad5[2 ];/* 0x1ed */ /* * The sentinel is set to a nonzero value (0xff) in header.S. *
drivers/firmware/efi/libstub/Makefile +1 -1
@@ -28,7 +28,7 @@ OBJECT_FILES_NON_STANDARD := y # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. KCOV_INSTRUMENT := n -lib-y := efi-stub-helper.o gop.o +lib-y := efi-stub-helper.o gop.o secureboot.o # include the stub's generic dependencies from lib/ when building for ARM/arm64 arm-deps := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c fdt_empty_tree.c fdt_sw.c sort.c
drivers/firmware/efi/libstub/arm-stub.c +0 -46
52 lines not on this page · raw message
drivers/firmware/efi/libstub/secureboot.c new file +66 -0
66 lines not on this page · raw message
include/linux/efi.h +2 -0
@@ -1477,6 +1477,8 @@ efi_status_t efi_setup_gop(efi_system_table_t *sys_table_arg,bool efi_runtime_disabled (void );extern void efi_call_virt_check_flags (unsigned long flags,const char *call); +int efi_get_secureboot (void ); +/* * Arch code can implement the following three template macros, avoiding * reptition for the void/non-void return cases of {__,}efi_call_virt():
Re: [PATCH 4/6] efi: Get the secure boot status
Quoted 2 lines · David Howells
Get the firmware's secure-boot status in the kernel boot wrapper and stash it somewhere that the main kernel image can find.
That's a bit terse. You could write here that you're moving the existing ARM function to generic stub code to be able to reuse it on x86.
Further comments below.
Quoted 41 lines
Signed-off-by Matthew Garrett <[email protected]>Signed-off-by David Howells <[email protected]>---
Documentation/x86/zero-page.txt | 2 + arch/x86/boot/compressed/eboot.c | 5 ++ arch/x86/include/uapi/asm/bootparam.h | 3 + drivers/firmware/efi/libstub/Makefile | 2 - drivers/firmware/efi/libstub/arm-stub.c | 46 -------------------- drivers/firmware/efi/libstub/secureboot.c | 66 +++++++++++++++++++++++++++++ include/linux/efi.h | 2 + 7 files changed, 78 insertions(+), 48 deletions(-) create mode 100644 drivers/firmware/efi/libstub/secureboot.cDocumentation/x86/zero-page.txt +2
-0@@ -31,6 +31,8 @@ Offset Proto Name Meaning 1E9/001 ALL eddbuf_entries Number of entries in eddbuf (below) 1EA/001 ALL edd_mbr_sig_buf_entries Number of entries in edd_mbr_sig_buffer (below) +1EB/001 ALL kbd_status Numlock is enabled +1EC/001 ALL secure_boot Secure boot is enabled in the firmware 1EF/001 ALL sentinel Used to detect broken bootloaders 290/040 ALL edd_mbr_sig_buffer EDD MBR signatures 2D0/A00 ALL e820_map E820 memory map tablearch/x86/boot/compressed/eboot.c +1
-0@@ -12,6 +12,7 @@#include <asm/efi.h> #include <asm/setup.h> #include <asm/desc.h> +#include <asm/bootparam_utils.h> #include "../string.h" #include "eboot.h"
arch/x86/boot/compressed/eboot.c struct boot_params *efi_main(struct efi_config *c, · line 1162
Quoted 4 lines
arch/x86/boot/compressed/eboot.c +1
-0@@ -1158,6 +1159,10 @@ struct boot_params *efi_main(struct efi_config *c,else setup_boot_services32 (efi_early); +sanitize_boot_params (boot_params);
What is the connection of this change to the rest of the patch? Needs an explanation in the commit message.
Quoted 101 lines
arch/x86/boot/compressed/eboot.c +3
-0+ + boot_params->secure_boot =efi_get_secureboot (); +setup_graphics (boot_params);setup_efi_pci (boot_params);arch/x86/include/uapi/asm/bootparam.h +2
-1@@ -135,7 +135,8 @@ struct boot_params {__u8 eddbuf_entries;/* 0x1e9 */ __u8 edd_mbr_sig_buf_entries;/* 0x1ea */ __u8 kbd_status;/* 0x1eb */ -__u8 _pad5[3 ];/* 0x1ec */ +__u8 secure_boot;/* 0x1ec */ +__u8 _pad5[2 ];/* 0x1ed */ /* * The sentinel is set to a nonzero value (0xff) in header.S. * drivers/firmware/efi/libstub/Makefile +1
-1@@ -28,7 +28,7 @@ OBJECT_FILES_NON_STANDARD := y # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. KCOV_INSTRUMENT := n -lib-y := efi-stub-helper.o gop.o +lib-y := efi-stub-helper.o gop.o secureboot.o # include the stub's generic dependencies from lib/ when building for ARM/arm64 arm-deps := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c fdt_empty_tree.c fdt_sw.c sort.cdrivers/firmware/efi/libstub/arm-stub.c +0
-46@@ -20,52 +20,6 @@bool __nokaslr; -static int efi_get_secureboot (efi_system_table_t *sys_table_arg) -{ -static efi_char16_t const sb_var_name[] = { -'S' ,'e' ,'c' ,'u' ,'r' ,'e' ,'B' ,'o' ,'o' ,'t' ,0 }; -static efi_char16_t const sm_var_name[] = { -'S' ,'e' ,'t' ,'u' ,'p' ,'M' ,'o' ,'d' ,'e' ,0 }; - -efi_guid_t var_guid =EFI_GLOBAL_VARIABLE_GUID ; -efi_get_variable_t *f_getvar = sys_table_arg->runtime->get_variable; -u8 val; -unsigned long size =sizeof (val); -efi_status_t status; - - status =f_getvar ((efi_char16_t *)sb_var_name, (efi_guid_t *)&var_guid, -NULL , &size, &val); - -if (status !=EFI_SUCCESS ) - goto out_efi_err; - -if (val ==0 ) -return 0 ; - - status =f_getvar ((efi_char16_t *)sm_var_name, (efi_guid_t *)&var_guid, -NULL , &size, &val); - -if (status !=EFI_SUCCESS ) - goto out_efi_err; - -if (val ==1 ) -return 0 ; - -return 1 ; - -out_efi_err: -switch (status) { -case EFI_NOT_FOUND : -return 0 ; -case EFI_DEVICE_ERROR : -return -EIO ; -case EFI_SECURITY_VIOLATION : -return -EACCES ; -default : -return -EINVAL ; - } -} -efi_status_t efi_open_volume (efi_system_table_t *sys_table_arg,void *__image,void **__fh) {drivers/firmware/efi/libstub/secureboot.c new file +5
-0@@ -0,0 +1,66 @@ +/* +* Secure boot handling. +* +* Copyright (C) 2013,2014 Linaro Limited +* Roy Franz <[email protected]
drivers/firmware/efi/libstub/secureboot.c line 15
Quoted 10 lines
drivers/firmware/efi/libstub/secureboot.c new file +10
-0+* Copyright (C) 2013 Red Hat, Inc. +* Mark Salter <[email protected]> +* +* This file is part of the Linux kernel, and is made available under the +* terms of the GNU General Public License version 2. +* +*/ + +#include <linux/efi.h> +#include <linux/sort.h>
You don't need sort.h.
drivers/firmware/efi/libstub/secureboot.c
Quoted 9 lines
drivers/firmware/efi/libstub/secureboot.c new file +3
-0+#include <asm/efi.h> + +#include "efistub.h" From a cursory look at
efistub.h, you don't seem to need this either.drivers/firmware/efi/libstub/secureboot.c new file +2
-0+ +int efi_get_secureboot (void )
It looks like you didn't compile-test this on ARM.
You dropped the efi_system_table_t *sys_table_arg argument but this isn't defined anywhere as a static global.
drivers/firmware/efi/libstub/secureboot.c line 28
Quoted 8 lines
drivers/firmware/efi/libstub/secureboot.c new file +8
-0+{ +static const efi_char16_t const sb_var_name[] = { +'S' ,'e' ,'c' ,'u' ,'r' ,'e' ,'B' ,'o' ,'o' ,'t' ,0 }; +static const efi_char16_t const sm_var_name[] = { +'S' ,'e' ,'t' ,'u' ,'p' ,'M' ,'o' ,'d' ,'e' ,0 }; + +static const efi_guid_t var_guid =EFI_GLOBAL_VARIABLE_GUID ; +
Gratuitous newline in-between variable declarations.
drivers/firmware/efi/libstub/secureboot.c line 36
Quoted 8 lines
drivers/firmware/efi/libstub/secureboot.c new file +8
-0+u8 val; +unsigned long size =sizeof (val); +efi_status_t status; + +#define f_getvar (...) efi_call_runtime(get_variable, __VA_ARGS__) + + status =f_getvar ((efi_char16_t *)sb_var_name, (efi_guid_t *)&var_guid, +NULL , &size, &val);
Just replace the f_getvar yourself instead of having cpp do it:
status = efi_call_runtime(get_variable, (efi_char16_t *)sb_var_name, (efi_guid_t *)&var_guid, NULL, &size, &val);
drivers/firmware/efi/libstub/secureboot.c line 45
Quoted 9 lines
drivers/firmware/efi/libstub/secureboot.c new file +9
-0+ +if (status !=EFI_SUCCESS ) + goto out_efi_err; + +if (val ==0 ) +return 0 ; + + status =f_getvar ((efi_char16_t *)sm_var_name, (efi_guid_t *)&var_guid, +NULL , &size, &val);
Same here.
Quoted 10 lines
drivers/firmware/efi/libstub/secureboot.c new file +10
-0+ +if (status !=EFI_SUCCESS ) + goto out_efi_err; + +if (val ==1 ) +return 0 ; + +return 1 ; + +out_efi_err:
drivers/firmware/efi/libstub/secureboot.c line 65
Quoted 10 lines
drivers/firmware/efi/libstub/secureboot.c new file +10
-0+switch (status) { +case EFI_NOT_FOUND : +return 0 ; +case EFI_DEVICE_ERROR : +return -EIO ; +case EFI_SECURITY_VIOLATION : +return -EACCES ; +default : +return -EINVAL ; + }
The "out_efi_err" portion differs from the previous version of this patch. Setting a __u8 to a negative value, is this really what you want?
Thanks,
Lukas
Quoted 15 lines
drivers/firmware/efi/libstub/secureboot.c new file +1
-0+}include/linux/efi.h +2
-0@@ -1477,6 +1477,8 @@ efi_status_t efi_setup_gop(efi_system_table_t *sys_table_arg,bool efi_runtime_disabled (void );extern void efi_call_virt_check_flags (unsigned long flags,const char *call); +int efi_get_secureboot (void ); +/* * Arch code can implement the following three template macros, avoiding * reptition for the void/non-void return cases of {__,}efi_call_virt():
Re: [PATCH 4/6] efi: Get the secure boot status
Quoted 183 lines · Lukas Wunner
Quoted 2 lines · David Howells
Get the firmware's secure-boot status in the kernel boot wrapper and stash it somewhere that the main kernel image can find.
That's a bit terse. You could write here that you're moving the existing ARM function to generic stub code to be able to reuse it on x86.
Further comments below.
Quoted 41 lines
Signed-off-by David Howells <[email protected]>---
Documentation/x86/zero-page.txt | 2 + arch/x86/boot/compressed/eboot.c | 5 ++ arch/x86/include/uapi/asm/bootparam.h | 3 + drivers/firmware/efi/libstub/Makefile | 2 - drivers/firmware/efi/libstub/arm-stub.c | 46 -------------------- drivers/firmware/efi/libstub/secureboot.c | 66 +++++++++++++++++++++++++++++ include/linux/efi.h | 2 + 7 files changed, 78 insertions(+), 48 deletions(-) create mode 100644 drivers/firmware/efi/libstub/secureboot.cDocumentation/x86/zero-page.txt +2
-0@@ -31,6 +31,8 @@ Offset Proto Name Meaning 1E9/001 ALL eddbuf_entries Number of entries in eddbuf (below) 1EA/001 ALL edd_mbr_sig_buf_entries Number of entries in edd_mbr_sig_buffer (below) +1EB/001 ALL kbd_status Numlock is enabled +1EC/001 ALL secure_boot Secure boot is enabled in the firmware 1EF/001 ALL sentinel Used to detect broken bootloaders 290/040 ALL edd_mbr_sig_buffer EDD MBR signatures 2D0/A00 ALL e820_map E820 memory map tablearch/x86/boot/compressed/eboot.c +1
-0@@ -12,6 +12,7 @@#include <asm/efi.h> #include <asm/setup.h> #include <asm/desc.h> +#include <asm/bootparam_utils.h> #include "../string.h" #include "eboot.h" arch/x86/boot/compressed/eboot.c struct boot_params *efi_main(struct efi_config *c, · line 1162
Quoted 4 lines
arch/x86/boot/compressed/eboot.c +1
-0@@ -1158,6 +1159,10 @@ struct boot_params *efi_main(struct efi_config *c,else setup_boot_services32 (efi_early); +sanitize_boot_params (boot_params);What is the connection of this change to the rest of the patch? Needs an explanation in the commit message.
Quoted 101 lines
arch/x86/boot/compressed/eboot.c +3
-0+ + boot_params->secure_boot =efi_get_secureboot (); +setup_graphics (boot_params);setup_efi_pci (boot_params);arch/x86/include/uapi/asm/bootparam.h +2
-1@@ -135,7 +135,8 @@ struct boot_params {__u8 eddbuf_entries;/* 0x1e9 */ __u8 edd_mbr_sig_buf_entries;/* 0x1ea */ __u8 kbd_status;/* 0x1eb */ -__u8 _pad5[3 ];/* 0x1ec */ +__u8 secure_boot;/* 0x1ec */ +__u8 _pad5[2 ];/* 0x1ed */ /* * The sentinel is set to a nonzero value (0xff) in header.S. * drivers/firmware/efi/libstub/Makefile +1
-1@@ -28,7 +28,7 @@ OBJECT_FILES_NON_STANDARD := y # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. KCOV_INSTRUMENT := n -lib-y := efi-stub-helper.o gop.o +lib-y := efi-stub-helper.o gop.o secureboot.o # include the stub's generic dependencies from lib/ when building for ARM/arm64 arm-deps := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c fdt_empty_tree.c fdt_sw.c sort.cdrivers/firmware/efi/libstub/arm-stub.c +0
-46@@ -20,52 +20,6 @@bool __nokaslr; -static int efi_get_secureboot (efi_system_table_t *sys_table_arg) -{ -static efi_char16_t const sb_var_name[] = { -'S' ,'e' ,'c' ,'u' ,'r' ,'e' ,'B' ,'o' ,'o' ,'t' ,0 }; -static efi_char16_t const sm_var_name[] = { -'S' ,'e' ,'t' ,'u' ,'p' ,'M' ,'o' ,'d' ,'e' ,0 }; - -efi_guid_t var_guid =EFI_GLOBAL_VARIABLE_GUID ; -efi_get_variable_t *f_getvar = sys_table_arg->runtime->get_variable; -u8 val; -unsigned long size =sizeof (val); -efi_status_t status; - - status =f_getvar ((efi_char16_t *)sb_var_name, (efi_guid_t *)&var_guid, -NULL , &size, &val); - -if (status !=EFI_SUCCESS ) - goto out_efi_err; - -if (val ==0 ) -return 0 ; - - status =f_getvar ((efi_char16_t *)sm_var_name, (efi_guid_t *)&var_guid, -NULL , &size, &val); - -if (status !=EFI_SUCCESS ) - goto out_efi_err; - -if (val ==1 ) -return 0 ; - -return 1 ; - -out_efi_err: -switch (status) { -case EFI_NOT_FOUND : -return 0 ; -case EFI_DEVICE_ERROR : -return -EIO ; -case EFI_SECURITY_VIOLATION : -return -EACCES ; -default : -return -EINVAL ; - } -} -efi_status_t efi_open_volume (efi_system_table_t *sys_table_arg,void *__image,void **__fh) {drivers/firmware/efi/libstub/secureboot.c new file +5
-0@@ -0,0 +1,66 @@ +/* +* Secure boot handling. +* +* Copyright (C) 2013,2014 Linaro Limited +* Roy Franz <[email protected] drivers/firmware/efi/libstub/secureboot.c line 15
Quoted 10 lines
drivers/firmware/efi/libstub/secureboot.c new file +10
-0+* Copyright (C) 2013 Red Hat, Inc. +* Mark Salter <[email protected]> +* +* This file is part of the Linux kernel, and is made available under the +* terms of the GNU General Public License version 2. +* +*/ + +#include <linux/efi.h> +#include <linux/sort.h> You don't need
sort.h.drivers/firmware/efi/libstub/secureboot.c line 18
Quoted 3 lines
drivers/firmware/efi/libstub/secureboot.c new file +3
-0+#include <asm/efi.h> + +#include "efistub.h" From a cursory look at
efistub.h, you don't seem to need this either.
Quoted 8 lines
drivers/firmware/efi/libstub/secureboot.c line 20
Quoted 2 lines
drivers/firmware/efi/libstub/secureboot.c new file +2
-0+ +int efi_get_secureboot (void )It looks like you didn't compile-test this on ARM.
You dropped the
efi_system_table_t*sys_table_argargument but this isn't defined anywhere as a static global.
That is actually a thing that has been annoying me: the efi_call_xxx macros on ARM/arm64 rely on sys_table_arg being defined in the current scope, which hides this dependency from users of the macro, and is also a pain given that you are forced to use the exact name 'sys_table_arg'. Patches that clean that up are gladly accepted, or I may take a stab at this myself (but not for a week or two)
Quoted 88 lines
drivers/firmware/efi/libstub/secureboot.c line 28
Quoted 9 lines
drivers/firmware/efi/libstub/secureboot.c new file +8
-0+{ +static const efi_char16_t const sb_var_name[] = { +'S' ,'e' ,'c' ,'u' ,'r' ,'e' ,'B' ,'o' ,'o' ,'t' ,0 }; +static const efi_char16_t const sm_var_name[] = { +'S' ,'e' ,'t' ,'u' ,'p' ,'M' ,'o' ,'d' ,'e' ,0 }; + +static const efi_guid_t var_guid =EFI_GLOBAL_VARIABLE_GUID ; +Gratuitous newline in-between variable declarations.
drivers/firmware/efi/libstub/secureboot.c line 36
Quoted 8 lines
drivers/firmware/efi/libstub/secureboot.c new file +8
-0+u8 val; +unsigned long size =sizeof (val); +efi_status_t status; + +#define f_getvar (...) efi_call_runtime(get_variable, __VA_ARGS__) + + status =f_getvar ((efi_char16_t *)sb_var_name, (efi_guid_t *)&var_guid, +NULL , &size, &val);Just replace the
f_getvaryourself instead of having cpp do it:status = efi_call_runtime(get_variable, (
efi_char16_t*)sb_var_name,
(efi_guid_t*)&var_guid, NULL, &size, &val);drivers/firmware/efi/libstub/secureboot.c line 45
Quoted 9 lines
drivers/firmware/efi/libstub/secureboot.c new file +9
-0+ +if (status !=EFI_SUCCESS ) + goto out_efi_err; + +if (val ==0 ) +return 0 ; + + status =f_getvar ((efi_char16_t *)sm_var_name, (efi_guid_t *)&var_guid, +NULL , &size, &val);Same here.
Quoted 10 lines
drivers/firmware/efi/libstub/secureboot.c new file +10
-0+ +if (status !=EFI_SUCCESS ) + goto out_efi_err; + +if (val ==1 ) +return 0 ; + +return 1 ; + +out_efi_err:drivers/firmware/efi/libstub/secureboot.c line 65
Quoted 10 lines
drivers/firmware/efi/libstub/secureboot.c new file +10
-0+switch (status) { +case EFI_NOT_FOUND : +return 0 ; +case EFI_DEVICE_ERROR : +return -EIO ; +case EFI_SECURITY_VIOLATION : +return -EACCES ; +default : +return -EINVAL ; + }The "
out_efi_err" portion differs from the previous version of this patch. Setting a__u8to a negative value, is this really what you want?Thanks,
Lukas
Quoted 7 lines
drivers/firmware/efi/libstub/secureboot.c new file +1
-0+}include/linux/efi.h +0
-0include/linux/efi.h efi_status_t efi_setup_gop(efi_system_table_t *sys_table_arg, · line 1484
Quoted 8 lines
include/linux/efi.h +2
-0@@ -1477,6 +1477,8 @@ efi_status_t efi_setup_gop(efi_system_table_t *sys_table_arg,bool efi_runtime_disabled (void );extern void efi_call_virt_check_flags (unsigned long flags,const char *call); +int efi_get_secureboot (void ); +/* * Arch code can implement the following three template macros, avoiding * reptition for the void/non-void return cases of {__,}efi_call_virt(): --
To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/6] efi: Get the secure boot status
In reply to Lukas WunnerQuoted 3 lines · Lukas Wunner
Quoted 1 line
+int
efi_get_secureboot(void)It looks like you didn't compile-test this on ARM.
Yes. What arm config would you suggest?
Quoted 9 lines
drivers/firmware/efi/libstub/secureboot.c line 36
Quoted 4 lines
drivers/firmware/efi/libstub/secureboot.c new file +4
-0+#define f_getvar (...) efi_call_runtime(get_variable, __VA_ARGS__) + + status =f_getvar ((efi_char16_t *)sb_var_name, (efi_guid_t *)&var_guid, +NULL , &size, &val);Just replace the
f_getvaryourself instead of having cpp do it:status = efi_call_runtime(get_variable, (efi_char16_t *)sb_var_name, (efi_guid_t *)&var_guid, NULL, &size, &val);
That makes it less clear. I think something like this makes it much more obvious:
static efi_status_t get_efi_var(const efi_char16_t *name,
const efi_guid_t *vendor,
u32 *attr,
unsigned long *data_size, void *data)
{
return efi_call_runtime(get_variable,
(efi_char16_t *)name, (efi_guid_t *)vendor,
attr, data_size, data);
}And then doing:
status = get_efi_var(efi_SecureBoot_name, &efi_variable_guid, NULL, &size, &val);
which the compiler will inline.
Quoted 3 lines
The "
out_efi_err" portion differs from the previous version of this patch. Setting a__u8to a negative value, is this really what you want?
Eh? efi_get_secureboot() returns an int as before. The out_efi_err: portions are exactly the same:
Quoted 4 lines
-static int
efi_get_secureboot(...)> +intefi_get_secureboot(...)
... > ...(quoted diff) +0
-2-out_efi_err: > +out_efi_err: - switch (status) { > + switch (status) {
Review
Quoted 10 lines
(quoted diff) +0
-10- case EFI_NOT_FOUND: > + case EFI_NOT_FOUND: - return 0; > + return 0; - case EFI_DEVICE_ERROR: > + case EFI_DEVICE_ERROR: - return -EIO; > + return -EIO; - case EFI_SECURITY_VIOLATION: > + case EFI_SECURITY_VIOLATION: - return -EACCES; > + return -EACCES; - default: > + default: - return -EINVAL; > + return -EINVAL; - } > + } -}
David
Re: [PATCH 4/6] efi: Get the secure boot status
Quoted 13 lines · David Howells
That makes it less clear. I think something like this makes it much more obvious:
static efi_status_t get_efi_var(const efi_char16_t *name, const efi_guid_t *vendor, u32 *attr, unsigned long *data_size, void *data) { return efi_call_runtime(get_variable, (efi_char16_t *)name, (efi_guid_t *)vendor, attr, data_size, data); }
Quoted 6 lines
And then doing:
status = get_efi_var(efi_SecureBoot_name, &efi_variable_guid, NULL, &size, &val);which the compiler will inline.
Of course, it has to be a macro because efi_call_runtime() has an undeclared argument on ARM...
David
Re: [PATCH 4/6] efi: Get the secure boot status
In reply to David HowellsQuoted 7 lines · David Howells
Quoted 3 lines · Lukas Wunner
The "
out_efi_err" portion differs from the previous version of this patch. Setting a__u8to a negative value, is this really what you want?Eh?
efi_get_secureboot()returns an int as before. Theout_efi_err:
portions are exactly the same:
By "the previous version of this patch" I was referring to your submission of Nov 16, not the existing code in the kernel. Your patch didn't contain the out_efi_err portion.
You're assigning a negative value to boot_params->secure_boot (which is declared __u8).
In the next patch you're just checking if the value isn't 0 and you're considerung secure boot to be enabled even though GetVariable failed. Hence my question above, is this what you want? Likely not, perhaps this is what you really want:
boot_params->secure_boot = (efi_get_secureboot() == 1);
Best regards,
Lukas
Re: [PATCH 4/6] efi: Get the secure boot status
Quoted 9 lines · Lukas Wunner
Quoted 7 lines · David Howells
Quoted 3 lines · Lukas Wunner
The "
out_efi_err" portion differs from the previous version of this patch. Setting a__u8to a negative value, is this really what you want?Eh?
efi_get_secureboot()returns an int as before. Theout_efi_err:
portions are exactly the same:
Quoted 6 lines
By "the previous version of this patch" I was referring to your submission of Nov 16, not the existing code in the kernel. Your patch didn't contain the
out_efi_errportion.You're assigning a negative value to
boot_params->secure_boot(which is declared__u8).
Ah, yes. Sorry, you confused me by specifying a comparison against the last version.
David
Re: [PATCH 4/6] efi: Get the secure boot status
In reply to Lukas WunnerQuoted 2 lines · Lukas Wunner
You dropped the
efi_system_table_t*sys_table_argargument but this isn't defined anywhere as a static global.
It seems to me that passing this value in on x86 is probably a bad idea as it's not mixed-mode safe. Should I just pass NULL there in that case?
David
Re: [PATCH 4/6] efi: Get the secure boot status
Quoted 6 lines · David Howells
Quoted 2 lines · Lukas Wunner
You dropped the
efi_system_table_t*sys_table_argargument but this isn't defined anywhere as a static global.It seems to me that passing this value in on x86 is probably a bad idea as it's not mixed-mode safe. Should I just pass NULL there in that case?
It's safe, it's merely a pointer below 4 Gig. Just on dereference it needs to be cast to the correct variant. Passing in sys_table_arg is done all over the place in the EFI stub, see e.g. efi_printk().
Best regards,
Lukas
PATCH 5/6 efi: Disable secure boot if shim is in insecure mode
In reply to Lukas WunnerFrom: Josh Boyer <[email protected]>
A user can manually tell the shim boot loader to disable validation of images it loads. When a user does this, it creates a UEFI variable called MokSBState that does not have the runtime attribute set. Given that the user explicitly disabled validation, we can honor that and not enable secure boot mode if that variable is set.
---
drivers/firmware/efi/libstub/secureboot.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
drivers/firmware/efi/libstub/secureboot.c +21 -1
@@ -23,10 +23,14 @@ int efi_get_secureboot(void) 'S', 'e', 'c', 'u', 'r', 'e', 'B', 'o', 'o', 't', 0 };static const efi_char16_t const sm_var_name[] = {'S' ,'e' ,'t' ,'u' ,'p' ,'M' ,'o' ,'d' ,'e' ,0 }; +static efi_char16_t const MokSBState_var_name[] = { +'M' ,'o' ,'k' ,'S' ,'B' ,'S' ,'t' ,'a' ,'t' ,'e' ,0 };static const efi_guid_t var_guid =EFI_GLOBAL_VARIABLE_GUID ; +static const efi_guid_t shim_guid =EFI_SHIM_LOCK_GUID ; -u8 val; +u32 attr; +u8 val, moksbstate;unsigned long size =sizeof (val);efi_status_t status;
@@ -50,6 +54,22 @@ int efi_get_secureboot(void)if (val ==1 )return 0 ; +/* See if a user has put shim into insecure mode. If so, and if the +* variable doesn't have the runtime attribute set, we might as well +* honor that. +*/ + size =sizeof (moksbstate); + status =f_getvar ((efi_char16_t *)MokSBState_var_name, &shim_guid, + &attr, &size, &moksbstate); + +/* If it fails, we don't care why. Default to secure */ +if (status !=EFI_SUCCESS ) +return 1 ; + +if (!(attr &EFI_VARIABLE_RUNTIME_ACCESS ) && + moksbstate ==1 ) +return 0 ; +return 1 ; out_efi_err:
Re: [PATCH 5/6] efi: Disable secure boot if shim is in insecure mode
Quoted 36 lines · David Howells
From: Josh Boyer <[email protected]>
A user can manually tell the shim boot loader to disable validation of images it loads. When a user does this, it creates a UEFI variable called MokSBState that does not have the runtime attribute set. Given that the user explicitly disabled validation, we can honor that and not enable secure boot mode if that variable is set.
Signed-off-by Josh Boyer <[email protected]>Signed-off-by David Howells <[email protected]>---
drivers/firmware/efi/libstub/secureboot.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)drivers/firmware/efi/libstub/secureboot.c +5
-1@@ -23,10 +23,14 @@ int efi_get_secureboot(void) 'S', 'e', 'c', 'u', 'r', 'e', 'B', 'o', 'o', 't', 0 };static const efi_char16_t const sm_var_name[] = {'S' ,'e' ,'t' ,'u' ,'p' ,'M' ,'o' ,'d' ,'e' ,0 }; +static efi_char16_t const MokSBState_var_name[] = { +'M' ,'o' ,'k' ,'S' ,'B' ,'S' ,'t' ,'a' ,'t' ,'e' ,0 };static const efi_guid_t var_guid =EFI_GLOBAL_VARIABLE_GUID ; +static const efi_guid_t shim_guid =EFI_SHIM_LOCK_GUID ; -u8 val; +u32 attr; +u8 val, moksbstate;unsigned long size =sizeof (val);efi_status_t status;
drivers/firmware/efi/libstub/secureboot.c int efi_get_secureboot(void) · line 63
Quoted 10 lines
drivers/firmware/efi/libstub/secureboot.c +7
-0@@ -50,6 +54,22 @@ int efi_get_secureboot(void)if (val ==1 )return 0 ; +/* See if a user has put shim into insecure mode. If so, and if the +* variable doesn't have the runtime attribute set, we might as well +* honor that. +*/ + size =sizeof (moksbstate); + status =f_getvar ((efi_char16_t *)MokSBState_var_name, &shim_guid, + &attr, &size, &moksbstate);
Please use efi_call_runtime() instead of f_getvar().
drivers/firmware/efi/libstub/secureboot.c int efi_get_secureboot(void) · line 70
Quoted 7 lines
drivers/firmware/efi/libstub/secureboot.c +7
-0+ +/* If it fails, we don't care why. Default to secure */ +if (status !=EFI_SUCCESS ) +return 1 ; + +if (!(attr &EFI_VARIABLE_RUNTIME_ACCESS ) && + moksbstate ==1 )
This would fit on a single line.
Thanks,
Lukas
Quoted 6 lines
drivers/firmware/efi/libstub/secureboot.c +2
-0+return 0 ; +return 1 ; out_efi_err:
PATCH 6/6 efi: Add EFI_SECURE_BOOT bit
In reply to Lukas WunnerFrom: Josh Boyer <[email protected]>
UEFI machines can be booted in Secure Boot mode. Add a EFI_SECURE_BOOT bit for use with efi_enabled.
---
arch/x86/kernel/setup.c | 5 +++++ include/linux/efi.h | 1 + 2 files changed, 6 insertions(+)
arch/x86/kernel/setup.c +5 -0
@@ -1160,6 +1160,11 @@ void __init setup_arch(char **cmdline_p)io_delay_init (); +if (boot_params.secure_boot) { +set_bit (EFI_SECURE_BOOT , &efi.flags); +pr_info ("Secure boot enabled\n" ); + } +/* * Parse the ACPI tables for possible boot-time SMP configuration. */
include/linux/efi.h +1 -0
@@ -1066,6 +1066,7 @@ extern int __init efi_setup_pcdp_console(char *);#define EFI_ARCH_1 7/* First arch-specific bit */ #define EFI_DBG 8/* Print additional debug info at runtime */ #define EFI_NX_PE_DATA 9/* Can runtime data regions be mapped non-executable? */ +#define EFI_SECURE_BOOT 10/* Are we in Secure Boot mode? */ #ifdef CONFIG_EFI /*
Re: [PATCH 6/6] efi: Add EFI_SECURE_BOOT bit
Quoted 4 lines · David Howells
From: Josh Boyer <[email protected]>
UEFI machines can be booted in Secure Boot mode. Add a
EFI_SECURE_BOOTbit for use withefi_enabled.
Please add an explanation what you plan to do with this bit going forward.
Thanks,
Lukas
Quoted 38 lines
Signed-off-by Josh Boyer <[email protected]>Signed-off-by David Howells <[email protected]>---
arch/x86/kernel/setup.c | 5 +++++ include/linux/efi.h | 1 + 2 files changed, 6 insertions(+)arch/x86/kernel/setup.c +5
-0@@ -1160,6 +1160,11 @@ void __init setup_arch(char **cmdline_p)io_delay_init (); +if (boot_params.secure_boot) { +set_bit (EFI_SECURE_BOOT , &efi.flags); +pr_info ("Secure boot enabled\n" ); + } +/* * Parse the ACPI tables for possible boot-time SMP configuration. */ include/linux/efi.h +1
-0@@ -1066,6 +1066,7 @@ extern int __init efi_setup_pcdp_console(char *);#define EFI_ARCH_1 7/* First arch-specific bit */ #define EFI_DBG 8/* Print additional debug info at runtime */ #define EFI_NX_PE_DATA 9/* Can runtime data regions be mapped non-executable? */ +#define EFI_SECURE_BOOT 10/* Are we in Secure Boot mode? */ #ifdef CONFIG_EFI /*
PATCH 3/16 efi: Disable secure boot if shim is in insecure mode
In reply to David HowellsFrom: Josh Boyer <[email protected]>
A user can manually tell the shim boot loader to disable validation of images it loads. When a user does this, it creates a UEFI variable called MokSBState that does not have the runtime attribute set. Given that the user explicitly disabled validation, we can honor that and not enable secure boot mode if that variable is set.
---
arch/x86/boot/compressed/eboot.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
arch/x86/boot/compressed/eboot.c +19 -1
@@ -540,8 +540,9 @@ static void setup_efi_pci(struct boot_params *params)static int get_secure_boot (void ) { -u8 sb, setup; +u8 sb, setup, moksbstate;unsigned long datasize =sizeof (sb); +u32 attr;efi_guid_t var_guid =EFI_GLOBAL_VARIABLE_GUID ;efi_status_t status;
@@ -565,6 +566,23 @@ static int get_secure_boot(void)if (setup ==1 )return 0 ; +/* See if a user has put shim into insecure_mode. If so, and the variable +* doesn't have the runtime attribute set, we might as well honor that. +*/ + var_guid =EFI_SHIM_LOCK_GUID ; + status = efi_early->call ((unsigned long )sys_table->runtime->get_variable, +L"MokSBState" , &var_guid, &attr, &datasize, + &moksbstate); + +/* If it fails, we don't care why. Default to secure */ +if (status !=EFI_SUCCESS ) +return 1 ; + +if (!(attr &EFI_VARIABLE_RUNTIME_ACCESS )) { +if (moksbstate ==1 ) +return 0 ; + } +return 1 ; }
PATCH 4/16 efi: Lock down the kernel if booted in secure boot mode
In reply to David HowellsUEFI Secure Boot provides a mechanism for ensuring that the firmware will only load signed bootloaders and kernels. Certain use cases may also require that all kernel modules also be signed. Add a configuration option that to lock down the kernel - which includes requiring validly signed modules - if the kernel is secure-booted.
---
arch/x86/Kconfig | 12 ++++++++++++ arch/x86/kernel/setup.c | 7 +++++++ kernel/module.c | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-)
arch/x86/Kconfig +12 -0
@@ -1786,6 +1786,18 @@ config EFI_MIXED If unsure, say N. +config EFI_SECURE_BOOT_LOCK_DOWN + def_bool n + depends on EFI + prompt "Lock down the kernel when UEFI Secure Boot is enabled" + ---help--- + UEFI Secure Boot provides a mechanism for ensuring that the firmware + will only load signed bootloaders and kernels. Certain use cases may + also require that all kernel modules also be signed and that + userspace is prevented from directly changing the running kernel + image. Say Y here to automatically lock down the kernel when a + system boots with UEFI Secure Boot enabled. + config SECCOMP def_bool y prompt "Enable seccomp to safely compute untrusted bytecode"
arch/x86/kernel/setup.c +7 -0
@@ -69,6 +69,7 @@#include <linux/crash_dump.h> #include <linux/tboot.h> #include <linux/jiffies.h> +#include <linux/security.h> #include <video/edid.h>
@@ -1160,6 +1161,12 @@ void __init setup_arch(char **cmdline_p)io_delay_init (); +if (boot_params.secure_boot && +IS_ENABLED (CONFIG_EFI_SECURE_BOOT_LOCK_DOWN )) { +lock_kernel_down (); +pr_info ("Secure boot enabled\n" ); + } +/* * Parse the ACPI tables for possible boot-time SMP configuration. */
kernel/module.c +1 -1
@@ -2744,7 +2744,7 @@ static int module_sig_check(struct load_info *info, int flags) }/* Not having a signature is only an error if we're strict. */ -if (err == -ENOKEY && !sig_enforce) +if (err == -ENOKEY && !sig_enforce && !kernel_is_locked_down ()) err =0 ;return err;
PATCH 5/16 efi: Add EFI_SECURE_BOOT bit
In reply to David HowellsFrom: Josh Boyer <[email protected]>
UEFI machines can be booted in Secure Boot mode. Add a EFI_SECURE_BOOT bit for use with efi_enabled.
---
arch/x86/kernel/setup.c | 1 + include/linux/efi.h | 1 + 2 files changed, 2 insertions(+)
arch/x86/kernel/setup.c +1 -0
@@ -1164,6 +1164,7 @@ void __init setup_arch(char **cmdline_p)if (boot_params.secure_boot &&IS_ENABLED (CONFIG_EFI_SECURE_BOOT_LOCK_DOWN )) {lock_kernel_down (); +set_bit (EFI_SECURE_BOOT , &efi.flags);pr_info ("Secure boot enabled\n" ); }
include/linux/efi.h +1 -0
@@ -1079,6 +1079,7 @@ extern int __init efi_setup_pcdp_console(char *);#define EFI_ARCH_1 7/* First arch-specific bit */ #define EFI_DBG 8/* Print additional debug info at runtime */ #define EFI_NX_PE_DATA 9/* Can runtime data regions be mapped non-executable? */ +#define EFI_SECURE_BOOT 10/* Are we in Secure Boot mode? */ #ifdef CONFIG_EFI /*
Re: [PATCH 05/16] efi: Add EFI_SECURE_BOOT bit
Quoted 18 lines · David Howells
From: Josh Boyer <[email protected]>
UEFI machines can be booted in Secure Boot mode. Add a
EFI_SECURE_BOOTbit for use withefi_enabled.Signed-off-by Josh Boyer <[email protected]>Signed-off-by David Howells <[email protected]>---
arch/x86/kernel/setup.c | 1 + include/linux/efi.h | 1 + 2 files changed, 2 insertions(+)arch/x86/kernel/setup.c +0
-0
arch/x86/kernel/setup.c void __init setup_arch(char **cmdline_p) · line 1167
Quoted 4 lines
arch/x86/kernel/setup.c +1
-0@@ -1164,6 +1164,7 @@ void __init setup_arch(char **cmdline_p)if (boot_params.secure_boot &&IS_ENABLED (CONFIG_EFI_SECURE_BOOT_LOCK_DOWN )) {lock_kernel_down (); +set_bit (EFI_SECURE_BOOT , &efi.flags);
Why is this x86 only? And why is this bit only set if CONFIG_EFI_SECURE_BOOT_LOCK_DOWN is enabled?
Quoted 20 lines
arch/x86/kernel/setup.c +0
-0pr_info ("Secure boot enabled\n" ); }include/linux/efi.h +1
-1@@ -1079,6 +1079,7 @@ extern int __init efi_setup_pcdp_console(char *);#define EFI_ARCH_1 7/* First arch-specific bit */ #define EFI_DBG 8/* Print additional debug info at runtime */ #define EFI_NX_PE_DATA 9/* Can runtime data regions be mapped non-executable? */ +#define EFI_SECURE_BOOT 10/* Are we in Secure Boot mode? */ #ifdef CONFIG_EFI /* -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 05/16] efi: Add EFI_SECURE_BOOT bit
Quoted 14 lines · Ard Biesheuvel
Quoted 13 lines · David Howells
From: Josh Boyer <[email protected]>
UEFI machines can be booted in Secure Boot mode. Add a
EFI_SECURE_BOOTbit for use withefi_enabled.Signed-off-by Josh Boyer <[email protected]>Signed-off-by David Howells <[email protected]>---
arch/x86/kernel/setup.c | 1 + include/linux/efi.h | 1 + 2 files changed, 2 insertions(+)
Quoted 11 lines
arch/x86/kernel/setup.c void __init setup_arch(char **cmdline_p) · line 1167
Quoted 9 lines
arch/x86/kernel/setup.c +1
-0@@ -1164,6 +1164,7 @@ void __init setup_arch(char **cmdline_p)if (boot_params.secure_boot &&IS_ENABLED (CONFIG_EFI_SECURE_BOOT_LOCK_DOWN )) {lock_kernel_down (); +set_bit (EFI_SECURE_BOOT , &efi.flags);Why is this x86 only? And why is this bit only set if
Because it was initially written like 3 years ago before ARM even had UEFI. Needs a refresh.
Quoted 1 line
CONFIG_EFI_SECURE_BOOT_LOCK_DOWNis enabled?
That part is new and something David added. Probably not necessary.
josh
Re: [PATCH 05/16] efi: Add EFI_SECURE_BOOT bit
Quoted 28 lines · Josh Boyer
Quoted 14 lines · Ard Biesheuvel
Quoted 13 lines · David Howells
From: Josh Boyer <jwboyer-rxtnV0ftBwyoClj4AeEUq9i2O/[email protected]>
UEFI machines can be booted in Secure Boot mode. Add a
EFI_SECURE_BOOTbit for use withefi_enabled.Signed-off-by David Howells <[email protected]>---
arch/x86/kernel/setup.c | 1 + include/linux/efi.h | 1 + 2 files changed, 2 insertions(+)Quoted 11 lines
arch/x86/kernel/setup.c void __init setup_arch(char **cmdline_p) · line 1167
Quoted 9 lines
arch/x86/kernel/setup.c +1
-0@@ -1164,6 +1164,7 @@ void __init setup_arch(char **cmdline_p)if (boot_params.secure_boot &&IS_ENABLED (CONFIG_EFI_SECURE_BOOT_LOCK_DOWN )) {lock_kernel_down (); +set_bit (EFI_SECURE_BOOT , &efi.flags);Why is this x86 only? And why is this bit only set if
Quoted 3 lines
Because it was initially written like 3 years ago before ARM even had UEFI. Needs a refresh.
Ah ok. I missed that part.
In any case, we have been working very hard over the past couple of years to move all the UEFI stuff out of arch/x86, except for the pieces that *really* belong there. For this series, that means that a fair share of the changes will need to be reworked and moved under drivers/firmware/efi. Note that that also means you cannot use L"" string literals anymore, since arm64's UEFI stub is linked into the kernel proper, and the wide character formats are incompatible between UEFI and the wide char handling that occurs under fs/. Please check the existing secureboot_enabled() function Lukas referred to as an example how to emit wide string literals instead.
Quoted 4 lines
Quoted 1 line
CONFIG_EFI_SECURE_BOOT_LOCK_DOWNis enabled?That part is new and something David added. Probably not necessary.
Regardless of anything else, think is is useful to have a EFI_xx flag that is always set when secure boot is enabled.
Re: [PATCH 05/16] efi: Add EFI_SECURE_BOOT bit
In reply to Ard BiesheuvelQuoted 7 lines · Ard Biesheuvel
arch/x86/kernel/setup.c void __init setup_arch(char **cmdline_p) · line 1167
Quoted 5 lines
arch/x86/kernel/setup.c +1
-0@@ -1164,6 +1164,7 @@ void __init setup_arch(char **cmdline_p)if (boot_params.secure_boot &&IS_ENABLED (CONFIG_EFI_SECURE_BOOT_LOCK_DOWN )) {lock_kernel_down (); +set_bit (EFI_SECURE_BOOT , &efi.flags);Why is this x86 only?
It probably doesn't really need to be, but that's what the patches I ported do.
Quoted 1 line
And why is this bit only set if
CONFIG_EFI_SECURE_BOOT_LOCK_DOWNis enabled?
Actually, the EFI_SECURE_BOOT bit should probably be set outside of that portion of the if-condition.
David
PATCH 6/16 Add a sysrq option to exit secure boot mode
In reply to David HowellsFrom: Kyle McMartin <[email protected]>
Make sysrq+x exit secure boot mode on x86_64, thereby allowing the running kernel image to be modified. This lifts the lockdown.
---
arch/x86/Kconfig | 10 ++++++++++ arch/x86/kernel/setup.c | 31 +++++++++++++++++++++++++++++++ drivers/input/misc/uinput.c | 1 + drivers/tty/sysrq.c | 19 +++++++++++++------ include/linux/input.h | 5 +++++ include/linux/sysrq.h | 8 +++++++- kernel/debug/kdb/kdb_main.c | 2 +- 7 files changed, 68 insertions(+), 8 deletions(-)
arch/x86/Kconfig +10 -0
@@ -1798,6 +1798,16 @@ config EFI_SECURE_BOOT_LOCK_DOWN image. Say Y here to automatically lock down the kernel when a system boots with UEFI Secure Boot enabled. +config EFI_ALLOW_SECURE_BOOT_EXIT + def_bool n + depends on EFI_SECURE_BOOT_LOCK_DOWN && MAGIC_SYSRQ + select ALLOW_LOCKDOWN_LIFT + prompt "Allow secure boot mode to be exited with SysRq+x on a keyboard" + ---help--- + Allow secure boot mode to be exited and the kernel lockdown lifted by + typing SysRq+x on a keyboard attached to the system (not permitted + through procfs). + config SECCOMP def_bool y prompt "Enable seccomp to safely compute untrusted bytecode"
arch/x86/kernel/setup.c +31 -0
@@ -71,6 +71,11 @@#include <linux/jiffies.h> #include <linux/security.h> +#include <linux/fips.h> +#include <linux/cred.h> +#include <linux/sysrq.h> +#include <linux/init_task.h> +#include <video/edid.h> #include <asm/mtrr.h>
@@ -1291,6 +1296,32 @@ void __init i386_reserve_resources(void)#endif /* CONFIG_X86_32 */ +#ifdef CONFIG_EFI_ALLOW_SECURE_BOOT_EXIT + +static void sysrq_handle_secure_boot (int key) +{ +if (!efi_enabled (EFI_SECURE_BOOT )) +return ; + +pr_info ("Secure boot disabled\n" ); +lift_kernel_lockdown (); +} +static struct sysrq_key_op secure_boot_sysrq_op = { + .handler = sysrq_handle_secure_boot, + .help_msg ="unSB(x)" , + .action_msg ="Disabling Secure Boot restrictions" , + .enable_mask =SYSRQ_DISABLE_USERSPACE , +}; +static int __init secure_boot_sysrq (void ) +{ +if (efi_enabled (EFI_SECURE_BOOT )) +register_sysrq_key ('x' , &secure_boot_sysrq_op); +return 0 ; +} +late_initcall (secure_boot_sysrq); +#endif /*CONFIG_EFI_ALLOW_SECURE_BOOT_EXIT*/ + +static struct notifier_block kernel_offset_notifier = { .notifier_call = dump_kernel_offset };
drivers/input/misc/uinput.c +1 -0
@@ -379,6 +379,7 @@ static int uinput_allocate_device(struct uinput_device *udev)if (!udev->dev)return -ENOMEM ; + udev->dev->flags |=INPUTDEV_FLAGS_SYNTHETIC ; udev->dev->event = uinput_dev_event;input_set_drvdata (udev->dev, udev);
drivers/tty/sysrq.c +13 -6
@@ -479,6 +479,7 @@ static struct sysrq_key_op *sysrq_key_table[36] = {/* x: May be registered on mips for TLB dump */ /* x: May be registered on ppc/powerpc for xmon */ /* x: May be registered on sparc64 for global PMU dump */ +/* x: May be registered on x86_64 for disabling secure boot */ NULL ,/* x */ /* y: May be registered on sparc64 for global register dump */ NULL, /* y */
@@ -522,7 +523,7 @@ static void __sysrq_put_key_op(int key, struct sysrq_key_op *op_p) sysrq_key_table[i] = op_p; } -void __handle_sysrq (int key,bool check_mask) +void __handle_sysrq (int key,unsigned int from) {struct sysrq_key_op *op_p;int orig_log_level;
@@ -542,11 +543,15 @@ void __handle_sysrq(int key, bool check_mask) op_p =__sysrq_get_key_op (key);if (op_p) { +/* Ban synthetic events from some sysrq functionality */ +if ((from ==SYSRQ_FROM_PROC || from ==SYSRQ_FROM_SYNTHETIC ) && + op_p->enable_mask &SYSRQ_DISABLE_USERSPACE ) +printk ("This sysrq operation is disabled from userspace.\n" );/* * Should we check for enabled operations (/proc/sysrq-trigger * should not) and is the invoked operation enabled? */ -if (!check_mask ||sysrq_on_mask (op_p->enable_mask)) { +if (from ==SYSRQ_FROM_KERNEL ||sysrq_on_mask (op_p->enable_mask)) {pr_cont ("%s\n" , op_p->action_msg); console_loglevel = orig_log_level; op_p->handler (key);
@@ -578,7 +583,7 @@ void __handle_sysrq(int key, bool check_mask)void handle_sysrq (int key) {if (sysrq_on ()) -__handle_sysrq (key, true); +__handle_sysrq (key,SYSRQ_FROM_KERNEL ); }EXPORT_SYMBOL (handle_sysrq);
@@ -659,7 +664,7 @@ static void sysrq_do_reset(unsigned long _state)static void sysrq_handle_reset_request (struct sysrq_state *state) {if (state->reset_requested) -__handle_sysrq (sysrq_xlate[KEY_B ], false); +__handle_sysrq (sysrq_xlate[KEY_B ],SYSRQ_FROM_KERNEL );if (sysrq_reset_downtime_ms) mod_timer(&state->keyreset_timer,
@@ -810,8 +815,10 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq,default :if (sysrq->active && value && value !=2 ) { +int from = sysrq->handle.dev->flags &INPUTDEV_FLAGS_SYNTHETIC ? +SYSRQ_FROM_SYNTHETIC :0 ; sysrq->need_reinject = false; -__handle_sysrq (sysrq_xlate[code], true); +__handle_sysrq (sysrq_xlate[code], from); }break ; }
@@ -1095,7 +1102,7 @@ static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,if (get_user (c, buf))return -EFAULT ; -__handle_sysrq (c, false); +__handle_sysrq (c,SYSRQ_FROM_PROC ); }return count;
include/linux/input.h +5 -0
@@ -42,6 +42,7 @@ struct input_value {* @phys: physical path to the device in the system hierarchy * @uniq: unique identification code for the device (if device has it) * @id: id of the device (struct input_id) +* @flags: input device flags (SYNTHETIC, etc.) * @propbit: bitmap of device properties and quirks * @evbit: bitmap of types of events supported by the device (EV_KEY, * EV_REL, etc.)
@@ -124,6 +125,8 @@ struct input_dev {const char *uniq;struct input_id id; +unsigned int flags; +unsigned long propbit[BITS_TO_LONGS (INPUT_PROP_CNT )];unsigned long evbit[BITS_TO_LONGS (EV_CNT )];
@@ -190,6 +193,8 @@ struct input_dev { };#define to_input_dev (d) container_of(d, struct input_dev, dev) +#define INPUTDEV_FLAGS_SYNTHETIC 0x000000001 +/* * Verify that we are in sync with input_device_id mod_devicetable.h #defines */
include/linux/sysrq.h +7 -1
@@ -28,6 +28,8 @@#define SYSRQ_ENABLE_BOOT 0x0080#define SYSRQ_ENABLE_RTNICE 0x0100 +#define SYSRQ_DISABLE_USERSPACE 0x00010000 +struct sysrq_key_op {void (*handler)(int );char *help_msg;
@@ -42,8 +44,12 @@ struct sysrq_key_op {* are available -- else NULL's). */ +#define SYSRQ_FROM_KERNEL 0x0001 +#define SYSRQ_FROM_PROC 0x0002 +#define SYSRQ_FROM_SYNTHETIC 0x0004 +void handle_sysrq (int key); -void __handle_sysrq (int key,bool check_mask); +void __handle_sysrq (int key,unsigned int from);int register_sysrq_key (int key,struct sysrq_key_op *op);int unregister_sysrq_key (int key,struct sysrq_key_op *op);struct sysrq_key_op *__sysrq_get_key_op (int key);
kernel/debug/kdb/kdb_main.c +1 -1
@@ -1968,7 +1968,7 @@ static int kdb_sr(int argc, const char **argv)return KDB_ARGCOUNT ; kdb_trap_printk++; -__handle_sysrq (*argv[1 ], check_mask); +__handle_sysrq (*argv[1 ], check_mask ?SYSRQ_FROM_KERNEL :0 ); kdb_trap_printk--;return 0 ;
PATCH 7/16 kexec: Disable at runtime if the kernel is locked down
In reply to David HowellsFrom: Matthew Garrett <[email protected]>
kexec permits the loading and execution of arbitrary code in ring 0, which is something that lock-down is meant to prevent. It makes sense to disable kexec in this situation.
This does not affect kexec_file_load() which can check for a signature on the image to be booted.
---
kernel/kexec.c | 8 ++++++++ 1 file changed, 8 insertions(+)
kernel/kexec.c +8 -0
@@ -12,6 +12,7 @@#include <linux/mm.h> #include <linux/file.h> #include <linux/kexec.h> +#include <linux/security.h> #include <linux/mutex.h> #include <linux/list.h> #include <linux/syscalls.h>
@@ -194,6 +195,13 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,return -EPERM ;/* +* kexec can be used to circumvent module loading restrictions, so +* prevent loading in that case +*/ +if (kernel_is_locked_down ()) +return -EPERM ; + +/* * Verify we have a legal set of flags * This leaves us room for future extensions. */
PATCH 8/16 Copy secure_boot flag in boot params across kexec reboot
In reply to David HowellsFrom: Dave Young <[email protected]>
Kexec reboot in case secure boot being enabled does not keep the secure boot mode in new kernel, so later one can load unsigned kernel via legacy kexec_load. In this state, the system is missing the protections provided by secure boot.
Adding a patch to fix this by retain the secure_boot flag in original kernel.
secure_boot flag in boot_params is set in EFI stub, but kexec bypasses the stub. Fixing this issue by copying secure_boot flag across kexec reboot.
---
arch/x86/kernel/kexec-bzimage64.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kernel/kexec-bzimage64.c +1 -0
@@ -179,6 +179,7 @@ setup_efi_state(struct boot_params *params, unsigned long params_load_addr,if (efi_enabled (EFI_OLD_MEMMAP ))return 0 ; + params->secure_boot = boot_params.secure_boot; ei->efi_loader_signature = current_ei->efi_loader_signature; ei->efi_systab = current_ei->efi_systab; ei->efi_systab_hi = current_ei->efi_systab_hi;
PATCH 9/16 hibernate: Disable when the kernel is locked down
In reply to David HowellsFrom: Josh Boyer <[email protected]>
There is currently no way to verify the resume image when returning from hibernate. This might compromise the signed modules trust model, so until we can work with signed hibernate images we disable it when the kernel is locked down.
---
kernel/power/hibernate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/power/hibernate.c +2 -1
@@ -29,6 +29,7 @@#include <linux/ctype.h> #include <linux/genhd.h> #include <linux/ktime.h> +#include <linux/security.h> #include <trace/events/power.h> #include "power.h"
@@ -67,7 +68,7 @@ static const struct platform_hibernation_ops *hibernation_ops;bool hibernation_available (void ) { -return (nohibernate ==0 ); +return nohibernate ==0 && !kernel_is_locked_down (); }/**
PATCH 10/16 PCI: Lock down BAR access when the kernel is locked down
In reply to David HowellsFrom: Matthew Garrett <[email protected]>
Any hardware that can potentially generate DMA has to be locked down in order to avoid it being possible for an attacker to modify kernel code, allowing them to circumvent disabled module loading or module signing. Default to paranoid - in future we can potentially relax this for sufficiently IOMMU-isolated devices.
---
drivers/pci/pci-sysfs.c | 10 ++++++++++ drivers/pci/proc.c | 9 ++++++++- drivers/pci/syscall.c | 3 ++- 3 files changed, 20 insertions(+), 2 deletions(-)
drivers/pci/pci-sysfs.c +10 -0
@@ -30,6 +30,7 @@#include <linux/vgaarb.h> #include <linux/pm_runtime.h> #include <linux/of.h> +#include <linux/security.h> #include "pci.h" static int sysfs_initialized;/* = 0 */
@@ -716,6 +717,9 @@ static ssize_t pci_write_config(struct file *filp, struct kobject *kobj,loff_t init_off = off;u8 *data = (u8 *) buf; +if (kernel_is_locked_down ()) +return -EPERM ; +if (off > dev->cfg_size)return 0 ;if (off + count > dev->cfg_size) {
@@ -1007,6 +1011,9 @@ static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,resource_size_t start, end;int i; +if (kernel_is_locked_down ()) +return -EPERM ; +for (i =0 ; i <PCI_ROM_RESOURCE ; i++)if (res == &pdev->resource[i])break ;
@@ -1106,6 +1113,9 @@ static ssize_t pci_write_resource_io(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, char *buf, loff_t off, size_t count) { + if (kernel_is_locked_down()) + return -EPERM; +return pci_resource_io (filp, kobj, attr, buf, off, count, true); }
drivers/pci/proc.c +8 -1
@@ -11,6 +11,7 @@#include <linux/proc_fs.h> #include <linux/seq_file.h> #include <linux/capability.h> +#include <linux/security.h> #include <asm/uaccess.h> #include <asm/byteorder.h> #include "pci.h"
@@ -116,6 +117,9 @@ static ssize_t proc_bus_pci_write(struct file *file, const char __user *buf,int size = dev->cfg_size;int cnt; +if (kernel_is_locked_down ()) +return -EPERM ; +if (pos >= size)return 0 ;if (nbytes >= size)
@@ -195,6 +199,9 @@ static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd,#endif /* HAVE_PCI_MMAP */ int ret =0 ; +if (kernel_is_locked_down ()) +return -EPERM ; +switch (cmd) {case PCIIOC_CONTROLLER : ret =pci_domain_nr (dev->bus);
@@ -233,7 +240,7 @@ static int proc_bus_pci_mmap(struct file *file, struct vm_area_struct *vma)struct pci_filp_private *fpriv = file->private_data;int i, ret, write_combine; -if (!capable (CAP_SYS_RAWIO )) +if (!capable (CAP_SYS_RAWIO ) ||kernel_is_locked_down ())return -EPERM ;/* Make sure the caller is mapping a real resource for this device */
drivers/pci/syscall.c +2 -1
@@ -10,6 +10,7 @@#include <linux/errno.h> #include <linux/pci.h> #include <linux/syscalls.h> +#include <linux/security.h> #include <asm/uaccess.h> #include "pci.h"
@@ -92,7 +93,7 @@ SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn,u32 dword;int err =0 ; -if (!capable (CAP_SYS_ADMIN )) +if (!capable (CAP_SYS_ADMIN ) ||kernel_is_locked_down ())return -EPERM ; dev =pci_get_bus_and_slot (bus, dfn);
PATCH 11/16 x86: Lock down IO port access when the kernel is locked down
In reply to David HowellsFrom: Matthew Garrett <matthew.garrett-05XSO3Yj/[email protected]>
IO port access would permit users to gain access to PCI configuration registers, which in turn (on a lot of hardware) give access to MMIO register space. This would potentially permit root to trigger arbitrary DMA, so lock it down by default.
---
arch/x86/kernel/ioport.c | 5 +++-- drivers/char/mem.c | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-)
arch/x86/kernel/ioport.c +3 -2
@@ -15,6 +15,7 @@#include <linux/thread_info.h> #include <linux/syscalls.h> #include <linux/bitmap.h> +#include <linux/security.h> #include <asm/syscalls.h> /*
@@ -28,7 +29,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)if ((from + num <= from) || (from + num >IO_BITMAP_BITS ))return -EINVAL ; -if (turn_on && !capable (CAP_SYS_RAWIO )) +if (turn_on && (!capable (CAP_SYS_RAWIO ) ||kernel_is_locked_down ()))return -EPERM ;/*
@@ -108,7 +109,7 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)return -EINVAL ;/* Trying to gain more privileges? */ if (level > old) { -if (!capable (CAP_SYS_RAWIO )) +if (!capable (CAP_SYS_RAWIO ) ||kernel_is_locked_down ())return -EPERM ; } regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) |
drivers/char/mem.c +4 -0
@@ -28,6 +28,7 @@#include <linux/export.h> #include <linux/io.h> #include <linux/uio.h> +#include <linux/security.h> #include <linux/uaccess.h>
@@ -580,6 +581,9 @@ static ssize_t write_port(struct file *file, const char __user *buf,unsigned long i = *ppos;const char __user *tmp = buf; +if (kernel_is_locked_down ()) +return -EPERM ; +if (!access_ok (VERIFY_READ , buf, count))return -EFAULT ;while (count-- >0 && i <65536 ) {
PATCH 12/16 ACPI: Limit access to custom_method when the kernel is locked down
In reply to David HowellsFrom: Matthew Garrett <[email protected]>
custom_method effectively allows arbitrary access to system memory, making it possible for an attacker to circumvent restrictions on module loading. Disable it if the kernel is locked down.
---
drivers/acpi/custom_method.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/acpi/custom_method.c +3 -0
@@ -29,6 +29,9 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,struct acpi_table_header table;acpi_status status; +if (kernel_is_locked_down ()) +return -EPERM ; +if (!(*ppos)) {/* parse the table header to get the table length */ if (count <=sizeof (struct acpi_table_header ))
PATCH 13/16 asus-wmi: Restrict debugfs interface when the kernel is locked down
In reply to David HowellsFrom: Matthew Garrett <[email protected]>
We have no way of validating what all of the Asus WMI methods do on a given machine - and there's a risk that some will allow hardware state to be manipulated in such a way that arbitrary code can be executed in the kernel, circumventing module loading restrictions. Prevent that if the kernel is locked down.
---
drivers/platform/x86/asus-wmi.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/platform/x86/asus-wmi.c +9 -0
@@ -1872,6 +1872,9 @@ static int show_dsts(struct seq_file *m, void *data)int err;u32 retval =-1 ; +if (kernel_is_locked_down ()) +return -EPERM ; + err =asus_wmi_get_devstate (asus, asus->debug.dev_id, &retval);if (err <0 )
@@ -1888,6 +1891,9 @@ static int show_devs(struct seq_file *m, void *data)int err;u32 retval =-1 ; +if (kernel_is_locked_down ()) +return -EPERM ; + err =asus_wmi_set_devstate (asus->debug.dev_id, asus->debug.ctrl_param, &retval);
@@ -1912,6 +1918,9 @@ static int show_call(struct seq_file *m, void *data)union acpi_object *obj;acpi_status status; +if (kernel_is_locked_down ()) +return -EPERM ; + status =wmi_evaluate_method (ASUS_WMI_MGMT_GUID ,1 , asus->debug.method_id, &input, &output);
PATCH 14/16 Restrict /dev/mem and /dev/kmem when the kernel is locked down
In reply to David HowellsFrom: Matthew Garrett <[email protected]>
Allowing users to write to address space makes it possible for the kernel to be subverted, avoiding module loading restrictions. Prevent this when the kernel has been locked down.
---
drivers/char/mem.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/char/mem.c +6 -0
@@ -164,6 +164,9 @@ static ssize_t write_mem(struct file *file, const char __user *buf,if (p != *ppos)return -EFBIG ; +if (kernel_is_locked_down ()) +return -EPERM ; +if (!valid_phys_addr_range (p, count))return -EFAULT ;
@@ -516,6 +519,9 @@ static ssize_t write_kmem(struct file *file, const char __user *buf,if (!pfn_valid (PFN_DOWN (p)))return -EIO ; +if (kernel_is_locked_down ()) +return -EPERM ; +if (p < (unsigned long ) high_memory) { unsigned long to_write = min_t(unsigned long, count, (unsigned long )high_memory - p);
PATCH 15/16 acpi: Ignore acpi_rsdp kernel param when the kernel has been locked down
In reply to David HowellsFrom: Josh Boyer <[email protected]>
This option allows userspace to pass the RSDP address to the kernel, which makes it possible for a user to circumvent any restrictions imposed on loading modules. Ignore the option when the kernel is locked down.
---
drivers/acpi/osl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/osl.c +2 -1
@@ -40,6 +40,7 @@#include <linux/list.h> #include <linux/jiffies.h> #include <linux/semaphore.h> +#include <linux/security.h> #include <asm/io.h> #include <asm/uaccess.h>
@@ -191,7 +192,7 @@ early_param("acpi_rsdp", setup_acpi_rsdp);acpi_physical_address __init acpi_os_get_root_pointer (void ) {#ifdef CONFIG_KEXEC -if (acpi_rsdp) +if (acpi_rsdp && !kernel_is_locked_down ())return acpi_rsdp;#endif
PATCH 16/16 x86: Restrict MSR access when the kernel is locked down
In reply to David HowellsFrom: Matthew Garrett <matthew.garrett-05XSO3Yj/[email protected]>
Writing to MSRs should not be allowed if the kernel is locked down, since it could lead to execution of arbitrary code in kernel mode. Based on a patch by Kees Cook.
---
arch/x86/kernel/msr.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/x86/kernel/msr.c +8 -0
@@ -39,6 +39,7 @@#include <linux/notifier.h> #include <linux/uaccess.h> #include <linux/gfp.h> +#include <linux/security.h> #include <asm/cpufeature.h> #include <asm/msr.h>
@@ -83,6 +84,9 @@ static ssize_t msr_write(struct file *file, const char __user *buf,int err =0 ;ssize_t bytes =0 ; +if (kernel_is_locked_down ()) +return -EPERM ; +if (count %8 )return -EINVAL ;/* Invalid chunk size */
@@ -130,6 +134,10 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg) err = -EBADF ;break ; } +if (kernel_is_locked_down ()) { + err = -EPERM ; +break ; + }if (copy_from_user (®s, uregs,sizeof regs)) { err = -EFAULT ;break ;
Whether it's a good idea aside
You need to filter or lock down kernel module options because a lot of modules let you set the I/O port or similar (eg mmio) which means you can hack the entire machine with say the 8250 driver just by using it with an mmio of the right location to patch the secure state to zero just by getting the ability to write to the modules conf file.
Without that at least fixed I don't see the point in merging this. Either we don't do it (which given the level of security the current Linux kernel provides, and also all the golden key messups from elsewhere might be the honest approach), or at least try and do the job right.
Less security is better than fake security. If you've got less security your take appropriate precautions. If you rely on fake security you don't.
The two other nasty cases you miss should be fine for x86 secure boot - but maybe not for secure boot in general. That is firmware loading and initial firewire state. Both should be fine on any 'secure' boot PC.
Alan
Quoted 8 lines · One Thousand Gnomes
Whether it's a good idea aside
You need to filter or lock down kernel module options because a lot of modules let you set the I/O port or similar (eg mmio) which means you can hack the entire machine with say the 8250 driver just by using it with an mmio of the right location to patch the secure state to zero just by getting the ability to write to the modules conf file.
This applies equally to the kernel command line, and given that we cannot authenticate it, we should whitelist params that we know to be safe, and filter out all others. A similar concern exists for the device tree on ARM/arm64, and we already disable the DTB loader in the UEFI stub if secure boot is enabled.
Quoted 8 lines
Without that at least fixed I don't see the point in merging this. Either we don't do it (which given the level of security the current Linux kernel provides, and also all the golden key messups from elsewhere might be the honest approach), or at least try and do the job right.
Less security is better than fake security. If you've got less security your take appropriate precautions. If you rely on fake security you don't.
In general, I think kernel hardening is an important topic, and this series covers many cases where userland APIs can be subverted to manipulate the state of the kernel in ways that weren't intended. However, it would be naive to think that the series covers all such cases, and I don't think that is what the authors intend to convey.
Quoted 5 lines
This applies equally to the kernel command line, and given that we cannot authenticate it, we should whitelist params that we know to be safe, and filter out all others. A similar concern exists for the device tree on ARM/arm64, and we already disable the DTB loader in the UEFI stub if secure boot is enabled.
Or you sign the boot command line.
Quoted 10 lines
Quoted 8 lines
Without that at least fixed I don't see the point in merging this. Either we don't do it (which given the level of security the current Linux kernel provides, and also all the golden key messups from elsewhere might be the honest approach), or at least try and do the job right.
Less security is better than fake security. If you've got less security your take appropriate precautions. If you rely on fake security you don't.
In general, I think kernel hardening is an important topic
It is - so pushing something with known trivial holes isn't a useful way to do this. The module parameter hole needs to be addressed before this is fit for upstream.
Alan
PATCH 1/1 Lock down drivers that can have io ports, io mem, irqs and dma changed
In reply to One Thousand GnomesQuoted 5 lines · One Thousand Gnomes
You need to filter or lock down kernel module options because a lot of modules let you set the I/O port or similar (eg mmio) which means you can hack the entire machine with say the 8250 driver just by using it with an mmio of the right location to patch the secure state to zero just by getting the ability to write to the modules conf file.
Is the attached patch the right sort of idea? [Note that I haven't actually compiled most of these drivers to check my changes yet.]
David
---
commit 8613a9655dad98c3358d82a9c4310cebdcb852ae
Author: David Howells <[email protected]> Date: Mon Nov 21 22:43:27 2016 +0000
Lock down drivers that can have io ports, io mem, irqs and dma changed
Lock down drivers that can have io ports, io mem, irqs and dma channels changed so that they can't be used to cause hardware to access the kernel image.
Notes:
(1) module_isa_driver() gets an extra parameter that, if true, will cause the module load to be rejected if the kernel is locked down.
(2) module_driver() calls module_lockdown_check() to ask if the module load should be rejected if the kernel is locked down. This is a macro that should be #undef'd and then redefined right before module_driver() is called.
(3) module_pci_driver() is a wrapper around module_driver(), so the same macro is used as in (2).
(4) A number of drivers use parport 'ports' - so I haven't touched those.
arch/x86/mm/testmmiotrace.c +5 -0
@@ -115,6 +115,11 @@ static int __init init(void) {unsigned long size = (read_far) ? (8 <<20 ) : (16 <<10 ); +if (kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (mmio_address ==0 ) {pr_err ("you have to use the module argument mmio_address.\n" );pr_err ("DO NOT LOAD THIS MODULE UNLESS YOU REALLY KNOW WHAT YOU ARE DOING!\n" );
drivers/char/applicom.c +5 -0
@@ -192,6 +192,11 @@ static int __init applicom_init(void)printk (KERN_INFO "Applicom driver: $Id: ac.c,v 1.30 2000/03/22 16:03:57 dwmw2 Exp $\n" ); +if ((irq || mem) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +/* No mem and irq given - check for a PCI card */ while ( (dev =pci_get_class (PCI_CLASS_OTHERS <<16 , dev))) {
drivers/char/ipmi/ipmi_si_intf.c +6 -0
@@ -3725,6 +3725,12 @@ static int init_ipmi_si(void)struct smi_info *e;enum ipmi_addr_src type =SI_INVALID ; +if ((num_addrs || num_ports || num_irqs) && +kernel_is_locked_down ()) { +pr_err (PFX "Kernel is locked down\n" ); +return -EPERM ; + } +if (initialized)return 0 ; initialized =1 ;
drivers/char/mwave/mwavedd.c +5 -0
@@ -572,6 +572,11 @@ static int __init mwave_init(void)int retval =0 ;pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd; +if (kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +PRINTK_1 (TRACE_MWAVE ,"mwavedd::mwave_init entry\n" );memset (&mwave_s_mdd,0 ,sizeof (MWAVE_DEVICE_DATA ));
drivers/clocksource/cs5535-clockevt.c +5 -0
@@ -145,6 +145,11 @@ static int __init cs5535_mfgpt_init(void)int ret;uint16_t val; +if (timer_irq !=0 &&kernel_is_locked_down ()) { +pr_err (DRV_NAME ": Kernel is locked down\n" ); +return -EPERM ; + } + timer =cs5535_mfgpt_alloc_timer (MFGPT_TIMER_ANY ,MFGPT_DOMAIN_WORKING );if (!timer) { printk(KERN_ERR DRV_NAME ": Could not allocate MFGPT timer\n");
drivers/cpufreq/speedstep-smi.c +5 -0
@@ -318,6 +318,11 @@ MODULE_DEVICE_TABLE(x86cpu, ss_smi_ids);*/ static int __init speedstep_init (void ) { +if (smi_port !=0 &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (!x86_match_cpu (ss_smi_ids))return -ENODEV ;
drivers/gpio/gpio-104-dio-48e.c +1 -1
@@ -393,7 +393,7 @@ static struct isa_driver dio48e_driver = { }, .remove = dio48e_remove }; -module_isa_driver (dio48e_driver, num_dio48e); +module_isa_driver (dio48e_driver, num_dio48e, num_dio48e >0 );MODULE_AUTHOR ("William Breathitt Gray <[email protected]>" );MODULE_DESCRIPTION ("ACCES 104-DIO-48E GPIO driver" );
drivers/gpio/gpio-104-idi-48.c +1 -1
@@ -299,7 +299,7 @@ static struct isa_driver idi_48_driver = { }, .remove = idi_48_remove }; -module_isa_driver (idi_48_driver, num_idi_48); +module_isa_driver (idi_48_driver, num_idi_48, num_idi_48 >0 );MODULE_AUTHOR ("William Breathitt Gray <[email protected]>" );MODULE_DESCRIPTION ("ACCES 104-IDI-48 GPIO driver" );
drivers/gpio/gpio-104-idio-16.c +1 -1
@@ -275,7 +275,7 @@ static struct isa_driver idio_16_driver = { .remove = idio_16_remove }; -module_isa_driver (idio_16_driver, num_idio_16); +module_isa_driver (idio_16_driver, num_idio_16, num_idio_16 >0 );MODULE_AUTHOR ("William Breathitt Gray <[email protected]>" );MODULE_DESCRIPTION ("ACCES 104-IDIO-16 GPIO driver" );
drivers/gpio/gpio-gpio-mm.c +1 -1
@@ -260,7 +260,7 @@ static struct isa_driver gpiomm_driver = { .remove = gpiomm_remove }; -module_isa_driver (gpiomm_driver, num_gpiomm); +module_isa_driver (gpiomm_driver, num_gpiomm, num_gpiomm >0 );MODULE_AUTHOR ("William Breathitt Gray <[email protected]>" );MODULE_DESCRIPTION ("Diamond Systems GPIO-MM GPIO driver" );
drivers/gpio/gpio-ws16c48.c +1 -1
@@ -388,7 +388,7 @@ static struct isa_driver ws16c48_driver = { .remove = ws16c48_remove }; -module_isa_driver (ws16c48_driver, num_ws16c48); +module_isa_driver (ws16c48_driver, num_ws16c48, num_ws16c48 >0 );MODULE_AUTHOR ("William Breathitt Gray <[email protected]>" );MODULE_DESCRIPTION ("WinSystems WS16C48 GPIO driver" );
drivers/i2c/busses/i2c-elektor.c +1 -1
@@ -328,4 +328,4 @@ module_param(irq, int, 0);module_param (clock, int,0 );module_param (own, int,0 );module_param (mmapped, int,0 ); -module_isa_driver (i2c_elektor_driver,1 ); +module_isa_driver (i2c_elektor_driver,1 , true);
drivers/i2c/busses/i2c-parport-light.c +5 -0
@@ -219,6 +219,11 @@ static int __init i2c_parport_init(void) {int err; +if ((base || irq) &&kernel_is_locked_down ()) { +pr_err (DRVNAME ": Kernel is locked down\n" ); +return -EPERM ; + } +if (type <0 ) { printk(KERN_ERR DRVNAME ": adapter type unspecified\n");return -ENODEV ;
drivers/i2c/busses/i2c-pca-isa.c +1 -1
@@ -209,4 +209,4 @@ MODULE_PARM_DESC(clock, "Clock rate in hertz.\n\t\t""\t\t\t\tFast: 100100 - 400099\n" "\t\t\t\tFast+: 400100 - 10000099\n" "\t\t\t\tTurbo: Up to 1265800"); -module_isa_driver (pca_isa_driver,1 ); +module_isa_driver (pca_isa_driver,1 , true);
drivers/i2c/busses/scx200_acb.c +7 -1
@@ -41,8 +41,9 @@ MODULE_ALIAS("platform:cs5535-smb");MODULE_LICENSE ("GPL" );#define MAX_DEVICES 4 +static unsigned int nr_base =0 ;static int base[MAX_DEVICES ] = {0x820 ,0x840 }; -module_param_array (base, int,NULL ,0 ); +module_param_array (base, int, &nr_base,0 );MODULE_PARM_DESC (base,"Base addresses for the ACCESS.bus controllers" );#define POLL_TIMEOUT (HZ/5)
@@ -573,6 +574,11 @@ static __init void scx200_scan_isa(void)static int __init scx200_acb_init (void ) { +if (nr_base >0 &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +pr_debug ("NatSemi SCx200 ACCESS.bus Driver\n" );/* First scan for ISA-based devices */
drivers/iio/adc/stx104.c +1 -1
@@ -373,7 +373,7 @@ static struct isa_driver stx104_driver = { .remove = stx104_remove }; -module_isa_driver (stx104_driver, num_stx104); +module_isa_driver (stx104_driver, num_stx104, num_stx104 >0 );MODULE_AUTHOR ("William Breathitt Gray <[email protected]>" );MODULE_DESCRIPTION ("Apex Embedded Systems STX104 IIO driver" );
drivers/iio/dac/cio-dac.c +1 -1
@@ -137,7 +137,7 @@ static struct isa_driver cio_dac_driver = { } }; -module_isa_driver (cio_dac_driver, num_cio_dac); +module_isa_driver (cio_dac_driver, num_cio_dac, num_cio_dac >0 );MODULE_AUTHOR ("William Breathitt Gray <[email protected]>" );MODULE_DESCRIPTION ("Measurement Computing CIO-DAC IIO driver" );
drivers/input/mouse/inport.c +5 -0
@@ -132,6 +132,11 @@ static int __init inport_init(void)unsigned char a, b, c;int err; +if (inport_irq !=INPORT_IRQ &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (!request_region (INPORT_BASE ,INPORT_EXTENT ,"inport" )) {printk (KERN_ERR "inport.c: Can't allocate ports at %#x\n" ,INPORT_BASE );return -EBUSY ;
drivers/input/mouse/logibm.c +5 -0
@@ -121,6 +121,11 @@ static int __init logibm_init(void) {int err; +if (logibm_irq !=LOGIBM_IRQ &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (!request_region (LOGIBM_BASE ,LOGIBM_EXTENT ,"logibm" )) {printk (KERN_ERR "logibm.c: Can't allocate ports at %#x\n" ,LOGIBM_BASE );return -EBUSY ;
drivers/input/touchscreen/mk712.c +6 -0
@@ -153,6 +153,12 @@ static int __init mk712_init(void) {int err; +if ((mk712_io !=0x260 || mk712_irq !=10 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (!request_region (mk712_io,8 ,"mk712" )) {printk (KERN_WARNING "mk712: unable to get IO region\n" );return -ENODEV ;
drivers/isdn/hardware/avm/b1isa.c +7 -1
@@ -166,10 +166,11 @@ static char *b1isa_procinfo(struct capi_ctr *ctrl)#define MAX_CARDS 4static struct pci_dev isa_dev[MAX_CARDS ]; +static unsigned int nr_io;static int io[MAX_CARDS ];static int irq[MAX_CARDS ]; -module_param_array (io, int,NULL ,0 ); +module_param_array (io, int, &nr_io,0 );module_param_array (irq, int,NULL ,0 );MODULE_PARM_DESC (io,"I/O base address(es)" );MODULE_PARM_DESC (irq,"IRQ number(s) (assigned)" );
@@ -203,6 +204,11 @@ static int __init b1isa_init(void)char rev[32 ];int i; +if (nr_io >0 &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if ((p =strchr (revision,':' )) !=NULL && p[1 ]) {strlcpy (rev, p +2 ,32 );if ((p =strchr (rev,'$' )) !=NULL && p > rev)
drivers/isdn/hardware/avm/t1isa.c +7 -1
@@ -512,11 +512,12 @@ static char *t1isa_procinfo(struct capi_ctr *ctrl)#define MAX_CARDS 4static struct pci_dev isa_dev[MAX_CARDS ]; +static unsigned int nr_io;static int io[MAX_CARDS ];static int irq[MAX_CARDS ];static int cardnr[MAX_CARDS ]; -module_param_array (io, int,NULL ,0 ); +module_param_array (io, int, &nr_io,0 );module_param_array (irq, int,NULL ,0 );module_param_array (cardnr, int,NULL ,0 );MODULE_PARM_DESC (io,"I/O base address(es)" );
@@ -552,6 +553,11 @@ static int __init t1isa_init(void)char *p;int i; +if (nr_io >0 &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if ((p =strchr (revision,':' )) !=NULL && p[1 ]) {strlcpy (rev, p +2 ,32 );if ((p =strchr (rev,'$' )) !=NULL && p > rev)
drivers/isdn/hisax/config.c +16 -4
@@ -328,6 +328,7 @@ static char *HiSax_id = HiSaxID;/* Variables for insmod */ static int type[HISAX_MAX_CARDS ] = {0 , };static int protocol[HISAX_MAX_CARDS ] = {0 , }; +static int nr_io;static int io[HISAX_MAX_CARDS ] = {0 , };#undef IO0_IO1#ifdef CONFIG_HISAX_16_3
@@ -338,10 +339,12 @@ static int io[HISAX_MAX_CARDS] = { 0, };#define IO0_IO1 #endif #ifdef IO0_IO1 +static int nr_io0, nr_io1;static int io0[HISAX_MAX_CARDS ] = {0 , };static int io1[HISAX_MAX_CARDS ] = {0 , };#endif static int irq[HISAX_MAX_CARDS ] = {0 , }; +static int nr_mem;static int mem[HISAX_MAX_CARDS ] = {0 , };static char *id = HiSaxID;
@@ -350,13 +353,13 @@ MODULE_AUTHOR("Karsten Keil");MODULE_LICENSE ("GPL" );module_param_array (type, int,NULL ,0 );module_param_array (protocol, int,NULL ,0 ); -module_param_array (io, int,NULL ,0 ); +module_param_array (io, int, &nr_io,0 );module_param_array (irq, int,NULL ,0 ); -module_param_array (mem, int,NULL ,0 ); +module_param_array (mem, int, &nr_mem,0 );module_param (id, charp,0 );#ifdef IO0_IO1 -module_param_array (io0, int,NULL ,0 ); -module_param_array (io1, int,NULL ,0 ); +module_param_array (io0, int, &nr_io0,0 ); +module_param_array (io1, int, &nr_io1,0 );#endif #endif /* MODULE */
@@ -1338,6 +1341,15 @@ static int __init HiSax_init(void)int nzproto =0 ;#endif +if ((nr_io >0 || nr_mem >0 +#ifdef IO0_IO1 + || nr_io0 >0 || nr_io1 >0 +#endif + ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +HiSaxVersion (); retval =CallcNew ();if (retval)
drivers/media/pci/zoran/zoran_card.c +5 -0
@@ -1466,6 +1466,11 @@ static int __init zoran_init(void) {int res; +if (vidmem &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +printk (KERN_INFO "Zoran MJPEG board driver version %s\n" ,ZORAN_VERSION );
drivers/misc/dummy-irq.c +6 -0
@@ -40,6 +40,12 @@ static int __init dummy_irq_init(void)printk (KERN_ERR "dummy-irq: no IRQ given. Use irq=N\n" );return -EIO ; } + +if (kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (request_irq (irq, &dummy_interrupt,IRQF_SHARED ,"dummy_irq" , &irq)) {printk (KERN_ERR "dummy-irq: cannot register IRQ %d\n" , irq);return -EIO ;
drivers/mmc/host/wbsd.c +6 -0
@@ -1939,6 +1939,12 @@ static int __init wbsd_drv_init(void) {int result; +if ((param_io !=0x248 || param_irq !=6 || param_dma !=2 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +pr_info (DRIVER_NAME ": Winbond W83L51xD SD/MMC card interface driver\n" );pr_info (DRIVER_NAME ": Copyright(c) Pierre Ossman\n" );
drivers/net/appletalk/cops.c +6 -0
@@ -992,6 +992,12 @@ module_param(board_type, int, 0);static int __init cops_module_init (void ) { +if ((io !=0x240 || irq !=5 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (io ==0 )printk (KERN_WARNING "%s: You shouldn't autoprobe with insmod\n" , cardname);
drivers/net/appletalk/ltpc.c +5 -0
@@ -1238,6 +1238,11 @@ module_param(dma, int, 0);static int __init ltpc_module_init (void ) { +if ((io || irq || dma) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (io ==0 )printk (KERN_NOTICE "ltpc: Autoprobing is not recommended for modules\n" );
drivers/net/arcnet/com20020-isa.c +5 -0
@@ -146,6 +146,11 @@ static int __init com20020_init(void)struct net_device *dev;struct arcnet_local *lp; +if ((io || irq) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + dev =alloc_arcdev (device);if (!dev)return -ENOMEM ;
drivers/net/arcnet/com90io.c +5 -0
@@ -382,6 +382,11 @@ static int __init com90io_init(void)struct net_device *dev;int err; +if ((io || irq) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + dev =alloc_arcdev (device);if (!dev)return -ENOMEM ;
drivers/net/arcnet/com90xx.c +5 -0
@@ -648,6 +648,11 @@ MODULE_LICENSE("GPL");static int __init com90xx_init (void ) { +if ((io || irq || shmem) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (irq ==2 ) irq =9 ;com90xx_probe ();
drivers/net/can/cc770/cc770_isa.c +8 -2
@@ -73,6 +73,7 @@ MODULE_LICENSE("GPL v2");#define COR_DEFAULT 0x00#define BCR_DEFAULT BUSCFG_CBY +static unsigned int nr_port, nr_mem;static unsigned long port[MAXDEV ];static unsigned long mem[MAXDEV ];static int irq[MAXDEV ];
@@ -82,10 +83,10 @@ static u8 cor[MAXDEV] = {[0 ... (MAXDEV - 1)] = 0xff};static u8 bcr[MAXDEV ] = {[0 ... (MAXDEV -1 )] =0xff };static int indirect[MAXDEV ] = {[0 ... (MAXDEV -1 )] =-1 }; -module_param_array (port, ulong,NULL ,S_IRUGO ); +module_param_array (port, ulong, &nr_port,S_IRUGO );MODULE_PARM_DESC (port,"I/O port number" ); -module_param_array (mem, ulong,NULL ,S_IRUGO ); +module_param_array (mem, ulong, &nr_mem,S_IRUGO );MODULE_PARM_DESC (mem,"I/O memory address" );module_param_array (indirect, int,NULL ,S_IRUGO );
@@ -325,6 +326,11 @@ static int __init cc770_isa_init(void) {int idx, err; +if ((nr_port >0 || nr_mem >0 ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +for (idx =0 ; idx <ARRAY_SIZE (cc770_isa_devs); idx++) {if ((port[idx] || mem[idx]) && irq[idx]) { cc770_isa_devs[idx] =
drivers/net/can/sja1000/sja1000_isa.c +8 -2
@@ -39,6 +39,7 @@ MODULE_LICENSE("GPL v2");#define CDR_DEFAULT (CDR_CBP | CDR_CLK_OFF)#define OCR_DEFAULT OCR_TX0_PUSHPULL +static unsigned int nr_port, nr_mem;static unsigned long port[MAXDEV ];static unsigned long mem[MAXDEV ];static int irq[MAXDEV ];
@@ -48,10 +49,10 @@ static unsigned char ocr[MAXDEV] = {[0 ... (MAXDEV - 1)] = 0xff};static int indirect[MAXDEV ] = {[0 ... (MAXDEV -1 )] =-1 };static spinlock_t indirect_lock[MAXDEV ];/* lock for indirect access mode */ -module_param_array (port, ulong,NULL ,S_IRUGO ); +module_param_array (port, ulong, &nr_port,S_IRUGO );MODULE_PARM_DESC (port,"I/O port number" ); -module_param_array (mem, ulong,NULL ,S_IRUGO ); +module_param_array (mem, ulong, &nr_mem,S_IRUGO );MODULE_PARM_DESC (mem,"I/O memory address" );module_param_array (indirect, int,NULL ,S_IRUGO );
@@ -266,6 +267,11 @@ static int __init sja1000_isa_init(void) {int idx, err; +if ((nr_port >0 || nr_mem >0 ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +for (idx =0 ; idx <MAXDEV ; idx++) {if ((port[idx] || mem[idx]) && irq[idx]) { sja1000_isa_devs[idx] =
drivers/net/ethernet/3com/3c509.c +7 -1
@@ -177,6 +177,7 @@ static struct net_device *el3_devs[EL3_MAX_CARDS];/* Parameters that may be passed into the module. */ static int debug =-1 ; +static unsigned int nr_irq;static int irq[] = {-1 ,-1 ,-1 ,-1 ,-1 ,-1 ,-1 ,-1 };/* Maximum events (Rx packets, etc.) to handle at each interrupt. */ static int max_interrupt_work =10 ;
@@ -1369,7 +1370,7 @@ el3_resume(struct device *pdev)#endif /* CONFIG_PM */ module_param (debug,int,0 ); -module_param_array (irq, int,NULL ,0 ); +module_param_array (irq, int, &nr_irq,0 );module_param (max_interrupt_work, int,0 );MODULE_PARM_DESC (debug,"debug level (0-6)" );MODULE_PARM_DESC (irq,"IRQ number(s) (assigned)" );
@@ -1385,6 +1386,11 @@ static int __init el3_init_module(void) {int ret =0 ; +if (nr_irq >0 &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (debug >=0 ) el3_debug = debug;
drivers/net/ethernet/3com/3c59x.c +5 -0
@@ -3330,6 +3330,11 @@ static int __init vortex_init(void) {int pci_rc, eisa_rc; +if ((compaq_ioaddr || compaq_irq) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + pci_rc =pci_register_driver (&vortex_driver); eisa_rc =vortex_eisa_init ();
drivers/net/ethernet/8390/ne.c +9 -2
@@ -74,8 +74,9 @@ static int bad[MAX_NE_CARDS];static u32 ne_msg_enable;#ifdef MODULE -module_param_array (io, int,NULL ,0 ); -module_param_array (irq, int,NULL ,0 ); +static unsigned int nr_io, nr_irq; +module_param_array (io, int, &nr_io,0 ); +module_param_array (irq, int, &nr_irq,0 );module_param_array (bad, int,NULL ,0 );module_param_named (msg_enable, ne_msg_enable, uint, (S_IRUSR |S_IRGRP |S_IROTH ));MODULE_PARM_DESC (io,"I/O base address(es),required" );
@@ -943,6 +944,12 @@ static void __init ne_add_devices(void)int __init init_module (void ) {int retval; + +if ((nr_io >0 || nr_irq >0 ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +ne_add_devices (); retval =platform_driver_probe (&ne_driver, ne_drv_probe);if (retval) {
drivers/net/ethernet/8390/smc-ultra.c +7 -1
@@ -559,10 +559,11 @@ ultra_close_card(struct net_device *dev)#ifdef MODULE #define MAX_ULTRA_CARDS 4/* Max number of Ultra cards per module */ static struct net_device *dev_ultra[MAX_ULTRA_CARDS ]; +static unsigned int nr_io;static int io[MAX_ULTRA_CARDS ];static int irq[MAX_ULTRA_CARDS ]; -module_param_array (io, int,NULL ,0 ); +module_param_array (io, int, &nr_io,0 );module_param_array (irq, int,NULL ,0 );module_param_named (msg_enable, ultra_msg_enable, uint, (S_IRUSR |S_IRGRP |S_IROTH ));MODULE_PARM_DESC (io,"I/O base address(es)" );
@@ -579,6 +580,11 @@ init_module(void)struct net_device *dev;int this_dev, found =0 ; +if (nr_io >0 &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +for (this_dev =0 ; this_dev <MAX_ULTRA_CARDS ; this_dev++) {if (io[this_dev] ==0 ) {if (this_dev !=0 )break ;/* only autoprobe 1st one */
drivers/net/ethernet/8390/wd.c +7 -1
@@ -499,12 +499,13 @@ wd_close(struct net_device *dev)#ifdef MODULE #define MAX_WD_CARDS 4/* Max number of wd cards per module */ static struct net_device *dev_wd[MAX_WD_CARDS ]; +static int nr_io;static int io[MAX_WD_CARDS ];static int irq[MAX_WD_CARDS ];static int mem[MAX_WD_CARDS ];static int mem_end[MAX_WD_CARDS ];/* for non std. mem size */ -module_param_array (io, int,NULL ,0 ); +module_param_array (io, int, &nr_io,0 );module_param_array (irq, int,NULL ,0 );module_param_array (mem, int,NULL ,0 );module_param_array (mem_end, int,NULL ,0 );
@@ -525,6 +526,11 @@ int __init init_module(void)struct net_device *dev;int this_dev, found =0 ; +if (nr_io >0 &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +for (this_dev =0 ; this_dev <MAX_WD_CARDS ; this_dev++) {if (io[this_dev] ==0 ) {if (this_dev !=0 )break ;/* only autoprobe 1st one */
drivers/net/ethernet/amd/lance.c +7 -1
@@ -314,11 +314,12 @@ static void lance_tx_timeout (struct net_device *dev);#define MAX_CARDS 8/* Max number of interfaces (cards) per module */ static struct net_device *dev_lance[MAX_CARDS ]; +static int nr_io;static int io[MAX_CARDS ];static int dma[MAX_CARDS ];static int irq[MAX_CARDS ]; -module_param_array (io, int,NULL ,0 ); +module_param_array (io, int, &nr_io,0 );module_param_array (dma, int,NULL ,0 );module_param_array (irq, int,NULL ,0 );module_param (lance_debug, int,0 );
@@ -332,6 +333,11 @@ int __init init_module(void)struct net_device *dev;int this_dev, found =0 ; +if (nr_io >0 &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +for (this_dev =0 ; this_dev <MAX_CARDS ; this_dev++) {if (io[this_dev] ==0 ) {if (this_dev !=0 )/* only complain once */
drivers/net/ethernet/amd/ni65.c +5 -0
@@ -1237,6 +1237,11 @@ MODULE_PARM_DESC(dma, "ni6510 ISA DMA channel (ignored for some cards)");int __init init_module (void ) { +if ((irq || io || dma) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + dev_ni65 =ni65_probe (-1 );return PTR_ERR_OR_ZERO (dev_ni65); }
drivers/net/ethernet/cirrus/cs89x0.c +5 -0
@@ -1765,6 +1765,11 @@ int __init init_module(void)struct net_local *lp;int ret =0 ; +if ((io || irq || dma) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +#if DEBUGGING net_debug = debug;#else
drivers/net/ethernet/dec/tulip/de4x5.c +5 -0
@@ -5554,6 +5554,11 @@ static int __init de4x5_module_init (void) {int err =0 ; +if (io &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +#ifdef CONFIG_PCI err =pci_register_driver (&de4x5_pci_driver);#endif
drivers/net/ethernet/hp/hp100.c +7 -1
@@ -2967,8 +2967,9 @@ MODULE_DESCRIPTION("HP CASCADE Architecture Driver for 100VG-AnyLan Network Adap#if defined(MODULE ) && defined(CONFIG_ISA )#define HP100_DEVICES 5/* Parameters set by insmod */ +static int hp100_nr_ports;static int hp100_port[HP100_DEVICES ] = {0 , [1 ... (HP100_DEVICES -1 )] =-1 }; -module_param_array (hp100_port, int,NULL ,0 ); +module_param_array (hp100_port, int, &hp100_nr_ports,0 );/* List of devices */ static struct net_device *hp100_devlist[HP100_DEVICES ];
@@ -2978,6 +2979,11 @@ static int __init hp100_isa_init(void)struct net_device *dev;int i, err, cards =0 ; +if (hp100_nr_ports >0 &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +/* Don't autoprobe ISA bus */ if (hp100_port[0 ] ==0 )return -ENODEV ;
drivers/net/ethernet/realtek/atp.c +10 -3
@@ -45,6 +45,7 @@ static int max_interrupt_work = 15;#define NUM_UNITS 2/* The standard set of ISA module parameters. */ +static unsigned int nr_io, nr_irq;static int io[NUM_UNITS ];static int irq[NUM_UNITS ];static int xcvr[NUM_UNITS ];/* The data transfer mode. */
@@ -151,8 +152,8 @@ MODULE_LICENSE("GPL");module_param (max_interrupt_work, int,0 );module_param (debug, int,0 ); -module_param_array (io, int,NULL ,0 ); -module_param_array (irq, int,NULL ,0 ); +module_param_array (io, int, &nr_io,0 ); +module_param_array (irq, int, &nr_irq,0 );module_param_array (xcvr, int,NULL ,0 );MODULE_PARM_DESC (max_interrupt_work,"ATP maximum events handled per interrupt" );MODULE_PARM_DESC (debug,"ATP debug level (0-7)" );
@@ -860,7 +861,13 @@ static void set_rx_mode(struct net_device *dev)write_reg_high (ioaddr,CMR2 , lp->addr_mode); } -static int __init atp_init_module (void ) { +static int __init atp_init_module (void ) +{ +if ((nr_io >0 || nr_irq >0 ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (debug)/* Emit version even if no cards detected. */ printk (KERN_INFO "%s" , version);return atp_init ();
drivers/net/ethernet/smsc/smc9194.c +5 -0
@@ -1511,6 +1511,11 @@ MODULE_PARM_DESC(ifport, "SMC 99194 interface port (0-default, 1-TP, 2-AUI)");int __init init_module (void ) { +if ((io || irq) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (io ==0 )printk (KERN_WARNING CARDNAME": You shouldn't use auto-probing with insmod!\n" );
drivers/net/hamradio/baycom_epp.c +7 -1
@@ -1167,12 +1167,13 @@ static void baycom_probe(struct net_device *dev)/* * command line settable parameters */ +static unsigned int nr_iobase;static char *mode[NR_PORTS ] = {"" , };static int iobase[NR_PORTS ] = {0x378 , };module_param_array (mode, charp,NULL ,0 );MODULE_PARM_DESC (mode,"baycom operating mode" ); -module_param_array (iobase, int,NULL ,0 ); +module_param_array (iobase, int, &nr_iobase,0 );MODULE_PARM_DESC (iobase,"baycom io base address" );MODULE_AUTHOR ("Thomas M. Sailer, [email protected], [email protected]" );
@@ -1203,6 +1204,11 @@ static int __init init_baycomepp(void)int i, found =0 ;char set_hw =1 ; +if (nr_iobase >0 &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +printk (bc_drvinfo);/* * register net devices
drivers/net/hamradio/baycom_par.c +7 -1
@@ -476,12 +476,13 @@ static int baycom_ioctl(struct net_device *dev, struct ifreq *ifr,/* * command line settable parameters */ +static unsigned int nr_iobase;static char *mode[NR_PORTS ] = {"picpar" , };static int iobase[NR_PORTS ] = {0x378 , };module_param_array (mode, charp,NULL ,0 );MODULE_PARM_DESC (mode,"baycom operating mode; eg. par96 or picpar" ); -module_param_array (iobase, int,NULL ,0 ); +module_param_array (iobase, int, &nr_iobase,0 );MODULE_PARM_DESC (iobase,"baycom io base address" );MODULE_AUTHOR ("Thomas M. Sailer, [email protected], [email protected]" );
@@ -495,6 +496,11 @@ static int __init init_baycompar(void)int i, found =0 ;char set_hw =1 ; +if (nr_iobase >0 &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +printk (bc_drvinfo);/* * register net devices
drivers/net/hamradio/baycom_ser_fdx.c +8 -2
@@ -607,6 +607,7 @@ static int baycom_ioctl(struct net_device *dev, struct ifreq *ifr,/* * command line settable parameters */ +static unsigned int nr_iobase, nr_irq;static char *mode[NR_PORTS ] = {"ser12*" , };static int iobase[NR_PORTS ] = {0x3f8 , };static int irq[NR_PORTS ] = {4 , };
@@ -614,9 +615,9 @@ static int baud[NR_PORTS] = { [0 ... NR_PORTS-1] = 1200 };module_param_array (mode, charp,NULL ,0 );MODULE_PARM_DESC (mode,"baycom operating mode; * for software DCD" ); -module_param_array (iobase, int,NULL ,0 ); +module_param_array (iobase, int, &nr_iobase,0 );MODULE_PARM_DESC (iobase,"baycom io base address" ); -module_param_array (irq, int,NULL ,0 ); +module_param_array (irq, int, &nr_irq,0 );MODULE_PARM_DESC (irq,"baycom irq number" );module_param_array (baud, int,NULL ,0 );MODULE_PARM_DESC (baud,"baycom baud rate (300 to 4800)" );
@@ -632,6 +633,11 @@ static int __init init_baycomserfdx(void)int i, found =0 ;char set_hw =1 ; +if ((nr_iobase >0 || nr_irq >0 ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +printk (bc_drvinfo);/* * register net devices
drivers/net/hamradio/baycom_ser_hdx.c +8 -2
@@ -636,15 +636,16 @@ static int baycom_ioctl(struct net_device *dev, struct ifreq *ifr,/* * command line settable parameters */ +static unsigned int nr_iobase, nr_irq;static char *mode[NR_PORTS ] = {"ser12*" , };static int iobase[NR_PORTS ] = {0x3f8 , };static int irq[NR_PORTS ] = {4 , };module_param_array (mode, charp,NULL ,0 );MODULE_PARM_DESC (mode,"baycom operating mode; * for software DCD" ); -module_param_array (iobase, int,NULL ,0 ); +module_param_array (iobase, int, &nr_iobase,0 );MODULE_PARM_DESC (iobase,"baycom io base address" ); -module_param_array (irq, int,NULL ,0 ); +module_param_array (irq, int, &nr_irq,0 );MODULE_PARM_DESC (irq,"baycom irq number" );MODULE_AUTHOR ("Thomas M. Sailer, [email protected], [email protected]" );
@@ -658,6 +659,11 @@ static int __init init_baycomserhdx(void)int i, found =0 ;char set_hw =1 ; +if ((nr_iobase >0 || nr_irq >0 ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +printk (bc_drvinfo);/* * register net devices
drivers/net/hamradio/dmascc.c +7 -2
@@ -259,7 +259,7 @@ static void tm_isr(struct scc_priv *priv);/* Initialization variables */ - +static unsigned int nr_io;static int io[MAX_NUM_DEVS ]__initdata = {0 , };/* Beware! hw[] is also used in dmascc_exit(). */
@@ -274,7 +274,7 @@ static unsigned long rand;MODULE_AUTHOR ("Klaus Kudielka" );MODULE_DESCRIPTION ("Driver for high-speed SCC boards" ); -module_param_array (io, int,NULL ,0 ); +module_param_array (io, int, &nr_io,0 );MODULE_LICENSE ("GPL" ); static void __exit dmascc_exit(void)
@@ -314,6 +314,11 @@ static int __init dmascc_init(void)unsigned long time, start[MAX_NUM_DEVS ], delay[MAX_NUM_DEVS ], counting[MAX_NUM_DEVS ]; +if (nr_io >0 &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +/* Initialize random number generator */ rand = jiffies;/* Cards found = 0 */
drivers/net/irda/ali-ircc.c +10 -3
@@ -68,6 +68,7 @@ static struct platform_driver ali_ircc_driver = {static int qos_mtt_bits =0x07 ;/* 1 ms or more */ /* Use BIOS settions by default, but user may supply module parameters */ +static unsigned int nr_io, nr_irq, nr_dma;static unsigned int io[] = { ~0 , ~0 , ~0 , ~0 };static unsigned int irq[] = {0 ,0 ,0 ,0 };static unsigned int dma[] = {0 ,0 ,0 ,0 };
@@ -152,6 +153,12 @@ static int __init ali_ircc_init(void)int cfg, cfg_base;int reg, revision;int i =0 ; + +if ((nr_io >0 || nr_irq >0 || nr_dma >0 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } ret =platform_driver_register (&ali_ircc_driver);if (ret) {
@@ -2207,11 +2214,11 @@ MODULE_LICENSE("GPL");MODULE_ALIAS ("platform:" ALI_IRCC_DRIVER_NAME ); -module_param_array (io, int,NULL ,0 ); +module_param_array (io, int, &nr_io,0 );MODULE_PARM_DESC (io,"Base I/O addresses" ); -module_param_array (irq, int,NULL ,0 ); +module_param_array (irq, int, &nr_irq,0 );MODULE_PARM_DESC (irq,"IRQ lines" ); -module_param_array (dma, int,NULL ,0 ); +module_param_array (dma, int, &nr_dma,0 );MODULE_PARM_DESC (dma,"DMA channels" );module_init (ali_ircc_init);
drivers/net/irda/nsc-ircc.c +10 -3
@@ -91,6 +91,7 @@ static int qos_mtt_bits = 0x07; /* 1 ms or more */static int dongle_id;/* Use BIOS settions by default, but user may supply module parameters */ +static unsigned int nr_io, nr_irq, nr_dma;static unsigned int io[] = { ~0 , ~0 , ~0 , ~0 , ~0 };static unsigned int irq[] = {0 ,0 ,0 ,0 ,0 };static unsigned int dma[] = {0 ,0 ,0 ,0 ,0 };
@@ -209,6 +210,12 @@ static int __init nsc_ircc_init(void)int reg;int i =0 ; +if ((nr_io >0 || nr_irq >0 || nr_dma >0 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + ret =platform_driver_register (&nsc_ircc_driver);if (ret) { net_err_ratelimited("%s, Can't register driver!\n",
@@ -2396,11 +2403,11 @@ MODULE_LICENSE("GPL");module_param (qos_mtt_bits, int,0 );MODULE_PARM_DESC (qos_mtt_bits,"Minimum Turn Time" ); -module_param_array (io, int,NULL ,0 ); +module_param_array (io, int, &nr_io,0 );MODULE_PARM_DESC (io,"Base I/O addresses" ); -module_param_array (irq, int,NULL ,0 ); +module_param_array (irq, int, &nr_irq,0 );MODULE_PARM_DESC (irq,"IRQ lines" ); -module_param_array (dma, int,NULL ,0 ); +module_param_array (dma, int, &nr_dma,0 );MODULE_PARM_DESC (dma,"DMA channels" );module_param (dongle_id, int,0 );MODULE_PARM_DESC (dongle_id,"Type-id of used dongle" );
drivers/net/irda/smsc-ircc2.c +7 -0
@@ -463,6 +463,13 @@ static int __init smsc_ircc_init(void)pr_debug ("%s\n" , __func__); +if ((ircc_fir || ircc_sir || ircc_cfg || + ircc_dma !=DMA_INVAL || ircc_irq !=IRQ_INVAL ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + ret =platform_driver_register (&smsc_ircc_driver);if (ret) { net_err_ratelimited("%s, Can't register driver!\n",
drivers/net/irda/w83977af_ir.c +9 -2
@@ -70,6 +70,7 @@ static int qos_mtt_bits = 0x07; /* 1 ms or more */#define CHIP_IO_EXTENT 8 +static unsigned int nr_io, nr_irq;static unsigned int io[] = {0x180 , ~0 , ~0 , ~0 };#ifdef CONFIG_ARCH_NETWINDER /* Adjust to NetWinder differences */ static unsigned int irq[] = {6 ,0 ,0 ,0 };
@@ -110,6 +111,12 @@ static int __init w83977af_init(void) {int i; +if ((nr_io >0 || nr_irq >0 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +for (i=0 ; i <ARRAY_SIZE (dev_self) && io[i] <2000 ; i++) {if (w83977af_open (i, io[i], irq[i], dma[i]) ==0 )return 0 ;
@@ -1264,9 +1271,9 @@ MODULE_LICENSE("GPL");module_param (qos_mtt_bits, int,0 );MODULE_PARM_DESC (qos_mtt_bits,"Mimimum Turn Time" ); -module_param_array (io, int,NULL ,0 ); +module_param_array (io, int, &nr_io,0 );MODULE_PARM_DESC (io,"Base I/O addresses" ); -module_param_array (irq, int,NULL ,0 ); +module_param_array (irq, int, &nr_irq,0 );MODULE_PARM_DESC (irq,"IRQ lines" );/*
drivers/net/wan/cosa.c +10 -3
@@ -232,11 +232,12 @@ static int irq[MAX_CARDS+1] = { -1, -1, -1, -1, -1, -1, 0, };static struct class *cosa_class;#ifdef MODULE -module_param_array (io, int,NULL ,0 ); +static unsigned int nr_io, nr_dma, nr_irq; +module_param_array (io, int, &nr_io,0 );MODULE_PARM_DESC (io,"The I/O bases of the COSA or SRP cards" ); -module_param_array (irq, int,NULL ,0 ); +module_param_array (irq, int, &nr_irq,0 );MODULE_PARM_DESC (irq,"The IRQ lines of the COSA or SRP cards" ); -module_param_array (dma, int,NULL ,0 ); +module_param_array (dma, int, &nr_dma,0 );MODULE_PARM_DESC (dma,"The DMA channels of the COSA or SRP cards" );MODULE_AUTHOR ("Jan \"Yenya\" Kasprzak, <[email protected]>" );
@@ -361,6 +362,12 @@ static int __init cosa_init(void) {int i, err =0 ; +if ((nr_io >0 || nr_irq >0 || nr_dma >0 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (cosa_major >0 ) {if (register_chrdev (cosa_major,"cosa" , &cosa_fops)) {pr_warn ("unable to get major %d\n" , cosa_major);
drivers/net/wan/hostess_sv11.c +6 -0
@@ -340,6 +340,12 @@ static struct z8530_dev *sv11_unit;int init_module (void ) { +if ((io || irq || dma) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if ((sv11_unit =sv11_init (io, irq)) ==NULL )return -ENODEV ;return 0 ;
drivers/net/wan/sbni.c +9 -2
@@ -1464,8 +1464,9 @@ set_multicast_list( struct net_device *dev )#ifdef MODULE -module_param_array (io, int,NULL ,0 ); -module_param_array (irq, int,NULL ,0 ); +unsigned int nr_io, nr_irq; +module_param_array (io, int, &nr_io,0 ); +module_param_array (irq, int, &nr_irq,0 );module_param_array (baud, int,NULL ,0 );module_param_array (rxl, int,NULL ,0 );module_param_array (mac, int,NULL ,0 );
@@ -1479,6 +1480,12 @@ int __init init_module( void )struct net_device *dev;int err; +if ((nr_io >0 || nr_irq >0 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +while ( num <SBNI_MAX_NUM_CARDS ) { dev =alloc_netdev (sizeof (struct net_local ),"sbni%d" ,NET_NAME_UNKNOWN , sbni_devsetup);
drivers/net/wan/sealevel.c +6 -0
@@ -383,6 +383,12 @@ static struct slvl_board *slvl_unit;static int __init slvl_init_module (void ) { +if ((io !=0x238 || irq !=5 || tx_dma !=1 || rx_dma !=3 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + slvl_unit =slvl_init (io, irq, txdma, rxdma, slow);return slvl_unit ?0 : -ENODEV ;
drivers/net/wireless/cisco/airo.c +9 -2
@@ -246,8 +246,9 @@ MODULE_DESCRIPTION("Support for Cisco/Aironet 802.11 wireless ethernet cards. " "Direct support for ISA/PCI/MPI cards and support for PCMCIA when used with airo_cs.");MODULE_LICENSE ("Dual BSD/GPL" );MODULE_SUPPORTED_DEVICE ("Aironet 4500, 4800 and Cisco 340/350" ); -module_param_array (io, int,NULL ,0 ); -module_param_array (irq, int,NULL ,0 ); +static unsigned int nr_io, nr_irq; +module_param_array (io, int, &nr_io,0 ); +module_param_array (irq, int, &nr_irq,0 );module_param_array (rates, int,NULL ,0 );module_param_array (ssids, charp,NULL ,0 );module_param (auto_wep, int,0 );
@@ -5649,6 +5650,12 @@ static int __init airo_init_module( void ) {int i; +if ((nr_io >0 || nr_irq >0 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + proc_kuid =make_kuid (&init_user_ns, proc_uid); proc_kgid =make_kgid (&init_user_ns, proc_gid);if (!uid_valid (proc_kuid) || !gid_valid (proc_kgid))
drivers/parport/parport_pc.c +11 -4
@@ -3149,14 +3149,15 @@ static int __init parport_init_mode_setup(char *str)static char *irq[PARPORT_PC_MAX_PORTS ];static char *dma[PARPORT_PC_MAX_PORTS ]; +static unsigned int nr_io, nr_io_hi, nr_irq, nr_dma;MODULE_PARM_DESC (io,"Base I/O address (SPP regs)" ); -module_param_array (io, int,NULL ,0 ); +module_param_array (io, int, &nr_io,0 );MODULE_PARM_DESC (io_hi,"Base I/O address (ECR)" ); -module_param_array (io_hi, int,NULL ,0 ); +module_param_array (io_hi, int, &nr_io_hi,0 );MODULE_PARM_DESC (irq,"IRQ line" ); -module_param_array (irq, charp,NULL ,0 ); +module_param_array (irq, charp, &nr_irq,0 );MODULE_PARM_DESC (dma,"DMA channel" ); -module_param_array (dma, charp,NULL ,0 ); +module_param_array (dma, charp, &nr_dma,0 );#if defined(CONFIG_PARPORT_PC_SUPERIO ) || \ (defined(CONFIG_PARPORT_1284 ) && defined(CONFIG_PARPORT_PC_FIFO ))MODULE_PARM_DESC (verbose_probing,"Log chit-chat during initialisation" );
@@ -3174,6 +3175,12 @@ static int __init parse_parport_params(void)unsigned int i;int val; +if ((nr_io >0 || nr_io_hi >0 || nr_irq >0 || nr_dma >0 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +#ifdef CONFIG_PCI if (init_mode)parport_init_mode_setup (init_mode);
drivers/pci/hotplug/cpcihp_generic.c +5 -0
@@ -145,6 +145,11 @@ static int __init cpcihp_generic_init(void)struct resource *r;struct pci_dev *dev; +if ((port || irq_mask !=0xffff ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +info (DRIVER_DESC " version: " DRIVER_VERSION ); status =validate_parameters ();if (status)
drivers/pcmcia/i82365.c +8 -0
@@ -757,7 +757,15 @@ static void __init isa_probe(void)#ifdef CONFIG_PNP struct isapnp_device_id *devid;struct pnp_dev *dev; +#endif + +if ((i365_base !=0x3e0 || irq_list_count >0 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +#ifdef CONFIG_PNP for (devid = id_table; devid->vendor; devid++) {if ((dev =pnp_find_dev (NULL , devid->vendor, devid->function,NULL ))) {
drivers/pcmcia/tcic.c +6 -0
@@ -782,6 +782,12 @@ static int tcic_init(struct pcmcia_socket *s)pccard_io_map io = {0 ,0 ,0 ,0 ,1 };pccard_mem_map mem = { .res = &res, }; +if ((tcic_base !=TCIC_BASE || irq_mask !=0xffff || irq_list_count >0 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +for (i =0 ; i <2 ; i++) { io.map = i;tcic_set_io_map (s, &io);
drivers/scsi/aha152x.c +7 -0
@@ -330,10 +330,12 @@ MODULE_LICENSE("GPL");#if !defined(PCMCIA )#if defined(MODULE ) +static unsigned int nr_io;static int io[] = {0 ,0 };module_param_array (io, int,NULL ,0 );MODULE_PARM_DESC (io,"base io address of controller" ); +static unsigned int nr_irq;static int irq[] = {0 ,0 };module_param_array (irq, int,NULL ,0 );MODULE_PARM_DESC (irq,"interrupt for controller" );
@@ -3083,6 +3085,11 @@ static int __init aha152x_init(void)struct pnp_dev *dev=NULL , *pnpdev[2 ] = {NULL ,NULL };#endif +if ((nr_io >0 || nr_irq >0 ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if ( setup_count ) {printk (KERN_INFO "aha152x: processing commandline: " );
drivers/scsi/aha1542.c +7 -1
@@ -30,8 +30,9 @@ static bool isapnp = 1;module_param (isapnp, bool,0 );MODULE_PARM_DESC (isapnp,"enable PnP support (default=1)" ); +static unsigned int nr_io;static int io[MAXBOARDS ] = {0x330 ,0x334 ,0 ,0 }; -module_param_array (io, int,NULL ,0 ); +module_param_array (io, int, &nr_io,0 );MODULE_PARM_DESC (io,"base IO address of controller (0x130,0x134,0x230,0x234,0x330,0x334, default=0x330,0x334)" );/* time AHA spends on the AT-bus during data transfer */
@@ -1039,6 +1040,11 @@ static int __init aha1542_init(void) {int ret =0 ; +if (nr_io >0 &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +#ifdef CONFIG_PNP if (isapnp) { ret =pnp_register_driver (&aha1542_pnp_driver);
drivers/scsi/eata.c +6 -1
@@ -1552,8 +1552,13 @@ static int eata2x_detect(struct scsi_host_template *tpnt) tpnt->proc_name ="eata2x" ; -if (strlen (boot_options)) +if (strlen (boot_options)) { +if (kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + }option_setup (boot_options); + }#if defined(MODULE )/* io_port could have been modified when loading as a module */
drivers/scsi/g_NCR5380.c +10 -2
@@ -52,12 +52,14 @@ module_param(ncr_53c400a, int, 0);module_param (dtc_3181e, int,0 );module_param (hp_c2502, int,0 ); +unsigned int nr_irq;static int irq[] = {0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 }; -module_param_array (irq, int,NULL ,0 ); +module_param_array (irq, int, &nr_irq,0 );MODULE_PARM_DESC (irq,"IRQ number(s)" ); +unsigned int nr_base;static int base[] = {0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 }; -module_param_array (base, int,NULL ,0 ); +module_param_array (base, int, &nr_base,0 );MODULE_PARM_DESC (base,"base address(es)" );static int card[] = {-1 ,-1 ,-1 ,-1 ,-1 ,-1 ,-1 ,-1 };
@@ -608,6 +610,12 @@ static int __init generic_NCR5380_init(void) {int ret =0 ; +if ((nr_base >0 || nr_irq >0 || ncr_addr || ncr_irq) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +/* compatibility with old-style parameters */ if (irq[0 ] ==0 && base[0 ] ==0 && card[0 ] ==-1 ) { irq[0 ] = ncr_irq;
drivers/scsi/gdth.c +7 -1
@@ -325,6 +325,7 @@ static u8 gdth_direction_tab[0x100] = {/* LILO and modprobe/insmod parameters */ /* IRQ list for GDT3000/3020 EISA controllers */ +static unsigned int nr_irq;static int irq[MAXHA ]__initdata = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff };
@@ -353,7 +354,7 @@ static int probe_eisa_isa = 0;static int force_dma32 =0 ;/* parameters for modprobe/insmod */ -module_param_array (irq, int,NULL ,0 ); +module_param_array (irq, int, &irq,0 );module_param (disable, int,0 );module_param (reserve_mode, int,0 );module_param_array (reserve_list, int,NULL ,0 );
@@ -5153,6 +5154,11 @@ static struct notifier_block gdth_notifier = {static int __init gdth_init (void ) { +if (nr_irq >0 &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (disable) {printk ("GDT-HA: Controller driver disabled from" " command line !\n" );
drivers/scsi/qlogicfas.c +8 -2
@@ -135,10 +135,11 @@ static struct Scsi_Host *__qlogicfas_detect(struct scsi_host_template *host,#define MAX_QLOGICFAS 8static struct qlogicfas408_priv *cards; +static unsigned int nr_iobase, nr_irq;static int iobase[MAX_QLOGICFAS ];static int irq[MAX_QLOGICFAS ] = { [0 ...MAX_QLOGICFAS -1 ] =-1 }; -module_param_array (iobase, int,NULL ,0 ); -module_param_array (irq, int,NULL ,0 ); +module_param_array (iobase, int, &nr_iobase,0 ); +module_param_array (irq, int, &nr_irq,0 );MODULE_PARM_DESC (iobase,"I/O address" );MODULE_PARM_DESC (irq,"IRQ" );
@@ -198,6 +199,11 @@ static struct scsi_host_template qlogicfas_driver_template = {static __init int qlogicfas_init (void ) { +if ((nr_iobase >0 || nr_irq >0 ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (!qlogicfas_detect (&qlogicfas_driver_template)) {/* no cards found */ printk(KERN_INFO "%s: no cards were found, please specify "
drivers/staging/i4l/act2000/module.c +7 -0
@@ -795,6 +795,13 @@ static void __exit act2000_exit(void) {act2000_card *card = cards;act2000_card *last; + +if ((act_bus || act_port !=-1 || act_irq !=-1 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +while (card) {unregister_card (card);del_timer_sync (&card->ptimer);
drivers/staging/i4l/icn/icn.c +6 -0
@@ -1659,6 +1659,12 @@ static void __exit icn_exit(void)int i;unsigned long flags; +if ((portbase !=ICN_BASEADDR || membase !=ICN_MEMADDR ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +icn_stopallcards ();while (card) { cmd.command =ISDN_STAT_UNLOAD ;
drivers/staging/i4l/pcbit/module.c +8 -2
@@ -22,11 +22,12 @@ MODULE_DESCRIPTION("ISDN4Linux: Driver for PCBIT-T card");MODULE_AUTHOR ("Pedro Roque Marques" );MODULE_LICENSE ("GPL" ); +static unsigned int nr_mem, nr_irq;static int mem[MAX_PCBIT_CARDS ];static int irq[MAX_PCBIT_CARDS ]; -module_param_array (mem, int,NULL ,0 ); -module_param_array (irq, int,NULL ,0 ); +module_param_array (mem, int, &nr_mem,0 ); +module_param_array (irq, int, &nr_irq,0 );static int num_boards;struct pcbit_dev *dev_pcbit[MAX_PCBIT_CARDS ];
@@ -35,6 +36,11 @@ static int __init pcbit_init(void) {int board; +if ((nr_mem >0 || nr_irq >0 ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + num_boards =0 ; printk(KERN_NOTICE
drivers/staging/media/lirc/lirc_parallel.c +5 -0
@@ -630,6 +630,11 @@ static int __init lirc_parallel_init(void) {int result; +if ((io || irq) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + result =platform_driver_register (&lirc_parallel_driver);if (result) {pr_notice ("platform_driver_register returned %d\n" , result);
drivers/staging/media/lirc/lirc_serial.c +5 -0
@@ -1030,6 +1030,11 @@ static int __init lirc_serial_init_module(void) {int result; +if ((io || irq || ioshift || iommap) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +switch (type) {case LIRC_HOMEBREW :case LIRC_IRDEO :
drivers/staging/media/lirc/lirc_sir.c +5 -0
@@ -917,6 +917,11 @@ static int __init lirc_sir_init(void) {int retval; +if ((io || irq) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + retval =platform_driver_register (&lirc_sir_driver);if (retval) {pr_err ("Platform driver register failed!\n" );
drivers/staging/speakup/speakup_acntpc.c +2 -0
@@ -313,6 +313,8 @@ module_param_named(start, synth_acntpc.startup, short, S_IRUGO);MODULE_PARM_DESC (port,"Set the port for the synthesizer (override probing)." );MODULE_PARM_DESC (start,"Start the synthesizer once it is loaded." ); +#undef define module_lockdown_check +#define module_lockdown_check () (port_forced)module_spk_synth (synth_acntpc);MODULE_AUTHOR ("Kirk Reiser <[email protected]>" );
drivers/staging/speakup/speakup_dtlk.c +2 -0
@@ -384,6 +384,8 @@ module_param_named(start, synth_dtlk.startup, short, S_IRUGO);MODULE_PARM_DESC (port,"Set the port for the synthesizer (override probing)." );MODULE_PARM_DESC (start,"Start the synthesizer once it is loaded." ); +#undef define module_lockdown_check +#define module_lockdown_check () (port_forced)module_spk_synth (synth_dtlk);MODULE_AUTHOR ("Kirk Reiser <[email protected]>" );
drivers/staging/speakup/speakup_keypc.c +2 -0
@@ -315,6 +315,8 @@ module_param_named(start, synth_keypc.startup, short, S_IRUGO);MODULE_PARM_DESC (port,"Set the port for the synthesizer (override probing)." );MODULE_PARM_DESC (start,"Start the synthesizer once it is loaded." ); +#undef define module_lockdown_check +#define module_lockdown_check () (port_forced)module_spk_synth (synth_keypc);MODULE_AUTHOR ("David Borowski" );
drivers/staging/vme/devices/vme_pio2_core.c +6 -0
@@ -158,6 +158,12 @@ static struct vme_driver pio2_driver = {static int __init pio2_init (void ) { +if ((bus_num >0 || base_num >0 || vector_num >0 || level_num >0 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (bus_num ==0 ) {pr_err ("No cards, skipping registration\n" );return -ENODEV ;
drivers/tty/cyclades.c +10 -2
@@ -153,11 +153,12 @@ static unsigned int cy_isa_addresses[] = {#define NR_ISA_ADDRS ARRAY_SIZE(cy_isa_addresses) +static unsigned int nr_maddr, nr_irq;static long maddr[NR_CARDS ];static int irq[NR_CARDS ]; -module_param_array (maddr, long,NULL ,0 ); -module_param_array (irq, int,NULL ,0 ); +module_param_array (maddr, long, &nr_maddr,0 ); +module_param_array (irq, int, &nr_irq,0 );#endif /* CONFIG_ISA */
@@ -4038,6 +4039,13 @@ static int __init cy_init(void)unsigned int nboards;int retval = -ENOMEM ; +#ifdef CONFIG_ISA +if ((nr_maddr >0 || nr_irq >0 ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +#endif + cy_serial_driver =alloc_tty_driver (NR_PORTS );if (!cy_serial_driver) goto err;
drivers/tty/moxa.c +8 -2
@@ -165,6 +165,7 @@ static unsigned int moxaLowWaterChk;static DEFINE_MUTEX (moxa_openlock);static DEFINE_SPINLOCK (moxa_lock); +unsigned int nr_baseaddr, nr_numports;static unsigned long baseaddr[MAX_BOARDS ];static unsigned int type[MAX_BOARDS ];static unsigned int numports[MAX_BOARDS ];
@@ -179,9 +180,9 @@ MODULE_FIRMWARE("c320tunx.cod");module_param_array (type, uint,NULL ,0 );MODULE_PARM_DESC (type,"card type: C218=2, C320=4" ); -module_param_array (baseaddr, ulong,NULL ,0 ); +module_param_array (baseaddr, ulong, &nr_baseaddr,0 );MODULE_PARM_DESC (baseaddr,"base address" ); -module_param_array (numports, uint,NULL ,0 ); +module_param_array (numports, uint, &nr_numports,0 );MODULE_PARM_DESC (numports,"numports (ignored for C218)" );module_param (ttymajor, int,0 );
@@ -1039,6 +1040,11 @@ static int __init moxa_init(void)struct moxa_board_conf *brd = moxa_boards;unsigned int i; +if ((nr_baseaddr >0 || nr_numports >0 ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +printk (KERN_INFO "MOXA Intellio family driver version %s\n" ,MOXA_VERSION );
drivers/tty/mxser.c +7 -1
@@ -176,6 +176,7 @@ static struct pci_device_id mxser_pcibrds[] = { };MODULE_DEVICE_TABLE (pci, mxser_pcibrds); +static unsigned int nr_ioaddr;static unsigned long ioaddr[MXSER_BOARDS ];static int ttymajor =MXSERMAJOR ;
@@ -183,7 +184,7 @@ static int ttymajor = MXSERMAJOR;MODULE_AUTHOR ("Casper Yang" );MODULE_DESCRIPTION ("MOXA Smartio/Industio Family Multiport Board Device Driver" ); -module_param_array (ioaddr, ulong,NULL ,0 ); +module_param_array (ioaddr, ulong, &nr_ioaddr,0 );MODULE_PARM_DESC (ioaddr,"ISA io addresses to look for a moxa board" );module_param (ttymajor, int,0 );MODULE_LICENSE ("GPL" );
@@ -2699,6 +2700,11 @@ static int __init mxser_module_init(void)unsigned int b, i, m;int retval; +if (nr_ioaddr >0 &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + mxvar_sdriver =alloc_tty_driver (MXSER_PORTS +1 );if (!mxvar_sdriver)return -ENOMEM ;
drivers/tty/rocket.c +6 -0
@@ -2363,6 +2363,12 @@ static int __init rp_init(void) {int ret = -ENOMEM , pci_boards_found, isa_boards_found, i; +if ((board1 || board2 || board3 || board4 || conroller) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +printk (KERN_INFO "RocketPort device driver module, version %s, %s\n" ,ROCKET_VERSION ,ROCKET_DATE );
drivers/tty/serial/8250/8250_core.c +5 -0
@@ -645,6 +645,11 @@ static int univ8250_console_match(struct console *co, char *name, int idx,if (strncmp (name, match,4 ) !=0 )return -ENODEV ; +if (kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (uart_parse_earlycon (options, &iotype, &addr, &options))return -ENODEV ;
drivers/tty/synclink.c +9 -3
@@ -859,6 +859,7 @@ static int ttymajor;/* * Array of user specified options for ISA adapters. */ +static unsigned int nr_io, nr_irq, nr_dma;static int io[MAX_ISA_DEVICES ];static int irq[MAX_ISA_DEVICES ];static int dma[MAX_ISA_DEVICES ];
@@ -869,9 +870,9 @@ static int txholdbufs[MAX_TOTAL_DEVICES];module_param (break_on_load, bool,0 );module_param (ttymajor, int,0 ); -module_param_array (io, int,NULL ,0 ); -module_param_array (irq, int,NULL ,0 ); -module_param_array (dma, int,NULL ,0 ); +module_param_array (io, int, &nr_io,0 ); +module_param_array (irq, int, &nr_irq,0 ); +module_param_array (dma, int, &nr_dma,0 );module_param (debug_level, int,0 );module_param_array (maxframe, int,NULL ,0 );module_param_array (txdmabufs, int,NULL ,0 );
@@ -4417,6 +4418,11 @@ static int __init synclink_init(void)BREAKPOINT (); } +if ((nr_io >0 || nr_irq >0 || nr_dma >0 ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +printk ("%s %s\n" , driver_name, driver_version);mgsl_enum_isa_devices ();
drivers/video/fbdev/arcfb.c +6 -0
@@ -611,6 +611,12 @@ static int __init arcfb_init(void) {int ret; +if ((dio_addr || cio_addr || c2io_addr || irq) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (!arcfb_enable)return -ENXIO ;
drivers/video/fbdev/n411.c +6 -0
@@ -153,6 +153,12 @@ static struct platform_device *n411_device;static int __init n411_init (void ) {int ret; + +if ((dio_addr || cio_addr || c2io_addr) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (!dio_addr || !cio_addr || !c2io_addr) {printk (KERN_WARNING "no IO addresses supplied\n" );return -EINVAL ;
drivers/watchdog/cpu5wdt.c +4 -0
@@ -257,6 +257,10 @@ static int cpu5wdt_init(void)static int cpu5wdt_init_module (void ) { +if (port !=0x91 &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + }return cpu5wdt_init (); }
drivers/watchdog/eurotechwdt.c +5 -0
@@ -427,6 +427,11 @@ static int __init eurwdt_init(void) {int ret; +if ((io !=0x3f0 || irq !=10 ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + ret =request_irq (irq, eurwdt_interrupt,0 ,"eurwdt" ,NULL );if (ret) {pr_err ("IRQ %d is not free\n" , irq);
drivers/watchdog/pc87413_wdt.c +5 -0
@@ -505,6 +505,11 @@ static int __init pc87413_init(void) {int ret; +if (io !=IO_DEFAULT &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +pr_info ("Version " VERSION " at io 0x%X\n" ,WDT_INDEX_IO_PORT );
drivers/watchdog/sc1200wdt.c +5 -0
@@ -390,6 +390,11 @@ static int __init sc1200wdt_init(void) {int ret; +if (io !=-1 &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +pr_info ("%s\n" ,SC1200_MODULE_VER );#if definedCONFIG_PNP
drivers/watchdog/wdt.c +5 -0
@@ -592,6 +592,11 @@ static int __init wdt_init(void) {int ret; +if ((io !=0x240 || irq !=11 ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (type !=500 && type !=501 ) {pr_err ("unknown card type '%d'\n" , type);return -ENODEV ;
fs/pstore/ram.c +5 -0
@@ -757,6 +757,11 @@ static void ramoops_register_dummy(void)static int __init ramoops_init (void ) { +if ((mem_address || mem_size) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +ramoops_register_dummy ();return platform_driver_register (&ramoops_driver); }
include/linux/device.h +12 -0
@@ -1332,6 +1332,14 @@ extern long sysfs_deprecated;#endif /** +* module_lockdown_check() - Called to check module params for lockdown mode +* +* This should return true if the module mustn't be allowed to load in lockdown +* mode and false otherwise. +*/ +#define module_lockdown_check () (false) + +/** * module_driver() - Helper macro for drivers that don't do anything * special in module init/exit. This eliminates a lot of boilerplate. * Each module may only use this macro once, and calling it replaces
@@ -1348,6 +1356,10 @@ extern long sysfs_deprecated;#define module_driver (__driver, __register, __unregister, ...) \ static int __init __driver##_init(void) \ { \ + if (module_lockdown_check() && kernel_is_locked_down()) { \ + pr_err("Kernel is locked down\n"); \ + return -EPERM; \ + } \ return __register(&(__driver) , ##__VA_ARGS__); \ } \ module_init(__driver##_init); \
include/linux/isa.h +4 -1
@@ -41,14 +41,17 @@ static inline void isa_unregister_driver(struct isa_driver *d)* module_isa_driver() - Helper macro for registering a ISA driver * @__isa_driver: isa_driver struct * @__num_isa_dev: number of devices to register +* @__lockdown: return -EPERM if this is true and lockdown is in effect * * Helper macro for ISA drivers which do not do anything special in module * init/exit. This eliminates a lot of boilerplate code. Each module may only * use this macro once, and calling it replaces module_init and module_exit. */ -#define module_isa_driver (__isa_driver, __num_isa_dev) \ +#define module_isa_driver (__isa_driver, __num_isa_dev, __lockdown) \ static int __init __isa_driver##_init(void) \ { \ + if ((__lockdown) && kernel_is_locked_down()) \ + return -EPERM; \ return isa_register_driver(&(__isa_driver), __num_isa_dev); \ } \ module_init(__isa_driver##_init); \
include/linux/kernel.h +9 -0
@@ -268,6 +268,15 @@ extern int oops_may_print(void);void do_exit (long error_code)__noreturn ;void complete_and_exit (struct completion *,long )__noreturn ; +#ifdef CONFIG_LOCK_DOWN_KERNEL +extern bool kernel_is_locked_down (void ); +#else +static inline bool kernel_is_locked_down (void ) +{ +return false; +} +#endif +/* Internal, do not use. */ int __must_check _kstrtoul (const char *s,unsigned int base,unsigned long *res);int __must_check _kstrtol (const char *s,unsigned int base,long *res);
include/linux/security.h +0 -5
@@ -1687,7 +1687,6 @@ static inline void free_secdata(void *secdata)#ifdef CONFIG_LOCK_DOWN_KERNEL extern void lock_kernel_down (void ); -extern bool kernel_is_locked_down (void );#ifdef CONFIG_ALLOW_LOCKDOWN_LIFT extern void lift_kernel_lockdown (void );#endif
@@ -1695,10 +1694,6 @@ extern void lift_kernel_lockdown(void);static inline void lock_kernel_down (void ) { } -static inline bool kernel_is_locked_down (void ) -{ -return false; -}#endif #endif /* ! __LINUX_SECURITY_H */
sound/drivers/mpu401/mpu401.c +8 -2
@@ -39,6 +39,7 @@ static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */#ifdef CONFIG_PNP static bool pnp[SNDRV_CARDS ] = {[0 ... (SNDRV_CARDS -1 )] =1 };#endif +static unsigned int nr_port, nr_irq;static long port[SNDRV_CARDS ] =SNDRV_DEFAULT_PORT ;/* MPU-401 port number */ static int irq[SNDRV_CARDS ] =SNDRV_DEFAULT_IRQ ;/* MPU-401 IRQ */ static bool uart_enter[SNDRV_CARDS ] = {[0 ... (SNDRV_CARDS -1 )] =1 };
@@ -53,9 +54,9 @@ MODULE_PARM_DESC(enable, "Enable MPU-401 device.");module_param_array (pnp, bool,NULL ,0444 );MODULE_PARM_DESC (pnp,"PnP detection for MPU-401 device." );#endif -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for MPU-401 device." ); -module_param_array (irq, int,NULL ,0444 ); +module_param_array (irq, int, &nr_irq,0444 );MODULE_PARM_DESC (irq,"IRQ # for MPU-401 device." );module_param_array (uart_enter, bool,NULL ,0444 );MODULE_PARM_DESC (uart_enter,"Issue UART_ENTER command at open." );
@@ -242,6 +243,11 @@ static int __init alsa_card_mpu401_init(void) {int i, err; +if ((nr_port >0 || nr_irq >0 ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if ((err =platform_driver_register (&snd_mpu401_driver)) <0 )return err;
sound/drivers/mtpav.c +7 -0
@@ -762,6 +762,13 @@ static int __init alsa_card_mtpav_init(void) {int err; +if ((port !=MTPAV_IOBASE || irq !=MTPAV_IRQ || + hwports !=MTPAV_MAX_PORTS ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if ((err =platform_driver_register (&snd_mtpav_driver)) <0 )return err;
sound/drivers/serial-u16550.c +8 -2
@@ -69,6 +69,7 @@ static char *adaptor_names[] = {static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE ;/* Enable this card */ +static unsigned int nr_port, nr_irq;static long port[SNDRV_CARDS ] =SNDRV_DEFAULT_PORT ;/* 0x3f8,0x2f8,0x3e8,0x2e8 */ static int irq[SNDRV_CARDS ] =SNDRV_DEFAULT_IRQ ;/* 3,4,5,7,9,10,11,14,15 */ static int speed[SNDRV_CARDS ] = {[0 ... (SNDRV_CARDS -1 )] =38400 };/* 9600,19200,38400,57600,115200 */
@@ -84,9 +85,9 @@ module_param_array(id, charp, NULL, 0444);MODULE_PARM_DESC (id,"ID string for Serial MIDI." );module_param_array (enable, bool,NULL ,0444 );MODULE_PARM_DESC (enable,"Enable UART16550A chip." ); -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for UART16550A chip." ); -module_param_array (irq, int,NULL ,0444 ); +module_param_array (irq, int, &nr_irq,0444 );MODULE_PARM_DESC (irq,"IRQ # for UART16550A chip." );module_param_array (speed, int,NULL ,0444 );MODULE_PARM_DESC (speed,"Speed in bauds." );
@@ -1007,6 +1008,11 @@ static int __init alsa_card_serial_init(void) {int i, cards, err; +if ((nr_port >0 || nr_irq >0 ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if ((err =platform_driver_register (&snd_serial_driver)) <0 )return err;
sound/isa/ad1848/ad1848.c +6 -4
@@ -44,6 +44,7 @@ MODULE_SUPPORTED_DEVICE("{{Analog Devices,AD1848},"static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE ;/* Enable this card */ +static unsigned int nr_port, nr_irq, nr_dma1;static long port[SNDRV_CARDS ] =SNDRV_DEFAULT_PORT ;/* PnP setup */ static int irq[SNDRV_CARDS ] =SNDRV_DEFAULT_IRQ ;/* 5,7,9,11,12,15 */ static int dma1[SNDRV_CARDS ] =SNDRV_DEFAULT_DMA ;/* 0,1,3,5,6,7 */
@@ -55,11 +56,11 @@ module_param_array(id, charp, NULL, 0444);MODULE_PARM_DESC (id,"ID string for " CRD_NAME " soundcard." );module_param_array (enable, bool,NULL ,0444 );MODULE_PARM_DESC (enable,"Enable " CRD_NAME " soundcard." ); -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for " CRD_NAME " driver." ); -module_param_array (irq, int,NULL ,0444 ); +module_param_array (irq, int, &nr_irq,0444 );MODULE_PARM_DESC (irq,"IRQ # for " CRD_NAME " driver." ); -module_param_array (dma1, int,NULL ,0444 ); +module_param_array (dma1, int, &nr_dma1,0444 );MODULE_PARM_DESC (dma1,"DMA1 # for " CRD_NAME " driver." );module_param_array (thinkpad, bool,NULL ,0444 );MODULE_PARM_DESC (thinkpad,"Enable only for the onboard CS4248 of IBM Thinkpad 360/750/755 series." );
@@ -170,4 +171,5 @@ static struct isa_driver snd_ad1848_driver = { } }; -module_isa_driver (snd_ad1848_driver,SNDRV_CARDS ); +module_isa_driver (snd_ad1848_driver,SNDRV_CARDS , + nr_port >0 || nr_irq >0 || nr_dma1 >0 );
sound/isa/adlib.c +3 -2
@@ -16,6 +16,7 @@ MODULE_DESCRIPTION(CRD_NAME);MODULE_AUTHOR ("Rene Herman" );MODULE_LICENSE ("GPL" ); +static unsigned int nr_port;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE ;
@@ -27,7 +28,7 @@ module_param_array(id, charp, NULL, 0444);MODULE_PARM_DESC (id,"ID string for " CRD_NAME " soundcard." );module_param_array (enable, bool,NULL ,0444 );MODULE_PARM_DESC (enable,"Enable " CRD_NAME " soundcard." ); -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for " CRD_NAME " driver." );static int snd_adlib_match (struct device *dev,unsigned int n)
@@ -112,4 +113,4 @@ static struct isa_driver snd_adlib_driver = { } }; -module_isa_driver (snd_adlib_driver,SNDRV_CARDS ); +module_isa_driver (snd_adlib_driver,SNDRV_CARDS , nr_port >0 );
sound/isa/cmi8328.c +10 -7
@@ -34,6 +34,7 @@ MODULE_LICENSE("GPL");static int cmi8328_ports[] = {0x530 ,0xe80 ,0xf40 ,0x604 };#define CMI8328_MAX ARRAY_SIZE(cmi8328_ports) +static unsigned int nr_port, nr_irq, nr_dma1, nr_dma2, nr_mpuport, nr_mpuirq;static int index[CMI8328_MAX ] = {[0 ... (CMI8328_MAX -1 )] =-1 };static char *id[CMI8328_MAX ] = {[0 ... (CMI8328_MAX -1 )] =NULL };static long port[CMI8328_MAX ] = {[0 ... (CMI8328_MAX -1 )] =SNDRV_AUTO_PORT };
@@ -51,18 +52,18 @@ MODULE_PARM_DESC(index, "Index value for CMI8328 soundcard.");module_param_array (id, charp,NULL ,0444 );MODULE_PARM_DESC (id,"ID string for CMI8328 soundcard." ); -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for CMI8328 driver." ); -module_param_array (irq, int,NULL ,0444 ); +module_param_array (irq, int, &nr_irq,0444 );MODULE_PARM_DESC (irq,"IRQ # for CMI8328 driver." ); -module_param_array (dma1, int,NULL ,0444 ); +module_param_array (dma1, int, &nr_dma1,0444 );MODULE_PARM_DESC (dma1,"DMA1 for CMI8328 driver." ); -module_param_array (dma2, int,NULL ,0444 ); +module_param_array (dma2, int, &nr_dma2,0444 );MODULE_PARM_DESC (dma2,"DMA2 for CMI8328 driver." ); -module_param_array (mpuport, long,NULL ,0444 ); +module_param_array (mpuport, long, &nr_mpuport,0444 );MODULE_PARM_DESC (mpuport,"MPU-401 port # for CMI8328 driver." ); -module_param_array (mpuirq, int,NULL ,0444 ); +module_param_array (mpuirq, int, &nr_mpuirq,0444 );MODULE_PARM_DESC (mpuirq,"IRQ # for CMI8328 MPU-401 port." );#ifdef SUPPORT_JOYSTICK module_param_array (gameport, bool,NULL ,0444 );
@@ -469,4 +470,6 @@ static struct isa_driver snd_cmi8328_driver = { }, }; -module_isa_driver (snd_cmi8328_driver,CMI8328_MAX ); +module_isa_driver (snd_cmi8328_driver,CMI8328_MAX , + nr_port >0 || nr_irq >0 || nr_dma1 >0 || nr_dma2 >0 || + nr_mpuport >0 || nr_mpuirq >0 );
sound/isa/cmi8330.c +21 -10
@@ -67,6 +67,9 @@ MODULE_DESCRIPTION("C-Media CMI8330/CMI8329");MODULE_LICENSE ("GPL" );MODULE_SUPPORTED_DEVICE ("{{C-Media,CMI8330,isapnp:{CMI0001,@@@0001,@X@0001}}}" ); +static unsigned int nr_sbport, nr_sbirq, nr_sbdma8, nr_sbdma16; +static unsigned int nr_wssport, nr_wssirq, nr_wssdma; +static unsigned int nr_fmport, nr_mpuport, nr_mpuirq;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE_ISAPNP ;
@@ -95,27 +98,27 @@ module_param_array(isapnp, bool, NULL, 0444);MODULE_PARM_DESC (isapnp,"PnP detection for specified soundcard." );#endif -module_param_array (sbport, long,NULL ,0444 ); +module_param_array (sbport, long, &nr_sbport,0444 );MODULE_PARM_DESC (sbport,"Port # for CMI8330/CMI8329 SB driver." ); -module_param_array (sbirq, int,NULL ,0444 ); +module_param_array (sbirq, int, &nr_sbirq,0444 );MODULE_PARM_DESC (sbirq,"IRQ # for CMI8330/CMI8329 SB driver." ); -module_param_array (sbdma8, int,NULL ,0444 ); +module_param_array (sbdma8, int, &nr_sbdma8,0444 );MODULE_PARM_DESC (sbdma8,"DMA8 for CMI8330/CMI8329 SB driver." ); -module_param_array (sbdma16, int,NULL ,0444 ); +module_param_array (sbdma16, int, &nr_sbdma16,0444 );MODULE_PARM_DESC (sbdma16,"DMA16 for CMI8330/CMI8329 SB driver." ); -module_param_array (wssport, long,NULL ,0444 ); +module_param_array (wssport, long, &nr_wssport,0444 );MODULE_PARM_DESC (wssport,"Port # for CMI8330/CMI8329 WSS driver." ); -module_param_array (wssirq, int,NULL ,0444 ); +module_param_array (wssirq, int, &nr_wssirq,0444 );MODULE_PARM_DESC (wssirq,"IRQ # for CMI8330/CMI8329 WSS driver." ); -module_param_array (wssdma, int,NULL ,0444 ); +module_param_array (wssdma, int, &nr_wssdma,0444 );MODULE_PARM_DESC (wssdma,"DMA for CMI8330/CMI8329 WSS driver." ); -module_param_array (fmport, long,NULL ,0444 ); +module_param_array (fmport, long, &nr_fmport,0444 );MODULE_PARM_DESC (fmport,"FM port # for CMI8330/CMI8329 driver." ); -module_param_array (mpuport, long,NULL ,0444 ); +module_param_array (mpuport, long, &nr_mpuport,0444 );MODULE_PARM_DESC (mpuport,"MPU-401 port # for CMI8330/CMI8329 driver." ); -module_param_array (mpuirq, int,NULL ,0444 ); +module_param_array (mpuirq, int, &nr_mpuirq,0444 );MODULE_PARM_DESC (mpuirq,"IRQ # for CMI8330/CMI8329 MPU-401 port." );#ifdef CONFIG_PNP static int isa_registered;
@@ -750,6 +753,14 @@ static int __init alsa_card_cmi8330_init(void) {int err; +if ((nr_sbport >0 || nr_sbirq >0 || nr_sbdma8 >0 || nr_sbdma16 >0 || + nr_wssport >0 || nr_wssirq >0 || nr_wssdma >0 || + nr_fmport >0 || nr_mpuport >0 || nr_mpuirq >0 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + err =isa_register_driver (&snd_cmi8330_driver,SNDRV_CARDS );#ifdef CONFIG_PNP if (!err)
sound/isa/cs423x/cs4231.c +11 -7
@@ -39,6 +39,8 @@ MODULE_AUTHOR("Jaroslav Kysela <[email protected]>");MODULE_LICENSE ("GPL" );MODULE_SUPPORTED_DEVICE ("{{Crystal Semiconductors,CS4231}}" ); +static unsigned int nr_port, nr_irq, nr_dma1, nr_dma2; +static unsigned int nr_mpuport, nr_mpuirq;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE ;/* Enable this card */
@@ -55,17 +57,17 @@ module_param_array(id, charp, NULL, 0444);MODULE_PARM_DESC (id,"ID string for " CRD_NAME " soundcard." );module_param_array (enable, bool,NULL ,0444 );MODULE_PARM_DESC (enable,"Enable " CRD_NAME " soundcard." ); -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for " CRD_NAME " driver." ); -module_param_array (mpu_port, long,NULL ,0444 ); +module_param_array (mpu_port, long, &nr_mpuport,0444 );MODULE_PARM_DESC (mpu_port,"MPU-401 port # for " CRD_NAME " driver." ); -module_param_array (irq, int,NULL ,0444 ); +module_param_array (irq, int, &nr_irq,0444 );MODULE_PARM_DESC (irq,"IRQ # for " CRD_NAME " driver." ); -module_param_array (mpu_irq, int,NULL ,0444 ); +module_param_array (mpu_irq, int, &nr_mpuirq,0444 );MODULE_PARM_DESC (mpu_irq,"MPU-401 IRQ # for " CRD_NAME " driver." ); -module_param_array (dma1, int,NULL ,0444 ); +module_param_array (dma1, int, &nr_dma1,0444 );MODULE_PARM_DESC (dma1,"DMA1 # for " CRD_NAME " driver." ); -module_param_array (dma2, int,NULL ,0444 ); +module_param_array (dma2, int, &nr_dma2,0444 );MODULE_PARM_DESC (dma2,"DMA2 # for " CRD_NAME " driver." );static int snd_cs4231_match (struct device *dev,unsigned int n)
@@ -186,4 +188,6 @@ static struct isa_driver snd_cs4231_driver = { } }; -module_isa_driver (snd_cs4231_driver,SNDRV_CARDS ); +module_isa_driver (snd_cs4231_driver,SNDRV_CARDS , + nr_port >0 || nr_irq >0 || nr_dma1 >0 || nr_dma2 >0 || + nr_mpuport >0 || nr_mpuirq >0 );
sound/isa/cs423x/cs4236.c +20 -9
@@ -72,6 +72,8 @@ MODULE_ALIAS("snd_cs4232");#define IDENT "CS4232+"#define DEV_NAME "cs4232+" +static unsigned int nr_port, nr_cport, nr_irq, nr_fm_port, nr_sb_port; +static unsigned int nr_mpuport, nr_mpuirq, nr_dma1, nr_dma2;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE_ISAPNP ;/* Enable this card */
@@ -98,23 +100,23 @@ MODULE_PARM_DESC(enable, "Enable " IDENT " soundcard.");module_param_array (isapnp, bool,NULL ,0444 );MODULE_PARM_DESC (isapnp,"ISA PnP detection for specified soundcard." );#endif -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for " IDENT " driver." ); -module_param_array (cport, long,NULL ,0444 ); +module_param_array (cport, long, &nr_cport,0444 );MODULE_PARM_DESC (cport,"Control port # for " IDENT " driver." ); -module_param_array (mpu_port, long,NULL ,0444 ); +module_param_array (mpu_port, long, &nr_mpuport,0444 );MODULE_PARM_DESC (mpu_port,"MPU-401 port # for " IDENT " driver." ); -module_param_array (fm_port, long,NULL ,0444 ); +module_param_array (fm_port, long, &nr_fm_port,0444 );MODULE_PARM_DESC (fm_port,"FM port # for " IDENT " driver." ); -module_param_array (sb_port, long,NULL ,0444 ); +module_param_array (sb_port, long, &nr_sb_port,0444 );MODULE_PARM_DESC (sb_port,"SB port # for " IDENT " driver (optional)." ); -module_param_array (irq, int,NULL ,0444 ); +module_param_array (irq, int, &nr_irq,0444 );MODULE_PARM_DESC (irq,"IRQ # for " IDENT " driver." ); -module_param_array (mpu_irq, int,NULL ,0444 ); +module_param_array (mpu_irq, int, &nr_mpu_irq,0444 );MODULE_PARM_DESC (mpu_irq,"MPU-401 IRQ # for " IDENT " driver." ); -module_param_array (dma1, int,NULL ,0444 ); +module_param_array (dma1, int, &nr_dma1,0444 );MODULE_PARM_DESC (dma1,"DMA1 # for " IDENT " driver." ); -module_param_array (dma2, int,NULL ,0444 ); +module_param_array (dma2, int, &nr_dma2,0444 );MODULE_PARM_DESC (dma2,"DMA2 # for " IDENT " driver." );#ifdef CONFIG_PNP
@@ -689,6 +691,15 @@ static int __init alsa_card_cs423x_init(void) {int err; +if ((nr_port >0 || nr_cport >0 || nr_irq >0 || + nr_fm_port >0 || nr_sb_port >0 || + nr_dma1 >0 || nr_dma2 >0 || + nr_mpuport >0 || nr_mpuirq >0 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + err =isa_register_driver (&cs423x_isa_driver,SNDRV_CARDS );#ifdef CONFIG_PNP if (!err)
sound/isa/es1688/es1688.c +16 -6
@@ -48,6 +48,8 @@ MODULE_SUPPORTED_DEVICE("{{ESS,ES688 PnP AudioDrive,pnp:ESS0100},"MODULE_ALIAS ("snd_es968" ); +static unsigned int nr_port, nr_irq, nr_fm_port; +static unsigned int nr_mpu_port, nr_mpu_irq, nr_dma8;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ #ifdef CONFIG_PNP
@@ -71,17 +73,17 @@ module_param_array(isapnp, bool, NULL, 0444);MODULE_PARM_DESC (isapnp,"PnP detection for specified soundcard." );#endif MODULE_PARM_DESC (enable,"Enable " CRD_NAME " soundcard." ); -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for " CRD_NAME " driver." ); -module_param_array (mpu_port, long,NULL ,0444 ); +module_param_array (mpu_port, long, &nr_mpu_port,0444 );MODULE_PARM_DESC (mpu_port,"MPU-401 port # for " CRD_NAME " driver." ); -module_param_array (irq, int,NULL ,0444 ); -module_param_array (fm_port, long,NULL ,0444 ); +module_param_array (irq, int, &nr_irq,0444 ); +module_param_array (fm_port, long, &nr_fm_port,0444 );MODULE_PARM_DESC (fm_port,"FM port # for ES1688 driver." );MODULE_PARM_DESC (irq,"IRQ # for " CRD_NAME " driver." ); -module_param_array (mpu_irq, int,NULL ,0444 ); +module_param_array (mpu_irq, int, &nr_mpu_irq,0444 );MODULE_PARM_DESC (mpu_irq,"MPU-401 IRQ # for " CRD_NAME " driver." ); -module_param_array (dma8, int,NULL ,0444 ); +module_param_array (dma8, int, &nr_dma8,0444 );MODULE_PARM_DESC (dma8,"8-bit DMA # for " CRD_NAME " driver." );#ifdef CONFIG_PNP
@@ -344,6 +346,14 @@ static struct pnp_card_driver es968_pnpc_driver = {static int __init alsa_card_es1688_init (void ) { +if ((nr_port >0 || nr_irq >0 || + nr_fm_port >0 || nr_dma8 >0 || + nr_mpuport >0 || nr_mpuirq >0 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +#ifdef CONFIG_PNP pnp_register_card_driver (&es968_pnpc_driver);if (snd_es968_pnp_is_probed)
sound/isa/es18xx.c +16 -6
@@ -1972,6 +1972,8 @@ MODULE_SUPPORTED_DEVICE("{{ESS,ES1868 PnP AudioDrive},""{ESS,ES1887 AudioDrive}," "{ESS,ES1888 AudioDrive}}"); +static unsigned int nr_port, nr_irq, nr_fm_port; +static unsigned int nr_mpu_port, nr_dma1, nr_dma2;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE_ISAPNP ;/* Enable this card */
@@ -1999,17 +2001,17 @@ MODULE_PARM_DESC(enable, "Enable ES18xx soundcard.");module_param_array (isapnp, bool,NULL ,0444 );MODULE_PARM_DESC (isapnp,"PnP detection for specified soundcard." );#endif -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for ES18xx driver." ); -module_param_array (mpu_port, long,NULL ,0444 ); +module_param_array (mpu_port, long, &nr_mpu_port,0444 );MODULE_PARM_DESC (mpu_port,"MPU-401 port # for ES18xx driver." ); -module_param_array (fm_port, long,NULL ,0444 ); +module_param_array (fm_port, long, &nr_fm_port,0444 );MODULE_PARM_DESC (fm_port,"FM port # for ES18xx driver." ); -module_param_array (irq, int,NULL ,0444 ); +module_param_array (irq, int, &nr_irq,0444 );MODULE_PARM_DESC (irq,"IRQ # for ES18xx driver." ); -module_param_array (dma1, int,NULL ,0444 ); +module_param_array (dma1, int, &nr_dma1,0444 );MODULE_PARM_DESC (dma1,"DMA 1 # for ES18xx driver." ); -module_param_array (dma2, int,NULL ,0444 ); +module_param_array (dma2, int, &nr_dma2,0444 );MODULE_PARM_DESC (dma2,"DMA 2 # for ES18xx driver." );#ifdef CONFIG_PNP
@@ -2405,6 +2407,14 @@ static int __init alsa_card_es18xx_init(void) {int err; +if ((nr_port >0 || nr_irq >0 || + nr_dma1 >0 || nr_dma2 >0 || + nr_fm_port >0 || nr_mpuport >0 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + err =isa_register_driver (&snd_es18xx_isa_driver,SNDRV_CARDS );#ifdef CONFIG_PNP if (!err)
sound/isa/galaxy/galaxy.c +14 -9
@@ -44,6 +44,8 @@ MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard.");module_param_array (enable, bool,NULL ,0444 );MODULE_PARM_DESC (enable,"Enable " CRD_NAME " soundcard." ); +static unsigned int nr_port, nr_wss_port, nr_mpu_port, nr_fm_port; +static unsigned int nr_irq, nr_mpu_irq, nr_dma1, nr_dma2;static long port[SNDRV_CARDS ] =SNDRV_DEFAULT_PORT ;static long wss_port[SNDRV_CARDS ] =SNDRV_DEFAULT_PORT ;static long mpu_port[SNDRV_CARDS ] =SNDRV_DEFAULT_PORT ;
@@ -53,21 +55,21 @@ static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;static int dma1[SNDRV_CARDS ] =SNDRV_DEFAULT_DMA ;static int dma2[SNDRV_CARDS ] =SNDRV_DEFAULT_DMA ; -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for " CRD_NAME " driver." ); -module_param_array (wss_port, long,NULL ,0444 ); +module_param_array (wss_port, long, &nr_wss_port,0444 );MODULE_PARM_DESC (wss_port,"WSS port # for " CRD_NAME " driver." ); -module_param_array (mpu_port, long,NULL ,0444 ); +module_param_array (mpu_port, long, &nr_mpu_port,0444 );MODULE_PARM_DESC (mpu_port,"MPU-401 port # for " CRD_NAME " driver." ); -module_param_array (fm_port, long,NULL ,0444 ); +module_param_array (fm_port, long, &nr_fm_port,0444 );MODULE_PARM_DESC (fm_port,"FM port # for " CRD_NAME " driver." ); -module_param_array (irq, int,NULL ,0444 ); +module_param_array (irq, int, &nr_irq,0444 );MODULE_PARM_DESC (irq,"IRQ # for " CRD_NAME " driver." ); -module_param_array (mpu_irq, int,NULL ,0444 ); +module_param_array (mpu_irq, int, &nr_mpu_irq,0444 );MODULE_PARM_DESC (mpu_irq,"MPU-401 IRQ # for " CRD_NAME " driver." ); -module_param_array (dma1, int,NULL ,0444 ); +module_param_array (dma1, int, &nr_dma1,0444 );MODULE_PARM_DESC (dma1,"Playback DMA # for " CRD_NAME " driver." ); -module_param_array (dma2, int,NULL ,0444 ); +module_param_array (dma2, int, &nr_dma2,0444 );MODULE_PARM_DESC (dma2,"Capture DMA # for " CRD_NAME " driver." );/*
@@ -634,4 +636,7 @@ static struct isa_driver snd_galaxy_driver = { } }; -module_isa_driver (snd_galaxy_driver,SNDRV_CARDS ); +module_isa_driver (snd_galaxy_driver,SNDRV_CARDS , + nr_port >0 || nr_wss_port >0 || nr_mpuport >0 || + nr_fm_port >0 || nr_irq >0 || nr_mpuirq >0 || + nr_dma1 >0 || nr_dma2 >0 );
sound/isa/gus/gusclassic.c +7 -5
@@ -40,6 +40,7 @@ MODULE_AUTHOR("Jaroslav Kysela <[email protected]>");MODULE_LICENSE ("GPL" );MODULE_SUPPORTED_DEVICE ("{{Gravis,UltraSound Classic}}" ); +static unsigned int nr_port, nr_irq, nr_dma1, nr_dma2;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE ;/* Enable this card */
@@ -58,13 +59,13 @@ module_param_array(id, charp, NULL, 0444);MODULE_PARM_DESC (id,"ID string for " CRD_NAME " soundcard." );module_param_array (enable, bool,NULL ,0444 );MODULE_PARM_DESC (enable,"Enable " CRD_NAME " soundcard." ); -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for " CRD_NAME " driver." ); -module_param_array (irq, int,NULL ,0444 ); +module_param_array (irq, int, &nr_irq,0444 );MODULE_PARM_DESC (irq,"IRQ # for " CRD_NAME " driver." ); -module_param_array (dma1, int,NULL ,0444 ); +module_param_array (dma1, int, &nr_dma1,0444 );MODULE_PARM_DESC (dma1,"DMA1 # for " CRD_NAME " driver." ); -module_param_array (dma2, int,NULL ,0444 ); +module_param_array (dma2, int, &nr_dma2,0444 );MODULE_PARM_DESC (dma2,"DMA2 # for " CRD_NAME " driver." );module_param_array (joystick_dac, int,NULL ,0444 );MODULE_PARM_DESC (joystick_dac,"Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for " CRD_NAME " driver." );
@@ -229,4 +230,5 @@ static struct isa_driver snd_gusclassic_driver = { } }; -module_isa_driver (snd_gusclassic_driver,SNDRV_CARDS ); +module_isa_driver (snd_gusclassic_driver,SNDRV_CARDS , + nr_port >0 || nr_irq >0 || nr_dma1 >0 || nr_dma2 >0 );
sound/isa/gus/gusextreme.c +14 -9
@@ -44,6 +44,8 @@ MODULE_AUTHOR("Jaroslav Kysela <[email protected]>");MODULE_LICENSE ("GPL" );MODULE_SUPPORTED_DEVICE ("{{Gravis,UltraSound Extreme}}" ); +static unsigned int nr_port, nr_gf1_port, nr_mpu_port; +static unsigned int nr_irq, nr_mpu_irq, nr_gf1_irq, nr_dma8, nr_dma1;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE ;/* Enable this card */
@@ -66,21 +68,21 @@ module_param_array(id, charp, NULL, 0444);MODULE_PARM_DESC (id,"ID string for " CRD_NAME " soundcard." );module_param_array (enable, bool,NULL ,0444 );MODULE_PARM_DESC (enable,"Enable " CRD_NAME " soundcard." ); -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for " CRD_NAME " driver." ); -module_param_array (gf1_port, long,NULL ,0444 ); +module_param_array (gf1_port, long, &nr_gf1_port,0444 );MODULE_PARM_DESC (gf1_port,"GF1 port # for " CRD_NAME " driver (optional)." ); -module_param_array (mpu_port, long,NULL ,0444 ); +module_param_array (mpu_port, long, &nr_mpu_port,0444 );MODULE_PARM_DESC (mpu_port,"MPU-401 port # for " CRD_NAME " driver." ); -module_param_array (irq, int,NULL ,0444 ); +module_param_array (irq, int, &nr_irq,0444 );MODULE_PARM_DESC (irq,"IRQ # for " CRD_NAME " driver." ); -module_param_array (mpu_irq, int,NULL ,0444 ); +module_param_array (mpu_irq, int, &nr_mpu_irq,0444 );MODULE_PARM_DESC (mpu_irq,"MPU-401 IRQ # for " CRD_NAME " driver." ); -module_param_array (gf1_irq, int,NULL ,0444 ); +module_param_array (gf1_irq, int, &nr_gf1_irq,0444 );MODULE_PARM_DESC (gf1_irq,"GF1 IRQ # for " CRD_NAME " driver." ); -module_param_array (dma8, int,NULL ,0444 ); +module_param_array (dma8, int, &nr_dma8,0444 );MODULE_PARM_DESC (dma8,"8-bit DMA # for " CRD_NAME " driver." ); -module_param_array (dma1, int,NULL ,0444 ); +module_param_array (dma1, int, &nr_dma1,0444 );MODULE_PARM_DESC (dma1,"GF1 DMA # for " CRD_NAME " driver." );module_param_array (joystick_dac, int,NULL ,0444 );MODULE_PARM_DESC (joystick_dac,"Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for " CRD_NAME " driver." );
@@ -358,4 +360,7 @@ static struct isa_driver snd_gusextreme_driver = { } }; -module_isa_driver (snd_gusextreme_driver,SNDRV_CARDS ); +module_isa_driver (snd_gusextreme_driver,SNDRV_CARDS , + nr_port >0 || nr_gf1_port >0 || nr_mpu_irq >0 || + nr_irq >0 || nr_mpu_irq >0 || nr_gf1_irq >0 || + nr_dma8 >0 || nr_dma1 >0 );
sound/isa/gus/gusmax.c +7 -5
@@ -50,19 +50,20 @@ static int joystick_dac[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 29};static int channels[SNDRV_CARDS ] = {[0 ... (SNDRV_CARDS -1 )] =24 };static int pcm_channels[SNDRV_CARDS ] = {[0 ... (SNDRV_CARDS -1 )] =2 }; +static unsigned int nr_port, nr_irq, nr_dma1, nr_dma2;module_param_array (index, int,NULL ,0444 );MODULE_PARM_DESC (index,"Index value for GUS MAX soundcard." );module_param_array (id, charp,NULL ,0444 );MODULE_PARM_DESC (id,"ID string for GUS MAX soundcard." );module_param_array (enable, bool,NULL ,0444 );MODULE_PARM_DESC (enable,"Enable GUS MAX soundcard." ); -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for GUS MAX driver." ); -module_param_array (irq, int,NULL ,0444 ); +module_param_array (irq, int, &nr_irq,0444 );MODULE_PARM_DESC (irq,"IRQ # for GUS MAX driver." ); -module_param_array (dma1, int,NULL ,0444 ); +module_param_array (dma1, int, &nr_dma1,0444 );MODULE_PARM_DESC (dma1,"DMA1 # for GUS MAX driver." ); -module_param_array (dma2, int,NULL ,0444 ); +module_param_array (dma2, int, &nr_dma2,0444 );MODULE_PARM_DESC (dma2,"DMA2 # for GUS MAX driver." );module_param_array (joystick_dac, int,NULL ,0444 );MODULE_PARM_DESC (joystick_dac,"Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for GUS MAX driver." );
@@ -370,4 +371,5 @@ static struct isa_driver snd_gusmax_driver = { }, }; -module_isa_driver (snd_gusmax_driver,SNDRV_CARDS ); +module_isa_driver (snd_gusmax_driver,SNDRV_CARDS , + nr_port >0 || nr_irq >0 || nr_dma1 >0 || nr_dma2 >0 );
sound/isa/gus/interwave.c +16 -5
@@ -53,6 +53,7 @@ MODULE_DESCRIPTION("AMD InterWave STB with TEA6330T");MODULE_SUPPORTED_DEVICE ("{{AMD,InterWave STB with TEA6330T}}" );#endif +static unsigned int nr_port, nr_irq, nr_dma1, nr_dma2;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE_ISAPNP ;/* Enable this card */
@@ -61,6 +62,7 @@ static bool isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};#endif static long port[SNDRV_CARDS ] =SNDRV_DEFAULT_PORT ;/* 0x210,0x220,0x230,0x240,0x250,0x260 */ #ifdef SNDRV_STB +static unsigned int nr_port_tc;static long port_tc[SNDRV_CARDS ] =SNDRV_DEFAULT_PORT ;/* 0x350,0x360,0x370,0x380 */ #endif static int irq[SNDRV_CARDS ] =SNDRV_DEFAULT_IRQ ;/* 2,3,5,9,11,12,15 */
@@ -92,17 +94,17 @@ MODULE_PARM_DESC(enable, "Enable InterWave soundcard.");module_param_array (isapnp, bool,NULL ,0444 );MODULE_PARM_DESC (isapnp,"ISA PnP detection for specified soundcard." );#endif -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for InterWave driver." );#ifdef SNDRV_STB -module_param_array (port_tc, long,NULL ,0444 ); +module_param_array (port_tc, long, &nr_port_tc,0444 );MODULE_PARM_DESC (port_tc,"Tone control (TEA6330T - i2c bus) port # for InterWave driver." );#endif -module_param_array (irq, int,NULL ,0444 ); +module_param_array (irq, int, &nr_port_irq,0444 );MODULE_PARM_DESC (irq,"IRQ # for InterWave driver." ); -module_param_array (dma1, int,NULL ,0444 ); +module_param_array (dma1, int, &nr_port_dma1,0444 );MODULE_PARM_DESC (dma1,"DMA1 # for InterWave driver." ); -module_param_array (dma2, int,NULL ,0444 ); +module_param_array (dma2, int, &nr_port_dma2,0444 );MODULE_PARM_DESC (dma2,"DMA2 # for InterWave driver." );module_param_array (joystick_dac, int,NULL ,0444 );MODULE_PARM_DESC (joystick_dac,"Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for InterWave driver." );
@@ -908,6 +910,15 @@ static int __init alsa_card_interwave_init(void) {int err; +if ((nr_port >0 || nr_irq >0 || nr_dma1 >0 || nr_dma2 >0 +#ifdef SNDRV_STB + || nr_port_tc >0 +#endif + ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + err =isa_register_driver (&snd_interwave_driver,SNDRV_CARDS );#ifdef CONFIG_PNP if (!err)
sound/isa/msnd/msnd_pinnacle.c +23 -9
@@ -800,22 +800,25 @@ MODULE_LICENSE("GPL");MODULE_FIRMWARE (INITCODEFILE );MODULE_FIRMWARE (PERMCODEFILE ); -module_param_array (io, long,NULL ,S_IRUGO ); +static unsigned int nr_io, nr_irq, nr_mem; +static unsigned int nr_mpu_io, nr_mpu_irq; +static unsigned int nr_ide_io0, nr_ide_io1, nr_ide_irq, nr_joystick_io; +module_param_array (io, long, &nr_io,S_IRUGO );MODULE_PARM_DESC (io,"IO port #" ); -module_param_array (irq, int,NULL ,S_IRUGO ); -module_param_array (mem, long,NULL ,S_IRUGO ); +module_param_array (irq, int, &nr_irq,S_IRUGO ); +module_param_array (mem, long, &nr_mem,S_IRUGO );module_param_array (write_ndelay, int,NULL ,S_IRUGO );module_param (calibrate_signal, int,S_IRUGO );#ifndef MSND_CLASSIC module_param_array (digital, int,NULL ,S_IRUGO );module_param_array (cfg, long,NULL ,S_IRUGO );module_param_array (reset, int,0 ,S_IRUGO ); -module_param_array (mpu_io, long,NULL ,S_IRUGO ); -module_param_array (mpu_irq, int,NULL ,S_IRUGO ); -module_param_array (ide_io0, long,NULL ,S_IRUGO ); -module_param_array (ide_io1, long,NULL ,S_IRUGO ); -module_param_array (ide_irq, int,NULL ,S_IRUGO ); -module_param_array (joystick_io, long,NULL ,S_IRUGO ); +module_param_array (mpu_io, long, &nr_mpu_io,S_IRUGO ); +module_param_array (mpu_irq, int, &nr_mpu_irq,S_IRUGO ); +module_param_array (ide_io0, long, &nr_ide_io0,S_IRUGO ); +module_param_array (ide_io1, long, &nr_ide_io1,S_IRUGO ); +module_param_array (ide_irq, int, &nr_ide_irq,S_IRUGO ); +module_param_array (joystick_io, long, &nr_joystick_io,S_IRUGO );#endif
@@ -1212,6 +1215,17 @@ static int __init snd_msnd_init(void) {int err; +if ((nr_io >0 || nr_irq >0 || nr_mem >0 +#ifndef MSND_CLASSIC + || nr_mpu_io >0 || nr_mpu_irq >0 || + nr_ide_io0 >0 || nr_ide_io1 >0 || nr_ide_irq >0 || + nr_joystick_io >0 +#endif + ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + err =isa_register_driver (&snd_msnd_driver,SNDRV_CARDS );#ifdef CONFIG_PNP if (!err)
sound/isa/opl3sa2.c +18 -8
@@ -43,6 +43,8 @@ MODULE_SUPPORTED_DEVICE("{{Yamaha,YMF719E-S},""{Intel,AL440LX sound}," "{NeoMagic,MagicWave 3DX}}"); +static unsigned int nr_port, nr_sb_port, nr_wss_port, nr_fm_port, nr_midi_port; +static unsigned int nr_irq, nr_dma1, nr_dma2;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE_ISAPNP ;/* Enable this card */
@@ -69,21 +71,21 @@ MODULE_PARM_DESC(enable, "Enable OPL3-SA soundcard.");module_param_array (isapnp, bool,NULL ,0444 );MODULE_PARM_DESC (isapnp,"PnP detection for specified soundcard." );#endif -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for OPL3-SA driver." ); -module_param_array (sb_port, long,NULL ,0444 ); +module_param_array (sb_port, long, &nr_sb_port,0444 );MODULE_PARM_DESC (sb_port,"SB port # for OPL3-SA driver." ); -module_param_array (wss_port, long,NULL ,0444 ); +module_param_array (wss_port, long, &nr_wss_port,0444 );MODULE_PARM_DESC (wss_port,"WSS port # for OPL3-SA driver." ); -module_param_array (fm_port, long,NULL ,0444 ); +module_param_array (fm_port, long, &nr_fm_port,0444 );MODULE_PARM_DESC (fm_port,"FM port # for OPL3-SA driver." ); -module_param_array (midi_port, long,NULL ,0444 ); +module_param_array (midi_port, long, &nr_midi_port,0444 );MODULE_PARM_DESC (midi_port,"MIDI port # for OPL3-SA driver." ); -module_param_array (irq, int,NULL ,0444 ); +module_param_array (irq, int, &nr_irq,0444 );MODULE_PARM_DESC (irq,"IRQ # for OPL3-SA driver." ); -module_param_array (dma1, int,NULL ,0444 ); +module_param_array (dma1, int, &nr_dma1,0444 );MODULE_PARM_DESC (dma1,"DMA1 # for OPL3-SA driver." ); -module_param_array (dma2, int,NULL ,0444 ); +module_param_array (dma2, int, &nr_dma2,0444 );MODULE_PARM_DESC (dma2,"DMA2 # for OPL3-SA driver." );module_param_array (opl3sa3_ymode, int,NULL ,0444 );MODULE_PARM_DESC (opl3sa3_ymode,"Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi." );
@@ -931,6 +933,14 @@ static int __init alsa_card_opl3sa2_init(void) {int err; +if ((nr_port >0 || nr_sb_port >0 || nr_wss_port >0 || + nr_fm_port >0 || nr_midi_port >0 || + nr_irq >0 || nr_dma1 >0 || nr_dma2) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + err =isa_register_driver (&snd_opl3sa2_isa_driver,SNDRV_CARDS );#ifdef CONFIG_PNP if (!err)
sound/isa/opti9xx/miro.c +12 -0
@@ -1636,6 +1636,18 @@ static struct pnp_card_driver miro_pnpc_driver = {static int __init alsa_card_miro_init (void ) { +if ((port !=SNDRV_DEFAULT_PORT1 || + mpu_port !=SNDRV_DEFAULT_PORT1 || + fm_port !=SNDRV_DEFAULT_PORT1 || + irq !=SNDRV_DEFAULT_IRQ1 || + mpu_irq !=SNDRV_DEFAULT_IRQ1 || + dma1 !=SNDRV_DEFAULT_DMA1 || + dma2 !=SNDRV_DEFAULT_DMA1 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +#ifdef CONFIG_PNP pnp_register_card_driver (&miro_pnpc_driver);if (snd_miro_pnp_is_probed)
sound/isa/opti9xx/opti92x-ad1848.c +15 -0
@@ -1177,6 +1177,21 @@ static struct pnp_card_driver opti9xx_pnpc_driver = {static int __init alsa_card_opti9xx_init (void ) { +if ((port !=SNDRV_DEFAULT_PORT1 || + mpu_port !=SNDRV_DEFAULT_PORT1 || + fm_port !=SNDRV_DEFAULT_PORT1 || + irq !=SNDRV_DEFAULT_IRQ1 || + mpu_irq !=SNDRV_DEFAULT_IRQ1 || + dma1 !=SNDRV_DEFAULT_DMA1 +#if defined(CS4231) || defined(OPTi93X) + || dma2 !=SNDRV_DEFAULT_DMA1 +#endif + ) && + kernel_is_locked_down()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +#ifdef CONFIG_PNP pnp_register_card_driver (&opti9xx_pnpc_driver);if (snd_opti9xx_pnp_is_probed)
sound/isa/sb/jazz16.c +10 -7
@@ -34,6 +34,7 @@ MODULE_SUPPORTED_DEVICE("{{Media Vision ??? },"MODULE_AUTHOR ("Krzysztof Helt <[email protected]>" );MODULE_LICENSE ("GPL" ); +static unsigned int nr_port, nr_mpu_port, nr_irq, nr_mpu_irq, nr_dma8, nr_dma16;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE ;/* Enable this card */
@@ -50,17 +51,17 @@ module_param_array(id, charp, NULL, 0444);MODULE_PARM_DESC (id,"ID string for Media Vision Jazz16 based soundcard." );module_param_array (enable, bool,NULL ,0444 );MODULE_PARM_DESC (enable,"Enable Media Vision Jazz16 based soundcard." ); -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for jazz16 driver." ); -module_param_array (mpu_port, long,NULL ,0444 ); +module_param_array (mpu_port, long, &nr_mpu_port,0444 );MODULE_PARM_DESC (mpu_port,"MPU-401 port # for jazz16 driver." ); -module_param_array (irq, int,NULL ,0444 ); +module_param_array (irq, int, &nr_irq,0444 );MODULE_PARM_DESC (irq,"IRQ # for jazz16 driver." ); -module_param_array (mpu_irq, int,NULL ,0444 ); +module_param_array (mpu_irq, int, &nr_mpu_irq,0444 );MODULE_PARM_DESC (mpu_irq,"MPU-401 IRQ # for jazz16 driver." ); -module_param_array (dma8, int,NULL ,0444 ); +module_param_array (dma8, int, &nr_dma8,0444 );MODULE_PARM_DESC (dma8,"DMA8 # for jazz16 driver." ); -module_param_array (dma16, int,NULL ,0444 ); +module_param_array (dma16, int, &nr_dma16,0444 );MODULE_PARM_DESC (dma16,"DMA16 # for jazz16 driver." );#define SB_JAZZ16_WAKEUP 0xaf
@@ -387,4 +388,6 @@ static struct isa_driver snd_jazz16_driver = { }, }; -module_isa_driver (snd_jazz16_driver,SNDRV_CARDS ); +module_isa_driver (snd_jazz16_driver,SNDRV_CARDS , + nr_port >0 || nr_mpu_port >0 || + nr_irq >0 || nr_mpu_irq >0 || nr_dma8 >0 || nr_dma16);
sound/isa/sb/sb16.c +22 -7
@@ -66,6 +66,11 @@ MODULE_SUPPORTED_DEVICE("{{Creative Labs,SB AWE 32},"#define SNDRV_SBAWE_EMU8000 #endif +static unsigned int nr_port, nr_mpu_port, nr_fm_port; +#ifdef SNDRV_SBAWE_EMU8000 +static unsigned int nr_awe_port; +#endif +static unsigned int nr_irq, nr_mpu_irq, nr_dma8, nr_dma16;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE_ISAPNP ;/* Enable this card */
@@ -99,21 +104,21 @@ MODULE_PARM_DESC(enable, "Enable SoundBlaster 16 soundcard.");module_param_array (isapnp, bool,NULL ,0444 );MODULE_PARM_DESC (isapnp,"PnP detection for specified soundcard." );#endif -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for SB16 driver." ); -module_param_array (mpu_port, long,NULL ,0444 ); +module_param_array (mpu_port, long, &nr_mpu_port,0444 );MODULE_PARM_DESC (mpu_port,"MPU-401 port # for SB16 driver." ); -module_param_array (fm_port, long,NULL ,0444 ); +module_param_array (fm_port, long, &nr_fm_port,0444 );MODULE_PARM_DESC (fm_port,"FM port # for SB16 PnP driver." );#ifdef SNDRV_SBAWE_EMU8000 -module_param_array (awe_port, long,NULL ,0444 ); +module_param_array (awe_port, long, &nr_awe_port,0444 );MODULE_PARM_DESC (awe_port,"AWE port # for SB16 PnP driver." );#endif -module_param_array (irq, int,NULL ,0444 ); +module_param_array (irq, int, &nr_irq,0444 );MODULE_PARM_DESC (irq,"IRQ # for SB16 driver." ); -module_param_array (dma8, int,NULL ,0444 ); +module_param_array (dma8, int, &nr_dma8,0444 );MODULE_PARM_DESC (dma8,"8-bit DMA # for SB16 driver." ); -module_param_array (dma16, int,NULL ,0444 ); +module_param_array (dma16, int, &nr_dma16,0444 );MODULE_PARM_DESC (dma16,"16-bit DMA # for SB16 driver." );module_param_array (mic_agc, int,NULL ,0444 );MODULE_PARM_DESC (mic_agc,"Mic Auto-Gain-Control switch." );
@@ -668,6 +673,16 @@ static int __init alsa_card_sb16_init(void) {int err; +if ((nr_port >0 || nr_mpu_port >0 || nr_fm_port >0 || + nr_irq >0 || nr_mpu_irq >0 || nr_dma8 >0 || nr_dma16 >0 +#ifdef SNDRV_SBAWE_EMU8000 + || nr_awe_port >0 +#endif + ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + err =isa_register_driver (&snd_sb16_isa_driver,SNDRV_CARDS );#ifdef CONFIG_PNP if (!err)
sound/isa/sb/sb8.c +6 -4
@@ -34,6 +34,7 @@ MODULE_DESCRIPTION("Sound Blaster 1.0/2.0/Pro");MODULE_LICENSE ("GPL" );MODULE_SUPPORTED_DEVICE ("{{Creative Labs,SB 1.0/SB 2.0/SB Pro}}" ); +static unsigned int nr_port, nr_irq, nr_dma8;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE ;/* Enable this card */
@@ -47,11 +48,11 @@ module_param_array(id, charp, NULL, 0444);MODULE_PARM_DESC (id,"ID string for Sound Blaster soundcard." );module_param_array (enable, bool,NULL ,0444 );MODULE_PARM_DESC (enable,"Enable Sound Blaster soundcard." ); -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for SB8 driver." ); -module_param_array (irq, int,NULL ,0444 ); +module_param_array (irq, int, &nr_irq,0444 );MODULE_PARM_DESC (irq,"IRQ # for SB8 driver." ); -module_param_array (dma8, int,NULL ,0444 ); +module_param_array (dma8, int, &nr_dma8,0444 );MODULE_PARM_DESC (dma8,"8-bit DMA # for SB8 driver." );struct snd_sb8 {
@@ -251,4 +252,5 @@ static struct isa_driver snd_sb8_driver = { }, }; -module_isa_driver (snd_sb8_driver,SNDRV_CARDS ); +module_isa_driver (snd_sb8_driver,SNDRV_CARDS , + nr_port >0 || nr_irq >0 || nr_dma8 >0 );
sound/isa/sc6000.c +12 -7
@@ -46,6 +46,8 @@ MODULE_SUPPORTED_DEVICE("{{Gallant, SC-6000},""{AudioExcel, Audio Excel DSP 16}," "{Zoltrix, AV302}}"); +static unsigned int nr_port, nr_irq, nr_mss_port; +static unsigned int nr_mpu_port, nr_mpu_irq, nr_dma;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE ;/* Enable this card */
@@ -64,17 +66,17 @@ module_param_array(id, charp, NULL, 0444);MODULE_PARM_DESC (id,"ID string for sc-6000 based soundcard." );module_param_array (enable, bool,NULL ,0444 );MODULE_PARM_DESC (enable,"Enable sc-6000 based soundcard." ); -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for sc-6000 driver." ); -module_param_array (mss_port, long,NULL ,0444 ); +module_param_array (mss_port, long, &nr_mss_port,0444 );MODULE_PARM_DESC (mss_port,"MSS Port # for sc-6000 driver." ); -module_param_array (mpu_port, long,NULL ,0444 ); +module_param_array (mpu_port, long, &nr_mpu_port,0444 );MODULE_PARM_DESC (mpu_port,"MPU-401 port # for sc-6000 driver." ); -module_param_array (irq, int,NULL ,0444 ); +module_param_array (irq, int, &nr_irq,0444 );MODULE_PARM_DESC (irq,"IRQ # for sc-6000 driver." ); -module_param_array (mpu_irq, int,NULL ,0444 ); +module_param_array (mpu_irq, int, &nr_mpu_irq,0444 );MODULE_PARM_DESC (mpu_irq,"MPU-401 IRQ # for sc-6000 driver." ); -module_param_array (dma, int,NULL ,0444 ); +module_param_array (dma, int, &nr_dma,0444 );MODULE_PARM_DESC (dma,"DMA # for sc-6000 driver." );module_param_array (joystick, bool,NULL ,0444 );MODULE_PARM_DESC (joystick,"Enable gameport." );
@@ -711,4 +713,7 @@ static struct isa_driver snd_sc6000_driver = { }; -module_isa_driver (snd_sc6000_driver,SNDRV_CARDS ); +module_isa_driver (snd_sc6000_driver,SNDRV_CARDS , + nr_port >0 || nr_irq >0 || nr_mss_port >0 || + nr_mpu_port >0 || nr_mpu_irq >0 || nr_dma >0 ); +
sound/isa/sscape.c +13 -6
@@ -47,6 +47,7 @@ MODULE_FIRMWARE("sndscape.co3");MODULE_FIRMWARE ("sndscape.co4" );MODULE_FIRMWARE ("scope.cod" ); +static unsigned int nr_port, nr_wss_port, nr_irq, nr_mpu_irq, nr_dma, nr_dma2;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;static char * id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;static long port[SNDRV_CARDS ] =SNDRV_DEFAULT_PORT ;
@@ -63,22 +64,22 @@ MODULE_PARM_DESC(index, "Index number for SoundScape soundcard");module_param_array (id, charp,NULL ,0444 );MODULE_PARM_DESC (id,"Description for SoundScape card" ); -module_param_array (port, long,NULL ,0444 ); +module_param_array (port, long, &nr_port,0444 );MODULE_PARM_DESC (port,"Port # for SoundScape driver." ); -module_param_array (wss_port, long,NULL ,0444 ); +module_param_array (wss_port, &nr_wss_port,NULL ,0444 );MODULE_PARM_DESC (wss_port,"WSS Port # for SoundScape driver." ); -module_param_array (irq, int,NULL ,0444 ); +module_param_array (irq, int, &nr_irq,0444 );MODULE_PARM_DESC (irq,"IRQ # for SoundScape driver." ); -module_param_array (mpu_irq, int,NULL ,0444 ); +module_param_array (mpu_irq, int, &nr_mpu_irq,0444 );MODULE_PARM_DESC (mpu_irq,"MPU401 IRQ # for SoundScape driver." ); -module_param_array (dma, int,NULL ,0444 ); +module_param_array (dma, int, &nr_dma,0444 );MODULE_PARM_DESC (dma,"DMA # for SoundScape driver." ); -module_param_array (dma2, int,NULL ,0444 ); +module_param_array (dma2, int, &nr_dma2,0444 );MODULE_PARM_DESC (dma2,"DMA2 # for SoundScape driver." );module_param_array (joystick, bool,NULL ,0444 );
@@ -1328,6 +1329,12 @@ static int __init sscape_init(void) {int err; +if ((nr_port >0 || nr_wss_port >0 || nr_irq >0 || nr_mpu_irq >0 || + nr_dma >0 || nr_dma2 >0 ) &&kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + err =isa_register_driver (&snd_sscape_driver,SNDRV_CARDS );#ifdef CONFIG_PNP if (!err)
sound/isa/wavefront/wavefront.c +22 -9
@@ -36,6 +36,10 @@ MODULE_DESCRIPTION("Turtle Beach Wavefront");MODULE_LICENSE ("GPL" );MODULE_SUPPORTED_DEVICE ("{{Turtle Beach,Maui/Tropez/Tropez+}}" ); +static unsigned int nr_cs4232_pcm_port, nr_cs4232_pcm_irq; +static unsigned int nr_cs4232_mpu_port, nr_cs4232_mpu_irq; +static unsigned int nr_ics2115_port, nr_ics2115_irq; +static unsigned int nr_fm_port, nr_dma1, nr_dma2;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE ;/* Enable this card */
@@ -63,23 +67,23 @@ MODULE_PARM_DESC(enable, "Enable WaveFront soundcard.");module_param_array (isapnp, bool,NULL ,0444 );MODULE_PARM_DESC (isapnp,"ISA PnP detection for WaveFront soundcards." );#endif -module_param_array (cs4232_pcm_port, long,NULL ,0444 ); +module_param_array (cs4232_pcm_port, long, &nr_cs4232_pcm_port,0444 );MODULE_PARM_DESC (cs4232_pcm_port,"Port # for CS4232 PCM interface." ); -module_param_array (cs4232_pcm_irq, int,NULL ,0444 ); +module_param_array (cs4232_pcm_irq, int, &nr_cs4232_pcm_irq,0444 );MODULE_PARM_DESC (cs4232_pcm_irq,"IRQ # for CS4232 PCM interface." ); -module_param_array (dma1, int,NULL ,0444 ); +module_param_array (dma1, int, &nr_dma1,0444 );MODULE_PARM_DESC (dma1,"DMA1 # for CS4232 PCM interface." ); -module_param_array (dma2, int,NULL ,0444 ); +module_param_array (dma2, int, &nr_dma2,0444 );MODULE_PARM_DESC (dma2,"DMA2 # for CS4232 PCM interface." ); -module_param_array (cs4232_mpu_port, long,NULL ,0444 ); +module_param_array (cs4232_mpu_port, long, &nr_cs4232_mpu_port,0444 );MODULE_PARM_DESC (cs4232_mpu_port,"port # for CS4232 MPU-401 interface." ); -module_param_array (cs4232_mpu_irq, int,NULL ,0444 ); +module_param_array (cs4232_mpu_irq, int, &nr_cs4232_mpu_irq,0444 );MODULE_PARM_DESC (cs4232_mpu_irq,"IRQ # for CS4232 MPU-401 interface." ); -module_param_array (ics2115_irq, int,NULL ,0444 ); +module_param_array (ics2115_irq, int, &nr_ics2115_irq,0444 );MODULE_PARM_DESC (ics2115_irq,"IRQ # for ICS2115." ); -module_param_array (ics2115_port, long,NULL ,0444 ); +module_param_array (ics2115_port, long, &nr_ics2115_port,0444 );MODULE_PARM_DESC (ics2115_port,"Port # for ICS2115." ); -module_param_array (fm_port, long,NULL ,0444 ); +module_param_array (fm_port, long, &nr_fm_port,0444 );MODULE_PARM_DESC (fm_port,"FM port #." );module_param_array (use_cs4232_midi, bool,NULL ,0444 );MODULE_PARM_DESC (use_cs4232_midi,"Use CS4232 MPU-401 interface (inaccessibly located inside your computer)" );
@@ -653,6 +657,15 @@ static int __init alsa_card_wavefront_init(void) {int err; +if ((nr_cs4232_pcm_port >0 || nr_cs4232_pcm_irq >0 || + nr_cs4232_mpu_port >0 || nr_cs4232_mpu_irq >0 || + nr_ics2115_port >0 || nr_ics2115_irq >0 || + nr_fm_port >0 || nr_dma1 >0 || nr_dma2 >0 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + err =isa_register_driver (&snd_wavefront_driver,SNDRV_CARDS );#ifdef CONFIG_PNP if (!err)
sound/oss/ad1848.c +6 -0
@@ -2983,6 +2983,12 @@ static int __init ad1848_isapnp_probe(struct address_info *hw_config)static int __init init_ad1848 (void ) { +if ((io !=-1 || irq !=-1 || dma !=-1 || dma2 !=-1 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +printk (KERN_INFO "ad1848/cs4248 codec driver Copyright (C) by Hannu Savolainen 1993-1996\n" );#ifdef CONFIG_PNP
sound/oss/aedsp16.c +7 -1
@@ -1319,7 +1319,13 @@ MODULE_AUTHOR("Riccardo Facchetti <[email protected]>");MODULE_DESCRIPTION ("Audio Excel DSP 16 Driver Version " VERSION );MODULE_LICENSE ("GPL" ); -static int __init do_init_aedsp16 (void ) { +static int __init do_init_aedsp16 (void ) +{ +if (kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +printk ("Audio Excel DSP 16 init driver Copyright (C) Riccardo Facchetti 1995-98\n" );if (io ==-1 || dma ==-1 || irq ==-1 ) {printk (KERN_INFO "aedsp16: I/O, IRQ and DMA are mandatory\n" );
sound/oss/mpu401.c +6 -0
@@ -1758,6 +1758,12 @@ static int __init init_mpu401(void)to others */ if (io !=-1 && irq !=-1 ) {struct resource *ports; + +if (kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + cfg.irq = irq; cfg.io_base = io; ports =request_region (io,2 ,"mpu401" );
sound/oss/msnd_pinnacle.c +23 -0
@@ -1750,6 +1750,29 @@ static int __init msnd_init(void)static msnd_pinnacle_cfg_t pinnacle_devs;#endif /* MSND_CLASSIC */ + if (( +#ifdef MSND_CLASSIC + io !=CONFIG_MSNDCLAS_IO || + irq !=CONFIG_MSNDCLAS_IRQ || + mem != CONFIG_MSNDCLAS_MEM +#else + io != CONFIG_MSNDPIN_IO || + irq != CONFIG_MSNDPIN_IRQ || + mem != CONFIG_MSNDPIN_MEM || + cfg != CONFIG_MSNDPIN_CFG || + mpu_io != CONFIG_MSNDPIN_MPU_IO || + mpu_irq != CONFIG_MSNDPIN_MPU_IRQ || + ide_io0 != CONFIG_MSNDPIN_IDE_IO0 || + ide_io1 != CONFIG_MSNDPIN_IDE_IO1 || + ide_irq != CONFIG_MSNDPIN_IDE_IRQ || + joystick_io != CONFIG_MSNDPIN_JOYSTICK_IO +#endif + ) && kernel_is_locked_down()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + + printk(KERN_INFO LOGNAME ": Turtle Beach " LONGNAME " Linux Driver Version " VERSION ", Copyright (C) 1998 Andrew Veliath\n");
sound/oss/opl3.c +5 -0
@@ -1208,6 +1208,11 @@ static int __init init_opl3 (void)if (io !=-1 )/* User loading pure OPL3 module */ { +if (kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +if (!opl3_detect (io)) {return -ENODEV ;
sound/oss/pas2_card.c +5 -0
@@ -401,6 +401,11 @@ MODULE_LICENSE("GPL");static int __init init_pas2 (void ) { +if (kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +printk (KERN_INFO "Pro Audio Spectrum driver Copyright (C) by Hannu Savolainen 1993-1996\n" ); cfg.io_base = io;
sound/oss/pss.c +4 -0
@@ -1177,6 +1177,10 @@ static int pssmpu = 0, pssmss = 0;static int __init init_pss (void ) { +if (kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + }if (pss_no_sound)/* If configuring only nonsound components */ {
sound/oss/sb_card.c +7 -0
@@ -304,6 +304,13 @@ static int __init sb_init(void)int lres =0 ;int pres =0 ; +if ((mpu_io !=0 || io !=-1 || irq !=-1 || + dma !=-1 || dma16 !=-1 ) && +kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +printk (KERN_INFO "sb: Init: Starting Probe...\n" );if (io !=-1 && irq !=-1 && dma !=-1 ) {
sound/oss/trix.c +5 -0
@@ -426,6 +426,11 @@ module_param(joystick, bool, 0);static int __init init_trix (void ) { +if (kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +printk (KERN_INFO "MediaTrix audio driver Copyright (C) by Hannu Savolainen 1993-1996\n" ); cfg.io_base = io;
sound/oss/uart401.c +5 -0
@@ -441,6 +441,11 @@ static int __init init_uart401(void)/* Can be loaded either for module use or to provide functions to others */ if (cfg_mpu.io_base !=-1 && cfg_mpu.irq !=-1 ) { +if (kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } +printk (KERN_INFO "MPU-401 UART driver Copyright (C) Hannu Savolainen 1993-1997" );if (!probe_uart401 (&cfg_mpu,THIS_MODULE ))return -ENODEV ;
sound/oss/uart6850.c +5 -0
@@ -320,6 +320,11 @@ module_param(irq, int, 0);static int __init init_uart6850 (void ) { +if (kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + cfg_mpu.io_base = io; cfg_mpu.irq = irq;
sound/oss/waveartist.c +3 -0
@@ -1986,6 +1986,9 @@ static int __init init_waveartist(void) irq =12 ; dma =3 ; dma2 =7 ; + }else if (kernel_is_locked_down ()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; } mix = &waveartist_mixer;
sound/pci/als4000.c +4 -1
@@ -88,6 +88,7 @@ MODULE_SUPPORTED_DEVICE("{{Avance Logic,ALS4000}}");#define SUPPORT_JOYSTICK 1#endif +static unsigned int nr_joystick_port;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE_PNP ;/* Enable this card */
@@ -102,7 +103,7 @@ MODULE_PARM_DESC(id, "ID string for ALS4000 soundcard.");module_param_array (enable, bool,NULL ,0444 );MODULE_PARM_DESC (enable,"Enable ALS4000 soundcard." );#ifdef SUPPORT_JOYSTICK -module_param_array (joystick_port, int,NULL ,0444 ); +module_param_array (joystick_port, int, &nr_joystick_port,0444 );MODULE_PARM_DESC (joystick_port,"Joystick port address for ALS4000 soundcard. (0 = disabled)" );#endif
@@ -1034,4 +1035,6 @@ static struct pci_driver als4000_driver = { }, }; +#undef module_lockdown_check +#define module_lockdown_check () (nr_joystick_port > 0)module_pci_driver (als4000_driver);
sound/pci/cmipci.c +5 -2
@@ -52,6 +52,7 @@ MODULE_SUPPORTED_DEVICE("{{C-Media,CMI8738},"#define SUPPORT_JOYSTICK 1#endif +static unsigned int nr_mpu_port, nr_fm_port, nr_joystick_port;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE_PNP ;/* Enable switches */
@@ -68,9 +69,9 @@ module_param_array(id, charp, NULL, 0444);MODULE_PARM_DESC (id,"ID string for C-Media PCI soundcard." );module_param_array (enable, bool,NULL ,0444 );MODULE_PARM_DESC (enable,"Enable C-Media PCI soundcard." ); -module_param_array (mpu_port, long,NULL ,0444 ); +module_param_array (mpu_port, long, &nr_mpu_port,0444 );MODULE_PARM_DESC (mpu_port,"MPU-401 port." ); -module_param_array (fm_port, long,NULL ,0444 ); +module_param_array (fm_port, long, &nr_fm_port,0444 );MODULE_PARM_DESC (fm_port,"FM port." );module_param_array (soft_ac3, bool,NULL ,0444 );MODULE_PARM_DESC (soft_ac3,"Software-conversion of raw SPDIF packets (model 033 only)." );
@@ -3401,4 +3402,6 @@ static struct pci_driver cmipci_driver = { }, }; +#undef module_lockdown_check +#define module_lockdown_check () (nr_mpu_port > 0 || nr_fm_port > 0 || nr_joystick_port > 0)module_pci_driver (cmipci_driver);
sound/pci/ens1370.c +4 -1
@@ -83,6 +83,7 @@ MODULE_SUPPORTED_DEVICE("{{Ensoniq,AudioPCI ES1371/73},"#define SUPPORT_JOYSTICK #endif +static unsigned int nr_joystick_port;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE_PNP ;/* Enable switches */
@@ -106,7 +107,7 @@ module_param_array(enable, bool, NULL, 0444);MODULE_PARM_DESC (enable,"Enable Ensoniq AudioPCI soundcard." );#ifdef SUPPORT_JOYSTICK #ifdef CHIP1371 -module_param_array (joystick_port, int,NULL ,0444 ); +module_param_array (joystick_port, int, &nr_joystick_port,0444 );MODULE_PARM_DESC (joystick_port,"Joystick port address." );#else module_param_array (joystick, bool,NULL ,0444 );
@@ -2475,4 +2476,6 @@ static struct pci_driver ens137x_driver = { }, }; +#undef module_lockdown_check +#define module_lockdown_check () (nr_joystick_port > 0)module_pci_driver (ens137x_driver);
sound/pci/riptide/riptide.c +16 -3
@@ -124,9 +124,11 @@ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE ; +static unsigned int nr_joystick_port;#ifdef SUPPORT_JOYSTICK static int joystick_port[SNDRV_CARDS ] = { [0 ... (SNDRV_CARDS -1 )] =0x200 };#endif +static unsigned int nr_mpu_port, nr_opl3_port;static int mpu_port[SNDRV_CARDS ] = { [0 ... (SNDRV_CARDS -1 )] =0x330 };static int opl3_port[SNDRV_CARDS ] = { [0 ... (SNDRV_CARDS -1 )] =0x388 };
@@ -137,12 +139,12 @@ MODULE_PARM_DESC(id, "ID string for Riptide soundcard.");module_param_array (enable, bool,NULL ,0444 );MODULE_PARM_DESC (enable,"Enable Riptide soundcard." );#ifdef SUPPORT_JOYSTICK -module_param_array (joystick_port, int,NULL ,0444 ); +module_param_array (joystick_port, int, &nr_joystick_port,0444 );MODULE_PARM_DESC (joystick_port,"Joystick port # for Riptide soundcard." );#endif -module_param_array (mpu_port, int,NULL ,0444 ); +module_param_array (mpu_port, int, &nr_mpu_port,0444 );MODULE_PARM_DESC (mpu_port,"MPU401 port # for Riptide driver." ); -module_param_array (opl3_port, int,NULL ,0444 ); +module_param_array (opl3_port, int, &nr_opl3_port,0444 );MODULE_PARM_DESC (opl3_port,"OPL3 port # for Riptide driver." );/*
@@ -2193,6 +2195,17 @@ static struct pci_driver joystick_driver = {static int __init alsa_card_riptide_init (void ) {int err; + + if (( +#ifdef SUPPORT_JOYSTICK + nr_joystick_port > 0 || +#endif + nr_mpu_port > 0 || nr_opl3_port > 0)) && + kernel_is_locked_down()) { +pr_err ("Kernel is locked down\n" ); +return -EPERM ; + } + err =pci_register_driver (&driver);if (err <0 )return err;
sound/pci/sonicvibes.c +2 -0
@@ -1539,4 +1539,6 @@ static struct pci_driver sonicvibes_driver = { .remove = snd_sonic_remove, }; +#undef module_lockdown_check +#define module_lockdown_check () (dmaio != 0x7a00)module_pci_driver (sonicvibes_driver);
sound/pci/via82xx.c +2 -0
@@ -2645,4 +2645,6 @@ static struct pci_driver via82xx_driver = { }, }; +#undef module_lockdown_check +#define module_lockdown_check () (mpu_port)module_pci_driver (via82xx_driver);
sound/pci/ymfpci/ymfpci.c +11 -3
@@ -39,12 +39,14 @@ MODULE_SUPPORTED_DEVICE("{{Yamaha,YMF724},""{Yamaha,YMF744}," "{Yamaha,YMF754}}"); +static unsigned int nr_fm_port, nr_mpu_port;static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE_PNP ;/* Enable this card */ static long fm_port[SNDRV_CARDS ];static long mpu_port[SNDRV_CARDS ];#ifdef SUPPORT_JOYSTICK +static unsigned int nr_joystick_port;static long joystick_port[SNDRV_CARDS ];#endif static bool rear_switch[SNDRV_CARDS ];
@@ -55,12 +57,12 @@ module_param_array(id, charp, NULL, 0444);MODULE_PARM_DESC (id,"ID string for the Yamaha DS-1 PCI soundcard." );module_param_array (enable, bool,NULL ,0444 );MODULE_PARM_DESC (enable,"Enable Yamaha DS-1 soundcard." ); -module_param_array (mpu_port, long,NULL ,0444 ); +module_param_array (mpu_port, long, &nr_mpu_port,0444 );MODULE_PARM_DESC (mpu_port,"MPU-401 Port." ); -module_param_array (fm_port, long,NULL ,0444 ); +module_param_array (fm_port, long, &nr_fm_port,0444 );MODULE_PARM_DESC (fm_port,"FM OPL-3 Port." );#ifdef SUPPORT_JOYSTICK -module_param_array (joystick_port, long,NULL ,0444 ); +module_param_array (joystick_port, long, &nr_joystick_port,0444 );MODULE_PARM_DESC (joystick_port,"Joystick port address" );#endif module_param_array (rear_switch, bool,NULL ,0444 );
@@ -370,4 +372,10 @@ static struct pci_driver ymfpci_driver = {#endif }; +#undef module_lockdown_check +#ifdef SUPPORT_JOYSTICK +#define module_lockdown_check () (nr_mpu_port > 0 || nr_fm_port > 0 || nr_joystick_port > 0) +#else +#define module_lockdown_check () (nr_mpu_port > 0 || nr_fm_port > 0) +#endif module_pci_driver (ymfpci_driver);
Dominik Brodowski
maintainerRe: [PATCH] Lock down drivers that can have io ports, io mem, irqs and dma changed
Quoted 33 lines · David Howells
Quoted 5 lines · One Thousand Gnomes
You need to filter or lock down kernel module options because a lot of modules let you set the I/O port or similar (eg mmio) which means you can hack the entire machine with say the 8250 driver just by using it with an mmio of the right location to patch the secure state to zero just by getting the ability to write to the modules conf file.
Is the attached patch the right sort of idea? [Note that I haven't actually compiled most of these drivers to check my changes yet.]
David
---
commit8613a9655dad98c3358d82a9c4310cebdcb852aeAuthor: David Howells <[email protected]> Date: Mon Nov 21 22:43:27 2016 +0000Lock down drivers that can have io ports, io mem, irqs and dma changed
Lock down drivers that can have io ports, io mem, irqs and dma channels changed so that they can't be used to cause hardware to access the kernel image.
Notes:
(1)
module_isa_driver()gets an extra parameter that, if true, will cause the module load to be rejected if the kernel is locked down.(2)
module_driver()callsmodule_lockdown_check()to ask if the module load should be rejected if the kernel is locked down. This is a macro that should be #undef'd and then redefined right beforemodule_driver()is called.
Quoted 4 lines
(3)
module_pci_driver()is a wrapper aroundmodule_driver(), so the same macro is used as in (2).(4) A number of drivers use parport 'ports' - so I haven't touched those.
You might also need to disable CIS overrides and CIS firmware loading for PCMCIA drivers, I presume. That needs two changes:
- Abort in drivers/pcmcia/ds.c::pcmcia_load_firmware() or disable the CONFIG_PCMCIA_LOAD_CIS config option permanently.
- Abort in drivers/pcmcia/cistpl.c::pccard_store_cis() or remove write access to the "cis" file in drivers/pcmcia/cistpl.c::pccard_cis_attr
Best,
Dominik
Re: [PATCH] Lock down drivers that can have io ports, io mem, irqs and dma changed
Quoted 5 lines · Dominik Brodowski
You might also need to disable CIS overrides and CIS firmware loading for PCMCIA drivers, I presume. That needs two changes:
- Abort in drivers/pcmcia/ds.c::pcmcia_load_firmware() or disable the
CONFIG_PCMCIA_LOAD_CISconfig option permanently.
This really ought to be handled through signature checking in request_firmware().
Quoted 3 lines
- Abort in drivers/pcmcia/cistpl.c::pccard_store_cis() or remove write access to the "cis" file in drivers/pcmcia/cistpl.c::pccard_cis_attr
What is that doing? Allowing the device to be reconfigured?
David
Dominik Brodowski
maintainerRe: [PATCH] Lock down drivers that can have io ports, io mem, irqs and dma changed
Quoted 8 lines · David Howells
Quoted 5 lines · Dominik Brodowski
You might also need to disable CIS overrides and CIS firmware loading for PCMCIA drivers, I presume. That needs two changes:
- Abort in drivers/pcmcia/ds.c::pcmcia_load_firmware() or disable the
CONFIG_PCMCIA_LOAD_CISconfig option permanently.
Quoted 8 lines
This really ought to be handled through signature checking in
request_firmware().Quoted 3 lines
- Abort in drivers/pcmcia/cistpl.c::pccard_store_cis() or remove write access to the "cis" file in drivers/pcmcia/cistpl.c::pccard_cis_attr
What is that doing? Allowing the device to be reconfigured?
Exactly. It is a different interface for updating the firmware -- which includes ioports etc. In theory, any access should be limited to areas which are registered to the bridge devices. But you never know...
Best
Dominik
Re: [PATCH] Lock down drivers that can have io ports, io mem, irqs and dma changed
Quoted 9 lines · Dominik Brodowski
Quoted 5 lines
Quoted 3 lines
- Abort in drivers/pcmcia/cistpl.c::pccard_store_cis() or remove write access to the "cis" file in drivers/pcmcia/cistpl.c::pccard_cis_attr
What is that doing? Allowing the device to be reconfigured?
Exactly. It is a different interface for updating the firmware -- which includes ioports etc. In theory, any access should be limited to areas which are registered to the bridge devices. But you never know...
Ah, I see. Should this be using request_firmware()?
David
Dominik Brodowski
maintainerRe: [PATCH] Lock down drivers that can have io ports, io mem, irqs and dma changed
Quoted 6 lines · David Howells
Quoted 4 lines · Dominik Brodowski
Quoted 4 lines
Quoted 3 lines
- Abort in drivers/pcmcia/cistpl.c::pccard_store_cis() or remove write access to the "cis" file in drivers/pcmcia/cistpl.c::pccard_cis_attr
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
What is that doing? Allowing the device to be reconfigured?
Exactly. It is a different interface for updating the firmware -- which includes ioports etc. In theory, any access should be limited to areas which are registered to the bridge devices. But you never know...
Ah, I see. Should this be using
request_firmware()?
For most cases, request_firmware() is being used -- for some rare cases, however, this alternative interface is provided for. It should be pretty safe nowadays to make pccard_cis_attr read-only (and who uses PCMCIA nowadays anyway?).
Best,
Dominik
Re: [PATCH] Lock down drivers that can have io ports, io mem, irqs and dma changed
Quoted 4 lines · Dominik Brodowski
For most cases,
request_firmware()is being used -- for some rare cases, however, this alternative interface is provided for. It should be pretty safe nowadays to makepccard_cis_attrread-only (and who uses PCMCIA nowadays anyway?).
Have a look at the top patch here:
http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/log/?h=efi-lock-down
David
Re: [PATCH] Lock down drivers that can have io ports, io mem, irqs and dma changed
In reply to David HowellsQuoted 12 lines · David Howells
Quoted 5 lines · One Thousand Gnomes
You need to filter or lock down kernel module options because a lot of modules let you set the I/O port or similar (eg mmio) which means you can hack the entire machine with say the 8250 driver just by using it with an mmio of the right location to patch the secure state to zero just by getting the ability to write to the modules conf file.
Is the attached patch the right sort of idea? [Note that I haven't actually compiled most of these drivers to check my changes yet.]
David
---
snip
Quoted 7 lines
drivers/char/ipmi/ipmi_si_intf.c +0
-0@@ -3725,6 +3725,12 @@ static int init_ipmi_si(void)struct smi_info *e;enum ipmi_addr_src type =SI_INVALID ;
drivers/char/ipmi/ipmi_si_intf.c static int init_ipmi_si(void) · line 3736
Quoted 10 lines
drivers/char/ipmi/ipmi_si_intf.c +6
-0+if ((num_addrs || num_ports || num_irqs) && +kernel_is_locked_down ()) { +pr_err (PFX "Kernel is locked down\n" ); +return -EPERM ; + } +if (initialized)return 0 ; initialized =1 ;
This would prevent any IPMI interface from working if any address was given on the kernel command line. I'm not sure what the best policy is, but that sounds like a possible DOS to me.
Can you put this check in hardcode_find_bmc()? Thats the only place where the hardcoded addresses are used, and a check there won't affect anything else.
Also, the error message sounds a little vague to me. If I was a sysadmin and got this, I wouldn't be sure what was going on. Maybe something like:
The kernel is locked down, but hard-coded device addresses were given on the driver command line. Ignoring these, but this is a possible security issue.
That's fairly wordy, but it gets the point across. You could also move the pr_err() into kernel_is_locked_down() and pass in the prefix, since there is basically the same pr_err() after every check.
Thanks,
-corey
Re: [PATCH] Lock down drivers that can have io ports, io mem, irqs and dma changed
Quoted 3 lines · Corey Minyard
This would prevent any IPMI interface from working if any address was given on the kernel command line. I'm not sure what the best policy is, but that sounds like a possible DOS to me.
Okay, reasonable point.
Quoted 3 lines
Can you put this check in
hardcode_find_bmc()? Thats the only place where the hardcoded addresses are used, and a check there won't affect anything else.
I could do that. I presume you'd want hardcode_find_bmc() to return 1 in that case without doing anything else. Another possibility is to give a warning and then clear ports[], addrs[] and irqs[].
Quoted 9 lines
Also, the error message sounds a little vague to me. If I was a sysadmin and got this, I wouldn't be sure what was going on. Maybe something like:
The kernel is locked down, but hard-coded device addresses were given on the driver command line. Ignoring these, but this is a possible security issue.That's fairly wordy, but it gets the point across. You could also move the
pr_err()intokernel_is_locked_down()and pass in the prefix, since there is basically the samepr_err()after every check.
I don't think your suggested summary quite gets it right. A lot of drivers, sound drivers, for example, that aren't really critical can simply be disabled - and some have to be disabled because there's no other way to configure them.
It would have to be more like pr_err("Hard-coded device addresses, irqs and dma channels are not permitted when the kernel is locked down."), possibly with the addition of either "The driver has been disabled" or "These settings have been ignored".
David
Re: [PATCH] Lock down drivers that can have io ports, io mem, irqs and dma changed
Quoted 5 lines · David Howells
Quoted 3 lines · Corey Minyard
This would prevent any IPMI interface from working if any address was given on the kernel command line. I'm not sure what the best policy is, but that sounds like a possible DOS to me.
Quoted 9 lines
Okay, reasonable point.
Quoted 3 lines
Can you put this check in
hardcode_find_bmc()? Thats the only place where the hardcoded addresses are used, and a check there won't affect anything else.I could do that. I presume you'd want
hardcode_find_bmc()to return 1 in that case without doing anything else. Another possibility is to give a warning and then clear ports[], addrs[] and irqs[].
Just returning -EPERM from that routine is fine, without doing anything else. You can basically just move your check to the top of that routine.
Quoted 6 lines
Quoted 6 lines
Also, the error message sounds a little vague to me. If I was a sysadmin and got this, I wouldn't be sure what was going on. Maybe something like:
The kernel is locked down, but hard-coded device addresses were given on the driver command line. Ignoring these, but this is a possible security issue.
Quoted 7 lines
Quoted 3 lines
That's fairly wordy, but it gets the point across. You could also move the
pr_err()intokernel_is_locked_down()and pass in the prefix, since there is basically the samepr_err()after every check.I don't think your suggested summary quite gets it right. A lot of drivers, sound drivers, for example, that aren't really critical can simply be disabled - and some have to be disabled because there's no other way to configure them.
Yeah. My main issue was that the sysadmin would see this and not have any idea what was going on.
Quoted 5 lines
It would have to be more like pr_err("Hard-coded device addresses, irqs and dma channels are not permitted when the kernel is locked down."), possibly with the addition of either "The driver has been disabled" or "These settings have been ignored".
That sounds better than what I had.
-corey
Re: [PATCH] Lock down drivers that can have io ports, io mem, irqs and dma changed
How about the attached? Obviously it need extending to other drivers.
I thought that if I'm changing the module_param annotations anyway then it's probably worth bunging in an extra parameter that notes what the parameter modifies (ioport, iomem, etc.) for future reference, even if we don't store it.
David
---
drivers/char/ipmi/ipmi_si_intf.c +7 -13
@@ -1375,39 +1375,39 @@ MODULE_PARM_DESC(type, "Defines the type of each interface, each"" interface separated by commas. The types are 'kcs'," " 'smic', and 'bt'. For example si_type=kcs,bt will set" " the first interface to kcs and the second to bt"); -module_param_array (addrs, ulong, &num_addrs,0 ); +module_param_hw_array (addrs, ulong, iomem, &num_addrs,0 );MODULE_PARM_DESC (addrs,"Sets the memory address of each interface, the" " addresses separated by commas. Only use if an interface" " is in memory. Otherwise, set it to zero or leave" " it blank." ); -module_param_array (ports, uint, &num_ports,0 ); +module_param_hw_array (ports, uint, ioport, &num_ports,0 );MODULE_PARM_DESC (ports,"Sets the port address of each interface, the" " addresses separated by commas. Only use if an interface" " is a port. Otherwise, set it to zero or leave" " it blank." ); -module_param_array (irqs, int, &num_irqs,0 ); +module_param_hw_array (irqs, int, irq, &num_irqs,0 );MODULE_PARM_DESC (irqs,"Sets the interrupt of each interface, the" " addresses separated by commas. Only use if an interface" " has an interrupt. Otherwise, set it to zero or leave" " it blank." ); -module_param_array (regspacings, int, &num_regspacings,0 ); +module_param_hw_array (regspacings, int, other, &num_regspacings,0 );MODULE_PARM_DESC (regspacings,"The number of bytes between the start address" " and each successive register used by the interface. For" " instance, if the start address is 0xca2 and the spacing" " is 2, then the second address is at 0xca4. Defaults" " to 1." ); -module_param_array (regsizes, int, &num_regsizes,0 ); +module_param_hw_array (regsizes, int, other, &num_regsizes,0 );MODULE_PARM_DESC (regsizes,"The size of the specific IPMI register in bytes." " This should generally be 1, 2, 4, or 8 for an 8-bit," " 16-bit, 32-bit, or 64-bit register. Use this if you" " the 8-bit IPMI register has to be read from a larger" " register." ); -module_param_array (regshifts, int, &num_regshifts,0 ); +module_param_hw_array (regshifts, int, other, &num_regshifts,0 );MODULE_PARM_DESC (regshifts,"The amount to shift the data read from the." " IPMI register, in bits. For instance, if the data" " is read from a 32-bit word and the IPMI data is in" " bit 8-15, then the shift would be 8" ); -module_param_array (slave_addrs, int, &num_slave_addrs,0 ); +module_param_hw_array (slave_addrs, int, other, &num_slave_addrs,0 );MODULE_PARM_DESC (slave_addrs,"Set the default IPMB slave address for" " the controller. Normally this is 0x20, but can be" " overridden by this parm. This is an array indexed"
@@ -3725,12 +3725,6 @@ static int init_ipmi_si(void)struct smi_info *e;enum ipmi_addr_src type =SI_INVALID ; -if ((num_addrs || num_ports || num_irqs) && -kernel_is_locked_down ()) { -pr_err (PFX "Kernel is locked down\n" ); -return -EPERM ; - } -if (initialized)return 0 ; initialized =1 ;
include/linux/moduleparam.h +59 -1
74 lines not on this page · raw message
kernel/params.c +16 -5
@@ -108,13 +108,20 @@ bool parameq(const char *a, const char *b)return parameqn (a, b,strlen (a)+1 ); } -static void param_check_unsafe (const struct kernel_param *kp) +static bool param_check_unsafe (const struct kernel_param *kp, +const char *doing) {if (kp->flags &KERNEL_PARAM_FL_UNSAFE ) {pr_warn ("Setting dangerous option %s - tainting kernel\n" , kp->name);add_taint (TAINT_USER ,LOCKDEP_STILL_OK ); } + +if (kp->flags &KERNEL_PARAM_FL_HWPARAM &&kernel_is_locked_down ()) { +pr_err ("Command line-specified device addresses, irqs and dma channels are not permitted when the kernel is locked down (%s.%s)\n" , doing, kp->name); +return false; + } +return true; } static int parse_one(char *param,
@@ -144,8 +151,10 @@ static int parse_one(char *param,pr_debug ("handling %s with %p\n" , param, params[i].ops->set);kernel_param_lock (params[i].mod); -param_check_unsafe (¶ms[i]); - err = params[i].ops->set (val, ¶ms[i]); +if (param_check_unsafe (¶ms[i], doing)) + err = params[i].ops->set (val, ¶ms[i]); +else + err = -EPERM ;kernel_param_unlock (params[i].mod);return err; }
@@ -620,8 +629,10 @@ static ssize_t param_attr_store(struct module_attribute *mattr,return -EPERM ;kernel_param_lock (mk->mod); -param_check_unsafe (attribute->param); - err = attribute->param->ops->set (buf, attribute->param); +if (param_check_unsafe (attribute->param, mk->mod->name)) + err = attribute->param->ops->set (buf, attribute->param); +else + err = -EPERM ;kernel_param_unlock (mk->mod);if (!err)return len;
Corey Minyard
Reviewed-byRe: [PATCH] Lock down drivers that can have io ports, io mem, irqs and dma changed
Quoted 1 line · David Howells
How about the attached? Obviously it need extending to other drivers.
This is great, I like it a lot better.
-corey
Quoted 203 lines
I thought that if I'm changing the
module_paramannotations anyway then it's probably worth bunging in an extra parameter that notes what the parameter modifies (ioport, iomem, etc.) for future reference, even if we don't store it.David
---drivers/char/ipmi/ipmi_si_intf.c +7
-13@@ -1375,39 +1375,39 @@ MODULE_PARM_DESC(type, "Defines the type of each interface, each"" interface separated by commas. The types are 'kcs'," " 'smic', and 'bt'. For example si_type=kcs,bt will set" " the first interface to kcs and the second to bt"); -module_param_array (addrs, ulong, &num_addrs,0 ); +module_param_hw_array (addrs, ulong, iomem, &num_addrs,0 );MODULE_PARM_DESC (addrs,"Sets the memory address of each interface, the" " addresses separated by commas. Only use if an interface" " is in memory. Otherwise, set it to zero or leave" " it blank." ); -module_param_array (ports, uint, &num_ports,0 ); +module_param_hw_array (ports, uint, ioport, &num_ports,0 );MODULE_PARM_DESC (ports,"Sets the port address of each interface, the" " addresses separated by commas. Only use if an interface" " is a port. Otherwise, set it to zero or leave" " it blank." ); -module_param_array (irqs, int, &num_irqs,0 ); +module_param_hw_array (irqs, int, irq, &num_irqs,0 );MODULE_PARM_DESC (irqs,"Sets the interrupt of each interface, the" " addresses separated by commas. Only use if an interface" " has an interrupt. Otherwise, set it to zero or leave" " it blank." ); -module_param_array (regspacings, int, &num_regspacings,0 ); +module_param_hw_array (regspacings, int, other, &num_regspacings,0 );MODULE_PARM_DESC (regspacings,"The number of bytes between the start address" " and each successive register used by the interface. For" " instance, if the start address is 0xca2 and the spacing" " is 2, then the second address is at 0xca4. Defaults" " to 1." ); -module_param_array (regsizes, int, &num_regsizes,0 ); +module_param_hw_array (regsizes, int, other, &num_regsizes,0 );MODULE_PARM_DESC (regsizes,"The size of the specific IPMI register in bytes." " This should generally be 1, 2, 4, or 8 for an 8-bit," " 16-bit, 32-bit, or 64-bit register. Use this if you" " the 8-bit IPMI register has to be read from a larger" " register." ); -module_param_array (regshifts, int, &num_regshifts,0 ); +module_param_hw_array (regshifts, int, other, &num_regshifts,0 );MODULE_PARM_DESC (regshifts,"The amount to shift the data read from the." " IPMI register, in bits. For instance, if the data" " is read from a 32-bit word and the IPMI data is in" " bit 8-15, then the shift would be 8" ); -module_param_array (slave_addrs, int, &num_slave_addrs,0 ); +module_param_hw_array (slave_addrs, int, other, &num_slave_addrs,0 );MODULE_PARM_DESC (slave_addrs,"Set the default IPMB slave address for" " the controller. Normally this is 0x20, but can be" " overridden by this parm. This is an array indexed"@@ -3725,12 +3725,6 @@ static int init_ipmi_si(void)struct smi_info *e;enum ipmi_addr_src type =SI_INVALID ; -if ((num_addrs || num_ports || num_irqs) && -kernel_is_locked_down ()) { -pr_err (PFX "Kernel is locked down\n" ); -return -EPERM ; - } -if (initialized)return 0 ; initialized =1 ;include/linux/moduleparam.h +59
-1@@ -60,9 +60,11 @@ struct kernel_param_ops {* Flags available for kernel_param * * UNSAFE - the parameter is dangerous and setting it will taint the kernel +* HWPARAM - Hardware param not permitted in lockdown mode */ enum { -KERNEL_PARAM_FL_UNSAFE = (1 <<0 ) +KERNEL_PARAM_FL_UNSAFE = (1 <<0 ), +KERNEL_PARAM_FL_HWPARAM = (1 <<1 ), };struct kernel_param {@@ -451,6 +453,62 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp); perm, -1, 0); \ __MODULE_PARM_TYPE(name, "array of " #type) +enum hwparam_type { + hwparam_ioport,/* Module parameter configures an I/O port */ + hwparam_iomem,/* Module parameter configures an I/O mem address */ + hwparam_irq,/* Module parameter configures an I/O port */ + hwparam_dma,/* Module parameter configures a DMA channel */ + hwparam_dma_addr,/* Module parameter configures a DMA buffer address */ + hwparam_other,/* Module parameter configures some other value */ +}; + +/** +* module_param_hw - A parameter representing a hw parameters +* @name: a valid C identifier which is the parameter name. +* @type: the type of the parameter +* @hwtype: what the value represents (enum hwparam_type) +* @perm: visibility in sysfs. +* +* Usually it's a good idea to have variable names and user-exposed names the +* same, but that's harder if the variable must be non-static or is inside a +* structure. This allows exposure under a different name. +*/ +#define module_param_hw (name, type, hwtype, perm) \ + param_check_##type(name, &(name)); \ + __module_param_call(MODULE_PARAM_PREFIX, name, \ + ¶m_ops_##type, &name, \ + perm, -1, \ + KERNEL_PARAM_FL_HWPARAM | (hwparam_##hwtype & 0)); \ + __MODULE_PARM_TYPE(name, #type) + +/** +* module_param_hw_array - A parameter representing an array of hw parameters +* @name: the name of the array variable +* @type: the type, as per module_param() +* @hwtype: what the value represents (enum hwparam_type) +* @nump: optional pointer filled in with the number written +* @perm: visibility in sysfs +* +* Input and output are as comma-separated values. Commas inside values +* don't work properly (eg. an array of charp). +* +* ARRAY_SIZE(@name) is used to determine the number of elements in the +* array, so the definition must be visible. +*/ +#define module_param_hw_array (name, type, hwtype, nump, perm) \ + param_check_##type(name, &(name)[0]); \ + static const struct kparam_array __param_arr_##name \ + = { .max = ARRAY_SIZE(name), .num = nump, \ + .ops = ¶m_ops_##type, \ + .elemsize = sizeof(name[0]), .elem = name }; \ + __module_param_call(MODULE_PARAM_PREFIX, name, \ + ¶m_array_ops, \ + .arr = &__param_arr_##name, \ + perm, -1, \ + KERNEL_PARAM_FL_HWPARAM | (hwparam_##hwtype & 0)); \ + __MODULE_PARM_TYPE(name, "array of " #type) + +extern const struct kernel_param_ops param_array_ops;extern const struct kernel_param_ops param_ops_string;kernel/params.c +16
-5@@ -108,13 +108,20 @@ bool parameq(const char *a, const char *b)return parameqn (a, b,strlen (a)+1 ); } -static void param_check_unsafe (const struct kernel_param *kp) +static bool param_check_unsafe (const struct kernel_param *kp, +const char *doing) {if (kp->flags &KERNEL_PARAM_FL_UNSAFE ) {pr_warn ("Setting dangerous option %s - tainting kernel\n" , kp->name);add_taint (TAINT_USER ,LOCKDEP_STILL_OK ); } + +if (kp->flags &KERNEL_PARAM_FL_HWPARAM &&kernel_is_locked_down ()) { +pr_err ("Command line-specified device addresses, irqs and dma channels are not permitted when the kernel is locked down (%s.%s)\n" , doing, kp->name); +return false; + } +return true; } static int parse_one(char *param,@@ -144,8 +151,10 @@ static int parse_one(char *param,pr_debug ("handling %s with %p\n" , param, params[i].ops->set);kernel_param_lock (params[i].mod); -param_check_unsafe (¶ms[i]); - err = params[i].ops->set (val, ¶ms[i]); +if (param_check_unsafe (¶ms[i], doing)) + err = params[i].ops->set (val, ¶ms[i]); +else + err = -EPERM ;kernel_param_unlock (params[i].mod);return err; }@@ -620,8 +629,10 @@ static ssize_t param_attr_store(struct module_attribute *mattr,return -EPERM ;kernel_param_lock (mk->mod); -param_check_unsafe (attribute->param); - err = attribute->param->ops->set (buf, attribute->param); +if (param_check_unsafe (attribute->param, mk->mod->name)) + err = attribute->param->ops->set (buf, attribute->param); +else + err = -EPERM ;kernel_param_unlock (mk->mod);if (!err)return len;
Re: [PATCH] Lock down drivers that can have io ports, io mem, irqs and dma changed
In reply to David HowellsQuoted 6 lines · On Tue, 29 Nov 2016 14:03:31 +0000 David Howells…
How about the attached? Obviously it need extending to other drivers.
I thought that if I'm changing the
module_paramannotations anyway then it's probably worth bunging in an extra parameter that notes what the parameter modifies (ioport, iomem, etc.) for future reference, even if we don't store it.
With a security hat on the security best practice and long standing accepted rule is that you whitelist rather than blacklist, so there ought to be a
module_param_safe_array()
etc
to mark parameters that are safe, not the reverse.
That debate aside I think the patch is exactly what is needed for this, and is probably useful for more general hardening as well.
Alan
Re: [PATCH] Lock down drivers that can have io ports, io mem, irqs and dma changed
Quoted 5 lines · One Thousand Gnomes
Quoted 4 lines
I thought that if I'm changing the
module_paramannotations anyway then it's probably worth bunging in an extra parameter that notes what the parameter modifies (ioport, iomem, etc.) for future reference, even if we don't store it.
Quoted 8 lines
With a security hat on the security best practice and long standing accepted rule is that you whitelist rather than blacklist, so there ought to be a
module_param_safe_array()
etcto mark parameters that are safe, not the reverse.
Whilst that may be true, it's a lot more work. Mind you, that said, you can take the annotations I've made and script the inverse.
Quoted 2 lines
That debate aside I think the patch is exactly what is needed for this, and is probably useful for more general hardening as well.
Okay, I've done a preliminary patchset, labelling all the parameters that appear to be associated with hardware details and pushed them here:
http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/log/?h=efi-lock-down
The patch that modifies the module parameter header is labelled:
Lock down module params that specify hardware parameters (eg. ioport)
and all the driver dir lockdown patches follow that.
I still need to do a bit of commenting in that patch and add various maintainer cc's in the other patches.
David
Re: [PATCH] Lock down drivers that can have io ports, io mem, irqs and dma changed
In reply to David HowellsQuoted 4 lines · David Howells
It would have to be more like pr_err("Hard-coded device addresses, irqs and dma channels are not permitted when the kernel is locked down."), possibly with the addition of either "The driver has been disabled" or "These settings have been ignored".
That should be "Command line-specified" rather than "Hard-coded". The latter are actually okay.
A better way to do this would probably be to annotate the module parameter declarations and have the module_param() invoker reject the locked-down parameters. I'm not sure how easy that would be to do, though.
David
Quoted 5 lines · David Howells
These patches provide a facility by which a variety of avenues by which userspace can feasibly modify the running kernel image can be locked down. These include:
Bit surprised to see this. Not that I am opposed to the patches themselves. These were pulled into my tree as the first step towards consolidating the implementation used for secure boot, and I know there is interest in using large parts outside of a secure boot context as well, but there were a few changes to be made after our discussions in Santa Fe. Those are going into
http://git.kernel.org/cgit/linux/kernel/git/jforbes/linux.git/log/?h=lockdown
I am completely happy to submit those changes as separate patches if people want to take these. They do actually work, and are being shipped and supported by multiple distributions at this point.
Justin