Skip to contentSkip to conversation

MODSIGN: Kernel module signing

PATCH In review David Howells 14 participants 34 messages Feb 14, 2007 – Feb 16, 2007

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover MODSIGN: Kernel module signing

These patches provide a GPG-based kernel module signing facility. Their use is not fully automated within the confines of the kernel build process because it needs provision of keys from outside of the kernel before the kernel can be compiled.

The patches are:

(1) A cut-down MPI library derived from GPG with error handling added.

(2) Permit hash algorithms to hash kernel data defined by a virtual address and a length rather than trying to use scattergather lists (which require struct page pointers to be determined).

(3) Add extra information to the per-arch ELF headers to more fully describe the format of the ELF metadata.

(4) Add module verification capabilities, including ELF metadata verification.

(5) Add a generic DSA signature checker. Given a SHA1 hash of the data to be verified and a binary blob holding a GPG signature stream, this verifies the signature using a built-in ring of public keys.

(6) Add a module signature checker that applies signature checking to modules on module load, checking the signature against the ring of public keys compiled into the kernel.

These patches have been in use by RHEL and Fedora kernels for years, and so have been thoroughly tested. The signed modules survive both the debuginfo separation performed by rpmbuild and the strip performed when modules are being reduced as much as possible before being included in an initial ramdisk composition. Signed modules have been tested to work with LE and BE, 32- and 64-bit arch kernels, including i386, x86_64, ppc64, ia64, s390 and s390x.

There are several reasons why these patches are useful, amongst which are:

(1) to protect against accidentally-corrupted modules causing damage;

(2) to protect against maliciously modified modules causing damage;

(3) to allow a sysadmin (or more likely an IT department) to enforce a policy that only known and approved modules shall be loaded onto machines which they're expected to support;

(4) to allow other support providers to do likewise, or at least to _detect_

     the fact that unsupported modules are loaded;

(5) to allow the detection of modules replaced by a second-order distro or a preloaded Linux purveyor.

Basically, these patches have two main appeals to me: (a) preventing malicious modules from being loaded, and (b) reducing support workload by pointing out modules on a crashing box that aren't what they're expected to be.

Now, this is not a complete solution by any means: the core kernel is not protected, and nor are /dev/mem or /dev/kmem, but it denies (or at least controls) one relatively simple attack vector.

This facility is optional: the builder of a kernel is by no means under any requirement to actually enable it, let alone force the set of loadable modules to be restricted to just those that the builder provides (there are degrees of restriction available).

Note to Andrew and Linus: Herbert Xu and the crypto guys need to check the crypto bits before this should be accepted. Possibly these patches should go via the crypto tree.

David

#1 lore raw

PATCH 2/6 MODSIGN: In-kernel crypto extensions

Two extensions are added:

(1) Support for SHA1 digestion of in-kernel buffers directly without the use of scatter-gather lists.

(2) Allocation of crypto algorithm instances without resort to fallback module loading.

SHA1 is used by module signature checking, and so must not itself require loading as a module when the module signature checking is enabled.

---

 crypto/api.c           |   46 +++++++++++++++++++++++++++++++++++++++++++++-
 crypto/digest.c        |    9 +++++++++
 include/linux/crypto.h |   11 +++++++++++
 3 files changed, 65 insertions(+), 1 deletions(-)
crypto/api.c +45 -1
index 55af8bb..3138d7c 100644
@@ -341,6 +341,45 @@ out:
 EXPORT_SYMBOL_GPL(__crypto_alloc_tfm);
 
 /*
+ *	crypto_alloc_tfm2 - Find or load crypto module
+ *	@name: Name of algorithm
+ *	@flags: Flags to control algorithm instance
+ *	@nomodload: True to suppress resort to module loading
+ *
+ *	Attempt to find or load a crypto algorithm module and create an
+ *	instance of it.
+ */
+struct crypto_tfm *crypto_alloc_tfm2(const char *name, u32 flags,
+				     int nomodload)
+{
+	struct crypto_tfm *tfm = NULL;
+	int err;
+
+	do {
+		struct crypto_alg *alg;
+
+		if (!nomodload)
+			alg = crypto_alg_mod_lookup(name, 0, CRYPTO_ALG_ASYNC);
+		else
+			alg = crypto_alg_lookup(name, 0, CRYPTO_ALG_ASYNC);
+
+		err = PTR_ERR(alg);
+		if (IS_ERR(alg))
+			continue;
+
+		tfm = __crypto_alloc_tfm(alg, flags, 0);
+		err = 0;
+		if (IS_ERR(tfm)) {
+			crypto_mod_put(alg);
+			err = PTR_ERR(tfm);
+			tfm = NULL;
+		}
+	} while (err == -EAGAIN && !signal_pending(current));
+
+	return tfm;
+}
+
+/*
  *	crypto_alloc_base - Locate algorithm and allocate transform
  *	@alg_name: Name of algorithm
  *	@type: Type of algorithm
@@ -392,7 +431,12 @@ err:
 	return ERR_PTR(err);
 }
 EXPORT_SYMBOL_GPL(crypto_alloc_base);
- 
+
+struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
+{
+	return crypto_alloc_tfm2(name, flags, 0);
+}
+
 /*
  *	crypto_free_tfm - Free crypto transform
  *	@tfm: Transform to free
crypto/digest.c +9 -0
index 1bf7414..d03a4e1 100644
@@ -91,6 +91,14 @@ static int update(struct hash_desc *desc,
 	return update2(desc, sg, nbytes);
 }
 
+static void update_kernel(struct hash_desc *desc,
+			  const void *data, size_t count)
+{
+	struct crypto_tfm *tfm = crypto_hash_tfm(desc->tfm);
+	tfm->__crt_alg->cra_digest.dia_update(tfm, data, count);
+	crypto_yield(desc->flags);
+}
+
 static int final(struct hash_desc *desc, u8 *out)
 {
 	struct crypto_tfm *tfm = crypto_hash_tfm(desc->tfm);
@@ -146,6 +154,7 @@ int crypto_init_digest_ops(struct crypto_tfm *tfm)
 	
 	ops->init	= init;
 	ops->update	= update;
+	ops->update_kernel = update_kernel;
 	ops->final	= final;
 	ops->digest	= digest;
 	ops->setkey	= dalg->dia_setkey ? setkey : nosetkey;
include/linux/crypto.h +11 -0
index 779aa78..d960ec1 100644
@@ -273,6 +273,8 @@ struct hash_tfm {
 	int (*init)(struct hash_desc *desc);
 	int (*update)(struct hash_desc *desc,
 		      struct scatterlist *sg, unsigned int nsg);
+	void (*update_kernel)(struct hash_desc *desc,
+			      const void *data, size_t count);
 	int (*final)(struct hash_desc *desc, u8 *out);
 	int (*digest)(struct hash_desc *desc, struct scatterlist *sg,
 		      unsigned int nsg, u8 *out);
@@ -341,6 +343,8 @@ struct crypto_attr_alg {
  */
  
 struct crypto_tfm *crypto_alloc_tfm(const char *alg_name, u32 tfm_flags);
+struct crypto_tfm *crypto_alloc_tfm2(const char *alg_name, u32 tfm_flags,
+		int nomodload);
 struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask);
 void crypto_free_tfm(struct crypto_tfm *tfm);
 
@@ -739,6 +743,13 @@ static inline int crypto_hash_update(struct hash_desc *desc,
 	return crypto_hash_crt(desc->tfm)->update(desc, sg, nbytes);
 }
 
+static inline void crypto_hash_update_kernel(struct hash_desc *desc,
+					     const void *data,
+					     size_t count)
+{
+	return crypto_hash_crt(desc->tfm)->update_kernel(desc, data, count);
+}
+
 static inline int crypto_hash_final(struct hash_desc *desc, u8 *out)
 {
 	return crypto_hash_crt(desc->tfm)->final(desc, out);
#2 lore raw

PATCH 3/6 MODSIGN: Add indications of module ELF types

In reply to David Howells

Add per-arch indications of module ELF types and relocation table entry types.

---

 include/asm-alpha/module.h   |    3 +++
 include/asm-arm/module.h     |    5 +++++
 include/asm-cris/module.h    |    5 +++++
 include/asm-h8300/module.h   |    5 +++++
 include/asm-i386/module.h    |    5 +++++
 include/asm-ia64/module.h    |    5 +++++
 include/asm-m32r/module.h    |    5 +++++
 include/asm-m68k/module.h    |    5 +++++
 include/asm-mips/module.h    |   12 ++++++++++--
 include/asm-parisc/module.h  |    8 ++++++++
 include/asm-powerpc/module.h |   10 ++++++++++
 include/asm-s390/module.h    |    3 +++
 include/asm-sh/module.h      |    5 +++++
 include/asm-sparc/module.h   |    5 +++++
 include/asm-sparc64/module.h |    5 +++++
 include/asm-um/module-i386.h |    4 ++++
 include/asm-v850/module.h    |    5 +++++
 include/asm-x86_64/module.h  |    5 +++++
 18 files changed, 98 insertions(+), 2 deletions(-)
include/asm-alpha/module.h +3 -0
index 7b63743..3d5a3ea 100644
@@ -6,6 +6,7 @@ struct mod_arch_specific
 	unsigned int gotsecindex;
 };
 
