mirror of
https://github.com/LuckfoxTECH/luckfox-pico.git
synced 2026-01-18 03:28:19 +01:00
project:build.sh: Added fastboot support; custom modifications to U-Boot and kernel implemented using patches.
project:cfg:BoardConfig_IPC: Added fastboot BoardConfig file and firmware post-scripts, distinguishing between the BoardConfigs for Luckfox Pico Pro and Luckfox Pico Max. project:app: Added fastboot_client and rk_smart_door for quick boot applications; updated rkipc app to adapt to the latest media library. media:samples: Added more usage examples. media:rockit: Fixed bugs; removed support for retrieving data frames from VPSS. media:isp: Updated rkaiq library and related tools to support connection to RKISP_Tuner. sysdrv:Makefile: Added support for compiling drv_ko on Luckfox Pico Ultra W using Ubuntu; added support for custom root filesystem. sysdrv:tools:board: Updated Buildroot optional mirror sources, updated some software versions, and stored device tree files and configuration files that undergo multiple modifications for U-Boot and kernel separately. sysdrv:source:mcu: Used RISC-V MCU SDK with RT-Thread system, mainly for initializing camera AE during quick boot. sysdrv:source:uboot: Added support for fastboot; added high baud rate DDR bin for serial firmware upgrades. sysdrv:source:kernel: Upgraded to version 5.10.160; increased NPU frequency for RV1106G3; added support for fastboot. Signed-off-by: luckfox-eng29 <eng29@luckfox.com>
This commit is contained in:
@@ -101,6 +101,11 @@ config INDIRECT_PIO
|
||||
|
||||
When in doubt, say N.
|
||||
|
||||
source "lib/crypto/Kconfig"
|
||||
|
||||
config LIB_MEMNEQ
|
||||
bool
|
||||
|
||||
config CRC_CCITT
|
||||
tristate "CRC-CCITT functions"
|
||||
help
|
||||
|
||||
@@ -302,8 +302,10 @@ config FRAME_WARN
|
||||
int "Warn for stack frames larger than"
|
||||
range 0 8192
|
||||
default 2048 if GCC_PLUGIN_LATENT_ENTROPY
|
||||
default 1280 if (!64BIT && PARISC)
|
||||
default 1024 if (!64BIT && !PARISC)
|
||||
default 2048 if PARISC
|
||||
default 1536 if (!64BIT && XTENSA)
|
||||
default 1280 if KASAN && !64BIT
|
||||
default 1024 if !64BIT
|
||||
default 2048 if 64BIT
|
||||
help
|
||||
Tell gcc to warn at build time for stack frames larger than this.
|
||||
@@ -1323,6 +1325,46 @@ config LOCKDEP
|
||||
config LOCKDEP_SMALL
|
||||
bool
|
||||
|
||||
config LOCKDEP_BITS
|
||||
int "Bitsize for MAX_LOCKDEP_ENTRIES"
|
||||
depends on LOCKDEP && !LOCKDEP_SMALL
|
||||
range 10 30
|
||||
default 15
|
||||
help
|
||||
Try increasing this value if you hit "BUG: MAX_LOCKDEP_ENTRIES too low!" message.
|
||||
|
||||
config LOCKDEP_CHAINS_BITS
|
||||
int "Bitsize for MAX_LOCKDEP_CHAINS"
|
||||
depends on LOCKDEP && !LOCKDEP_SMALL
|
||||
range 10 30
|
||||
default 16
|
||||
help
|
||||
Try increasing this value if you hit "BUG: MAX_LOCKDEP_CHAINS too low!" message.
|
||||
|
||||
config LOCKDEP_STACK_TRACE_BITS
|
||||
int "Bitsize for MAX_STACK_TRACE_ENTRIES"
|
||||
depends on LOCKDEP && !LOCKDEP_SMALL
|
||||
range 10 30
|
||||
default 19
|
||||
help
|
||||
Try increasing this value if you hit "BUG: MAX_STACK_TRACE_ENTRIES too low!" message.
|
||||
|
||||
config LOCKDEP_STACK_TRACE_HASH_BITS
|
||||
int "Bitsize for STACK_TRACE_HASH_SIZE"
|
||||
depends on LOCKDEP && !LOCKDEP_SMALL
|
||||
range 10 30
|
||||
default 14
|
||||
help
|
||||
Try increasing this value if you need large MAX_STACK_TRACE_ENTRIES.
|
||||
|
||||
config LOCKDEP_CIRCULAR_QUEUE_BITS
|
||||
int "Bitsize for elements in circular_queue struct"
|
||||
depends on LOCKDEP
|
||||
range 10 30
|
||||
default 12
|
||||
help
|
||||
Try increasing this value if you hit "lockdep bfs error:-1" warning due to __cq_enqueue() failure.
|
||||
|
||||
config DEBUG_LOCKDEP
|
||||
bool "Lock dependency engine debugging"
|
||||
depends on DEBUG_KERNEL && LOCKDEP
|
||||
@@ -1442,8 +1484,7 @@ config WARN_ALL_UNSEEDED_RANDOM
|
||||
so architecture maintainers really need to do what they can
|
||||
to get the CRNG seeded sooner after the system is booted.
|
||||
However, since users cannot do anything actionable to
|
||||
address this, by default the kernel will issue only a single
|
||||
warning for the first use of unseeded randomness.
|
||||
address this, by default this option is disabled.
|
||||
|
||||
Say Y here if you want to receive warnings for all uses of
|
||||
unseeded randomness. This will be of use primarily for
|
||||
@@ -1778,8 +1819,14 @@ config NETDEV_NOTIFIER_ERROR_INJECT
|
||||
If unsure, say N.
|
||||
|
||||
config FUNCTION_ERROR_INJECTION
|
||||
def_bool y
|
||||
bool "Fault-injections of functions"
|
||||
depends on HAVE_FUNCTION_ERROR_INJECTION && KPROBES
|
||||
help
|
||||
Add fault injections into various functions that are annotated with
|
||||
ALLOW_ERROR_INJECTION() in the kernel. BPF may also modify the return
|
||||
value of theses functions. This is useful to test error paths of code.
|
||||
|
||||
If unsure, say N
|
||||
|
||||
config FAULT_INJECTION
|
||||
bool "Fault-injection framework"
|
||||
|
||||
@@ -59,6 +59,7 @@ choice
|
||||
config KASAN_GENERIC
|
||||
bool "Generic mode"
|
||||
depends on HAVE_ARCH_KASAN && CC_HAS_KASAN_GENERIC
|
||||
depends on CC_HAS_WORKING_NOSANITIZE_ADDRESS
|
||||
select SLUB_DEBUG if SLUB
|
||||
select CONSTRUCTORS
|
||||
help
|
||||
@@ -79,6 +80,7 @@ config KASAN_GENERIC
|
||||
config KASAN_SW_TAGS
|
||||
bool "Software tag-based mode"
|
||||
depends on HAVE_ARCH_KASAN_SW_TAGS && CC_HAS_KASAN_SW_TAGS
|
||||
depends on CC_HAS_WORKING_NOSANITIZE_ADDRESS
|
||||
select SLUB_DEBUG if SLUB
|
||||
select CONSTRUCTORS
|
||||
help
|
||||
|
||||
@@ -248,6 +248,7 @@ obj-$(CONFIG_DIMLIB) += dim/
|
||||
obj-$(CONFIG_SIGNATURE) += digsig.o
|
||||
|
||||
lib-$(CONFIG_CLZ_TAB) += clz_tab.o
|
||||
lib-$(CONFIG_LIB_MEMNEQ) += memneq.o
|
||||
|
||||
obj-$(CONFIG_GENERIC_STRNCPY_FROM_USER) += strncpy_from_user.o
|
||||
obj-$(CONFIG_GENERIC_STRNLEN_USER) += strnlen_user.o
|
||||
@@ -274,7 +275,7 @@ $(foreach file, $(libfdt_files), \
|
||||
$(eval CFLAGS_$(file) = -I $(srctree)/scripts/dtc/libfdt))
|
||||
lib-$(CONFIG_LIBFDT) += $(libfdt_files)
|
||||
|
||||
lib-$(CONFIG_BOOT_CONFIG) += bootconfig.o
|
||||
obj-$(CONFIG_BOOT_CONFIG) += bootconfig.o
|
||||
|
||||
obj-$(CONFIG_RBTREE_TEST) += rbtree_test.o
|
||||
obj-$(CONFIG_INTERVAL_TREE_TEST) += interval_tree_test.o
|
||||
|
||||
@@ -1462,6 +1462,7 @@ int assoc_array_gc(struct assoc_array *array,
|
||||
struct assoc_array_ptr *cursor, *ptr;
|
||||
struct assoc_array_ptr *new_root, *new_parent, **new_ptr_pp;
|
||||
unsigned long nr_leaves_on_tree;
|
||||
bool retained;
|
||||
int keylen, slot, nr_free, next_slot, i;
|
||||
|
||||
pr_devel("-->%s()\n", __func__);
|
||||
@@ -1538,6 +1539,7 @@ continue_node:
|
||||
goto descend;
|
||||
}
|
||||
|
||||
retry_compress:
|
||||
pr_devel("-- compress node %p --\n", new_n);
|
||||
|
||||
/* Count up the number of empty slots in this node and work out the
|
||||
@@ -1555,6 +1557,7 @@ continue_node:
|
||||
pr_devel("free=%d, leaves=%lu\n", nr_free, new_n->nr_leaves_on_branch);
|
||||
|
||||
/* See what we can fold in */
|
||||
retained = false;
|
||||
next_slot = 0;
|
||||
for (slot = 0; slot < ASSOC_ARRAY_FAN_OUT; slot++) {
|
||||
struct assoc_array_shortcut *s;
|
||||
@@ -1604,9 +1607,14 @@ continue_node:
|
||||
pr_devel("[%d] retain node %lu/%d [nx %d]\n",
|
||||
slot, child->nr_leaves_on_branch, nr_free + 1,
|
||||
next_slot);
|
||||
retained = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (retained && new_n->nr_leaves_on_branch <= ASSOC_ARRAY_FAN_OUT) {
|
||||
pr_devel("internal nodes remain despite enough space, retrying\n");
|
||||
goto retry_compress;
|
||||
}
|
||||
pr_devel("after: %lu\n", new_n->nr_leaves_on_branch);
|
||||
|
||||
nr_leaves_on_tree = new_n->nr_leaves_on_branch;
|
||||
|
||||
@@ -3,17 +3,19 @@
|
||||
* lib/bitmap.c
|
||||
* Helper functions for bitmap.h.
|
||||
*/
|
||||
#include <linux/export.h>
|
||||
#include <linux/thread_info.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <linux/errno.h>
|
||||
|
||||
#include <linux/bitmap.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/bug.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/export.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/thread_info.h>
|
||||
#include <linux/uaccess.h>
|
||||
|
||||
#include <asm/page.h>
|
||||
@@ -1262,6 +1264,38 @@ void bitmap_free(const unsigned long *bitmap)
|
||||
}
|
||||
EXPORT_SYMBOL(bitmap_free);
|
||||
|
||||
static void devm_bitmap_free(void *data)
|
||||
{
|
||||
unsigned long *bitmap = data;
|
||||
|
||||
bitmap_free(bitmap);
|
||||
}
|
||||
|
||||
unsigned long *devm_bitmap_alloc(struct device *dev,
|
||||
unsigned int nbits, gfp_t flags)
|
||||
{
|
||||
unsigned long *bitmap;
|
||||
int ret;
|
||||
|
||||
bitmap = bitmap_alloc(nbits, flags);
|
||||
if (!bitmap)
|
||||
return NULL;
|
||||
|
||||
ret = devm_add_action_or_reset(dev, devm_bitmap_free, bitmap);
|
||||
if (ret)
|
||||
return NULL;
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devm_bitmap_alloc);
|
||||
|
||||
unsigned long *devm_bitmap_zalloc(struct device *dev,
|
||||
unsigned int nbits, gfp_t flags)
|
||||
{
|
||||
return devm_bitmap_alloc(dev, nbits, flags | __GFP_ZERO);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devm_bitmap_zalloc);
|
||||
|
||||
#if BITS_PER_LONG == 64
|
||||
/**
|
||||
* bitmap_from_arr32 - copy the contents of u32 array of bits to bitmap
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
comment "Crypto library routines"
|
||||
menu "Crypto library routines"
|
||||
|
||||
config CRYPTO_LIB_AES
|
||||
tristate
|
||||
@@ -9,14 +9,14 @@ config CRYPTO_LIB_ARC4
|
||||
tristate
|
||||
|
||||
config CRYPTO_ARCH_HAVE_LIB_BLAKE2S
|
||||
tristate
|
||||
bool
|
||||
help
|
||||
Declares whether the architecture provides an arch-specific
|
||||
accelerated implementation of the Blake2s library interface,
|
||||
either builtin or as a module.
|
||||
|
||||
config CRYPTO_LIB_BLAKE2S_GENERIC
|
||||
tristate
|
||||
def_bool !CRYPTO_ARCH_HAVE_LIB_BLAKE2S
|
||||
help
|
||||
This symbol can be depended upon by arch implementations of the
|
||||
Blake2s library interface that require the generic code as a
|
||||
@@ -24,15 +24,6 @@ config CRYPTO_LIB_BLAKE2S_GENERIC
|
||||
implementation is enabled, this implementation serves the users
|
||||
of CRYPTO_LIB_BLAKE2S.
|
||||
|
||||
config CRYPTO_LIB_BLAKE2S
|
||||
tristate "BLAKE2s hash function library"
|
||||
depends on CRYPTO_ARCH_HAVE_LIB_BLAKE2S || !CRYPTO_ARCH_HAVE_LIB_BLAKE2S
|
||||
select CRYPTO_LIB_BLAKE2S_GENERIC if CRYPTO_ARCH_HAVE_LIB_BLAKE2S=n
|
||||
help
|
||||
Enable the Blake2s library interface. This interface may be fulfilled
|
||||
by either the generic implementation or an arch-specific one, if one
|
||||
is available and enabled.
|
||||
|
||||
config CRYPTO_ARCH_HAVE_LIB_CHACHA
|
||||
tristate
|
||||
help
|
||||
@@ -42,7 +33,6 @@ config CRYPTO_ARCH_HAVE_LIB_CHACHA
|
||||
|
||||
config CRYPTO_LIB_CHACHA_GENERIC
|
||||
tristate
|
||||
select CRYPTO_ALGAPI
|
||||
help
|
||||
This symbol can be depended upon by arch implementations of the
|
||||
ChaCha library interface that require the generic code as a
|
||||
@@ -52,6 +42,7 @@ config CRYPTO_LIB_CHACHA_GENERIC
|
||||
|
||||
config CRYPTO_LIB_CHACHA
|
||||
tristate "ChaCha library interface"
|
||||
depends on CRYPTO
|
||||
depends on CRYPTO_ARCH_HAVE_LIB_CHACHA || !CRYPTO_ARCH_HAVE_LIB_CHACHA
|
||||
select CRYPTO_LIB_CHACHA_GENERIC if CRYPTO_ARCH_HAVE_LIB_CHACHA=n
|
||||
help
|
||||
@@ -79,6 +70,7 @@ config CRYPTO_LIB_CURVE25519
|
||||
tristate "Curve25519 scalar multiplication library"
|
||||
depends on CRYPTO_ARCH_HAVE_LIB_CURVE25519 || !CRYPTO_ARCH_HAVE_LIB_CURVE25519
|
||||
select CRYPTO_LIB_CURVE25519_GENERIC if CRYPTO_ARCH_HAVE_LIB_CURVE25519=n
|
||||
select LIB_MEMNEQ
|
||||
help
|
||||
Enable the Curve25519 library interface. This interface may be
|
||||
fulfilled by either the generic implementation or an arch-specific
|
||||
@@ -123,8 +115,12 @@ config CRYPTO_LIB_CHACHA20POLY1305
|
||||
tristate "ChaCha20-Poly1305 AEAD support (8-byte nonce library version)"
|
||||
depends on CRYPTO_ARCH_HAVE_LIB_CHACHA || !CRYPTO_ARCH_HAVE_LIB_CHACHA
|
||||
depends on CRYPTO_ARCH_HAVE_LIB_POLY1305 || !CRYPTO_ARCH_HAVE_LIB_POLY1305
|
||||
depends on CRYPTO
|
||||
select CRYPTO_LIB_CHACHA
|
||||
select CRYPTO_LIB_POLY1305
|
||||
select CRYPTO_ALGAPI
|
||||
|
||||
config CRYPTO_LIB_SHA256
|
||||
tristate
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -10,11 +10,10 @@ libaes-y := aes.o
|
||||
obj-$(CONFIG_CRYPTO_LIB_ARC4) += libarc4.o
|
||||
libarc4-y := arc4.o
|
||||
|
||||
obj-$(CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC) += libblake2s-generic.o
|
||||
libblake2s-generic-y += blake2s-generic.o
|
||||
|
||||
obj-$(CONFIG_CRYPTO_LIB_BLAKE2S) += libblake2s.o
|
||||
libblake2s-y += blake2s.o
|
||||
# blake2s is used by the /dev/random driver which is always builtin
|
||||
obj-y += libblake2s.o
|
||||
libblake2s-y := blake2s.o
|
||||
libblake2s-$(CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC) += blake2s-generic.o
|
||||
|
||||
obj-$(CONFIG_CRYPTO_LIB_CHACHA20POLY1305) += libchacha20poly1305.o
|
||||
libchacha20poly1305-y += chacha20poly1305.o
|
||||
|
||||
@@ -37,7 +37,11 @@ static inline void blake2s_increment_counter(struct blake2s_state *state,
|
||||
state->t[1] += (state->t[0] < inc);
|
||||
}
|
||||
|
||||
void blake2s_compress_generic(struct blake2s_state *state,const u8 *block,
|
||||
void blake2s_compress(struct blake2s_state *state, const u8 *block,
|
||||
size_t nblocks, const u32 inc)
|
||||
__weak __alias(blake2s_compress_generic);
|
||||
|
||||
void blake2s_compress_generic(struct blake2s_state *state, const u8 *block,
|
||||
size_t nblocks, const u32 inc)
|
||||
{
|
||||
u32 m[16];
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
* #include <stdio.h>
|
||||
*
|
||||
* #include <openssl/evp.h>
|
||||
* #include <openssl/hmac.h>
|
||||
*
|
||||
* #define BLAKE2S_TESTVEC_COUNT 256
|
||||
*
|
||||
@@ -58,16 +57,6 @@
|
||||
* }
|
||||
* printf("};\n\n");
|
||||
*
|
||||
* printf("static const u8 blake2s_hmac_testvecs[][BLAKE2S_HASH_SIZE] __initconst = {\n");
|
||||
*
|
||||
* HMAC(EVP_blake2s256(), key, sizeof(key), buf, sizeof(buf), hash, NULL);
|
||||
* print_vec(hash, BLAKE2S_OUTBYTES);
|
||||
*
|
||||
* HMAC(EVP_blake2s256(), buf, sizeof(buf), key, sizeof(key), hash, NULL);
|
||||
* print_vec(hash, BLAKE2S_OUTBYTES);
|
||||
*
|
||||
* printf("};\n");
|
||||
*
|
||||
* return 0;
|
||||
*}
|
||||
*/
|
||||
@@ -554,15 +543,6 @@ static const u8 blake2s_testvecs[][BLAKE2S_HASH_SIZE] __initconst = {
|
||||
0xd6, 0x98, 0x6b, 0x07, 0x10, 0x65, 0x52, 0x65, },
|
||||
};
|
||||
|
||||
static const u8 blake2s_hmac_testvecs[][BLAKE2S_HASH_SIZE] __initconst = {
|
||||
{ 0xce, 0xe1, 0x57, 0x69, 0x82, 0xdc, 0xbf, 0x43, 0xad, 0x56, 0x4c, 0x70,
|
||||
0xed, 0x68, 0x16, 0x96, 0xcf, 0xa4, 0x73, 0xe8, 0xe8, 0xfc, 0x32, 0x79,
|
||||
0x08, 0x0a, 0x75, 0x82, 0xda, 0x3f, 0x05, 0x11, },
|
||||
{ 0x77, 0x2f, 0x0c, 0x71, 0x41, 0xf4, 0x4b, 0x2b, 0xb3, 0xc6, 0xb6, 0xf9,
|
||||
0x60, 0xde, 0xe4, 0x52, 0x38, 0x66, 0xe8, 0xbf, 0x9b, 0x96, 0xc4, 0x9f,
|
||||
0x60, 0xd9, 0x24, 0x37, 0x99, 0xd6, 0xec, 0x31, },
|
||||
};
|
||||
|
||||
bool __init blake2s_selftest(void)
|
||||
{
|
||||
u8 key[BLAKE2S_KEY_SIZE];
|
||||
@@ -607,16 +587,5 @@ bool __init blake2s_selftest(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (success) {
|
||||
blake2s256_hmac(hash, buf, key, sizeof(buf), sizeof(key));
|
||||
success &= !memcmp(hash, blake2s_hmac_testvecs[0], BLAKE2S_HASH_SIZE);
|
||||
|
||||
blake2s256_hmac(hash, key, buf, sizeof(key), sizeof(buf));
|
||||
success &= !memcmp(hash, blake2s_hmac_testvecs[1], BLAKE2S_HASH_SIZE);
|
||||
|
||||
if (!success)
|
||||
pr_err("blake2s256_hmac self-test: FAIL\n");
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -16,63 +16,20 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/bug.h>
|
||||
|
||||
#if IS_ENABLED(CONFIG_CRYPTO_ARCH_HAVE_LIB_BLAKE2S)
|
||||
# define blake2s_compress blake2s_compress_arch
|
||||
#else
|
||||
# define blake2s_compress blake2s_compress_generic
|
||||
#endif
|
||||
|
||||
void blake2s_update(struct blake2s_state *state, const u8 *in, size_t inlen)
|
||||
{
|
||||
__blake2s_update(state, in, inlen, blake2s_compress);
|
||||
__blake2s_update(state, in, inlen, false);
|
||||
}
|
||||
EXPORT_SYMBOL(blake2s_update);
|
||||
|
||||
void blake2s_final(struct blake2s_state *state, u8 *out)
|
||||
{
|
||||
WARN_ON(IS_ENABLED(DEBUG) && !out);
|
||||
__blake2s_final(state, out, blake2s_compress);
|
||||
__blake2s_final(state, out, false);
|
||||
memzero_explicit(state, sizeof(*state));
|
||||
}
|
||||
EXPORT_SYMBOL(blake2s_final);
|
||||
|
||||
void blake2s256_hmac(u8 *out, const u8 *in, const u8 *key, const size_t inlen,
|
||||
const size_t keylen)
|
||||
{
|
||||
struct blake2s_state state;
|
||||
u8 x_key[BLAKE2S_BLOCK_SIZE] __aligned(__alignof__(u32)) = { 0 };
|
||||
u8 i_hash[BLAKE2S_HASH_SIZE] __aligned(__alignof__(u32));
|
||||
int i;
|
||||
|
||||
if (keylen > BLAKE2S_BLOCK_SIZE) {
|
||||
blake2s_init(&state, BLAKE2S_HASH_SIZE);
|
||||
blake2s_update(&state, key, keylen);
|
||||
blake2s_final(&state, x_key);
|
||||
} else
|
||||
memcpy(x_key, key, keylen);
|
||||
|
||||
for (i = 0; i < BLAKE2S_BLOCK_SIZE; ++i)
|
||||
x_key[i] ^= 0x36;
|
||||
|
||||
blake2s_init(&state, BLAKE2S_HASH_SIZE);
|
||||
blake2s_update(&state, x_key, BLAKE2S_BLOCK_SIZE);
|
||||
blake2s_update(&state, in, inlen);
|
||||
blake2s_final(&state, i_hash);
|
||||
|
||||
for (i = 0; i < BLAKE2S_BLOCK_SIZE; ++i)
|
||||
x_key[i] ^= 0x5c ^ 0x36;
|
||||
|
||||
blake2s_init(&state, BLAKE2S_HASH_SIZE);
|
||||
blake2s_update(&state, x_key, BLAKE2S_BLOCK_SIZE);
|
||||
blake2s_update(&state, i_hash, BLAKE2S_HASH_SIZE);
|
||||
blake2s_final(&state, i_hash);
|
||||
|
||||
memcpy(out, i_hash, BLAKE2S_HASH_SIZE);
|
||||
memzero_explicit(x_key, BLAKE2S_BLOCK_SIZE);
|
||||
memzero_explicit(i_hash, BLAKE2S_HASH_SIZE);
|
||||
}
|
||||
EXPORT_SYMBOL(blake2s256_hmac);
|
||||
|
||||
static int __init mod_init(void)
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_CRYPTO_MANAGER_DISABLE_TESTS) &&
|
||||
|
||||
@@ -12,41 +12,41 @@
|
||||
* Each profile size must be of NET_DIM_PARAMS_NUM_PROFILES
|
||||
*/
|
||||
#define NET_DIM_PARAMS_NUM_PROFILES 5
|
||||
#define NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE 256
|
||||
#define NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE 128
|
||||
#define NET_DIM_DEFAULT_RX_CQ_PKTS_FROM_EQE 256
|
||||
#define NET_DIM_DEFAULT_TX_CQ_PKTS_FROM_EQE 128
|
||||
#define NET_DIM_DEF_PROFILE_CQE 1
|
||||
#define NET_DIM_DEF_PROFILE_EQE 1
|
||||
|
||||
#define NET_DIM_RX_EQE_PROFILES { \
|
||||
{1, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \
|
||||
{8, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \
|
||||
{64, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \
|
||||
{128, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \
|
||||
{256, NET_DIM_DEFAULT_RX_CQ_MODERATION_PKTS_FROM_EQE}, \
|
||||
{.usec = 1, .pkts = NET_DIM_DEFAULT_RX_CQ_PKTS_FROM_EQE,}, \
|
||||
{.usec = 8, .pkts = NET_DIM_DEFAULT_RX_CQ_PKTS_FROM_EQE,}, \
|
||||
{.usec = 64, .pkts = NET_DIM_DEFAULT_RX_CQ_PKTS_FROM_EQE,}, \
|
||||
{.usec = 128, .pkts = NET_DIM_DEFAULT_RX_CQ_PKTS_FROM_EQE,}, \
|
||||
{.usec = 256, .pkts = NET_DIM_DEFAULT_RX_CQ_PKTS_FROM_EQE,} \
|
||||
}
|
||||
|
||||
#define NET_DIM_RX_CQE_PROFILES { \
|
||||
{2, 256}, \
|
||||
{8, 128}, \
|
||||
{16, 64}, \
|
||||
{32, 64}, \
|
||||
{64, 64} \
|
||||
{.usec = 2, .pkts = 256,}, \
|
||||
{.usec = 8, .pkts = 128,}, \
|
||||
{.usec = 16, .pkts = 64,}, \
|
||||
{.usec = 32, .pkts = 64,}, \
|
||||
{.usec = 64, .pkts = 64,} \
|
||||
}
|
||||
|
||||
#define NET_DIM_TX_EQE_PROFILES { \
|
||||
{1, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \
|
||||
{8, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \
|
||||
{32, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \
|
||||
{64, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE}, \
|
||||
{128, NET_DIM_DEFAULT_TX_CQ_MODERATION_PKTS_FROM_EQE} \
|
||||
{.usec = 1, .pkts = NET_DIM_DEFAULT_TX_CQ_PKTS_FROM_EQE,}, \
|
||||
{.usec = 8, .pkts = NET_DIM_DEFAULT_TX_CQ_PKTS_FROM_EQE,}, \
|
||||
{.usec = 32, .pkts = NET_DIM_DEFAULT_TX_CQ_PKTS_FROM_EQE,}, \
|
||||
{.usec = 64, .pkts = NET_DIM_DEFAULT_TX_CQ_PKTS_FROM_EQE,}, \
|
||||
{.usec = 128, .pkts = NET_DIM_DEFAULT_TX_CQ_PKTS_FROM_EQE,} \
|
||||
}
|
||||
|
||||
#define NET_DIM_TX_CQE_PROFILES { \
|
||||
{5, 128}, \
|
||||
{8, 64}, \
|
||||
{16, 32}, \
|
||||
{32, 32}, \
|
||||
{64, 32} \
|
||||
{.usec = 5, .pkts = 128,}, \
|
||||
{.usec = 8, .pkts = 64,}, \
|
||||
{.usec = 16, .pkts = 32,}, \
|
||||
{.usec = 32, .pkts = 32,}, \
|
||||
{.usec = 64, .pkts = 32,} \
|
||||
}
|
||||
|
||||
static const struct dim_cq_moder
|
||||
|
||||
@@ -207,10 +207,11 @@ static int ddebug_change(const struct ddebug_query *query,
|
||||
continue;
|
||||
#ifdef CONFIG_JUMP_LABEL
|
||||
if (dp->flags & _DPRINTK_FLAGS_PRINT) {
|
||||
if (!(modifiers->flags & _DPRINTK_FLAGS_PRINT))
|
||||
if (!(newflags & _DPRINTK_FLAGS_PRINT))
|
||||
static_branch_disable(&dp->key.dd_key_true);
|
||||
} else if (modifiers->flags & _DPRINTK_FLAGS_PRINT)
|
||||
} else if (newflags & _DPRINTK_FLAGS_PRINT) {
|
||||
static_branch_enable(&dp->key.dd_key_true);
|
||||
}
|
||||
#endif
|
||||
dp->flags = newflags;
|
||||
v2pr_info("changed %s:%d [%s]%s =%s\n",
|
||||
@@ -379,10 +380,6 @@ static int ddebug_parse_query(char *words[], int nwords,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (modname)
|
||||
/* support $modname.dyndbg=<multiple queries> */
|
||||
query->module = modname;
|
||||
|
||||
for (i = 0; i < nwords; i += 2) {
|
||||
char *keyword = words[i];
|
||||
char *arg = words[i+1];
|
||||
@@ -423,6 +420,13 @@ static int ddebug_parse_query(char *words[], int nwords,
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
if (!query->module && modname)
|
||||
/*
|
||||
* support $modname.dyndbg=<multiple queries>, when
|
||||
* not given in the query itself
|
||||
*/
|
||||
query->module = modname;
|
||||
|
||||
vpr_info_dq(query, "parsed");
|
||||
return 0;
|
||||
}
|
||||
@@ -548,35 +552,6 @@ static int ddebug_exec_queries(char *query, const char *modname)
|
||||
return nfound;
|
||||
}
|
||||
|
||||
/**
|
||||
* dynamic_debug_exec_queries - select and change dynamic-debug prints
|
||||
* @query: query-string described in admin-guide/dynamic-debug-howto
|
||||
* @modname: string containing module name, usually &module.mod_name
|
||||
*
|
||||
* This uses the >/proc/dynamic_debug/control reader, allowing module
|
||||
* authors to modify their dynamic-debug callsites. The modname is
|
||||
* canonically struct module.mod_name, but can also be null or a
|
||||
* module-wildcard, for example: "drm*".
|
||||
*/
|
||||
int dynamic_debug_exec_queries(const char *query, const char *modname)
|
||||
{
|
||||
int rc;
|
||||
char *qry; /* writable copy of query */
|
||||
|
||||
if (!query) {
|
||||
pr_err("non-null query/command string expected\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
qry = kstrndup(query, PAGE_SIZE, GFP_KERNEL);
|
||||
if (!qry)
|
||||
return -ENOMEM;
|
||||
|
||||
rc = ddebug_exec_queries(qry, modname);
|
||||
kfree(qry);
|
||||
return rc;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dynamic_debug_exec_queries);
|
||||
|
||||
#define PREFIX_SIZE 64
|
||||
|
||||
static int remaining(int wrote)
|
||||
|
||||
@@ -22,15 +22,41 @@ EXPORT_SYMBOL(hex_asc_upper);
|
||||
*
|
||||
* hex_to_bin() converts one hex digit to its actual value or -1 in case of bad
|
||||
* input.
|
||||
*
|
||||
* This function is used to load cryptographic keys, so it is coded in such a
|
||||
* way that there are no conditions or memory accesses that depend on data.
|
||||
*
|
||||
* Explanation of the logic:
|
||||
* (ch - '9' - 1) is negative if ch <= '9'
|
||||
* ('0' - 1 - ch) is negative if ch >= '0'
|
||||
* we "and" these two values, so the result is negative if ch is in the range
|
||||
* '0' ... '9'
|
||||
* we are only interested in the sign, so we do a shift ">> 8"; note that right
|
||||
* shift of a negative value is implementation-defined, so we cast the
|
||||
* value to (unsigned) before the shift --- we have 0xffffff if ch is in
|
||||
* the range '0' ... '9', 0 otherwise
|
||||
* we "and" this value with (ch - '0' + 1) --- we have a value 1 ... 10 if ch is
|
||||
* in the range '0' ... '9', 0 otherwise
|
||||
* we add this value to -1 --- we have a value 0 ... 9 if ch is in the range '0'
|
||||
* ... '9', -1 otherwise
|
||||
* the next line is similar to the previous one, but we need to decode both
|
||||
* uppercase and lowercase letters, so we use (ch & 0xdf), which converts
|
||||
* lowercase to uppercase
|
||||
*/
|
||||
/*
|
||||
* perserve abi due to 15b78a8e38e8 ("hex2bin: make the function hex_to_bin
|
||||
* constant-time"
|
||||
*/
|
||||
#ifdef __GENKSYMS__
|
||||
int hex_to_bin(char ch)
|
||||
#else
|
||||
int hex_to_bin(unsigned char ch)
|
||||
#endif
|
||||
{
|
||||
if ((ch >= '0') && (ch <= '9'))
|
||||
return ch - '0';
|
||||
ch = tolower(ch);
|
||||
if ((ch >= 'a') && (ch <= 'f'))
|
||||
return ch - 'a' + 10;
|
||||
return -1;
|
||||
unsigned char cu = ch & 0xdf;
|
||||
return -1 +
|
||||
((ch - '0' + 1) & (unsigned)((ch - '9' - 1) & ('0' - 1 - ch)) >> 8) +
|
||||
((cu - 'A' + 11) & (unsigned)((cu - 'F' - 1) & ('A' - 1 - cu)) >> 8);
|
||||
}
|
||||
EXPORT_SYMBOL(hex_to_bin);
|
||||
|
||||
@@ -45,10 +71,13 @@ EXPORT_SYMBOL(hex_to_bin);
|
||||
int hex2bin(u8 *dst, const char *src, size_t count)
|
||||
{
|
||||
while (count--) {
|
||||
int hi = hex_to_bin(*src++);
|
||||
int lo = hex_to_bin(*src++);
|
||||
int hi, lo;
|
||||
|
||||
if ((hi < 0) || (lo < 0))
|
||||
hi = hex_to_bin(*src++);
|
||||
if (unlikely(hi < 0))
|
||||
return -EINVAL;
|
||||
lo = hex_to_bin(*src++);
|
||||
if (unlikely(lo < 0))
|
||||
return -EINVAL;
|
||||
|
||||
*dst++ = (hi << 4) | lo;
|
||||
|
||||
@@ -491,7 +491,8 @@ void ida_free(struct ida *ida, unsigned int id)
|
||||
struct ida_bitmap *bitmap;
|
||||
unsigned long flags;
|
||||
|
||||
BUG_ON((int)id < 0);
|
||||
if ((int)id < 0)
|
||||
return;
|
||||
|
||||
xas_lock_irqsave(&xas, flags);
|
||||
bitmap = xas_load(&xas);
|
||||
|
||||
@@ -1836,24 +1836,38 @@ int import_single_range(int rw, void __user *buf, size_t len,
|
||||
}
|
||||
EXPORT_SYMBOL(import_single_range);
|
||||
|
||||
int iov_iter_for_each_range(struct iov_iter *i, size_t bytes,
|
||||
int (*f)(struct kvec *vec, void *context),
|
||||
void *context)
|
||||
/**
|
||||
* iov_iter_restore() - Restore a &struct iov_iter to the same state as when
|
||||
* iov_iter_save_state() was called.
|
||||
*
|
||||
* @i: &struct iov_iter to restore
|
||||
* @state: state to restore from
|
||||
*
|
||||
* Used after iov_iter_save_state() to bring restore @i, if operations may
|
||||
* have advanced it.
|
||||
*
|
||||
* Note: only works on ITER_IOVEC, ITER_BVEC, and ITER_KVEC
|
||||
*/
|
||||
void iov_iter_restore(struct iov_iter *i, struct iov_iter_state *state)
|
||||
{
|
||||
struct kvec w;
|
||||
int err = -EINVAL;
|
||||
if (!bytes)
|
||||
return 0;
|
||||
|
||||
iterate_all_kinds(i, bytes, v, -EINVAL, ({
|
||||
w.iov_base = kmap(v.bv_page) + v.bv_offset;
|
||||
w.iov_len = v.bv_len;
|
||||
err = f(&w, context);
|
||||
kunmap(v.bv_page);
|
||||
err;}), ({
|
||||
w = v;
|
||||
err = f(&w, context);})
|
||||
)
|
||||
return err;
|
||||
if (WARN_ON_ONCE(!iov_iter_is_bvec(i) && !iter_is_iovec(i)) &&
|
||||
!iov_iter_is_kvec(i))
|
||||
return;
|
||||
i->iov_offset = state->iov_offset;
|
||||
i->count = state->count;
|
||||
/*
|
||||
* For the *vec iters, nr_segs + iov is constant - if we increment
|
||||
* the vec, then we also decrement the nr_segs count. Hence we don't
|
||||
* need to track both of these, just one is enough and we can deduct
|
||||
* the other from that. ITER_KVEC and ITER_IOVEC are the same struct
|
||||
* size, so we can just increment the iov pointer as they are unionzed.
|
||||
* ITER_BVEC _may_ be the same size on some archs, but on others it is
|
||||
* not. Be safe and handle it separately.
|
||||
*/
|
||||
BUILD_BUG_ON(sizeof(struct iovec) != sizeof(struct kvec));
|
||||
if (iov_iter_is_bvec(i))
|
||||
i->bvec -= state->nr_segs - i->nr_segs;
|
||||
else
|
||||
i->iov -= state->nr_segs - i->nr_segs;
|
||||
i->nr_segs = state->nr_segs;
|
||||
}
|
||||
EXPORT_SYMBOL(iov_iter_for_each_range);
|
||||
|
||||
@@ -20,7 +20,11 @@
|
||||
bool __list_add_valid(struct list_head *new, struct list_head *prev,
|
||||
struct list_head *next)
|
||||
{
|
||||
if (CHECK_DATA_CORRUPTION(next->prev != prev,
|
||||
if (CHECK_DATA_CORRUPTION(prev == NULL,
|
||||
"list_add corruption. prev is NULL.\n") ||
|
||||
CHECK_DATA_CORRUPTION(next == NULL,
|
||||
"list_add corruption. next is NULL.\n") ||
|
||||
CHECK_DATA_CORRUPTION(next->prev != prev,
|
||||
"list_add corruption. next->prev should be prev (%px), but was %px. (next=%px).\n",
|
||||
prev, next->prev, next) ||
|
||||
CHECK_DATA_CORRUPTION(prev->next != next,
|
||||
@@ -42,7 +46,11 @@ bool __list_del_entry_valid(struct list_head *entry)
|
||||
prev = entry->prev;
|
||||
next = entry->next;
|
||||
|
||||
if (CHECK_DATA_CORRUPTION(next == LIST_POISON1,
|
||||
if (CHECK_DATA_CORRUPTION(next == NULL,
|
||||
"list_del corruption, %px->next is NULL\n", entry) ||
|
||||
CHECK_DATA_CORRUPTION(prev == NULL,
|
||||
"list_del corruption, %px->prev is NULL\n", entry) ||
|
||||
CHECK_DATA_CORRUPTION(next == LIST_POISON1,
|
||||
"list_del corruption, %px->next is LIST_POISON1 (%px)\n",
|
||||
entry, LIST_POISON1) ||
|
||||
CHECK_DATA_CORRUPTION(prev == LIST_POISON2,
|
||||
|
||||
@@ -16,10 +16,12 @@ MODULE_PARM_DESC(block_transition, "block_transition (default=false)");
|
||||
|
||||
static void busymod_work_func(struct work_struct *work);
|
||||
static DECLARE_WORK(work, busymod_work_func);
|
||||
static DECLARE_COMPLETION(busymod_work_started);
|
||||
|
||||
static void busymod_work_func(struct work_struct *work)
|
||||
{
|
||||
pr_info("%s enter\n", __func__);
|
||||
complete(&busymod_work_started);
|
||||
|
||||
while (READ_ONCE(block_transition)) {
|
||||
/*
|
||||
@@ -37,6 +39,12 @@ static int test_klp_callbacks_busy_init(void)
|
||||
pr_info("%s\n", __func__);
|
||||
schedule_work(&work);
|
||||
|
||||
/*
|
||||
* To synchronize kernel messages, hold the init function from
|
||||
* exiting until the work function's entry message has printed.
|
||||
*/
|
||||
wait_for_completion(&busymod_work_started);
|
||||
|
||||
if (!block_transition) {
|
||||
/*
|
||||
* Serialize output: print all messages from the work
|
||||
|
||||
@@ -271,8 +271,12 @@ static FORCE_INLINE int LZ4_decompress_generic(
|
||||
ip += length;
|
||||
op += length;
|
||||
|
||||
/* Necessarily EOF, due to parsing restrictions */
|
||||
if (!partialDecoding || (cpy == oend))
|
||||
/* Necessarily EOF when !partialDecoding.
|
||||
* When partialDecoding, it is EOF if we've either
|
||||
* filled the output buffer or
|
||||
* can't proceed with reading an offset for following match.
|
||||
*/
|
||||
if (!partialDecoding || (cpy == oend) || (ip >= (iend - 2)))
|
||||
break;
|
||||
} else {
|
||||
/* may overwrite up to WILDCOPYLENGTH beyond cpy */
|
||||
|
||||
168
sysdrv/source/kernel/lib/memneq.c
Normal file
168
sysdrv/source/kernel/lib/memneq.c
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Constant-time equality testing of memory regions.
|
||||
*
|
||||
* Authors:
|
||||
*
|
||||
* James Yonan <james@openvpn.net>
|
||||
* Daniel Borkmann <dborkman@redhat.com>
|
||||
*
|
||||
* This file is provided under a dual BSD/GPLv2 license. When using or
|
||||
* redistributing this file, you may do so under either license.
|
||||
*
|
||||
* GPL LICENSE SUMMARY
|
||||
*
|
||||
* Copyright(c) 2013 OpenVPN Technologies, Inc. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* The full GNU General Public License is included in this distribution
|
||||
* in the file called LICENSE.GPL.
|
||||
*
|
||||
* BSD LICENSE
|
||||
*
|
||||
* Copyright(c) 2013 OpenVPN Technologies, Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of OpenVPN Technologies nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <crypto/algapi.h>
|
||||
|
||||
#ifndef __HAVE_ARCH_CRYPTO_MEMNEQ
|
||||
|
||||
/* Generic path for arbitrary size */
|
||||
static inline unsigned long
|
||||
__crypto_memneq_generic(const void *a, const void *b, size_t size)
|
||||
{
|
||||
unsigned long neq = 0;
|
||||
|
||||
#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
|
||||
while (size >= sizeof(unsigned long)) {
|
||||
neq |= *(unsigned long *)a ^ *(unsigned long *)b;
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
a += sizeof(unsigned long);
|
||||
b += sizeof(unsigned long);
|
||||
size -= sizeof(unsigned long);
|
||||
}
|
||||
#endif /* CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */
|
||||
while (size > 0) {
|
||||
neq |= *(unsigned char *)a ^ *(unsigned char *)b;
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
a += 1;
|
||||
b += 1;
|
||||
size -= 1;
|
||||
}
|
||||
return neq;
|
||||
}
|
||||
|
||||
/* Loop-free fast-path for frequently used 16-byte size */
|
||||
static inline unsigned long __crypto_memneq_16(const void *a, const void *b)
|
||||
{
|
||||
unsigned long neq = 0;
|
||||
|
||||
#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
|
||||
if (sizeof(unsigned long) == 8) {
|
||||
neq |= *(unsigned long *)(a) ^ *(unsigned long *)(b);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
neq |= *(unsigned long *)(a+8) ^ *(unsigned long *)(b+8);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
} else if (sizeof(unsigned int) == 4) {
|
||||
neq |= *(unsigned int *)(a) ^ *(unsigned int *)(b);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
neq |= *(unsigned int *)(a+4) ^ *(unsigned int *)(b+4);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
neq |= *(unsigned int *)(a+8) ^ *(unsigned int *)(b+8);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
neq |= *(unsigned int *)(a+12) ^ *(unsigned int *)(b+12);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
} else
|
||||
#endif /* CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */
|
||||
{
|
||||
neq |= *(unsigned char *)(a) ^ *(unsigned char *)(b);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
neq |= *(unsigned char *)(a+1) ^ *(unsigned char *)(b+1);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
neq |= *(unsigned char *)(a+2) ^ *(unsigned char *)(b+2);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
neq |= *(unsigned char *)(a+3) ^ *(unsigned char *)(b+3);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
neq |= *(unsigned char *)(a+4) ^ *(unsigned char *)(b+4);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
neq |= *(unsigned char *)(a+5) ^ *(unsigned char *)(b+5);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
neq |= *(unsigned char *)(a+6) ^ *(unsigned char *)(b+6);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
neq |= *(unsigned char *)(a+7) ^ *(unsigned char *)(b+7);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
neq |= *(unsigned char *)(a+8) ^ *(unsigned char *)(b+8);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
neq |= *(unsigned char *)(a+9) ^ *(unsigned char *)(b+9);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
neq |= *(unsigned char *)(a+10) ^ *(unsigned char *)(b+10);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
neq |= *(unsigned char *)(a+11) ^ *(unsigned char *)(b+11);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
neq |= *(unsigned char *)(a+12) ^ *(unsigned char *)(b+12);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
neq |= *(unsigned char *)(a+13) ^ *(unsigned char *)(b+13);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
neq |= *(unsigned char *)(a+14) ^ *(unsigned char *)(b+14);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
neq |= *(unsigned char *)(a+15) ^ *(unsigned char *)(b+15);
|
||||
OPTIMIZER_HIDE_VAR(neq);
|
||||
}
|
||||
|
||||
return neq;
|
||||
}
|
||||
|
||||
/* Compare two areas of memory without leaking timing information,
|
||||
* and with special optimizations for common sizes. Users should
|
||||
* not call this function directly, but should instead use
|
||||
* crypto_memneq defined in crypto/algapi.h.
|
||||
*/
|
||||
noinline unsigned long __crypto_memneq(const void *a, const void *b,
|
||||
size_t size)
|
||||
{
|
||||
switch (size) {
|
||||
case 16:
|
||||
return __crypto_memneq_16(a, b);
|
||||
default:
|
||||
return __crypto_memneq_generic(a, b, size);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(__crypto_memneq);
|
||||
|
||||
#endif /* __HAVE_ARCH_CRYPTO_MEMNEQ */
|
||||
@@ -3,9 +3,9 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/random.h>
|
||||
|
||||
int __next_node_in(int node, const nodemask_t *srcp)
|
||||
unsigned int __next_node_in(int node, const nodemask_t *srcp)
|
||||
{
|
||||
int ret = __next_node(node, srcp);
|
||||
unsigned int ret = __next_node(node, srcp);
|
||||
|
||||
if (ret == MAX_NUMNODES)
|
||||
ret = __first_node(srcp);
|
||||
|
||||
@@ -61,3 +61,33 @@ void __do_once_done(bool *done, struct static_key_true *once_key,
|
||||
once_disable_jump(once_key);
|
||||
}
|
||||
EXPORT_SYMBOL(__do_once_done);
|
||||
|
||||
static DEFINE_MUTEX(once_mutex);
|
||||
|
||||
bool __do_once_slow_start(bool *done)
|
||||
__acquires(once_mutex)
|
||||
{
|
||||
mutex_lock(&once_mutex);
|
||||
if (*done) {
|
||||
mutex_unlock(&once_mutex);
|
||||
/* Keep sparse happy by restoring an even lock count on
|
||||
* this mutex. In case we return here, we don't call into
|
||||
* __do_once_done but return early in the DO_ONCE_SLOW() macro.
|
||||
*/
|
||||
__acquire(once_mutex);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
EXPORT_SYMBOL(__do_once_slow_start);
|
||||
|
||||
void __do_once_slow_done(bool *done, struct static_key_true *once_key,
|
||||
struct module *mod)
|
||||
__releases(once_mutex)
|
||||
{
|
||||
*done = true;
|
||||
mutex_unlock(&once_mutex);
|
||||
once_disable_jump(once_key);
|
||||
}
|
||||
EXPORT_SYMBOL(__do_once_slow_done);
|
||||
|
||||
@@ -75,6 +75,7 @@ int percpu_ref_init(struct percpu_ref *ref, percpu_ref_func_t *release,
|
||||
data = kzalloc(sizeof(*ref->data), gfp);
|
||||
if (!data) {
|
||||
free_percpu((void __percpu *)ref->percpu_count_ptr);
|
||||
ref->percpu_count_ptr = 0;
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,9 @@
|
||||
#include <linux/random.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/notifier.h>
|
||||
#include <asm/unaligned.h>
|
||||
#include <trace/events/random.h>
|
||||
|
||||
/**
|
||||
* prandom_u32_state - seeded pseudo-random number generator.
|
||||
@@ -386,7 +387,6 @@ u32 prandom_u32(void)
|
||||
struct siprand_state *state = get_cpu_ptr(&net_rand_state);
|
||||
u32 res = siprand_u32(state);
|
||||
|
||||
trace_prandom_u32(res);
|
||||
put_cpu_ptr(&net_rand_state);
|
||||
return res;
|
||||
}
|
||||
@@ -552,9 +552,11 @@ static void prandom_reseed(struct timer_list *unused)
|
||||
* To avoid worrying about whether it's safe to delay that interrupt
|
||||
* long enough to seed all CPUs, just schedule an immediate timer event.
|
||||
*/
|
||||
static void prandom_timer_start(struct random_ready_callback *unused)
|
||||
static int prandom_timer_start(struct notifier_block *nb,
|
||||
unsigned long action, void *data)
|
||||
{
|
||||
mod_timer(&seed_timer, jiffies);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_RANDOM32_SELFTEST
|
||||
@@ -618,13 +620,13 @@ core_initcall(prandom32_state_selftest);
|
||||
*/
|
||||
static int __init prandom_init_late(void)
|
||||
{
|
||||
static struct random_ready_callback random_ready = {
|
||||
.func = prandom_timer_start
|
||||
static struct notifier_block random_ready = {
|
||||
.notifier_call = prandom_timer_start
|
||||
};
|
||||
int ret = add_random_ready_callback(&random_ready);
|
||||
int ret = register_random_ready_notifier(&random_ready);
|
||||
|
||||
if (ret == -EALREADY) {
|
||||
prandom_timer_start(&random_ready);
|
||||
prandom_timer_start(&random_ready, 0, NULL);
|
||||
ret = 0;
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -26,10 +26,16 @@
|
||||
*/
|
||||
int ___ratelimit(struct ratelimit_state *rs, const char *func)
|
||||
{
|
||||
/* Paired with WRITE_ONCE() in .proc_handler().
|
||||
* Changing two values seperately could be inconsistent
|
||||
* and some message could be lost. (See: net_ratelimit_state).
|
||||
*/
|
||||
int interval = READ_ONCE(rs->interval);
|
||||
int burst = READ_ONCE(rs->burst);
|
||||
unsigned long flags;
|
||||
int ret;
|
||||
|
||||
if (!rs->interval)
|
||||
if (!interval)
|
||||
return 1;
|
||||
|
||||
/*
|
||||
@@ -44,7 +50,7 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func)
|
||||
if (!rs->begin)
|
||||
rs->begin = jiffies;
|
||||
|
||||
if (time_is_before_jiffies(rs->begin + rs->interval)) {
|
||||
if (time_is_before_jiffies(rs->begin + interval)) {
|
||||
if (rs->missed) {
|
||||
if (!(rs->flags & RATELIMIT_MSG_ON_RELEASE)) {
|
||||
printk_deferred(KERN_WARNING
|
||||
@@ -56,7 +62,7 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func)
|
||||
rs->begin = jiffies;
|
||||
rs->printed = 0;
|
||||
}
|
||||
if (rs->burst && rs->burst > rs->printed) {
|
||||
if (burst && burst > rs->printed) {
|
||||
rs->printed++;
|
||||
ret = 1;
|
||||
} else {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/export.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/string.h>
|
||||
#include <crypto/sha.h>
|
||||
#include <asm/unaligned.h>
|
||||
|
||||
@@ -55,7 +56,8 @@
|
||||
#define SHA_ROUND(t, input, fn, constant, A, B, C, D, E) do { \
|
||||
__u32 TEMP = input(t); setW(t, TEMP); \
|
||||
E += TEMP + rol32(A,5) + (fn) + (constant); \
|
||||
B = ror32(B, 2); } while (0)
|
||||
B = ror32(B, 2); \
|
||||
TEMP = E; E = D; D = C; C = B; B = A; A = TEMP; } while (0)
|
||||
|
||||
#define T_0_15(t, A, B, C, D, E) SHA_ROUND(t, SHA_SRC, (((C^D)&B)^D) , 0x5a827999, A, B, C, D, E )
|
||||
#define T_16_19(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (((C^D)&B)^D) , 0x5a827999, A, B, C, D, E )
|
||||
@@ -84,6 +86,7 @@
|
||||
void sha1_transform(__u32 *digest, const char *data, __u32 *array)
|
||||
{
|
||||
__u32 A, B, C, D, E;
|
||||
unsigned int i = 0;
|
||||
|
||||
A = digest[0];
|
||||
B = digest[1];
|
||||
@@ -92,94 +95,24 @@ void sha1_transform(__u32 *digest, const char *data, __u32 *array)
|
||||
E = digest[4];
|
||||
|
||||
/* Round 1 - iterations 0-16 take their input from 'data' */
|
||||
T_0_15( 0, A, B, C, D, E);
|
||||
T_0_15( 1, E, A, B, C, D);
|
||||
T_0_15( 2, D, E, A, B, C);
|
||||
T_0_15( 3, C, D, E, A, B);
|
||||
T_0_15( 4, B, C, D, E, A);
|
||||
T_0_15( 5, A, B, C, D, E);
|
||||
T_0_15( 6, E, A, B, C, D);
|
||||
T_0_15( 7, D, E, A, B, C);
|
||||
T_0_15( 8, C, D, E, A, B);
|
||||
T_0_15( 9, B, C, D, E, A);
|
||||
T_0_15(10, A, B, C, D, E);
|
||||
T_0_15(11, E, A, B, C, D);
|
||||
T_0_15(12, D, E, A, B, C);
|
||||
T_0_15(13, C, D, E, A, B);
|
||||
T_0_15(14, B, C, D, E, A);
|
||||
T_0_15(15, A, B, C, D, E);
|
||||
for (; i < 16; ++i)
|
||||
T_0_15(i, A, B, C, D, E);
|
||||
|
||||
/* Round 1 - tail. Input from 512-bit mixing array */
|
||||
T_16_19(16, E, A, B, C, D);
|
||||
T_16_19(17, D, E, A, B, C);
|
||||
T_16_19(18, C, D, E, A, B);
|
||||
T_16_19(19, B, C, D, E, A);
|
||||
for (; i < 20; ++i)
|
||||
T_16_19(i, A, B, C, D, E);
|
||||
|
||||
/* Round 2 */
|
||||
T_20_39(20, A, B, C, D, E);
|
||||
T_20_39(21, E, A, B, C, D);
|
||||
T_20_39(22, D, E, A, B, C);
|
||||
T_20_39(23, C, D, E, A, B);
|
||||
T_20_39(24, B, C, D, E, A);
|
||||
T_20_39(25, A, B, C, D, E);
|
||||
T_20_39(26, E, A, B, C, D);
|
||||
T_20_39(27, D, E, A, B, C);
|
||||
T_20_39(28, C, D, E, A, B);
|
||||
T_20_39(29, B, C, D, E, A);
|
||||
T_20_39(30, A, B, C, D, E);
|
||||
T_20_39(31, E, A, B, C, D);
|
||||
T_20_39(32, D, E, A, B, C);
|
||||
T_20_39(33, C, D, E, A, B);
|
||||
T_20_39(34, B, C, D, E, A);
|
||||
T_20_39(35, A, B, C, D, E);
|
||||
T_20_39(36, E, A, B, C, D);
|
||||
T_20_39(37, D, E, A, B, C);
|
||||
T_20_39(38, C, D, E, A, B);
|
||||
T_20_39(39, B, C, D, E, A);
|
||||
for (; i < 40; ++i)
|
||||
T_20_39(i, A, B, C, D, E);
|
||||
|
||||
/* Round 3 */
|
||||
T_40_59(40, A, B, C, D, E);
|
||||
T_40_59(41, E, A, B, C, D);
|
||||
T_40_59(42, D, E, A, B, C);
|
||||
T_40_59(43, C, D, E, A, B);
|
||||
T_40_59(44, B, C, D, E, A);
|
||||
T_40_59(45, A, B, C, D, E);
|
||||
T_40_59(46, E, A, B, C, D);
|
||||
T_40_59(47, D, E, A, B, C);
|
||||
T_40_59(48, C, D, E, A, B);
|
||||
T_40_59(49, B, C, D, E, A);
|
||||
T_40_59(50, A, B, C, D, E);
|
||||
T_40_59(51, E, A, B, C, D);
|
||||
T_40_59(52, D, E, A, B, C);
|
||||
T_40_59(53, C, D, E, A, B);
|
||||
T_40_59(54, B, C, D, E, A);
|
||||
T_40_59(55, A, B, C, D, E);
|
||||
T_40_59(56, E, A, B, C, D);
|
||||
T_40_59(57, D, E, A, B, C);
|
||||
T_40_59(58, C, D, E, A, B);
|
||||
T_40_59(59, B, C, D, E, A);
|
||||
for (; i < 60; ++i)
|
||||
T_40_59(i, A, B, C, D, E);
|
||||
|
||||
/* Round 4 */
|
||||
T_60_79(60, A, B, C, D, E);
|
||||
T_60_79(61, E, A, B, C, D);
|
||||
T_60_79(62, D, E, A, B, C);
|
||||
T_60_79(63, C, D, E, A, B);
|
||||
T_60_79(64, B, C, D, E, A);
|
||||
T_60_79(65, A, B, C, D, E);
|
||||
T_60_79(66, E, A, B, C, D);
|
||||
T_60_79(67, D, E, A, B, C);
|
||||
T_60_79(68, C, D, E, A, B);
|
||||
T_60_79(69, B, C, D, E, A);
|
||||
T_60_79(70, A, B, C, D, E);
|
||||
T_60_79(71, E, A, B, C, D);
|
||||
T_60_79(72, D, E, A, B, C);
|
||||
T_60_79(73, C, D, E, A, B);
|
||||
T_60_79(74, B, C, D, E, A);
|
||||
T_60_79(75, A, B, C, D, E);
|
||||
T_60_79(76, E, A, B, C, D);
|
||||
T_60_79(77, D, E, A, B, C);
|
||||
T_60_79(78, C, D, E, A, B);
|
||||
T_60_79(79, B, C, D, E, A);
|
||||
for (; i < 80; ++i)
|
||||
T_60_79(i, A, B, C, D, E);
|
||||
|
||||
digest[0] += A;
|
||||
digest[1] += B;
|
||||
|
||||
@@ -18,19 +18,13 @@
|
||||
#include <asm/word-at-a-time.h>
|
||||
#endif
|
||||
|
||||
#define SIPROUND \
|
||||
do { \
|
||||
v0 += v1; v1 = rol64(v1, 13); v1 ^= v0; v0 = rol64(v0, 32); \
|
||||
v2 += v3; v3 = rol64(v3, 16); v3 ^= v2; \
|
||||
v0 += v3; v3 = rol64(v3, 21); v3 ^= v0; \
|
||||
v2 += v1; v1 = rol64(v1, 17); v1 ^= v2; v2 = rol64(v2, 32); \
|
||||
} while (0)
|
||||
#define SIPROUND SIPHASH_PERMUTATION(v0, v1, v2, v3)
|
||||
|
||||
#define PREAMBLE(len) \
|
||||
u64 v0 = 0x736f6d6570736575ULL; \
|
||||
u64 v1 = 0x646f72616e646f6dULL; \
|
||||
u64 v2 = 0x6c7967656e657261ULL; \
|
||||
u64 v3 = 0x7465646279746573ULL; \
|
||||
u64 v0 = SIPHASH_CONST_0; \
|
||||
u64 v1 = SIPHASH_CONST_1; \
|
||||
u64 v2 = SIPHASH_CONST_2; \
|
||||
u64 v3 = SIPHASH_CONST_3; \
|
||||
u64 b = ((u64)(len)) << 56; \
|
||||
v3 ^= key->key[1]; \
|
||||
v2 ^= key->key[0]; \
|
||||
@@ -389,19 +383,13 @@ u32 hsiphash_4u32(const u32 first, const u32 second, const u32 third,
|
||||
}
|
||||
EXPORT_SYMBOL(hsiphash_4u32);
|
||||
#else
|
||||
#define HSIPROUND \
|
||||
do { \
|
||||
v0 += v1; v1 = rol32(v1, 5); v1 ^= v0; v0 = rol32(v0, 16); \
|
||||
v2 += v3; v3 = rol32(v3, 8); v3 ^= v2; \
|
||||
v0 += v3; v3 = rol32(v3, 7); v3 ^= v0; \
|
||||
v2 += v1; v1 = rol32(v1, 13); v1 ^= v2; v2 = rol32(v2, 16); \
|
||||
} while (0)
|
||||
#define HSIPROUND HSIPHASH_PERMUTATION(v0, v1, v2, v3)
|
||||
|
||||
#define HPREAMBLE(len) \
|
||||
u32 v0 = 0; \
|
||||
u32 v1 = 0; \
|
||||
u32 v2 = 0x6c796765U; \
|
||||
u32 v3 = 0x74656462U; \
|
||||
u32 v0 = HSIPHASH_CONST_0; \
|
||||
u32 v1 = HSIPHASH_CONST_1; \
|
||||
u32 v2 = HSIPHASH_CONST_2; \
|
||||
u32 v3 = HSIPHASH_CONST_3; \
|
||||
u32 b = ((u32)(len)) << 24; \
|
||||
v3 ^= key->key[1]; \
|
||||
v2 ^= key->key[0]; \
|
||||
|
||||
@@ -46,9 +46,9 @@ unsigned int check_preemption_disabled(const char *what1, const char *what2)
|
||||
|
||||
printk("caller is %pS\n", __builtin_return_address(0));
|
||||
dump_stack();
|
||||
instrumentation_end();
|
||||
|
||||
out_enable:
|
||||
instrumentation_end();
|
||||
preempt_enable_no_resched_notrace();
|
||||
out:
|
||||
return this_cpu;
|
||||
|
||||
@@ -6918,9 +6918,9 @@ static struct skb_segment_test skb_segment_tests[] __initconst = {
|
||||
.build_skb = build_test_skb_linear_no_head_frag,
|
||||
.features = NETIF_F_SG | NETIF_F_FRAGLIST |
|
||||
NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_GSO |
|
||||
NETIF_F_LLTX_BIT | NETIF_F_GRO |
|
||||
NETIF_F_LLTX | NETIF_F_GRO |
|
||||
NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |
|
||||
NETIF_F_HW_VLAN_STAG_TX_BIT
|
||||
NETIF_F_HW_VLAN_STAG_TX
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -98,23 +98,11 @@ static void test_ubsan_misaligned_access(void)
|
||||
*ptr = val;
|
||||
}
|
||||
|
||||
static void test_ubsan_object_size_mismatch(void)
|
||||
{
|
||||
/* "((aligned(8)))" helps this not into be misaligned for ptr-access. */
|
||||
volatile int val __aligned(8) = 4;
|
||||
volatile long long *ptr, val2;
|
||||
|
||||
UBSAN_TEST(CONFIG_UBSAN_OBJECT_SIZE);
|
||||
ptr = (long long *)&val;
|
||||
val2 = *ptr;
|
||||
}
|
||||
|
||||
static const test_ubsan_fp test_ubsan_array[] = {
|
||||
test_ubsan_shift_out_of_bounds,
|
||||
test_ubsan_out_of_bounds,
|
||||
test_ubsan_load_invalid_value,
|
||||
test_ubsan_misaligned_access,
|
||||
test_ubsan_object_size_mismatch,
|
||||
};
|
||||
|
||||
/* Excluded because they Oops the module. */
|
||||
|
||||
@@ -17,6 +17,6 @@ $(error ARCH_REL_TYPE_ABS is not set)
|
||||
endif
|
||||
|
||||
quiet_cmd_vdso_check = VDSOCHK $@
|
||||
cmd_vdso_check = if $(OBJDUMP) -R $@ | egrep -h "$(ARCH_REL_TYPE_ABS)"; \
|
||||
cmd_vdso_check = if $(OBJDUMP) -R $@ | grep -E -h "$(ARCH_REL_TYPE_ABS)"; \
|
||||
then (echo >&2 "$@: dynamic relocations are not supported"; \
|
||||
rm -f $@; /bin/false); fi
|
||||
|
||||
@@ -46,8 +46,8 @@ static inline bool vdso_cycles_ok(u64 cycles)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIME_NS
|
||||
static int do_hres_timens(const struct vdso_data *vdns, clockid_t clk,
|
||||
struct __kernel_timespec *ts)
|
||||
static __always_inline int do_hres_timens(const struct vdso_data *vdns, clockid_t clk,
|
||||
struct __kernel_timespec *ts)
|
||||
{
|
||||
const struct vdso_data *vd = __arch_get_timens_vdso_data();
|
||||
const struct timens_offset *offs = &vdns->offset[clk];
|
||||
@@ -97,8 +97,8 @@ static __always_inline const struct vdso_data *__arch_get_timens_vdso_data(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int do_hres_timens(const struct vdso_data *vdns, clockid_t clk,
|
||||
struct __kernel_timespec *ts)
|
||||
static __always_inline int do_hres_timens(const struct vdso_data *vdns, clockid_t clk,
|
||||
struct __kernel_timespec *ts)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -159,8 +159,8 @@ static __always_inline int do_hres(const struct vdso_data *vd, clockid_t clk,
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TIME_NS
|
||||
static int do_coarse_timens(const struct vdso_data *vdns, clockid_t clk,
|
||||
struct __kernel_timespec *ts)
|
||||
static __always_inline int do_coarse_timens(const struct vdso_data *vdns, clockid_t clk,
|
||||
struct __kernel_timespec *ts)
|
||||
{
|
||||
const struct vdso_data *vd = __arch_get_timens_vdso_data();
|
||||
const struct vdso_timestamp *vdso_ts = &vd->basetime[clk];
|
||||
@@ -188,8 +188,8 @@ static int do_coarse_timens(const struct vdso_data *vdns, clockid_t clk,
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static int do_coarse_timens(const struct vdso_data *vdns, clockid_t clk,
|
||||
struct __kernel_timespec *ts)
|
||||
static __always_inline int do_coarse_timens(const struct vdso_data *vdns, clockid_t clk,
|
||||
struct __kernel_timespec *ts)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -53,6 +53,10 @@
|
||||
#include <linux/string_helpers.h>
|
||||
#include "kstrtox.h"
|
||||
|
||||
/* Disable pointer hashing if requested */
|
||||
bool no_hash_pointers __ro_after_init;
|
||||
EXPORT_SYMBOL_GPL(no_hash_pointers);
|
||||
|
||||
static unsigned long long simple_strntoull(const char *startp, size_t max_chars,
|
||||
char **endp, unsigned int base)
|
||||
{
|
||||
@@ -756,14 +760,16 @@ static void enable_ptr_key_workfn(struct work_struct *work)
|
||||
|
||||
static DECLARE_WORK(enable_ptr_key_work, enable_ptr_key_workfn);
|
||||
|
||||
static void fill_random_ptr_key(struct random_ready_callback *unused)
|
||||
static int fill_random_ptr_key(struct notifier_block *nb,
|
||||
unsigned long action, void *data)
|
||||
{
|
||||
/* This may be in an interrupt handler. */
|
||||
queue_work(system_unbound_wq, &enable_ptr_key_work);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct random_ready_callback random_ready = {
|
||||
.func = fill_random_ptr_key
|
||||
static struct notifier_block random_ready = {
|
||||
.notifier_call = fill_random_ptr_key
|
||||
};
|
||||
|
||||
static int __init initialize_ptr_random(void)
|
||||
@@ -777,7 +783,7 @@ static int __init initialize_ptr_random(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = add_random_ready_callback(&random_ready);
|
||||
ret = register_random_ready_notifier(&random_ready);
|
||||
if (!ret) {
|
||||
return 0;
|
||||
} else if (ret == -EALREADY) {
|
||||
@@ -847,6 +853,19 @@ static char *ptr_to_id(char *buf, char *end, const void *ptr,
|
||||
return pointer_string(buf, end, (const void *)hashval, spec);
|
||||
}
|
||||
|
||||
static char *default_pointer(char *buf, char *end, const void *ptr,
|
||||
struct printf_spec spec)
|
||||
{
|
||||
/*
|
||||
* default is to _not_ leak addresses, so hash before printing,
|
||||
* unless no_hash_pointers is specified on the command line.
|
||||
*/
|
||||
if (unlikely(no_hash_pointers))
|
||||
return pointer_string(buf, end, ptr, spec);
|
||||
|
||||
return ptr_to_id(buf, end, ptr, spec);
|
||||
}
|
||||
|
||||
int kptr_restrict __read_mostly;
|
||||
|
||||
static noinline_for_stack
|
||||
@@ -856,7 +875,7 @@ char *restricted_pointer(char *buf, char *end, const void *ptr,
|
||||
switch (kptr_restrict) {
|
||||
case 0:
|
||||
/* Handle as %p, hash and do _not_ leak addresses. */
|
||||
return ptr_to_id(buf, end, ptr, spec);
|
||||
return default_pointer(buf, end, ptr, spec);
|
||||
case 1: {
|
||||
const struct cred *cred;
|
||||
|
||||
@@ -2116,10 +2135,6 @@ char *fwnode_string(char *buf, char *end, struct fwnode_handle *fwnode,
|
||||
return widen_string(buf, buf - buf_start, end, spec);
|
||||
}
|
||||
|
||||
/* Disable pointer hashing if requested */
|
||||
bool no_hash_pointers __ro_after_init;
|
||||
EXPORT_SYMBOL_GPL(no_hash_pointers);
|
||||
|
||||
static int __init no_hash_pointers_enable(char *str)
|
||||
{
|
||||
no_hash_pointers = true;
|
||||
@@ -2337,7 +2352,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
|
||||
case 'e':
|
||||
/* %pe with a non-ERR_PTR gets treated as plain %p */
|
||||
if (!IS_ERR(ptr))
|
||||
break;
|
||||
return default_pointer(buf, end, ptr, spec);
|
||||
return err_ptr(buf, end, ptr, spec);
|
||||
case 'u':
|
||||
case 'k':
|
||||
@@ -2347,16 +2362,9 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
|
||||
default:
|
||||
return error_string(buf, end, "(einval)", spec);
|
||||
}
|
||||
default:
|
||||
return default_pointer(buf, end, ptr, spec);
|
||||
}
|
||||
|
||||
/*
|
||||
* default is to _not_ leak addresses, so hash before printing,
|
||||
* unless no_hash_pointers is specified on the command line.
|
||||
*/
|
||||
if (unlikely(no_hash_pointers))
|
||||
return pointer_string(buf, end, ptr, spec);
|
||||
else
|
||||
return ptr_to_id(buf, end, ptr, spec);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user