forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'hardening-v5.20-rc1' of git://git.kernel.org/pub/scm/linux…
…/kernel/git/kees/linux Pull hardening updates from Kees Cook: - Fix Sparse warnings with randomizd kstack (GONG, Ruiqi) - Replace uintptr_t with unsigned long in usercopy (Jason A. Donenfeld) - Fix Clang -Wforward warning in LKDTM (Justin Stitt) - Fix comment to correctly refer to STRICT_DEVMEM (Lukas Bulwahn) - Introduce dm-verity binding logic to LoadPin LSM (Matthias Kaehlcke) - Clean up warnings and overflow and KASAN tests (Kees Cook) * tag 'hardening-v5.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: dm: verity-loadpin: Drop use of dm_table_get_num_targets() kasan: test: Silence GCC 12 warnings drivers: lkdtm: fix clang -Wformat warning x86: mm: refer to the intended config STRICT_DEVMEM in a comment dm: verity-loadpin: Use CONFIG_SECURITY_LOADPIN_VERITY for conditional compilation LoadPin: Enable loading from trusted dm-verity devices dm: Add verity helpers for LoadPin stack: Declare {randomize_,}kstack_offset to fix Sparse warnings lib: overflow: Do not define 64-bit tests on 32-bit MAINTAINERS: Add a general "kernel hardening" section usercopy: use unsigned long instead of uintptr_t
- Loading branch information
Showing
14 changed files
with
379 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4998,7 +4998,7 @@ R: Nick Desaulniers <[email protected]> | |
L: [email protected] | ||
S: Supported | ||
B: https://github.com/ClangBuiltLinux/linux/issues | ||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/clang/features | ||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening | ||
F: include/linux/cfi.h | ||
F: kernel/cfi.c | ||
|
||
|
@@ -7909,6 +7909,7 @@ FORTIFY_SOURCE | |
M: Kees Cook <[email protected]> | ||
L: [email protected] | ||
S: Supported | ||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening | ||
F: include/linux/fortify-string.h | ||
F: lib/test_fortify/* | ||
F: scripts/test_fortify.sh | ||
|
@@ -8351,6 +8352,7 @@ GCC PLUGINS | |
M: Kees Cook <[email protected]> | ||
L: [email protected] | ||
S: Maintained | ||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening | ||
F: Documentation/kbuild/gcc-plugins.rst | ||
F: scripts/Makefile.gcc-plugins | ||
F: scripts/gcc-plugins/ | ||
|
@@ -10878,6 +10880,17 @@ F: scripts/mk* | |
F: scripts/mod/ | ||
F: scripts/package/ | ||
|
||
KERNEL HARDENING (not covered by other areas) | ||
M: Kees Cook <[email protected]> | ||
L: [email protected] | ||
S: Supported | ||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening | ||
F: include/linux/overflow.h | ||
F: include/linux/randomize_kstack.h | ||
F: mm/usercopy.c | ||
K: \b(add|choose)_random_kstack_offset\b | ||
K: \b__check_(object_size|heap_object)\b | ||
|
||
KERNEL JANITORS | ||
L: [email protected] | ||
S: Odd Fixes | ||
|
@@ -11688,7 +11701,7 @@ F: drivers/media/usb/dvb-usb-v2/lmedm04* | |
LOADPIN SECURITY MODULE | ||
M: Kees Cook <[email protected]> | ||
S: Supported | ||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git lsm/loadpin | ||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening | ||
F: Documentation/admin-guide/LSM/LoadPin.rst | ||
F: security/loadpin/ | ||
|
||
|
@@ -18026,7 +18039,7 @@ M: Kees Cook <[email protected]> | |
R: Andy Lutomirski <[email protected]> | ||
R: Will Drewry <[email protected]> | ||
S: Supported | ||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git seccomp | ||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/seccomp | ||
F: Documentation/userspace-api/seccomp_filter.rst | ||
F: include/linux/seccomp.h | ||
F: include/uapi/linux/seccomp.h | ||
|
@@ -22174,7 +22187,7 @@ F: include/linux/yam.h | |
YAMA SECURITY MODULE | ||
M: Kees Cook <[email protected]> | ||
S: Supported | ||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git yama/tip | ||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening | ||
F: Documentation/admin-guide/LSM/Yama.rst | ||
F: security/yama/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
|
||
#include <linux/list.h> | ||
#include <linux/kernel.h> | ||
#include <linux/dm-verity-loadpin.h> | ||
|
||
#include "dm.h" | ||
#include "dm-core.h" | ||
#include "dm-verity.h" | ||
|
||
#define DM_MSG_PREFIX "verity-loadpin" | ||
|
||
LIST_HEAD(dm_verity_loadpin_trusted_root_digests); | ||
|
||
static bool is_trusted_verity_target(struct dm_target *ti) | ||
{ | ||
u8 *root_digest; | ||
unsigned int digest_size; | ||
struct dm_verity_loadpin_trusted_root_digest *trd; | ||
bool trusted = false; | ||
|
||
if (!dm_is_verity_target(ti)) | ||
return false; | ||
|
||
if (dm_verity_get_root_digest(ti, &root_digest, &digest_size)) | ||
return false; | ||
|
||
list_for_each_entry(trd, &dm_verity_loadpin_trusted_root_digests, node) { | ||
if ((trd->len == digest_size) && | ||
!memcmp(trd->data, root_digest, digest_size)) { | ||
trusted = true; | ||
break; | ||
} | ||
} | ||
|
||
kfree(root_digest); | ||
|
||
return trusted; | ||
} | ||
|
||
/* | ||
* Determines whether the file system of a superblock is located on | ||
* a verity device that is trusted by LoadPin. | ||
*/ | ||
bool dm_verity_loadpin_is_bdev_trusted(struct block_device *bdev) | ||
{ | ||
struct mapped_device *md; | ||
struct dm_table *table; | ||
struct dm_target *ti; | ||
int srcu_idx; | ||
bool trusted = false; | ||
|
||
if (list_empty(&dm_verity_loadpin_trusted_root_digests)) | ||
return false; | ||
|
||
md = dm_get_md(bdev->bd_dev); | ||
if (!md) | ||
return false; | ||
|
||
table = dm_get_live_table(md, &srcu_idx); | ||
|
||
if (table->num_targets != 1) | ||
goto out; | ||
|
||
ti = dm_table_get_target(table, 0); | ||
|
||
if (is_trusted_verity_target(ti)) | ||
trusted = true; | ||
|
||
out: | ||
dm_put_live_table(md, srcu_idx); | ||
dm_put(md); | ||
|
||
return trusted; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
|
||
#ifndef __LINUX_DM_VERITY_LOADPIN_H | ||
#define __LINUX_DM_VERITY_LOADPIN_H | ||
|
||
#include <linux/list.h> | ||
|
||
struct block_device; | ||
|
||
extern struct list_head dm_verity_loadpin_trusted_root_digests; | ||
|
||
struct dm_verity_loadpin_trusted_root_digest { | ||
struct list_head node; | ||
unsigned int len; | ||
u8 data[]; | ||
}; | ||
|
||
#if IS_ENABLED(CONFIG_SECURITY_LOADPIN_VERITY) | ||
bool dm_verity_loadpin_is_bdev_trusted(struct block_device *bdev); | ||
#else | ||
static inline bool dm_verity_loadpin_is_bdev_trusted(struct block_device *bdev) | ||
{ | ||
return false; | ||
} | ||
#endif | ||
|
||
#endif /* __LINUX_DM_VERITY_LOADPIN_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | ||
/* | ||
* Copyright (c) 2022, Google LLC | ||
*/ | ||
|
||
#ifndef _UAPI_LINUX_LOOP_LOADPIN_H | ||
#define _UAPI_LINUX_LOOP_LOADPIN_H | ||
|
||
#define LOADPIN_IOC_MAGIC 'L' | ||
|
||
/** | ||
* LOADPIN_IOC_SET_TRUSTED_VERITY_DIGESTS - Set up the root digests of verity devices | ||
* that loadpin should trust. | ||
* | ||
* Takes a file descriptor from which to read the root digests of trusted verity devices. The file | ||
* is expected to contain a list of digests in ASCII format, with one line per digest. The ioctl | ||
* must be issued on the securityfs attribute 'loadpin/dm-verity' (which can be typically found | ||
* under /sys/kernel/security/loadpin/dm-verity). | ||
*/ | ||
#define LOADPIN_IOC_SET_TRUSTED_VERITY_DIGESTS _IOW(LOADPIN_IOC_MAGIC, 0x00, unsigned int) | ||
|
||
#endif /* _UAPI_LINUX_LOOP_LOADPIN_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.