+#define MODULES_ARE_ELF64
 #define Elf_Sym Elf64_Sym
 #define Elf_Shdr Elf64_Shdr
 #define Elf_Ehdr Elf64_Ehdr
@@ -13,6 +14,8 @@ struct mod_arch_specific
 #define Elf_Dyn Elf64_Dyn
 #define Elf_Rel Elf64_Rel
 #define Elf_Rela Elf64_Rela
+#define ELF_R_TYPE(X)	ELF64_R_TYPE(X)
+#define ELF_R_SYM(X)	ELF64_R_SYM(X)
 
 #define ARCH_SHF_SMALL SHF_ALPHA_GPREL
 
include/asm-arm/module.h +5 -0
index 24b168d..f1558f3 100644
@@ -6,9 +6,14 @@ struct mod_arch_specific
 	int foo;
 };
 
+#define MODULES_ARE_ELF32
 #define Elf_Shdr	Elf32_Shdr
 #define Elf_Sym		Elf32_Sym
 #define Elf_Ehdr	Elf32_Ehdr
+#define Elf_Rel		Elf32_Rel
+#define Elf_Rela	Elf32_Rela
+#define ELF_R_TYPE(X)	ELF32_R_TYPE(X)
+#define ELF_R_SYM(X)	ELF32_R_SYM(X)
 
 /*
  * Include the ARM architecture version.
include/asm-cris/module.h +5 -0
index 7ee7231..03f7b2e 100644
@@ -3,7 +3,12 @@
 /* cris is simple */
 struct mod_arch_specific { };
 
+#define MODULES_ARE_ELF32
 #define Elf_Shdr Elf32_Shdr
 #define Elf_Sym Elf32_Sym
 #define Elf_Ehdr Elf32_Ehdr
+#define Elf_Rel Elf32_Rel
+#define Elf_Rela Elf32_Rela
+#define ELF_R_TYPE(X)	ELF32_R_TYPE(X)
+#define ELF_R_SYM(X)	ELF32_R_SYM(X)
 #endif /* _ASM_CRIS_MODULE_H */
include/asm-h8300/module.h +5 -0
index de23231..b1c08e2 100644
@@ -4,9 +4,14 @@
  * This file contains the H8/300 architecture specific module code.
  */
 struct mod_arch_specific { };
+#define MODULES_ARE_ELF32
 #define Elf_Shdr Elf32_Shdr
 #define Elf_Sym Elf32_Sym
 #define Elf_Ehdr Elf32_Ehdr
+#define Elf_Rel Elf32_Rel
+#define Elf_Rela Elf32_Rela
+#define ELF_R_TYPE(X)	ELF32_R_TYPE(X)
+#define ELF_R_SYM(X)	ELF32_R_SYM(X)
 
 #define MODULE_SYMBOL_PREFIX "_"
 
include/asm-i386/module.h +5 -0
index 02f8f54..42ab093 100644
@@ -6,9 +6,14 @@ struct mod_arch_specific
 {
 };
 
+#define MODULES_ARE_ELF32
 #define Elf_Shdr Elf32_Shdr
 #define Elf_Sym Elf32_Sym
 #define Elf_Ehdr Elf32_Ehdr
+#define Elf_Rel Elf32_Rel
+#define Elf_Rela Elf32_Rela
+#define ELF_R_TYPE(X)	ELF32_R_TYPE(X)
+#define ELF_R_SYM(X)	ELF32_R_SYM(X)
 
 #ifdef CONFIG_M386
 #define MODULE_PROC_FAMILY "386 "
include/asm-ia64/module.h +5 -0
index d2da61e..191355a 100644
@@ -23,9 +23,14 @@ struct mod_arch_specific {
 	unsigned int next_got_entry;	/* index of next available got entry */
 };
 
+#define MODULES_ARE_ELF64
 #define Elf_Shdr	Elf64_Shdr
 #define Elf_Sym		Elf64_Sym
 #define Elf_Ehdr	Elf64_Ehdr
+#define Elf_Rel		Elf64_Rel
+#define Elf_Rela	Elf64_Rela
+#define ELF_R_TYPE(X)	ELF64_R_TYPE(X)
+#define ELF_R_SYM(X)	ELF64_R_SYM(X)
 
 #define MODULE_PROC_FAMILY	"ia64"
 #define MODULE_ARCH_VERMAGIC	MODULE_PROC_FAMILY \
include/asm-m32r/module.h +5 -0
index eb73ee0..7146455 100644
@@ -3,8 +3,13 @@
 
 struct mod_arch_specific { };
 
+#define MODULES_ARE_ELF32
 #define Elf_Shdr	Elf32_Shdr
 #define Elf_Sym		Elf32_Sym
 #define Elf_Ehdr	Elf32_Ehdr
+#define Elf_Rel		Elf32_Rel
+#define Elf_Rela	Elf32_Rela
+#define ELF_R_TYPE(X)	ELF32_R_TYPE(X)
+#define ELF_R_SYM(X)	ELF32_R_SYM(X)
 
 #endif /* _ASM_M32R_MODULE_H */
include/asm-m68k/module.h +5 -0
index c6d75af..ee98908 100644
@@ -1,7 +1,12 @@
 #ifndef _ASM_M68K_MODULE_H
 #define _ASM_M68K_MODULE_H
 struct mod_arch_specific { };
+#define MODULES_ARE_ELF32
 #define Elf_Shdr Elf32_Shdr
 #define Elf_Sym Elf32_Sym
 #define Elf_Ehdr Elf32_Ehdr
+#define Elf_Rel Elf32_Rel
+#define Elf_Rela Elf32_Rela
+#define ELF_R_TYPE(X)	ELF32_R_TYPE(X)
+#define ELF_R_SYM(X)	ELF32_R_SYM(X)
 #endif /* _ASM_M68K_MODULE_H */
include/asm-mips/module.h +10 -2
index 399d03f..694f979 100644
@@ -33,11 +33,15 @@ typedef struct {
 } Elf64_Mips_Rela;
 
 #ifdef CONFIG_32BIT
-
+#define MODULES_ARE_ELF32
 #define Elf_Shdr	Elf32_Shdr
 #define Elf_Sym		Elf32_Sym
 #define Elf_Ehdr	Elf32_Ehdr
 #define Elf_Addr	Elf32_Addr
+#define Elf_Rel		Elf32_Rel
+#define Elf_Rela	Elf32_Rela
+#define ELF_R_TYPE(X)	ELF32_R_TYPE(X)
+#define ELF_R_SYM(X)	ELF32_R_SYM(X)
 
 #define Elf_Mips_Rel	Elf32_Rel
 #define Elf_Mips_Rela	Elf32_Rela
@@ -48,11 +52,15 @@ typedef struct {
 #endif
 
 #ifdef CONFIG_64BIT
-
+#define MODULES_ARE_ELF64
 #define Elf_Shdr	Elf64_Shdr
 #define Elf_Sym		Elf64_Sym
 #define Elf_Ehdr	Elf64_Ehdr
 #define Elf_Addr	Elf64_Addr
+#define Elf_Rel		Elf64_Rel
+#define Elf_Rela	Elf64_Rela
+#define ELF_R_TYPE(X)	ELF64_R_TYPE(X)
+#define ELF_R_SYM(X)	ELF64_R_SYM(X)
 
 #define Elf_Mips_Rel	Elf64_Mips_Rel
 #define Elf_Mips_Rela	Elf64_Mips_Rela
include/asm-parisc/module.h +8 -0
index 00f0688..ebd9a5e 100644
@@ -4,17 +4,25 @@
  * This file contains the parisc architecture specific module code.
  */
 #ifdef __LP64__
+#define MODULES_ARE_ELF64
 #define Elf_Shdr Elf64_Shdr
 #define Elf_Sym Elf64_Sym
 #define Elf_Ehdr Elf64_Ehdr
 #define Elf_Addr Elf64_Addr
+#define Elf_Rel Elf64_Rel
 #define Elf_Rela Elf64_Rela
+#define ELF_R_TYPE(X)	ELF64_R_TYPE(X)
+#define ELF_R_SYM(X)	ELF64_R_SYM(X)
 #else
+#define MODULES_ARE_ELF32
 #define Elf_Shdr Elf32_Shdr
 #define Elf_Sym Elf32_Sym
 #define Elf_Ehdr Elf32_Ehdr
 #define Elf_Addr Elf32_Addr
+#define Elf_Rel Elf32_Rel
 #define Elf_Rela Elf32_Rela
+#define ELF_R_TYPE(X)	ELF32_R_TYPE(X)
+#define ELF_R_SYM(X)	ELF32_R_SYM(X)
 #endif
 
 struct unwind_table;
include/asm-powerpc/module.h +10 -0
index e5f14b1..f9baae1 100644
@@ -52,16 +52,26 @@ struct mod_arch_specific {
  */
 
 #ifdef __powerpc64__
+#    define MODULES_ARE_ELF64
 #    define Elf_Shdr	Elf64_Shdr
 #    define Elf_Sym	Elf64_Sym
 #    define Elf_Ehdr	Elf64_Ehdr
+#    define Elf_Rel Elf64_Rel
+#    define Elf_Rela Elf64_Rela
+#    define ELF_R_TYPE(X)	ELF64_R_TYPE(X)
+#    define ELF_R_SYM(X)	ELF64_R_SYM(X)
 #    ifdef MODULE
 	asm(".section .stubs,\"ax\",@nobits; .align 3; .previous");
 #    endif
 #else
+#    define MODULES_ARE_ELF32
 #    define Elf_Shdr	Elf32_Shdr
 #    define Elf_Sym	Elf32_Sym
 #    define Elf_Ehdr	Elf32_Ehdr
+#    define Elf_Rel Elf32_Rel
+#    define Elf_Rela Elf32_Rela
+#    define ELF_R_TYPE(X)	ELF32_R_TYPE(X)
+#    define ELF_R_SYM(X)	ELF32_R_SYM(X)
 #    ifdef MODULE
 	asm(".section .plt,\"ax\",@nobits; .align 3; .previous");
 	asm(".section .init.plt,\"ax\",@nobits; .align 3; .previous");
include/asm-s390/module.h +3 -0
index 1cc1c5a..b64dab0 100644
@@ -29,14 +29,17 @@ struct mod_arch_specific
 };
 
 #ifdef __s390x__
+#define MODULES_ARE_ELF64
 #define ElfW(x) Elf64_ ## x
 #define ELFW(x) ELF64_ ## x
 #else
+#define MODULES_ARE_ELF32
 #define ElfW(x) Elf32_ ## x
 #define ELFW(x) ELF32_ ## x
 #endif
 
 #define Elf_Addr ElfW(Addr)
+#define Elf_Rel ElfW(Rel)
 #define Elf_Rela ElfW(Rela)
 #define Elf_Shdr ElfW(Shdr)
 #define Elf_Sym ElfW(Sym)
include/asm-sh/module.h +5 -0
index 118d5a2..c3cf495 100644
@@ -9,9 +9,14 @@ struct mod_arch_specific {
 	/* Nothing to see here .. */
 };
 
+#define MODULES_ARE_ELF32
 #define Elf_Shdr		Elf32_Shdr
 #define Elf_Sym			Elf32_Sym
 #define Elf_Ehdr		Elf32_Ehdr
+#define Elf_Rel			Elf32_Rel
+#define Elf_Rela		Elf32_Rela
+#define ELF_R_TYPE(X)	ELF32_R_TYPE(X)
+#define ELF_R_SYM(X)	ELF32_R_SYM(X)
 
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
 # ifdef CONFIG_CPU_SH2
include/asm-sparc/module.h +5 -0
index cbd9e67..e2921e2 100644
@@ -1,7 +1,12 @@
 #ifndef _ASM_SPARC_MODULE_H
 #define _ASM_SPARC_MODULE_H
 struct mod_arch_specific { };
+#define MODULES_ARE_ELF32
 #define Elf_Shdr Elf32_Shdr
 #define Elf_Sym Elf32_Sym
 #define Elf_Ehdr Elf32_Ehdr
+#define Elf_Rel Elf32_Rel
+#define Elf_Rela Elf32_Rela
+#define ELF_R_TYPE(X)	ELF32_R_TYPE(X)
+#define ELF_R_SYM(X)	ELF32_R_SYM(X)
 #endif /* _ASM_SPARC_MODULE_H */
include/asm-sparc64/module.h +5 -0
index 3d77ba4..2e7ca17 100644
@@ -1,7 +1,12 @@
 #ifndef _ASM_SPARC64_MODULE_H
 #define _ASM_SPARC64_MODULE_H
 struct mod_arch_specific { };
+#define MODULES_ARE_ELF64
 #define Elf_Shdr Elf64_Shdr
 #define Elf_Sym Elf64_Sym
 #define Elf_Ehdr Elf64_Ehdr
+#define Elf_Rel Elf64_Rel
+#define Elf_Rela Elf64_Rela
+#define ELF_R_TYPE(X)	ELF64_R_TYPE(X)
+#define ELF_R_SYM(X)	ELF64_R_SYM(X)
 #endif /* _ASM_SPARC64_MODULE_H */
include/asm-um/module-i386.h +4 -0
index 5ead4a0..b441057 100644
@@ -9,5 +9,9 @@ struct mod_arch_specific
 #define Elf_Shdr Elf32_Shdr
 #define Elf_Sym Elf32_Sym
 #define Elf_Ehdr Elf32_Ehdr
+#define Elf_Rel Elf32_Rel
+#define Elf_Rela Elf32_Rela
+#define ELF_R_TYPE(X)	ELF32_R_TYPE(X)
+#define ELF_R_SYM(X)	ELF32_R_SYM(X)
 
 #endif
include/asm-v850/module.h +5 -0
index 2c2f494..48752f3 100644
@@ -31,9 +31,14 @@ struct mod_arch_specific
 	unsigned int core_plt_section, init_plt_section;
 };
 
+#define MODULES_ARE_ELF32
 #define Elf_Shdr Elf32_Shdr
 #define Elf_Sym Elf32_Sym
 #define Elf_Ehdr Elf32_Ehdr
+#define Elf_Rel Elf32_Rel
+#define Elf_Rela Elf32_Rela
+#define ELF_R_TYPE(X)	ELF32_R_TYPE(X)
+#define ELF_R_SYM(X)	ELF32_R_SYM(X)
 
 /* Make empty sections for module_frob_arch_sections to expand. */
 #ifdef MODULE
include/asm-x86_64/module.h +5 -0
index 67f8f69..3a7373a 100644
@@ -3,8 +3,13 @@
 
 struct mod_arch_specific {}; 
 
+#define MODULES_ARE_ELF64
 #define Elf_Shdr Elf64_Shdr
 #define Elf_Sym Elf64_Sym
 #define Elf_Ehdr Elf64_Ehdr
+#define Elf_Rel Elf64_Rel
+#define Elf_Rela Elf64_Rela
+#define ELF_R_TYPE(X)	ELF64_R_TYPE(X)
+#define ELF_R_SYM(X)	ELF64_R_SYM(X)
 
 #endif 
#3 lore raw

PATCH 4/6 MODSIGN: Module ELF verifier

In reply to David Howells

Do preliminary verification of the ELF structure of a module. This is used to make sure that the ELF structure can then be used to check the module signature and access the module data without breaking the module loader.

If the module's ELF metadata is determined to be bad, then ELIBBAD will be returned and a message will be logged to the kernel log.

---

 init/Kconfig               |   11 ++
 kernel/Makefile            |    2 
 kernel/module-verify-elf.c |  304 ++++++++++++++++++++++++++++++++++++++++++++
 kernel/module-verify.c     |   41 ++++++
 kernel/module-verify.h     |   53 ++++++++
 kernel/module.c            |    7 +
 6 files changed, 416 insertions(+), 2 deletions(-)
init/Kconfig +11 -0
index ad33c97..0013f45 100644
@@ -553,6 +553,17 @@ config MODULE_SRCVERSION_ALL
 	  the version).  With this option, such a "srcversion" field
 	  will be created for all modules.  If unsure, say N.
 
+config MODULE_VERIFY_ELF
+	bool "Module ELF structure verification"
+	depends on MODULES
+	help
+	  Check ELF structure of modules upon load
+
+config MODULE_VERIFY
+	bool
+	depends on MODULES
+	default y if MODULE_VERIFY_ELF
+
 config KMOD
 	bool "Automatic kernel module loading"
 	depends on MODULES
kernel/Makefile +2 -0
index 14f4d45..5ed0824 100644
@@ -30,6 +30,8 @@ obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock.o
 obj-$(CONFIG_PROVE_LOCKING) += spinlock.o
 obj-$(CONFIG_UID16) += uid16.o
 obj-$(CONFIG_MODULES) += module.o
+obj-$(CONFIG_MODULE_VERIFY) += module-verify.o
+obj-$(CONFIG_MODULE_VERIFY_ELF) += module-verify-elf.o
 obj-$(CONFIG_KALLSYMS) += kallsyms.o
 obj-$(CONFIG_PM) += power/
 obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
kernel/module-verify-elf.c new file +304 -0

304 lines not on this page · raw message

kernel/module-verify.c new file +41 -0

41 lines not on this page · raw message

kernel/module-verify.h new file +53 -0

53 lines not on this page · raw message

kernel/module.c +5 -2
index 8a94e05..86abdce 100644
@@ -44,6 +44,7 @@
 #include <asm/semaphore.h>
 #include <asm/cacheflush.h>
 #include <linux/license.h>
+#include "module-verify.h"
 
 #if 0
 #define DEBUGP printk
@@ -1605,8 +1606,10 @@ static struct module *load_module(void __user *umod,
 		goto free_hdr;
 	}
 
-	if (len < hdr->e_shoff + hdr->e_shnum * sizeof(Elf_Shdr))
-		goto truncated;
+	/* Verify the module's contents */
+	err = module_verify(hdr, len);
+	if (err < 0)
+		goto free_hdr;
 
 	/* Convenience variables */
 	sechdrs = (void *)hdr + hdr->e_shoff;
#4 lore raw

PATCH 5/6 MODSIGN: Module signature checker and key manager

In reply to David Howells

Add a facility to retain public keys and to verify signatures made with those public keys, given a signature and crypto_hash of the data that was signed.

---

 crypto/Kconfig                     |   13 +
 crypto/Makefile                    |    1 
 crypto/signature/Makefile          |   10 +
 crypto/signature/dsa.c             |   96 ++++++
 crypto/signature/key.h             |    7 
 crypto/signature/ksign-keyring.c   |  116 +++++++
 crypto/signature/ksign-parse.c     |  603 ++++++++++++++++++++++++++++++++++++
 crypto/signature/ksign-publickey.c |   18 +
 crypto/signature/ksign.c           |  180 +++++++++++
 crypto/signature/local.h           |  160 ++++++++++
 include/linux/crypto/ksign.h       |   22 +
 11 files changed, 1226 insertions(+), 0 deletions(-)
crypto/Kconfig +13 -0
index aab5b8f..e764509 100644
@@ -453,6 +453,19 @@ config CRYPTO_MPILIB
 	help
 	  Multiprecision maths library from GnuPG
 
+config CRYPTO_SIGNATURE
+	bool "In-kernel signature checker (EXPERIMENTAL)"
+	depends on CRYPTO
+	help
+	  Signature checker (used for module sig checking).
+
+config CRYPTO_SIGNATURE_DSA
+	bool "Handle DSA signatures (EXPERIMENTAL)"
+	depends on CRYPTO_SIGNATURE
+	select CRYPTO_MPILIB
+	help
+	  DSA Signature checker.
+
 source "drivers/crypto/Kconfig"
 
 endif	# if CRYPTO
crypto/Makefile +1 -0
index 49fc857..fe33414 100644
@@ -50,3 +50,4 @@ obj-$(CONFIG_CRYPTO_CRC32C) += crc32c.o
 obj-$(CONFIG_CRYPTO_TEST) += tcrypt.o
 
 obj-$(CONFIG_CRYPTO_MPILIB) += mpi/
+obj-$(CONFIG_CRYPTO_SIGNATURE) += signature/
crypto/signature/Makefile new file +10 -0
new file mode 100644
index 0000000..4d1042e
@@ -0,0 +1,10 @@
+#
+# Makefile for the signature checker
+#
+
+obj-y := \
+	ksign.o \
+	ksign-parse.o \
+	ksign-keyring.o \
+	ksign-publickey.o \
+	dsa.o
crypto/signature/dsa.c new file +96 -0

96 lines not on this page · raw message

crypto/signature/key.h new file +7 -0
new file mode 100644
index 0000000..7297968
@@ -0,0 +1,7 @@
+const int ksign_def_public_key_size = 0;
+/* automatically generated by bin2hex */
+static unsigned char ksign_def_public_key[] __initdata =
+{
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
crypto/signature/ksign-keyring.c new file +116 -0

116 lines not on this page · raw message

crypto/signature/ksign-parse.c new file +603 -0

603 lines not on this page · raw message

crypto/signature/ksign-publickey.c new file +18 -0
new file mode 100644
index 0000000..832a419
@@ -0,0 +1,18 @@
+#include "local.h"
+#include "key.h"
+
+static int __init ksign_init(void)
+{
+	int rc;
+
+	printk("ksign: Installing public key data\n");
+
+	rc = ksign_load_keyring_from_buffer(ksign_def_public_key,
+					    ksign_def_public_key_size);
+	if (rc < 0)
+		printk("Unable to load default keyring: error=%d\n", -rc);
+
+	return rc;
+}
+
+module_init(ksign_init)
crypto/signature/ksign.c new file +180 -0

180 lines not on this page · raw message

crypto/signature/local.h new file +160 -0

160 lines not on this page · raw message

include/linux/crypto/ksign.h new file +22 -0
new file mode 100644
index 0000000..27c9e4a
@@ -0,0 +1,22 @@
+/* ksign.h: in-kernel signature checker
+ *
+ * Copyright (C) 2004 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 License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#ifndef _LINUX_CRYPTO_KSIGN_H
+#define _LINUX_CRYPTO_KSIGN_H
+
+#include <linux/types.h>
+
+#ifdef CONFIG_CRYPTO_SIGNATURE
+extern int ksign_verify_signature(const char *sig, unsigned sig_size,
+				  struct crypto_hash *sha1);
+#endif
+
+#endif /* _LINUX_CRYPTO_KSIGN_H */
#5 lore raw

PATCH 6/6 MODSIGN: Apply signature checking to modules on module load

In reply to David Howells

Apply signature checking to modules on module load, checking the signature against the ring of public keys compiled into the kernel (if enabled by CONFIG_MODULE_SIG). Turning on signature checking will also force the module's ELF metadata to be verified first.

These patches have been in use by RHEL and Fedora kernels for years, and so have been thoroughly tested. The signed modules survive both the debuginfo separation performed by rpmbuild and the strip performed when modules are being reduced as much as possible before being included in an initial ramdisk composition. Signed modules have been tested to work with LE and BE, 32- and 64-bit arch kernels, including i386, x86_64, ppc64, ia64, s390 and s390x.

There are several reasons why these patches are useful, amongst which are:

(1) to protect against accidentally-corrupted modules causing damage;

(2) to protect against maliciously modified modules causing damage;

(3) to allow a sysadmin (or more likely an IT department) to enforce a policy that only known and approved modules shall be loaded onto machines which they're expected to support;

(4) to allow other support providers to do likewise, or at least to _detect_

     the fact that unsupported modules are loaded;

(5) to allow the detection of modules replaced by a second-order distro or a preloaded Linux purveyor.

Basically, these patches have two main appeals to me: (a) preventing malicious modules from being loaded, and (b) reducing support workload by pointing out modules on a crashing box that aren't what they're expected to be.

Now, this is not a complete solution by any means: the core kernel is not protected, and nor are /dev/mem or /dev/kmem, but it denies (or at least controls) one relatively simple attack vector.

This facility is optional: the builder of a kernel is by no means under any requirement to actually enable it, let alone force the set of loadable modules to be restricted to just those that the builder provides (there are degrees of restriction available).

Use of the module signing facility is documentated in:

Documentation/module-signing.txt

which I've included here for reference:

			==============================
			KERNEL MODULE SIGNING FACILITY
			==============================

The module signing facilitiy applies cryptographic signature checking to modules on module load, checking the signature against a ring of public keys compiled into the kernel. GPG is used to do the cryptographic work and determines the format of the signature and key data. The facility uses GPG's MPI library to handle the huge numbers involved.

This facility is enabled through CONFIG_MODULE_SIG. Turning on signature checking will also force the module's ELF metadata to be verified before the signature is checked.

=====================
SUPPLYING PUBLIC KEYS
=====================

A set of public keys must be supplied at main kernel compile time. This is done by taking a GPG public key file, running it through the kernel's bin2c program and writing the result over crypto/signature/key.h. To automate this process, something like this could be done:

cat >genkey <<EOF
%pubring kernel.pub
%secring kernel.sec
Key-Type: DSA
Key-Length: 512
Name-Real: A. N. Other
Name-Comment: Kernel Module GPG key
%commit
EOF
make scripts/bin2c
gpg --homedir . --batch --gen-key genkey
gpg --homedir . --export --keyring kernel.pub keyname |
scripts/bin2c ksign_def_public_key __initdata >crypto/signature/key.h

The above generates fresh keys using /dev/random. If there's insufficient data in /dev/random, more can be provided more by running:

rngd -r /dev/urandom

in the background.

Note:

(1) That "keyname" is the name of the key in the keyring. This differentiates it from any other keys that may be added to the keyring.

(2) That no GPG password is used in the above scriptlet.

(3) It may be desirable to shred and delete the private key file after signing the modules.

==============
MODULE SIGNING
==============

Modules will then be signed automatically. The kernel make command line can include the following options:

(*) MODSECKEY=<secret-key-ring-path>

This indicates the whereabouts of the GPG keyring that is the source of the secret key to be used. The default is "./kernel.sec".

(*) MODPUBKEY=<public-key-ring-path>

This indicates the whereabouts of the GPG keyring that is the source of the public key to be used. The default is "./kernel.pub".

(*) MODKEYNAME=<key-name>

The name of the key pair to be used from the aforementioned keyrings. This defaults to being unset, thus leaving the choice of default key to gpg.

(*) KEYFLAGS="gpg-options"

     Override the complete gpg command line, including the preceding three
     options.  The default options supplied to gpg are:

	--no-default-keyring
	--secret-keyring $(MODSECKEY)
	--keyring $(MODPUBKEY)
	--no-default-keyring
	--homedir .
	--no-options
	--no-auto-check-trustdb
	--no-permission-warning

      with:

	--default-key $(MODKEYNAME)

      being added if requested.

The resulting module.ko file will be the signed module.

========================
STRIPPING SIGNED MODULES
========================

Signed modules may be safely stripped as the signature only covers those parts of the module the kernel actually uses and any ELF metadata required to deal with them. Any necessary ELF metadata that is affected by stripping is canonicalised by the sig generator and the sig checker to hide strip effects.

This permits the debuginfo to be detached from the module and placed in another spot so that gdb can find it when referring to that module without the need for multiple signed versions of the module. Such is done by rpmbuild when producing RPMs.

It also permits the module to be stripped as far as possible for when modules are being reduced prior to being included in an initial ramdisk composition.

======================
LOADING SIGNED MODULES
======================

Modules are loaded with insmod, exactly as for unsigned modules. The signature is inserted into the module object file as an ELF section called ".module_sig". The signature checker will spot it and apply signature checking.

=========================================
NON-VALID SIGNATURES AND UNSIGNED MODULES
=========================================

If CONFIG_MODULE_SIG_FORCE is enabled or "enforcemodulesig=1" is supplied on the kernel command line, the kernel will _only_ load validly signed modules for which it has a public key. Otherwise, it will also load modules that are unsigned. Any module for which the kernel has a key, but which proves to have a signature mismatch will not be permitted to load (returning EKEYREJECTED).

This table indicates the behaviours of the various situations:

MODULE STATE PERMISSIVE MODE ENFORCING MODE
=============================== =============== ===============
Unsigned Ok EKEYREJECTED
Signed, no public key ENOKEY ENOKEY
Validly signed, public key Ok Ok
Invalidly signed, public key EKEYREJECTED EKEYREJECTED
Validly signed, expired key EKEYEXPIRED EKEYEXPIRED
Corrupt signature ELIBBAD ELIBBAD
Corrupt ELF ELIBBAD ELIBBAD

---

 .gitignore                       |    9 
 Documentation/module-signing.txt |  147 ++++++
 Makefile                         |    7 
 include/linux/module.h           |    3 
 init/Kconfig                     |   22 +
 kernel/Makefile                  |    1 
 kernel/module-verify-sig.c       |  455 +++++++++++++++++++
 kernel/module-verify.c           |    5 
 kernel/module-verify.h           |   17 +
 kernel/module.c                  |   12 -
 scripts/Makefile.modpost         |   36 +-
 scripts/mod/.gitignore           |    1 
 scripts/mod/Makefile             |    2 
 scripts/mod/mod-extract.c        |  890 ++++++++++++++++++++++++++++++++++++++
 14 files changed, 1596 insertions(+), 11 deletions(-)
.gitignore +9 -0
index 060a71d..144cd50 100644
@@ -9,6 +9,9 @@
 *.o
 *.a
 *.s
+*.ko.unsigned
+*.ko.out
+*.ko.out.sig
 *.ko
 *.so
 *.mod.c
@@ -45,3 +48,9 @@ series
 
 # cscope files
 cscope.*
+
+#
+# GPG leavings from module signing
+#
+trustdb.gpg
+random_seed
Documentation/module-signing.txt new file +147 -0

147 lines not on this page · raw message

Makefile +5 -2
index 7e4968f..efbb768 100644
@@ -1041,7 +1041,8 @@ clean: archclean $(clean-dirs)
 	@find . $(RCS_FIND_IGNORE) \
 		\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
 		-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
-		-o -name '*.symtypes' \) \
+		-o -name '*.symtypes' -o -name '*.ko.unsigned' \
+		-o -name "*.ko.out" -o -name "*.ko.out.sig" \) \
 		-type f -print | xargs rm -f
 
 # mrproper - Delete all generated files, including .config
@@ -1229,7 +1230,9 @@ clean: $(clean-dirs)
 	$(call cmd,rmdirs)
 	@find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \
 		\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
-		-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
+		-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
+		-o -name '*.ko.unsigned' -o -name "*.ko.out" \
+		-o -name "*.ko.out.sig" \) \
 		-type f -print | xargs rm -f
 
 help:
include/linux/module.h +3 -0
index 419d3ef..aaae69a 100644
@@ -327,6 +327,9 @@ struct module
 	unsigned num_bugs;
 #endif
 
+	/* Is this module GPG signed */
+	int gpgsig_ok;
+
 #ifdef CONFIG_MODULE_UNLOAD
 	/* Reference counts */
 	struct module_ref ref[NR_CPUS];
init/Kconfig +21 -1
index 0013f45..246b9cc 100644
@@ -559,10 +559,30 @@ config MODULE_VERIFY_ELF
 	help
 	  Check ELF structure of modules upon load
 
+config MODULE_SIG
+	bool "Module signature verification (EXPERIMENTAL)"
+	depends on MODULES && EXPERIMENTAL
+	select CRYPTO
+	select CRYPTO_SHA1
+	select CRYPTO_SIGNATURE
+	select MODULE_VERIFY_ELF
+	help
+	  Check modules for valid signatures upon load.  For more information
+	  see:
+
+	  Documentation/module-signing.txt
+
+config MODULE_SIG_FORCE
+	bool "Required modules to be validly signed (EXPERIMENTAL)"
+	depends on MODULE_SIG
+	help
+	  Reject unsigned modules or signed modules for which we don't have a
+	  key.
+
 config MODULE_VERIFY
 	bool
 	depends on MODULES
-	default y if MODULE_VERIFY_ELF
+	default y if MODULE_VERIFY_ELF || MODULE_SIG
 
 config KMOD
 	bool "Automatic kernel module loading"
kernel/Makefile +1 -0
index 5ed0824..715da89 100644
@@ -32,6 +32,7 @@ obj-$(CONFIG_UID16) += uid16.o
 obj-$(CONFIG_MODULES) += module.o
 obj-$(CONFIG_MODULE_VERIFY) += module-verify.o
 obj-$(CONFIG_MODULE_VERIFY_ELF) += module-verify-elf.o
+obj-$(CONFIG_MODULE_SIG) += module-verify-sig.o
 obj-$(CONFIG_KALLSYMS) += kallsyms.o
 obj-$(CONFIG_PM) += power/
 obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
kernel/module-verify-sig.c new file +455 -0

455 lines not on this page · raw message

kernel/module-verify.c +4 -1
index 875279f..64c5813 100644
@@ -16,8 +16,9 @@
 /*
  * verify a module's integrity
  * - check the ELF is viable
+ * - check the module's signature
  */
-int module_verify(const Elf_Ehdr *hdr, size_t size)
+int module_verify(const Elf_Ehdr *hdr, size_t size, int *_gpgsig_ok)
 {
 	struct module_verify_data mvdata;
 	int ret;
@@ -34,6 +35,8 @@ int module_verify(const Elf_Ehdr *hdr, size_t size)
 		goto error;
 	}
 
+	ret = module_verify_signature(&mvdata, _gpgsig_ok);
+
 error:
 	kfree(mvdata.secsizes);
 	kfree(mvdata.canonlist);
kernel/module-verify.h +14 -3
index 63f5e08..95995b2 100644
@@ -10,11 +10,12 @@
  */
 
 #include <linux/types.h>
+#include <linux/crypto.h>
 #include <asm/module.h>
 
 #ifdef CONFIG_MODULE_VERIFY
 struct module_verify_data {
-	struct crypto_tfm	*digest;	/* module signature digest */
+	struct hash_desc	hash;		/* module signature digest */
 	const void		*buffer;	/* module buffer */
 	const Elf_Ehdr		*hdr;		/* ELF header */
 	const Elf_Shdr		*sections;	/* ELF section table */
@@ -37,7 +38,7 @@ struct module_verify_data {
 /*
  * module-verify.c
  */
-extern int module_verify(const Elf_Ehdr *hdr, size_t size);
+extern int module_verify(const Elf_Ehdr *hdr, size_t size, int *_gpgsig_ok);
 
 /*
  * module-verify-elf.c
@@ -48,6 +49,16 @@ extern int module_verify_elf(struct module_verify_data *mvdata);
 #define module_verify_elf(m) (0)
 #endif
 
+/*
+ * module-verify-sig.c
+ */
+#ifdef CONFIG_MODULE_SIG
+extern int module_verify_signature(struct module_verify_data *mvdata,
+				   int *_gpgsig_ok);
+#else
+#define module_verify_signature(m, g) (0)
+#endif
+
 #else
-#define module_verify(h, s) (0)
+#define module_verify(h, s, g) (0)
 #endif
kernel/module.c +10 -2
index 86abdce..c3a1dca 100644
@@ -1581,6 +1581,7 @@ static struct module *load_module(void __user *umod,
 	void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */
 	struct exception_table_entry *extable;
 	mm_segment_t old_fs;
+	int gpgsig_ok;
 
 	DEBUGP("load_module: umod=%p, len=%lu, uargs=%p\n",
 	       umod, len, uargs);
@@ -1607,7 +1608,8 @@ static struct module *load_module(void __user *umod,
 	}
 
 	/* Verify the module's contents */
-	err = module_verify(hdr, len);
+	gpgsig_ok = 0;
+	err = module_verify(hdr, len, &gpgsig_ok);
 	if (err < 0)
 		goto free_hdr;
 
@@ -1646,6 +1648,7 @@ static struct module *load_module(void __user *umod,
 		goto free_hdr;
 	}
 	mod = (void *)sechdrs[modindex].sh_addr;
+	mod->gpgsig_ok = gpgsig_ok;
 
 	if (symindex == 0) {
 		printk(KERN_WARNING "%s: module has no symbols (stripped?)\n",
@@ -2343,8 +2346,13 @@ void print_modules(void)
 	char buf[8];
 
 	printk("Modules linked in:");
-	list_for_each_entry(mod, &modules, list)
+	list_for_each_entry(mod, &modules, list) {
 		printk(" %s%s", mod->name, taint_flags(mod->taints, buf));
+#ifdef CONFIG_MODULE_SIG
+		if (!mod->gpgsig_ok)
+			printk("(U)");
+#endif
+	}
 	printk("\n");
 }
 
scripts/Makefile.modpost +35 -1
index 65e0a79..cd78aed 100644
@@ -14,7 +14,8 @@
 # 3)  create one <module>.mod.c file pr. module
 # 4)  create one Module.symvers file with CRC for all exported symbols
 # 5) compile all <module>.mod.c files
-# 6) final link of the module to a <module.ko> file
+# 6) final link of the module to a <module.ko> (or <module.unsigned>) file
+# 7) signs the modules to a <module.ko> file
 
 # Step 3 is used to place certain information in the module's ELF
 # section, including information such as:
@@ -32,6 +33,8 @@
 # Step 4 is solely used to allow module versioning in external modules,
 # where the CRC of each module is retrieved from the Module.symers file.
 
+# Step 7 is dependent on CONFIG_MODULE_SIG being enabled.
+
 # KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined
 # symbols in the final module linking stage
 # KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
@@ -96,6 +99,7 @@ $(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE
 targets += $(modules:.ko=.mod.o)
 
 # Step 6), final link of the modules
+ifneq ($(CONFIG_MODULE_SIG),y)
 quiet_cmd_ld_ko_o = LD [M]  $@
       cmd_ld_ko_o = $(LD) $(LDFLAGS) $(LDFLAGS_MODULE) -o $@		\
 			  $(filter-out FORCE,$^)
@@ -104,7 +108,37 @@ $(modules): %.ko :%.o %.mod.o FORCE
 	$(call if_changed,ld_ko_o)
 
 targets += $(modules)
+else
+quiet_cmd_ld_ko_unsigned_o = LD [M]  $@
+      cmd_ld_ko_unsigned_o = $(LD) $(LDFLAGS) $(LDFLAGS_MODULE) -o $@		\
+			  $(filter-out FORCE,$^)
+
+$(modules:.ko=.ko.unsigned): %.ko.unsigned :%.o %.mod.o FORCE
+	$(call if_changed,ld_ko_unsigned_o)
+
+targets += $(modules)
 
+# Step 7), sign the modules
+MODSECKEY = ./kernel.sec
+MODPUBKEY = ./kernel.pub
+KEYFLAGS = --no-default-keyring --secret-keyring $(MODSECKEY) --keyring $(MODPUBKEY) --no-default-keyring --homedir . --no-options --no-auto-check-trustdb --no-permission-warning
+ifdef MODKEYNAME
+KEYFLAGS += --default-key $(MODKEYNAME)
+endif
+
+quiet_cmd_sign_ko_ko_unsigned = SIGN [M] $@
+      cmd_sign_ko_ko_unsigned = \
+		scripts/mod/mod-extract $< [email protected] && \
+		rm -f [email protected] && \
+		gpg --batch --no-greeting $(KEYFLAGS) -b [email protected] && \
+		$(OBJCOPY) --add-section [email protected] $< $@ && \
+		$(OBJCOPY) --set-section-flags .module_sig=alloc $@
+
+$(modules): %.ko :%.ko.unsigned FORCE
+	$(call if_changed,sign_ko_ko_unsigned)
+
+targets += $(modules)
+endif
 
 # Add FORCE to the prequisites of a target to force it to be always rebuilt.
 # ---------------------------------------------------------------------------
scripts/mod/.gitignore +1 -0
index e9b7abe..223dfd6 100644
@@ -1,4 +1,5 @@
 elfconfig.h
 mk_elfconfig
 modpost
+mod-extract
 
scripts/mod/Makefile +1 -1
index 11d69c3..bba0494 100644
@@ -1,4 +1,4 @@
-hostprogs-y	:= modpost mk_elfconfig
+hostprogs-y	:= modpost mk_elfconfig mod-extract
 always		:= $(hostprogs-y) empty.o
 
 modpost-objs	:= modpost.o file2alias.o sumversion.o
scripts/mod/mod-extract.c new file +890 -0

890 lines not on this page · raw message

#6 lore raw
In reply to David Howells
Quoted 2 lines · David Howells

(1) A cut-down MPI library derived from GPG with error handling added.

Do we really need to add this?

Wouldn't it be much nicer to just teach people to use one of the existing signature things that we need for _other_ cases anyway, and already have merged?

(Of course, it's possible that none of the current crypto supports any signature checking at all - I didn't actually look. In which case my argument is pointless).

Linus

#7 lore raw
Quoted 3 lines · Linus Torvalds
Quoted 1 line

(1) A cut-down MPI library derived from GPG with error handling added.

Do we really need to add this?

I presume you mean the MPI library specifically? If so, then yes. It's necessary to do DSA signature verification (or RSA for that matter).

Quoted 3 lines

Wouldn't it be much nicer to just teach people to use one of the existing signature things that we need for _other_ cases anyway, and already have merged?

Existing signature things? I know not of such beasts, nor can I see them offhand.

Quoted 3 lines

(Of course, it's possible that none of the current crypto supports any signature checking at all - I didn't actually look. In which case my argument is pointless).

Hashing, yes; encryption, yes; signature checking: no from what I can see.

It's possible that I can share code with eCryptFS, though at first sight that doesn't seem to overlap with what I want to do.

David

#8 lore raw
Quoted 5 lines · David Howells

Hashing, yes; encryption, yes; signature checking: no from what I can see.

It's possible that I can share code with eCryptFS, though at first sight that doesn't seem to overlap with what I want to do.

Right now, eCryptfs just delegates its modular exponentiation operations to a userspace daemon. If RSA ever finds its way into the kernel, I might tweak eCryptfs to use that instead for some of the public key operations.

Mike

#9 lore raw
Quoted 4 lines · Michael Halcrow

Right now, eCryptfs just delegates its modular exponentiation operations to a userspace daemon. If RSA ever finds its way into the kernel, I might tweak eCryptfs to use that instead for some of the public key operations.

Am I right in thinking that RSA uses many of the same MPI lib bits as DSA?

David

#10 lore raw
Quoted 9 lines · David Howells
Quoted 4 lines · Michael Halcrow

Right now, eCryptfs just delegates its modular exponentiation operations to a userspace daemon. If RSA ever finds its way into the kernel, I might tweak eCryptfs to use that instead for some of the public key operations.

Am I right in thinking that RSA uses many of the same MPI lib bits as DSA?

I would imagine so. Assuming we aren't having to hassle with key generation (eCryptfs takes care of that in userspace), then RSA is, more or less, a^b mod c (mpi_mulpowm() and friends).

Mike

#12 lore raw
In reply to David Howells
Quoted 18 lines · On Wed, 14 Feb 2007 19:09:38 +0000 David Howells <[email protected]> wrote:

These patches provide a GPG-based kernel module signing facility. Their use is not fully automated within the confines of the kernel build process because it needs provision of keys from outside of the kernel before the kernel can be compiled.

The patches are:

(1) A cut-down MPI library derived from GPG with error handling added.

(2) Permit hash algorithms to hash kernel data defined by a virtual address and a length rather than trying to use scattergather lists (which require struct page pointers to be determined).

(3) Add extra information to the per-arch ELF headers to more fully describe the format of the ELF metadata.

(4) Add module verification capabilities, including ELF metadata verification.

Quoted 7 lines

(5) Add a generic DSA signature checker. Given a SHA1 hash of the data to be verified and a binary blob holding a GPG signature stream, this verifies the signature using a built-in ring of public keys.

(6) Add a module signature checker that applies signature checking to modules on module load, checking the signature against the ring of public keys compiled into the kernel.

Grand total:

 77 files changed, 9681 insertions(+), 10 deletions(-)

just to be able to sign modules.

Normally I'd collapse writhing in laughter, but..

Quoted 2 lines

These patches have been in use by RHEL and Fedora kernels for years, and so have been thoroughly tested.

so I guess there's an argument for merging them so we can send them back to you guys. But there's also an argument to declare all this gunk a vendor-only thing. How much pain would that cause?

#13 lore raw
Quoted 4 lines · Andrew Morton
 77 files changed, 9681 insertions(+), 10 deletions(-)

just to be able to sign modules.

Quoted 8 lines

Normally I'd collapse writhing in laughter, but..

Quoted 2 lines

These patches have been in use by RHEL and Fedora kernels for years, and so have been thoroughly tested.

so I guess there's an argument for merging them so we can send them back to you guys. But there's also an argument to declare all this gunk a vendor-only thing. How much pain would that cause?

it needs rediffing pretty much every time the cryptoapi changes. On a good month that means once per point release, otherwise...

One argument in its favour is aparently Red Hat isn't the only vendor with something like this. I've not investigated it, but I hear rumours that suse has something similar. Having everyone using the same code would be a win for obvious reasons.

Dave

Signature · 1 line
http://www.codemonkey.org.uk
#14 lore raw
Quoted 2 lines · Dave Jones

I've not investigated it, but I hear rumours that suse has something similar.

Actually, no. We don't belive that module signing adds significant value, and it also doesn't work well with external modules. (The external modules we really care about are GPL ones; it gives us a way to update drivers without pushing out entirely new kernels.)

Cheers,
Andreas

#15 lore raw
Quoted 5 lines · Andreas Gruenbacher
Quoted 2 lines · Dave Jones

I've not investigated it, but I hear rumours that suse has something similar.

Actually, no. We don't belive that module signing adds significant value,

ok, then I was misinformed.

Quoted 1 line

and it also doesn't work well with external modules.

well, the situation for external modules is no worse than usual. They still work, they just aren't signed. Which from a distributor point of view, is actually a nice thing, as they stick out like a sore thumb in oops reports with (U) markers :)

Quoted 2 lines

(The external modules we really care about are GPL ones; it gives us a way to update drivers without pushing out entirely new kernels.)

external modules still compile, and run just fine. The signed modules code doesn't prevent loading of them unless the user decides to do so with a special boot option (which is no different really than say, reducing the cap-bound sysctl to prevent module loading).

Dave

Signature · 1 line
http://www.codemonkey.org.uk
#16 lore raw
Quoted 4 lines · Dave Jones

well, the situation for external modules is no worse than usual. They still work, they just aren't signed. Which from a distributor point of view, is actually a nice thing, as they stick out like a sore thumb in oops reports with (U) markers :)

I agree, that's really what should happen. We solve this by marking modules as supported, partner supported, or unsupported, but in an "insecure" way, so partners and users could try to fake the support status of a module and/or remove status flags from Oopses, and cryptography wouldn't save us. We could try to sign Oopses which I guess you guys are doing. This whole issue hasn't been a serious problem in the past though, and we generally try to trust users not to play games on us.

In the end, it all seems to boils down to a difference in philosophy.

Thanks,
Andreas

#17 lore raw
Quoted 6 lines · Andreas Gruenbacher
Quoted 4 lines · Dave Jones

well, the situation for external modules is no worse than usual. They still work, they just aren't signed. Which from a distributor point of view, is actually a nice thing, as they stick out like a sore thumb in oops reports with (U) markers :)

Quoted 7 lines

I agree, that's really what should happen. We solve this by marking modules as supported, partner supported, or unsupported, but in an "insecure" way, so partners and users could try to fake the support status of a module and/or remove status flags from Oopses, and cryptography wouldn't save us. We could try to sign Oopses which I guess you guys are doing. This whole issue hasn't been a serious problem in the past though, and we generally try to trust users not to play games on us.

For the most part it works out. I've had users file oopses where they've editted out Tainted: P, and left in nvidia(U) for example :-)

Dave

Signature · 1 line
http://www.codemonkey.org.uk
#25 lore raw
In reply to David Howells

Hi,

Quoted 3 lines · David Howells

Now, this is not a complete solution by any means: the core kernel is not protected, and nor are /dev/mem or /dev/kmem, but it denies (or at least controls) one relatively simple attack vector.

This is really the weak point - it offers no advantage over an equivalent implementation in user space (e.g. in the module tools). So why has to be done in the kernel?

bye, Roman

#26 lore raw
Quoted 7 lines · Roman Zippel
Quoted 3 lines

Now, this is not a complete solution by any means: the core kernel is not protected, and nor are /dev/mem or /dev/kmem, but it denies (or at least controls) one relatively simple attack vector.

This is really the weak point - it offers no advantage over an equivalent implementation in user space (e.g. in the module tools). So why has to be done in the kernel?

Because the init_module() system call is the common point of module submission to the kernel, not any particular userspace program. There is no requirement for userspace to load a module by invoking a module tools program or library, and so userspace can bypass the checks entirely by just calling init_module(). Assume for a moment that you can't trust userspace... (Obviously, if you can't trust the kernel then you're already stuffed.)

It is possible to protect /dev/mem and /dev/kmem or make them unavailable and it is possible to protect the kernel's memory whilst it is running (provided you don't have nommu or broken hardware and you don't let userspace concoct any DMA request it likes) which mostly closes those other vectors I mentioned. This isn't something I intended to look at with this patch. Those are separate holes.

Making the core kernel load image inaccessible or immutable to root is not something I can provide a generic solution for and security checking the core kernel load image has to be done at an earlier layer as you can't rely on something guaranteeing its own integrity because if someone can alter that something, then they can bypass the self-checking too...

However, modules permits arbitrary modification of the running kernel to be attempted.

David

#27 lore raw

Hi,

Quoted 10 lines · David Howells
Quoted 3 lines

This is really the weak point - it offers no advantage over an equivalent implementation in user space (e.g. in the module tools). So why has to be done in the kernel?

Because the init_module() system call is the common point of module submission to the kernel, not any particular userspace program. There is no requirement for userspace to load a module by invoking a module tools program or library, and so userspace can bypass the checks entirely by just calling init_module(). Assume for a moment that you can't trust userspace... (Obviously, if you can't trust the kernel then you're already stuffed.)

All the security stuff in the kernel should provide the necessary means to restrict this system call.

Quoted 6 lines

It is possible to protect /dev/mem and /dev/kmem or make them unavailable and it is possible to protect the kernel's memory whilst it is running (provided you don't have nommu or broken hardware and you don't let userspace concoct any DMA request it likes) which mostly closes those other vectors I mentioned. This isn't something I intended to look at with this patch. Those are separate holes.

Exactly and as long as there are these holes, these patches are only kernel bloat. The simple verification can also be done in userspace and module signing offers no real security.
What real value do these patches provide, that can't be reached via other means? Who else than distributions would be interested in this? Pretty much any use you initially mentioned can be done in simpler ways, e.g. anyone afraid of modules simply disables module loading completely.

bye, Roman

#28 lore raw
Quoted 9 lines · Roman Zippel
Quoted 6 lines · David Howells

It is possible to protect /dev/mem and /dev/kmem or make them unavailable and it is possible to protect the kernel's memory whilst it is running (provided you don't have nommu or broken hardware and you don't let userspace concoct any DMA request it likes) which mostly closes those other vectors I mentioned. This isn't something I intended to look at with this patch. Those are separate holes.

Quoted 7 lines

Exactly and as long as there are these holes, these patches are only kernel bloat. The simple verification can also be done in userspace and module signing offers no real security.
What real value do these patches provide, that can't be reached via other means? Who else than distributions would be interested in this? Pretty much any use you initially mentioned can be done in simpler ways, e.g. anyone afraid of modules simply disables module loading completely.

this issue, and these holes keep comeing up in discussions, why can't these holes be closed? I seem to remember seeing patches that would remove /dev/kmem being sent to the list, but they weren't accepted into the kernel (and I seem to remember people being against the concept of removeing them, not against techincal details of the patches. but this was many years ago)

at one point I remember hearing that X required raw /dev/kmem, but for servers you don't need/want X anyway, so this is a useful option even if X doesn't get fixed.

David Lang

#18 lore raw
In reply to Andreas Gruenbacher
Quoted 4 lines · Andreas Gruenbacher

I agree, that's really what should happen. We solve this by marking modules as supported, partner supported, or unsupported, but in an "insecure" way, so partners and users could try to fake the support status of a module and/or remove status flags from Oopses, and cryptography wouldn't save us.

Where cryptography *can* save you is that a partner or user can't fake a 'Suse Supported' signature without access to the Suse private key.

#22 lore raw
In reply to Dave Jones
Quoted 4 lines · Dave Jones

One argument in its favour is aparently Red Hat isn't the only vendor with something like this. I've not investigated it, but I hear rumours that suse has something similar. Having everyone using the same code would be a win for obvious reasons.

Another argument in its favor is that it actually allows the kernel to implement *real* checking of module licenses and trumps all the proposals to deal with MODULE_LICENSE("GPL\0Haha!"). A vendor (or user) that wants to be *sure* that only *really really* GPL modules are loaded can simply refuse to load unsigned modules - and then refuse to sign a module until after they had themselves visited the source's website, verified that the source code was available under GPL, and so on.

Remember - the GPL is about the availability of the source. And at modprobe time, the source isn't available. So you're left with two options:

1) Trust the binary to not lie to you about its license.
2) Ask a trusted 3rd party (usually, the person/distro that built the kernel) whether they've verified the claim that it's really GPL.

#29 lore raw
In reply to David Lang

Hi,

Quoted 5 lines · David Lang

this issue, and these holes keep comeing up in discussions, why can't these holes be closed? I seem to remember seeing patches that would remove /dev/kmem being sent to the list, but they weren't accepted into the kernel (and I seem to remember people being against the concept of removeing them, not against techincal details of the patches. but this was many years ago)

1. It depends on the ratio of added code and its usefulness. I must assume the first patch didn't even make it to the kernel due to its size, so I think it's not unreasonable to explore the alternatives.
2. There are many ways to load an unauthorized module, thus you have to prevent any modification of the kernel not just in memory but also on disk.

bye, Roman

#30 lore raw
In reply to David Howells
Quoted 9 lines · David Howells

...
There are several reasons why these patches are useful, amongst which are:
...
(4) to allow other support providers to do likewise, or at least to _detect_

     the fact that unsupported modules are loaded;

(5) to allow the detection of modules replaced by a second-order distro or a preloaded Linux purveyor.
...

Who might have rebuilt the whole kernel using a new signature.

Or a bug reporter might have edited out the parts containing the information that unsupported code was loaded.

Or the unsupported module itself might have removed all traces of having been loaded from the kernel.

For printing nvidia(U), you could simply add some marker similar to MODULE_LICENSE() that gets added to supported modules during "official" builds and gets checked when loading a module.

That's 10k LOC less and the same level of security...

Quoted 1 line

David

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#11 lore raw
In reply to David Howells

Hello,

Quoted 9 lines · David Howells
Quoted 3 lines · Linus Torvalds
Quoted 1 line

(1) A cut-down MPI library derived from GPG with error handling added.

Do we really need to add this?

I presume you mean the MPI library specifically? If so, then yes. It's necessary to do DSA signature verification (or RSA for that matter).

Quoted 6 lines
Quoted 3 lines

Wouldn't it be much nicer to just teach people to use one of the existing signature things that we need for _other_ cases anyway, and already have merged?

Existing signature things? I know not of such beasts, nor can I see them offhand.

The question is if using DSA/RSA is the right choice for something like this. I think that the symmetrically encrypted hash output as signature would provide the same amount of security. The only additional requirement is that the key can't be read by userspace. But if they can reach the kernel binary, they can modify it too. Same for the bootloader, where you'd want the key and initial checking anyway. Else this whole thing could be done in user space as Roman Zippel said...

The ELF section stuff seems like unnecessary bloat too. Can't you use/extend modinfo, or kernel symbols?

With the above changes the code should shrink to only a few hundred new lines of code, instead of thousands, and signature checking will be much faster too.

Greetings,

Indan

#23 lore raw
In reply to [email protected]
Quoted 14 lines · On Thu, Feb 15, 2007 at 03:55:41PM -0500, [email protected] wrote:
Quoted 4 lines · Dave Jones

One argument in its favour is aparently Red Hat isn't the only vendor with something like this. I've not investigated it, but I hear rumours that suse has something similar. Having everyone using the same code would be a win for obvious reasons.

Another argument in its favor is that it actually allows the kernel to implement *real* checking of module licenses and trumps all the proposals to deal with MODULE_LICENSE("GPL\0Haha!"). A vendor (or user) that wants to be *sure* that only *really really* GPL modules are loaded can simply refuse to load unsigned modules - and then refuse to sign a module until after they had themselves visited the source's website, verified that the source code was available under GPL, and so on.

Quoted 6 lines

Remember - the GPL is about the availability of the source. And at modprobe time, the source isn't available. So you're left with two options:

1) Trust the binary to not lie to you about its license.
2) Ask a trusted 3rd party (usually, the person/distro that built the kernel) whether they've verified the claim that it's really GPL.

There are different opinions whether the "complete source code" of the GPLv2 includes in such cases public keys, making it questionable whether your example will survive at court in all jurisdictions.

E.g. remember that gpl-violations.org has already successfully enforced the publication of public keys for "firmware only loads signed kernels" cases by threatening companies to otherwise take legal actions in Germany.

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#24 lore raw
Quoted 3 lines · Adrian Bunk

There are different opinions whether the "complete source code" of the GPLv2 includes in such cases public keys, making it questionable whether your example will survive at court in all jurisdictions.

It's no less shaky than the whole EXPORT_SYMBOL_GPL-as-enforcement crock. :)

Quoted 4 lines

E.g. remember that gpl-violations.org has already successfully enforced the publication of public keys for "firmware only loads signed kernels" cases by threatening companies to otherwise take legal actions in Germany.

A court order for the publication of *public* keys? :)

I think you meant "private keys" in both paragraphs above. And it's probably a non-issue the way Red Hat implemented it - they included a document on "How to generate your own public/private key pair", which invokes commands that create a bitstring that you can then use to sign the entire applicable part of the kernel tree. The fact that it's not the *same* bitstring as they used is (IMHO) legally about as relevant as the fact that they compiled the tree with one release of GCC, included instructions on how to compile it, and I don't get a bitwise identical binary if I compile it with a different GCC release.

Yes, you're still screwed if you only build *part* of the kernel tree and expect it to work - modules you sign won't load into their kernel, and vice versa. But that's the same problem as the old 2.4 "You didn't do a make clean between rebuilds and you bugged out because different parts of the tree were built with different GCC releases". As distributed, you *can* build a working kernel from the pieces and instructions provided.

#19 lore raw
In reply to [email protected]
Quoted 9 lines · On Thursday 15 February 2007 12:34, [email protected] wrote:
Quoted 5 lines · Andreas Gruenbacher

I agree, that's really what should happen. We solve this by marking modules as supported, partner supported, or unsupported, but in an "insecure" way, so partners and users could try to fake the support status of a module and/or remove status flags from Oopses, and cryptography wouldn't save us.

Where cryptography *can* save you is that a partner or user can't fake a 'Suse Supported' signature without access to the Suse private key.

No question about that. We actually already get this from rpm signatures. What would module signatures buy us? The kernel could then reliably determine that an unsigned module was loaded. But people could still fake their Oopses, or overwite the flags which indicate that a module's signature didn't match, so we still wouldn't reliably get at that information.

Andreas

#20 lore raw
Quoted 9 lines · On Thursday 15 February 2007 12:34, [email protected] wrote:
Quoted 5 lines · Andreas Gruenbacher

I agree, that's really what should happen. We solve this by marking modules as supported, partner supported, or unsupported, but in an "insecure" way, so partners and users could try to fake the support status of a module and/or remove status flags from Oopses, and cryptography wouldn't save us.

Where cryptography *can* save you is that a partner or user can't fake a 'Suse Supported' signature without access to the Suse private key.

The user has control over the running kernel, and given enough time and clue, can circumvent any protection mechanism the vendor comes up with. And that's a good thing IMO, unless you believe in "trusted computing" and all those Bigbrotherisms some agencies want to put in your machines.

So the user is running a system in some state that may or may not resemble what the vendor shipped. When the machine crashes, the user is free to munge the oops until it looks like a valid one.

Someone mentioned in this context that you can sign the oops - but to do that you need a private key. And the whole point of this exercise is that the user does not have access to that key.

So as far as support is concerned, you're back in square one. You cannot tell a "genuine" oops produced on a supported kernel from a doctored one produced on Joe Doe's Garage Kernel.

Olaf

Signature · 3 lines
Olaf Kirch        |  Anyone who has had to work with X.509 has probably
[email protected]       |  experienced what can best be described as
------------------+  ISO water torture. -- Peter Gutmann
#31 lore raw
In reply to David Howells

Hi!

Quoted 3 lines

Now, this is not a complete solution by any means: the core kernel is not protected, and nor are /dev/mem or /dev/kmem, but it denies (or at least controls) one relatively simple attack vector.

Could we fix the /dev/*mem holes, first? They are already used by malicious modules (aka rootkits...). Or can selinux already provide /dev/*mem protection with no way for admin to turn it off?

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#21 lore raw
In reply to Andreas Gruenbacher

Hi!

Quoted 10 lines
Quoted 4 lines

well, the situation for external modules is no worse than usual. They still work, they just aren't signed. Which from a distributor point of view, is actually a nice thing, as they stick out like a sore thumb in oops reports with (U) markers :)

I agree, that's really what should happen. We solve this by marking modules as supported, partner supported, or unsupported, but in an "insecure" way, so partners and users could try to fake the support status of a module and/or remove status flags from Oopses, and cryptography wouldn't save us. We could try to sign Oopses which I guess you guys are doing. This whole issue hasn't

I do not think any ammount of crypto can determine that I loaded unsupported module, then edited oops. (TPM hw module may be able to do that, not sure).

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#32 lore raw
In reply to Pavel Machek
Quoted 9 lines · Pavel Machek

Hi!

Quoted 3 lines

Now, this is not a complete solution by any means: the core kernel is not protected, and nor are /dev/mem or /dev/kmem, but it denies (or at least controls) one relatively simple attack vector.

Could we fix the /dev/*mem holes, first? They are already used by malicious modules (aka rootkits...). Or can selinux already provide /dev/*mem protection with no way for admin to turn it off?

There are some valid uses for peeking through /dev/mem. Things like dmidecode for example. So you don't want to disable it completely in a lot of cases, but have fine-grained access to specific parts of the file. I'm not sure SELinux can do this. Maybe the MLS stuff helps here (though I'm far from an expert on this, so I could be talking out of my rear).

The restricted dev/mem patches we've had in Fedora for a while do the right thing, but they're a bit crufty (in part due to drivers/char/mem.c being a bit of a mess before we even start patching it). I've had "clean these up for upstream" on my todo for a while. I might get around to it one of these days.

Dave

Signature · 1 line
http://www.codemonkey.org.uk
#33 lore raw
Quoted 7 lines

The restricted dev/mem patches we've had in Fedora for a while do the right thing, but they're a bit crufty (in part due to drivers/char/mem.c being a bit of a mess before we even start patching it). I've had "clean these up for upstream" on my todo for a while. I might get around to it one of these days.

the real thing is that /dev/mem is too many things for too many people. Fundamentally it has 3 components
1) ram-but-not-kernel data: basically BIOS datastructures
2) kernel visible ram: user/kernel data, this has all the nasty cache coherency issues. This is also a "debug only" use, and "rootkit only" sometimes ;)
3) MMIO space: this really should not be used anymore, sysfs provides a MUCH better interface and it also breaks if you have enforcing IOMMU's in the system... it can't really work since the kernel doesn't get told which device is being accessed

unless we split this up (well the third is split already) it's going to remain a big mess.

Signature · 2 lines
if you want to mail me at work (you don't), use arjan (at) linux.intel.com
Test the interaction between Linux and your BIOS via http://www.linuxfirmwarekit.org