Merge branch 'android12-5.10' into android12-5.10-lts

Sync up with android12-5.10 for the following commits:

32432740cd ANDROID: GKI: Add symbols abi for USB IP kernel modules.
c27d7f71b5 ANDROID: GKI: Fix file mode on mtk abi file
ca9ee53cea UPSTREAM: erofs: fix deadlock when shrink erofs slab
898e7ec950 ANDROID: init_task: Init android vendor and oem data
3c54070823 UPSTREAM: sched/core: Mitigate race cpus_share_cache()/update_top_cache_domain()
f0a7e5394b ANDROID: Update symbol list for mtk
b943d32888 UPSTREAM: erofs: fix unsafe pagevec reuse of hooked pclusters
028f7128c4 UPSTREAM: erofs: remove the occupied parameter from z_erofs_pagevec_enqueue()
504b13fb83 UPSTREAM: usb: dwc3: gadget: Fix null pointer exception
143ac63130 ANDROID: fips140: support "evaluation testing" builds via build.sh
cbd64e25c2 FROMGIT: sched/scs: Reset task stack state in bringup_cpu()
3ed40fb65a ANDROID: dma-buf: heaps: fix dma-buf heap pool pages stat
851990cc99 ANDROID: ABI: Add several spi_mem related symbols
be30f0ce33 UPSTREAM: spi: spi-mem: add spi_mem_dtr_supports_op()
e5dfa89138 ANDROID: gki_defconfig: enable CONFIG_SPI_MEM
bb18be4257 ANDROID: ABI: Add several iio related symbols
1407b7e124 ANDROID: ABI: Update symbol list for IMX
575a552ac7 ANDROID: usb: gadget: f_accessory: Mitgate handling of non-existent USB request
376046be3b ANDROID: GKI: fix up abi break in ehci code
bf13278d66 UPSTREAM: usb: ehci: handshake CMD_RUN instead of STS_HALT
c3c2bb34ac ANDROID: arm64/mm: Add command line option to make ZONE_DMA32 empty
f8f6c7332b ANDROID: GKI: Add newly added vendor hook to abi symbol list
109f31ac23 ANDROID: fips140: add userspace interface for evaluation testing
97fb2104fe ANDROID: fips140: add support for injecting integrity error
903e97a0ca ANDROID: fips140: refactor evaluation testing support
53a812c6bb ANDROID: sched: add hook point in do_sched_yield()
00d29953bb ANDROID: GKI: Update symbols to symbol list
7a069c6071 FROMGIT: usb: gadget: f_fs: Use stream_open() for endpoint files

Due to api additions in android12-5.10, this also adds more api symbols
to track:

Leaf changes summary: 44 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 38 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 6 Added variables

38 Added functions:

  [A] 'function int __traceiter_android_rvh_binder_transaction(void*, binder_proc*, binder_proc*, binder_thread*, binder_transaction_data*)'
  [A] 'function int __traceiter_android_rvh_do_sched_yield(void*, rq*)'
  [A] 'function int __traceiter_android_vh_binder_del_ref(void*, task_struct*, uint32_t)'
  [A] 'function int __traceiter_android_vh_binder_new_ref(void*, task_struct*, uint32_t, int)'
  [A] 'function int __traceiter_android_vh_binder_proc_transaction(void*, task_struct*, task_struct*, task_struct*, int, unsigned int, bool)'
  [A] 'function i3c_device* dev_to_i3cdev(device*)'
  [A] 'function spi_mem_dirmap_desc* devm_spi_mem_dirmap_create(device*, spi_mem*, const spi_mem_dirmap_info*)'
  [A] 'function int genphy_restart_aneg(phy_device*)'
  [A] 'function const i3c_device_id* i3c_device_match_id(i3c_device*, const i3c_device_id*)'
  [A] 'function int iio_device_claim_direct_mode(iio_dev*)'
  [A] 'function void iio_device_release_direct_mode(iio_dev*)'
  [A] 'function int iio_push_event(iio_dev*, u64, s64)'
  [A] 'function int iio_read_mount_matrix(device*, const char*, iio_mount_matrix*)'
  [A] 'function ssize_t iio_show_mount_matrix(iio_dev*, uintptr_t, const iio_chan_spec*, char*)'
  [A] 'function int kernel_sock_shutdown(socket*, sock_shutdown_cmd)'
  [A] 'function int kill_pid(pid*, int, int)'
  [A] 'function bool kthread_freezable_should_stop(bool*)'
  [A] 'function int phy_modify_mmd(phy_device*, int, u32, u16, u16)'
  [A] 'function int snd_interval_ranges(snd_interval*, unsigned int, const snd_interval*, unsigned int)'
  [A] 'function int snd_pcm_hw_constraint_ratnums(snd_pcm_runtime*, unsigned int, snd_pcm_hw_param_t, const snd_pcm_hw_constraint_ratnums*)'
  [A] 'function int snd_soc_limit_volume(snd_soc_card*, const char*, int)'
  [A] 'function int sock_recvmsg(socket*, msghdr*, int)'
  [A] 'function socket* sockfd_lookup(int, int*)'
  [A] 'function const spi_device_id* spi_get_device_id(const spi_device*)'
  [A] 'function int spi_mem_adjust_op_size(spi_mem*, spi_mem_op*)'
  [A] 'function bool spi_mem_default_supports_op(spi_mem*, const spi_mem_op*)'
  [A] 'function ssize_t spi_mem_dirmap_read(spi_mem_dirmap_desc*, u64, size_t, void*)'
  [A] 'function ssize_t spi_mem_dirmap_write(spi_mem_dirmap_desc*, u64, size_t, void*)'
  [A] 'function int spi_mem_driver_register_with_owner(spi_mem_driver*, module*)'
  [A] 'function void spi_mem_driver_unregister(spi_mem_driver*)'
  [A] 'function bool spi_mem_dtr_supports_op(spi_mem*, const spi_mem_op*)'
  [A] 'function int spi_mem_exec_op(spi_mem*, const spi_mem_op*)'
  [A] 'function const char* spi_mem_get_name(spi_mem*)'
  [A] 'function bool spi_mem_supports_op(spi_mem*, const spi_mem_op*)'
  [A] 'function void touchscreen_parse_properties(input_dev*, bool, touchscreen_properties*)'
  [A] 'function void touchscreen_report_pos(input_dev*, const touchscreen_properties*, unsigned int, unsigned int, bool)'
  [A] 'function int trace_set_clr_event(const char*, const char*, int)'
  [A] 'function int vsscanf(const char*, const char*, va_list)'

6 Added variables:

  [A] 'tracepoint __tracepoint_android_rvh_binder_transaction'
  [A] 'tracepoint __tracepoint_android_rvh_do_sched_yield'
  [A] 'tracepoint __tracepoint_android_vh_binder_del_ref'
  [A] 'tracepoint __tracepoint_android_vh_binder_new_ref'
  [A] 'tracepoint __tracepoint_android_vh_binder_proc_transaction'
  [A] 'device platform_bus'

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I6de103b0d75261c17c11454051e2559bb6d1eecf
This commit is contained in:
Greg Kroah-Hartman
2021-12-03 11:02:05 +01:00
39 changed files with 3174 additions and 2064 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -975,6 +975,7 @@
kfree_skb kfree_skb
kfree_skb_list kfree_skb_list
kill_anon_super kill_anon_super
kill_pid
kimage_vaddr kimage_vaddr
kimage_voffset kimage_voffset
__kmalloc __kmalloc
@@ -1022,6 +1023,7 @@
kthread_destroy_worker kthread_destroy_worker
kthread_flush_work kthread_flush_work
kthread_flush_worker kthread_flush_worker
kthread_freezable_should_stop
__kthread_init_worker __kthread_init_worker
kthread_queue_delayed_work kthread_queue_delayed_work
kthread_queue_work kthread_queue_work
@@ -2056,6 +2058,7 @@
trace_raw_output_prep trace_raw_output_prep
trace_seq_printf trace_seq_printf
trace_seq_putc trace_seq_putc
trace_set_clr_event
tracing_off tracing_off
try_wait_for_completion try_wait_for_completion
tty_flip_buffer_push tty_flip_buffer_push
@@ -2370,6 +2373,7 @@
vscnprintf vscnprintf
vsnprintf vsnprintf
vsprintf vsprintf
vsscanf
vunmap vunmap
vzalloc vzalloc
wait_for_completion wait_for_completion

View File

@@ -2585,6 +2585,9 @@
__traceiter_android_vh_alter_rwsem_list_add __traceiter_android_vh_alter_rwsem_list_add
__traceiter_android_vh_arch_set_freq_scale __traceiter_android_vh_arch_set_freq_scale
__traceiter_android_vh_binder_alloc_new_buf_locked __traceiter_android_vh_binder_alloc_new_buf_locked
__traceiter_android_vh_binder_new_ref
__traceiter_android_vh_binder_del_ref
__traceiter_android_vh_binder_proc_transaction
__traceiter_android_vh_binder_preset __traceiter_android_vh_binder_preset
__traceiter_android_vh_binder_priority_skip __traceiter_android_vh_binder_priority_skip
__traceiter_android_vh_binder_reply __traceiter_android_vh_binder_reply
@@ -2776,6 +2779,9 @@
__tracepoint_android_vh_alter_rwsem_list_add __tracepoint_android_vh_alter_rwsem_list_add
__tracepoint_android_vh_arch_set_freq_scale __tracepoint_android_vh_arch_set_freq_scale
__tracepoint_android_vh_binder_alloc_new_buf_locked __tracepoint_android_vh_binder_alloc_new_buf_locked
__tracepoint_android_vh_binder_new_ref
__tracepoint_android_vh_binder_del_ref
__tracepoint_android_vh_binder_proc_transaction
__tracepoint_android_vh_binder_preset __tracepoint_android_vh_binder_preset
__tracepoint_android_vh_binder_priority_skip __tracepoint_android_vh_binder_priority_skip
__tracepoint_android_vh_binder_reply __tracepoint_android_vh_binder_reply

View File

@@ -2501,6 +2501,7 @@
__traceiter_android_rvh_cpu_cgroup_online __traceiter_android_rvh_cpu_cgroup_online
__traceiter_android_rvh_cpufreq_transition __traceiter_android_rvh_cpufreq_transition
__traceiter_android_rvh_dequeue_task __traceiter_android_rvh_dequeue_task
__traceiter_android_rvh_do_sched_yield
__traceiter_android_rvh_enqueue_task __traceiter_android_rvh_enqueue_task
__traceiter_android_rvh_find_busiest_queue __traceiter_android_rvh_find_busiest_queue
__traceiter_android_rvh_find_lowest_rq __traceiter_android_rvh_find_lowest_rq
@@ -2612,6 +2613,7 @@
__tracepoint_android_rvh_cpu_cgroup_online __tracepoint_android_rvh_cpu_cgroup_online
__tracepoint_android_rvh_cpufreq_transition __tracepoint_android_rvh_cpufreq_transition
__tracepoint_android_rvh_dequeue_task __tracepoint_android_rvh_dequeue_task
__tracepoint_android_rvh_do_sched_yield
__tracepoint_android_rvh_enqueue_task __tracepoint_android_rvh_enqueue_task
__tracepoint_android_rvh_find_busiest_queue __tracepoint_android_rvh_find_busiest_queue
__tracepoint_android_rvh_find_lowest_rq __tracepoint_android_rvh_find_lowest_rq

View File

@@ -1105,6 +1105,9 @@
anon_inode_getfile anon_inode_getfile
compat_ptr_ioctl compat_ptr_ioctl
# required by usbip-core.ko
sock_recvmsg
# required by vcan.ko # required by vcan.ko
sock_efree sock_efree
@@ -1124,6 +1127,11 @@
devm_gpiochip_add_data_with_key devm_gpiochip_add_data_with_key
devm_mfd_add_devices devm_mfd_add_devices
# required by vhci-hcd.ko
kernel_sock_shutdown
platform_bus
sockfd_lookup
# required by virt_wifi.ko # required by virt_wifi.ko
__module_get __module_get
netdev_upper_dev_link netdev_upper_dev_link

View File

@@ -1673,6 +1673,7 @@
trace_event_reg trace_event_reg
trace_handle_return trace_handle_return
__traceiter_android_rvh_account_irq __traceiter_android_rvh_account_irq
__traceiter_android_rvh_binder_transaction
__traceiter_android_rvh_build_perf_domains __traceiter_android_rvh_build_perf_domains
__traceiter_android_rvh_can_migrate_task __traceiter_android_rvh_can_migrate_task
__traceiter_android_rvh_check_preempt_wakeup __traceiter_android_rvh_check_preempt_wakeup
@@ -1772,6 +1773,7 @@
__traceiter_usb_gadget_connect __traceiter_usb_gadget_connect
__traceiter_usb_gadget_disconnect __traceiter_usb_gadget_disconnect
__tracepoint_android_rvh_account_irq __tracepoint_android_rvh_account_irq
__tracepoint_android_rvh_binder_transaction
__tracepoint_android_rvh_build_perf_domains __tracepoint_android_rvh_build_perf_domains
__tracepoint_android_rvh_can_migrate_task __tracepoint_android_rvh_can_migrate_task
__tracepoint_android_rvh_check_preempt_wakeup __tracepoint_android_rvh_check_preempt_wakeup

View File

@@ -0,0 +1 @@
CONFIG_CRYPTO_FIPS140_MOD_EVAL_TESTING=y

View File

@@ -386,6 +386,7 @@ CONFIG_HW_RANDOM=y
# CONFIG_I2C_HELPER_AUTO is not set # CONFIG_I2C_HELPER_AUTO is not set
CONFIG_I3C=y CONFIG_I3C=y
CONFIG_SPI=y CONFIG_SPI=y
CONFIG_SPI_MEM=y
CONFIG_SPMI=y CONFIG_SPMI=y
# CONFIG_SPMI_MSM_PMIC_ARB is not set # CONFIG_SPMI_MSM_PMIC_ARB is not set
# CONFIG_PINCTRL_SUN8I_H3_R is not set # CONFIG_PINCTRL_SUN8I_H3_R is not set

View File

@@ -62,6 +62,12 @@ EXPORT_SYMBOL(memstart_addr);
*/ */
phys_addr_t arm64_dma_phys_limit __ro_after_init; phys_addr_t arm64_dma_phys_limit __ro_after_init;
/*
* Provide a run-time mean of disabling ZONE_DMA32 if it is enabled via
* CONFIG_ZONE_DMA32.
*/
static bool disable_dma32 __ro_after_init;
#ifdef CONFIG_KEXEC_CORE #ifdef CONFIG_KEXEC_CORE
/* /*
* reserve_crashkernel() - reserves memory for crash kernel * reserve_crashkernel() - reserves memory for crash kernel
@@ -207,7 +213,7 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max)
max_zone_pfns[ZONE_DMA] = PFN_DOWN(arm64_dma_phys_limit); max_zone_pfns[ZONE_DMA] = PFN_DOWN(arm64_dma_phys_limit);
#endif #endif
#ifdef CONFIG_ZONE_DMA32 #ifdef CONFIG_ZONE_DMA32
max_zone_pfns[ZONE_DMA32] = PFN_DOWN(dma32_phys_limit); max_zone_pfns[ZONE_DMA32] = disable_dma32 ? 0 : PFN_DOWN(dma32_phys_limit);
if (!arm64_dma_phys_limit) if (!arm64_dma_phys_limit)
arm64_dma_phys_limit = dma32_phys_limit; arm64_dma_phys_limit = dma32_phys_limit;
#endif #endif
@@ -218,6 +224,18 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max)
free_area_init(max_zone_pfns); free_area_init(max_zone_pfns);
} }
static int __init early_disable_dma32(char *buf)
{
if (!buf)
return -EINVAL;
if (!strcmp(buf, "on"))
disable_dma32 = true;
return 0;
}
early_param("disable_dma32", early_disable_dma32);
int pfn_valid(unsigned long pfn) int pfn_valid(unsigned long pfn)
{ {
phys_addr_t addr = pfn << PAGE_SHIFT; phys_addr_t addr = pfn << PAGE_SHIFT;

View File

@@ -351,6 +351,7 @@ CONFIG_HPET=y
# CONFIG_I2C_HELPER_AUTO is not set # CONFIG_I2C_HELPER_AUTO is not set
CONFIG_I3C=y CONFIG_I3C=y
CONFIG_SPI=y CONFIG_SPI=y
CONFIG_SPI_MEM=y
CONFIG_GPIOLIB=y CONFIG_GPIOLIB=y
CONFIG_GPIO_GENERIC_PLATFORM=y CONFIG_GPIO_GENERIC_PLATFORM=y
# CONFIG_HWMON is not set # CONFIG_HWMON is not set

View File

@@ -102,6 +102,12 @@ static unsigned long min_pfn_mapped;
static bool __initdata can_use_brk_pgt = true; static bool __initdata can_use_brk_pgt = true;
/*
* Provide a run-time mean of disabling ZONE_DMA32 if it is enabled via
* CONFIG_ZONE_DMA32.
*/
static bool disable_dma32 __ro_after_init;
/* /*
* Pages returned are already directly mapped. * Pages returned are already directly mapped.
* *
@@ -996,7 +1002,7 @@ void __init zone_sizes_init(void)
max_zone_pfns[ZONE_DMA] = min(MAX_DMA_PFN, max_low_pfn); max_zone_pfns[ZONE_DMA] = min(MAX_DMA_PFN, max_low_pfn);
#endif #endif
#ifdef CONFIG_ZONE_DMA32 #ifdef CONFIG_ZONE_DMA32
max_zone_pfns[ZONE_DMA32] = min(MAX_DMA32_PFN, max_low_pfn); max_zone_pfns[ZONE_DMA32] = disable_dma32 ? 0 : min(MAX_DMA32_PFN, max_low_pfn);
#endif #endif
max_zone_pfns[ZONE_NORMAL] = max_low_pfn; max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
#ifdef CONFIG_HIGHMEM #ifdef CONFIG_HIGHMEM
@@ -1006,6 +1012,18 @@ void __init zone_sizes_init(void)
free_area_init(max_zone_pfns); free_area_init(max_zone_pfns);
} }
static int __init early_disable_dma32(char *buf)
{
if (!buf)
return -EINVAL;
if (!strcmp(buf, "on"))
disable_dma32 = true;
return 0;
}
early_param("disable_dma32", early_disable_dma32);
__visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate) = { __visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate) = {
.loaded_mm = &init_mm, .loaded_mm = &init_mm,
.next_asid = 1, .next_asid = 1,

View File

@@ -0,0 +1,3 @@
. ${ROOT_DIR}/${KERNEL_DIR}/build.config.gki.aarch64.fips140
PRE_DEFCONFIG_CMDS+=" cat ${ROOT_DIR}/${KERNEL_DIR}/arch/arm64/configs/fips140_gki_eval_testing.fragment >> ${ROOT_DIR}/${KERNEL_DIR}/arch/arm64/configs/${DEFCONFIG};"

View File

@@ -53,14 +53,14 @@ config CRYPTO_FIPS140_MOD
meet FIPS 140 and NIAP FPT_TST_EXT.1 requirements. It shouldn't be meet FIPS 140 and NIAP FPT_TST_EXT.1 requirements. It shouldn't be
used if you don't need to meet these requirements. used if you don't need to meet these requirements.
config CRYPTO_FIPS140_MOD_ERROR_INJECTION config CRYPTO_FIPS140_MOD_EVAL_TESTING
bool "Support injecting failures into the FIPS 140 self-tests" bool "Enable evaluation testing features in FIPS 140 module"
depends on CRYPTO_FIPS140_MOD depends on CRYPTO_FIPS140_MOD
help help
This option adds a module parameter "broken_alg" to the fips140 module This option adds some features to the FIPS 140 module which are needed
which can be used to fail the self-tests for a particular algorithm, for lab evaluation testing of the module, e.g. support for injecting
causing a kernel panic. This option is for FIPS lab testing only, and errors and support for a userspace interface to some of the module's
it shouldn't be enabled on production systems. services. This option should not be enabled in production builds.
config CRYPTO_ALGAPI config CRYPTO_ALGAPI
tristate tristate

View File

@@ -239,11 +239,14 @@ fips140-objs := \
fips140-refs.o \ fips140-refs.o \
fips140-selftests.o \ fips140-selftests.o \
crypto-fips.a crypto-fips.a
fips140-$(CONFIG_CRYPTO_FIPS140_MOD_EVAL_TESTING) += \
fips140-eval-testing.o
obj-m += fips140.o obj-m += fips140.o
CFLAGS_fips140-alg-registration.o += $(FIPS140_CFLAGS) CFLAGS_fips140-alg-registration.o += $(FIPS140_CFLAGS)
CFLAGS_fips140-module.o += $(FIPS140_CFLAGS) CFLAGS_fips140-module.o += $(FIPS140_CFLAGS)
CFLAGS_fips140-selftests.o += $(FIPS140_CFLAGS) CFLAGS_fips140-selftests.o += $(FIPS140_CFLAGS)
CFLAGS_fips140-eval-testing.o += $(FIPS140_CFLAGS)
hostprogs-always-y := fips140_gen_hmac hostprogs-always-y := fips140_gen_hmac
HOSTLDLIBS_fips140_gen_hmac := -lcrypto -lelf HOSTLDLIBS_fips140_gen_hmac := -lcrypto -lelf

View File

@@ -0,0 +1,30 @@
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _CRYPTO_FIPS140_EVAL_TESTING_H
#define _CRYPTO_FIPS140_EVAL_TESTING_H
#include <linux/ioctl.h>
/*
* This header defines the ioctls that are available on the fips140 character
* device. These ioctls expose some of the module's services to userspace so
* that they can be tested by the FIPS certification lab; this is a required
* part of getting a FIPS 140 certification. These ioctls do not have any other
* purpose, and they do not need to be present in production builds.
*/
/*
* Call the fips140_is_approved_service() function. The argument must be the
* service name as a NUL-terminated string. The return value will be 1 if
* fips140_is_approved_service() returned true, or 0 if it returned false.
*/
#define FIPS140_IOCTL_IS_APPROVED_SERVICE _IO('F', 0)
/*
* Call the fips140_module_version() function. The argument must be a pointer
* to a buffer of size >= 256 chars. The NUL-terminated string returned by
* fips140_module_version() will be written to this buffer.
*/
#define FIPS140_IOCTL_MODULE_VERSION _IOR('F', 1, char[256])
#endif /* _CRYPTO_FIPS140_EVAL_TESTING_H */

View File

@@ -0,0 +1,129 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2021 Google LLC
*
* This file can optionally be built into fips140.ko in order to support certain
* types of testing that the FIPS lab has to do to evaluate the module. It
* should not be included in production builds of the module.
*/
/*
* We have to redefine inline to mean always_inline, so that _copy_to_user()
* gets inlined. This is needed for it to be placed into the correct section.
* See fips140_copy_to_user().
*
* We also need to undefine BUILD_FIPS140_KO to allow the use of the code
* patching which copy_to_user() requires.
*/
#undef inline
#define inline inline __attribute__((__always_inline__)) __gnu_inline \
__inline_maybe_unused notrace
#undef BUILD_FIPS140_KO
#include <linux/cdev.h>
#include <linux/fs.h>
#include <linux/module.h>
#include <linux/slab.h>
#include "fips140-module.h"
#include "fips140-eval-testing-uapi.h"
/*
* This option allows deliberately failing the self-tests for a particular
* algorithm.
*/
static char *fips140_fail_selftest;
module_param_named(fail_selftest, fips140_fail_selftest, charp, 0);
/* This option allows deliberately failing the integrity check. */
static bool fips140_fail_integrity_check;
module_param_named(fail_integrity_check, fips140_fail_integrity_check, bool, 0);
static dev_t fips140_devnum;
static struct cdev fips140_cdev;
/* Inject a self-test failure (via corrupting the result) if requested. */
void fips140_inject_selftest_failure(const char *impl, u8 *result)
{
if (fips140_fail_selftest && strcmp(impl, fips140_fail_selftest) == 0)
result[0] ^= 0xff;
}
/* Inject an integrity check failure (via corrupting the text) if requested. */
void fips140_inject_integrity_failure(u8 *textcopy)
{
if (fips140_fail_integrity_check)
textcopy[0] ^= 0xff;
}
static long fips140_ioctl_is_approved_service(unsigned long arg)
{
const char *service_name = strndup_user((const char __user *)arg, 256);
long ret;
if (IS_ERR(service_name))
return PTR_ERR(service_name);
ret = fips140_is_approved_service(service_name);
kfree(service_name);
return ret;
}
/*
* Code in fips140.ko is covered by an integrity check by default, and this
* check breaks if copy_to_user() is called. This is because copy_to_user() is
* an inline function that relies on code patching. However, since this is
* "evaluation testing" code which isn't included in the production builds of
* fips140.ko, it's acceptable to just exclude it from the integrity check.
*/
static noinline unsigned long __section("text.._fips140_unchecked")
fips140_copy_to_user(void __user *to, const void *from, unsigned long n)
{
return copy_to_user(to, from, n);
}
static long fips140_ioctl_module_version(unsigned long arg)
{
const char *version = fips140_module_version();
size_t len = strlen(version) + 1;
if (len > 256)
return -EOVERFLOW;
if (fips140_copy_to_user((void __user *)arg, version, len))
return -EFAULT;
return 0;
}
static long fips140_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
switch (cmd) {
case FIPS140_IOCTL_IS_APPROVED_SERVICE:
return fips140_ioctl_is_approved_service(arg);
case FIPS140_IOCTL_MODULE_VERSION:
return fips140_ioctl_module_version(arg);
default:
return -ENOTTY;
}
}
static const struct file_operations fips140_fops = {
.unlocked_ioctl = fips140_ioctl,
};
bool fips140_eval_testing_init(void)
{
if (alloc_chrdev_region(&fips140_devnum, 1, 1, "fips140") != 0) {
pr_err("failed to allocate device number\n");
return false;
}
cdev_init(&fips140_cdev, &fips140_fops);
if (cdev_add(&fips140_cdev, fips140_devnum, 1) != 0) {
pr_err("failed to add fips140 character device\n");
return false;
}
return true;
}

View File

@@ -29,15 +29,6 @@
#include "fips140-module.h" #include "fips140-module.h"
#include "internal.h" #include "internal.h"
/*
* This option allows deliberately failing the self-tests for a particular
* algorithm. This is for FIPS lab testing only.
*/
#ifdef CONFIG_CRYPTO_FIPS140_MOD_ERROR_INJECTION
char *fips140_broken_alg;
module_param_named(broken_alg, fips140_broken_alg, charp, 0);
#endif
/* /*
* FIPS 140-2 prefers the use of HMAC with a public key over a plain hash. * FIPS 140-2 prefers the use of HMAC with a public key over a plain hash.
*/ */
@@ -397,6 +388,8 @@ static bool __init check_fips140_module_hmac(void)
offset_to_ptr(&fips140_rela_rodata.offset), offset_to_ptr(&fips140_rela_rodata.offset),
fips140_rela_rodata.count); fips140_rela_rodata.count);
fips140_inject_integrity_failure(textcopy);
tfm = crypto_alloc_shash("hmac(sha256)", 0, 0); tfm = crypto_alloc_shash("hmac(sha256)", 0, 0);
if (IS_ERR(tfm)) { if (IS_ERR(tfm)) {
pr_err("failed to allocate hmac tfm (%ld)\n", PTR_ERR(tfm)); pr_err("failed to allocate hmac tfm (%ld)\n", PTR_ERR(tfm));
@@ -545,6 +538,9 @@ fips140_init(void)
if (!update_fips140_library_routines()) if (!update_fips140_library_routines())
goto panic; goto panic;
if (!fips140_eval_testing_init())
goto panic;
pr_info("module successfully loaded\n"); pr_info("module successfully loaded\n");
return 0; return 0;

View File

@@ -20,16 +20,31 @@
#define FIPS140_MODULE_NAME "Android Kernel Cryptographic Module" #define FIPS140_MODULE_NAME "Android Kernel Cryptographic Module"
#define FIPS140_MODULE_VERSION UTS_RELEASE #define FIPS140_MODULE_VERSION UTS_RELEASE
#ifdef CONFIG_CRYPTO_FIPS140_MOD_ERROR_INJECTION /* fips140-eval-testing.c */
extern char *fips140_broken_alg; #ifdef CONFIG_CRYPTO_FIPS140_MOD_EVAL_TESTING
#endif void fips140_inject_selftest_failure(const char *impl, u8 *result);
void fips140_inject_integrity_failure(u8 *textcopy);
bool fips140_eval_testing_init(void);
#else
static inline void fips140_inject_selftest_failure(const char *impl, u8 *result)
{
}
static inline void fips140_inject_integrity_failure(u8 *textcopy)
{
}
static inline bool fips140_eval_testing_init(void)
{
return true;
}
#endif /* !CONFIG_CRYPTO_FIPS140_MOD_EVAL_TESTING */
/* fips140-module.c */
extern struct completion fips140_tests_done; extern struct completion fips140_tests_done;
extern struct task_struct *fips140_init_thread; extern struct task_struct *fips140_init_thread;
bool __init __must_check fips140_run_selftests(void);
bool fips140_is_approved_service(const char *name); bool fips140_is_approved_service(const char *name);
const char *fips140_module_version(void); const char *fips140_module_version(void);
/* fips140-selftests.c */
bool __init __must_check fips140_run_selftests(void);
#endif /* _CRYPTO_FIPS140_MODULE_H */ #endif /* _CRYPTO_FIPS140_MODULE_H */

View File

@@ -146,11 +146,7 @@ static int __init __must_check
fips_check_result(u8 *result, const u8 *expected_result, size_t result_size, fips_check_result(u8 *result, const u8 *expected_result, size_t result_size,
const char *impl, const char *operation) const char *impl, const char *operation)
{ {
#ifdef CONFIG_CRYPTO_FIPS140_MOD_ERROR_INJECTION fips140_inject_selftest_failure(impl, result);
/* Inject a failure (via corrupting the result) if requested. */
if (fips140_broken_alg && strcmp(impl, fips140_broken_alg) == 0)
result[0] ^= 0xff;
#endif
if (memcmp(result, expected_result, result_size) != 0) { if (memcmp(result, expected_result, result_size) != 0) {
pr_err("wrong result from %s %s\n", impl, operation); pr_err("wrong result from %s %s\n", impl, operation);
return -EBADMSG; return -EBADMSG;

View File

@@ -239,6 +239,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_create_worker);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_check_preempt_tick); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_check_preempt_tick);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_check_preempt_wakeup_ignore); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_check_preempt_wakeup_ignore);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_replace_next_task_fair); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_replace_next_task_fair);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_sched_yield);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_wait_for_work); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_wait_for_work);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sync_txn_recvd); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sync_txn_recvd);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_build_sched_domains); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_build_sched_domains);

View File

@@ -44,9 +44,9 @@ static void dmabuf_page_pool_add(struct dmabuf_page_pool *pool, struct page *pag
mutex_lock(&pool->mutex); mutex_lock(&pool->mutex);
list_add_tail(&page->lru, &pool->items[index]); list_add_tail(&page->lru, &pool->items[index]);
pool->count[index]++; pool->count[index]++;
mutex_unlock(&pool->mutex);
mod_node_page_state(page_pgdat(page), NR_KERNEL_MISC_RECLAIMABLE, mod_node_page_state(page_pgdat(page), NR_KERNEL_MISC_RECLAIMABLE,
1 << pool->order); 1 << pool->order);
mutex_unlock(&pool->mutex);
} }
static struct page *dmabuf_page_pool_remove(struct dmabuf_page_pool *pool, int index) static struct page *dmabuf_page_pool_remove(struct dmabuf_page_pool *pool, int index)

View File

@@ -137,8 +137,8 @@ static int spi_check_buswidth_req(struct spi_mem *mem, u8 buswidth, bool tx)
return -ENOTSUPP; return -ENOTSUPP;
} }
bool spi_mem_default_supports_op(struct spi_mem *mem, static bool spi_mem_check_buswidth(struct spi_mem *mem,
const struct spi_mem_op *op) const struct spi_mem_op *op)
{ {
if (spi_check_buswidth_req(mem, op->cmd.buswidth, true)) if (spi_check_buswidth_req(mem, op->cmd.buswidth, true))
return false; return false;
@@ -156,13 +156,29 @@ bool spi_mem_default_supports_op(struct spi_mem *mem,
op->data.dir == SPI_MEM_DATA_OUT)) op->data.dir == SPI_MEM_DATA_OUT))
return false; return false;
return true;
}
bool spi_mem_dtr_supports_op(struct spi_mem *mem,
const struct spi_mem_op *op)
{
if (op->cmd.nbytes != 2)
return false;
return spi_mem_check_buswidth(mem, op);
}
EXPORT_SYMBOL_GPL(spi_mem_dtr_supports_op);
bool spi_mem_default_supports_op(struct spi_mem *mem,
const struct spi_mem_op *op)
{
if (op->cmd.dtr || op->addr.dtr || op->dummy.dtr || op->data.dtr) if (op->cmd.dtr || op->addr.dtr || op->dummy.dtr || op->data.dtr)
return false; return false;
if (op->cmd.nbytes != 1) if (op->cmd.nbytes != 1)
return false; return false;
return true; return spi_mem_check_buswidth(mem, op);
} }
EXPORT_SYMBOL_GPL(spi_mem_default_supports_op); EXPORT_SYMBOL_GPL(spi_mem_default_supports_op);

View File

@@ -3264,6 +3264,9 @@ static bool dwc3_gadget_endpoint_trbs_complete(struct dwc3_ep *dep,
struct dwc3 *dwc = dep->dwc; struct dwc3 *dwc = dep->dwc;
bool no_started_trb = true; bool no_started_trb = true;
if (!dep->endpoint.desc)
return no_started_trb;
dwc3_gadget_ep_cleanup_completed_requests(dep, event, status); dwc3_gadget_ep_cleanup_completed_requests(dep, event, status);
if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) if (dep->flags & DWC3_EP_END_TRANSFER_PENDING)
@@ -3311,6 +3314,9 @@ static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3_ep *dep,
{ {
int status = 0; int status = 0;
if (!dep->endpoint.desc)
return;
if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) if (usb_endpoint_xfer_isoc(dep->endpoint.desc))
dwc3_gadget_endpoint_frame_from_event(dep, event); dwc3_gadget_endpoint_frame_from_event(dep, event);

View File

@@ -678,8 +678,11 @@ fail:
pr_err("acc_bind() could not allocate requests\n"); pr_err("acc_bind() could not allocate requests\n");
while ((req = req_get(dev, &dev->tx_idle))) while ((req = req_get(dev, &dev->tx_idle)))
acc_request_free(req, dev->ep_in); acc_request_free(req, dev->ep_in);
for (i = 0; i < RX_REQ_MAX; i++) for (i = 0; i < RX_REQ_MAX; i++) {
acc_request_free(dev->rx_req[i], dev->ep_out); acc_request_free(dev->rx_req[i], dev->ep_out);
dev->rx_req[i] = NULL;
}
return -1; return -1;
} }
@@ -711,6 +714,12 @@ static ssize_t acc_read(struct file *fp, char __user *buf,
goto done; goto done;
} }
if (!dev->rx_req[0]) {
pr_warn("acc_read: USB request already handled/freed");
r = -EINVAL;
goto done;
}
/* /*
* Calculate the data length by considering termination character. * Calculate the data length by considering termination character.
* Then compansite the difference of rounding up to * Then compansite the difference of rounding up to
@@ -1187,8 +1196,10 @@ acc_function_unbind(struct usb_configuration *c, struct usb_function *f)
while ((req = req_get(dev, &dev->tx_idle))) while ((req = req_get(dev, &dev->tx_idle)))
acc_request_free(req, dev->ep_in); acc_request_free(req, dev->ep_in);
for (i = 0; i < RX_REQ_MAX; i++) for (i = 0; i < RX_REQ_MAX; i++) {
acc_request_free(dev->rx_req[i], dev->ep_out); acc_request_free(dev->rx_req[i], dev->ep_out);
dev->rx_req[i] = NULL;
}
acc_hid_unbind(dev); acc_hid_unbind(dev);
} }

View File

@@ -614,7 +614,7 @@ static int ffs_ep0_open(struct inode *inode, struct file *file)
file->private_data = ffs; file->private_data = ffs;
ffs_data_opened(ffs); ffs_data_opened(ffs);
return 0; return stream_open(inode, file);
} }
static int ffs_ep0_release(struct inode *inode, struct file *file) static int ffs_ep0_release(struct inode *inode, struct file *file)
@@ -1152,7 +1152,7 @@ ffs_epfile_open(struct inode *inode, struct file *file)
file->private_data = epfile; file->private_data = epfile;
ffs_data_opened(epfile->ffs); ffs_data_opened(epfile->ffs);
return 0; return stream_open(inode, file);
} }
static int ffs_aio_cancel(struct kiocb *kiocb) static int ffs_aio_cancel(struct kiocb *kiocb)

View File

@@ -142,7 +142,7 @@ static bool erofs_try_to_release_workgroup(struct erofs_sb_info *sbi,
* however in order to avoid some race conditions, add a * however in order to avoid some race conditions, add a
* DBG_BUGON to observe this in advance. * DBG_BUGON to observe this in advance.
*/ */
DBG_BUGON(xa_erase(&sbi->managed_pslots, grp->index) != grp); DBG_BUGON(__xa_erase(&sbi->managed_pslots, grp->index) != grp);
/* last refcount should be connected with its managed pslot. */ /* last refcount should be connected with its managed pslot. */
erofs_workgroup_unfreeze(grp, 0); erofs_workgroup_unfreeze(grp, 0);
@@ -157,15 +157,19 @@ static unsigned long erofs_shrink_workstation(struct erofs_sb_info *sbi,
unsigned int freed = 0; unsigned int freed = 0;
unsigned long index; unsigned long index;
xa_lock(&sbi->managed_pslots);
xa_for_each(&sbi->managed_pslots, index, grp) { xa_for_each(&sbi->managed_pslots, index, grp) {
/* try to shrink each valid workgroup */ /* try to shrink each valid workgroup */
if (!erofs_try_to_release_workgroup(sbi, grp)) if (!erofs_try_to_release_workgroup(sbi, grp))
continue; continue;
xa_unlock(&sbi->managed_pslots);
++freed; ++freed;
if (!--nr_shrink) if (!--nr_shrink)
break; return freed;
xa_lock(&sbi->managed_pslots);
} }
xa_unlock(&sbi->managed_pslots);
return freed; return freed;
} }

View File

@@ -737,7 +737,7 @@ hitted:
retry: retry:
err = z_erofs_attach_page(clt, page, page_type, err = z_erofs_attach_page(clt, page, page_type,
clt->mode >= COLLECT_PRIMARY_FOLLOWED); clt->mode >= COLLECT_PRIMARY_FOLLOWED);
/* should allocate an additional staging page for pagevec */ /* should allocate an additional short-lived page for pagevec */
if (err == -EAGAIN) { if (err == -EAGAIN) {
struct page *const newpage = struct page *const newpage =
alloc_page(GFP_NOFS | __GFP_NOFAIL); alloc_page(GFP_NOFS | __GFP_NOFAIL);

View File

@@ -24,6 +24,28 @@ struct bus_dma_region {
u64 offset; u64 offset;
}; };
static inline bool zone_dma32_is_empty(int node)
{
#ifdef CONFIG_ZONE_DMA32
pg_data_t *pgdat = NODE_DATA(node);
return zone_is_empty(&pgdat->node_zones[ZONE_DMA32]);
#else
return true;
#endif
}
static inline bool zone_dma32_are_empty(void)
{
int node;
for_each_node(node)
if (!zone_dma32_is_empty(node))
return false;
return true;
}
static inline dma_addr_t translate_phys_to_dma(struct device *dev, static inline dma_addr_t translate_phys_to_dma(struct device *dev,
phys_addr_t paddr) phys_addr_t paddr)
{ {

View File

@@ -311,6 +311,9 @@ void spi_controller_dma_unmap_mem_op_data(struct spi_controller *ctlr,
bool spi_mem_default_supports_op(struct spi_mem *mem, bool spi_mem_default_supports_op(struct spi_mem *mem,
const struct spi_mem_op *op); const struct spi_mem_op *op);
bool spi_mem_dtr_supports_op(struct spi_mem *mem,
const struct spi_mem_op *op);
#else #else
static inline int static inline int
spi_controller_dma_map_mem_op_data(struct spi_controller *ctlr, spi_controller_dma_map_mem_op_data(struct spi_controller *ctlr,
@@ -334,6 +337,12 @@ bool spi_mem_default_supports_op(struct spi_mem *mem,
return false; return false;
} }
static inline
bool spi_mem_dtr_supports_op(struct spi_mem *mem,
const struct spi_mem_op *op)
{
return false;
}
#endif /* CONFIG_SPI_MEM */ #endif /* CONFIG_SPI_MEM */
int spi_mem_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op); int spi_mem_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op);

View File

@@ -291,6 +291,10 @@ DECLARE_RESTRICTED_HOOK(android_rvh_replace_next_task_fair,
bool simple, struct task_struct *prev), bool simple, struct task_struct *prev),
TP_ARGS(rq, p, se, repick, simple, prev), 1); TP_ARGS(rq, p, se, repick, simple, prev), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_do_sched_yield,
TP_PROTO(struct rq *rq),
TP_ARGS(rq), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_util_est_update, DECLARE_RESTRICTED_HOOK(android_rvh_util_est_update,
TP_PROTO(struct cfs_rq *cfs_rq, struct task_struct *p, bool task_sleep, int *ret), TP_PROTO(struct cfs_rq *cfs_rq, struct task_struct *p, bool task_sleep, int *ret),
TP_ARGS(cfs_rq, p, task_sleep, ret), 1); TP_ARGS(cfs_rq, p, task_sleep, ret), 1);

View File

@@ -213,6 +213,8 @@ struct task_struct init_task
#ifdef CONFIG_SECCOMP_FILTER #ifdef CONFIG_SECCOMP_FILTER
.seccomp = { .filter_count = ATOMIC_INIT(0) }, .seccomp = { .filter_count = ATOMIC_INIT(0) },
#endif #endif
.android_vendor_data1 = {0, },
.android_oem_data1 = {0, },
}; };
EXPORT_SYMBOL(init_task); EXPORT_SYMBOL(init_task);

View File

@@ -31,6 +31,7 @@
#include <linux/smpboot.h> #include <linux/smpboot.h>
#include <linux/relay.h> #include <linux/relay.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/scs.h>
#include <linux/percpu-rwsem.h> #include <linux/percpu-rwsem.h>
#include <linux/cpuset.h> #include <linux/cpuset.h>
#include <uapi/linux/sched/types.h> #include <uapi/linux/sched/types.h>
@@ -558,6 +559,12 @@ static int bringup_cpu(unsigned int cpu)
struct task_struct *idle = idle_thread_get(cpu); struct task_struct *idle = idle_thread_get(cpu);
int ret; int ret;
/*
* Reset stale stack state from the last time this CPU was online.
*/
scs_task_reset(idle);
kasan_unpoison_task_stack(idle);
/* /*
* Some architectures have to walk the irq descriptors to * Some architectures have to walk the irq descriptors to
* setup the vector space for the cpu which comes online. * setup the vector space for the cpu which comes online.

View File

@@ -61,7 +61,8 @@ static gfp_t dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask,
*phys_limit = dma_to_phys(dev, dma_limit); *phys_limit = dma_to_phys(dev, dma_limit);
if (*phys_limit <= DMA_BIT_MASK(zone_dma_bits)) if (*phys_limit <= DMA_BIT_MASK(zone_dma_bits))
return GFP_DMA; return GFP_DMA;
if (*phys_limit <= DMA_BIT_MASK(32)) if (*phys_limit <= DMA_BIT_MASK(32) &&
!zone_dma32_is_empty(dev_to_node(dev)))
return GFP_DMA32; return GFP_DMA32;
return 0; return 0;
} }
@@ -101,7 +102,8 @@ again:
if (IS_ENABLED(CONFIG_ZONE_DMA32) && if (IS_ENABLED(CONFIG_ZONE_DMA32) &&
phys_limit < DMA_BIT_MASK(64) && phys_limit < DMA_BIT_MASK(64) &&
!(gfp & (GFP_DMA32 | GFP_DMA))) { !(gfp & (GFP_DMA32 | GFP_DMA)) &&
!zone_dma32_is_empty(node)) {
gfp |= GFP_DMA32; gfp |= GFP_DMA32;
goto again; goto again;
} }

View File

@@ -74,7 +74,7 @@ static bool cma_in_zone(gfp_t gfp)
end = cma_get_base(cma) + size - 1; end = cma_get_base(cma) + size - 1;
if (IS_ENABLED(CONFIG_ZONE_DMA) && (gfp & GFP_DMA)) if (IS_ENABLED(CONFIG_ZONE_DMA) && (gfp & GFP_DMA))
return end <= DMA_BIT_MASK(zone_dma_bits); return end <= DMA_BIT_MASK(zone_dma_bits);
if (IS_ENABLED(CONFIG_ZONE_DMA32) && (gfp & GFP_DMA32)) if (IS_ENABLED(CONFIG_ZONE_DMA32) && (gfp & GFP_DMA32) && !zone_dma32_are_empty())
return end <= DMA_BIT_MASK(32); return end <= DMA_BIT_MASK(32);
return true; return true;
} }
@@ -156,7 +156,7 @@ static void atomic_pool_work_fn(struct work_struct *work)
if (IS_ENABLED(CONFIG_ZONE_DMA)) if (IS_ENABLED(CONFIG_ZONE_DMA))
atomic_pool_resize(atomic_pool_dma, atomic_pool_resize(atomic_pool_dma,
GFP_KERNEL | GFP_DMA); GFP_KERNEL | GFP_DMA);
if (IS_ENABLED(CONFIG_ZONE_DMA32)) if (IS_ENABLED(CONFIG_ZONE_DMA32) && !zone_dma32_are_empty())
atomic_pool_resize(atomic_pool_dma32, atomic_pool_resize(atomic_pool_dma32,
GFP_KERNEL | GFP_DMA32); GFP_KERNEL | GFP_DMA32);
atomic_pool_resize(atomic_pool_kernel, GFP_KERNEL); atomic_pool_resize(atomic_pool_kernel, GFP_KERNEL);
@@ -212,7 +212,7 @@ static int __init dma_atomic_pool_init(void)
if (!atomic_pool_dma) if (!atomic_pool_dma)
ret = -ENOMEM; ret = -ENOMEM;
} }
if (IS_ENABLED(CONFIG_ZONE_DMA32)) { if (IS_ENABLED(CONFIG_ZONE_DMA32) && !zone_dma32_are_empty()) {
atomic_pool_dma32 = __dma_atomic_pool_init(atomic_pool_size, atomic_pool_dma32 = __dma_atomic_pool_init(atomic_pool_size,
GFP_KERNEL | GFP_DMA32); GFP_KERNEL | GFP_DMA32);
if (!atomic_pool_dma32) if (!atomic_pool_dma32)
@@ -227,7 +227,7 @@ postcore_initcall(dma_atomic_pool_init);
static inline struct gen_pool *dma_guess_pool(struct gen_pool *prev, gfp_t gfp) static inline struct gen_pool *dma_guess_pool(struct gen_pool *prev, gfp_t gfp)
{ {
if (prev == NULL) { if (prev == NULL) {
if (IS_ENABLED(CONFIG_ZONE_DMA32) && (gfp & GFP_DMA32)) if (IS_ENABLED(CONFIG_ZONE_DMA32) && (gfp & GFP_DMA32) && !zone_dma32_are_empty())
return atomic_pool_dma32; return atomic_pool_dma32;
if (IS_ENABLED(CONFIG_ZONE_DMA) && (gfp & GFP_DMA)) if (IS_ENABLED(CONFIG_ZONE_DMA) && (gfp & GFP_DMA))
return atomic_pool_dma; return atomic_pool_dma;

View File

@@ -978,6 +978,8 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node)
#ifdef CONFIG_MEMCG #ifdef CONFIG_MEMCG
tsk->active_memcg = NULL; tsk->active_memcg = NULL;
#endif #endif
memset(&tsk->android_vendor_data1, 0, sizeof(tsk->android_vendor_data1));
memset(&tsk->android_oem_data1, 0, sizeof(tsk->android_oem_data1));
trace_android_vh_dup_task_struct(tsk, orig); trace_android_vh_dup_task_struct(tsk, orig);
return tsk; return tsk;

View File

@@ -6347,6 +6347,8 @@ static void do_sched_yield(void)
schedstat_inc(rq->yld_count); schedstat_inc(rq->yld_count);
current->sched_class->yield_task(rq); current->sched_class->yield_task(rq);
trace_android_rvh_do_sched_yield(rq);
preempt_disable(); preempt_disable();
rq_unlock_irq(rq, &rf); rq_unlock_irq(rq, &rf);
sched_preempt_enable_no_resched(); sched_preempt_enable_no_resched();
@@ -6777,9 +6779,6 @@ void __init init_idle(struct task_struct *idle, int cpu)
idle->se.exec_start = sched_clock(); idle->se.exec_start = sched_clock();
idle->flags |= PF_IDLE; idle->flags |= PF_IDLE;
scs_task_reset(idle);
kasan_unpoison_task_stack(idle);
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
/* /*
* Its possible that init_idle() gets called multiple times on a task, * Its possible that init_idle() gets called multiple times on a task,
@@ -6935,7 +6934,6 @@ void idle_task_exit(void)
finish_arch_post_lock_switch(); finish_arch_post_lock_switch();
} }
scs_task_reset(current);
/* finish_cpu(), as ran on the BP, will clean up the active_mm state */ /* finish_cpu(), as ran on the BP, will clean up the active_mm state */
} }

View File

@@ -0,0 +1,187 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2021 Google LLC
*
* This is a sample program which calls some ioctls on /dev/fips140 and prints
* the results. The purpose of this program is to allow the FIPS certification
* lab to test some services of fips140.ko, which they are required to do. This
* is a sample program only, and it can be modified by the lab as needed. This
* program must be run as root, and it only works if the system has loaded a
* build of fips140.ko with evaluation testing support enabled.
*
* This program can be compiled and run on an Android device as follows:
*
* NDK_DIR=$HOME/android-ndk-r23b # adjust directory path as needed
* $NDK_DIR/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android31-clang \
* fips140_lab_test.c -O2 -Wall -o fips140_lab_test
* adb push fips140_lab_test /data/local/tmp/
* adb root
* adb shell /data/local/tmp/fips140_lab_test
*/
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <unistd.h>
#include "../../crypto/fips140-eval-testing-uapi.h"
static int fips140_dev_fd = -1;
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
static const char *booltostr(bool b)
{
return b ? "true" : "false";
}
static void __attribute__((noreturn))
do_die(const char *format, va_list va, int err)
{
fputs("ERROR: ", stderr);
vfprintf(stderr, format, va);
if (err)
fprintf(stderr, ": %s", strerror(err));
putc('\n', stderr);
exit(1);
}
static void __attribute__((noreturn, format(printf, 1, 2)))
die_errno(const char *format, ...)
{
va_list va;
va_start(va, format);
do_die(format, va, errno);
va_end(va);
}
static void __attribute__((noreturn, format(printf, 1, 2)))
die(const char *format, ...)
{
va_list va;
va_start(va, format);
do_die(format, va, 0);
va_end(va);
}
static int get_fips140_device_number(void)
{
FILE *f;
char line[128];
int number;
char name[32];
f = fopen("/proc/devices", "r");
if (!f)
die_errno("failed to open /proc/devices");
while (fgets(line, sizeof(line), f)) {
if (sscanf(line, "%d %31s", &number, name) == 2 &&
strcmp(name, "fips140") == 0)
return number;
}
fclose(f);
die("fips140 device node is unavailable.\n"
"The fips140 device node is only available when the fips140 module is loaded\n"
"and has been built with evaluation testing support.");
}
static void create_fips140_node_if_needed(void)
{
struct stat stbuf;
int major;
if (stat("/dev/fips140", &stbuf) == 0)
return;
major = get_fips140_device_number();
if (mknod("/dev/fips140", S_IFCHR | 0600, makedev(major, 1)) != 0)
die_errno("failed to create fips140 device node");
}
static bool fips140_is_approved_service(const char *name)
{
int ret = ioctl(fips140_dev_fd, FIPS140_IOCTL_IS_APPROVED_SERVICE, name);
if (ret < 0)
die_errno("FIPS140_IOCTL_IS_APPROVED_SERVICE unexpectedly failed");
if (ret == 1)
return true;
if (ret == 0)
return false;
die("FIPS140_IOCTL_IS_APPROVED_SERVICE returned unexpected value %d",
ret);
}
static const char *fips140_module_version(void)
{
char buf[256];
char *str;
int ret = ioctl(fips140_dev_fd, FIPS140_IOCTL_MODULE_VERSION, buf);
if (ret < 0)
die_errno("FIPS140_IOCTL_MODULE_VERSION unexpectedly failed");
if (ret != 0)
die("FIPS140_IOCTL_MODULE_VERSION returned unexpected value %d", ret);
str = strdup(buf);
if (!str)
die("out of memory");
return str;
}
static const char * const services_to_check[] = {
"aes",
"cbc(aes)",
"cbcmac(aes)",
"cmac(aes)",
"ctr(aes)",
"cts(cbc(aes))",
"ecb(aes)",
"essiv(cbc(aes),sha256)",
"gcm(aes)",
"hmac(sha1)",
"hmac(sha224)",
"hmac(sha256)",
"hmac(sha384)",
"hmac(sha512)",
"jitterentropy_rng",
"sha1",
"sha224",
"sha256",
"sha384",
"sha512",
"stdrng",
"xcbc(aes)",
"xts(aes)",
};
int main(void)
{
size_t i;
if (getuid() != 0)
die("This program requires root. Run 'adb root' first.");
create_fips140_node_if_needed();
fips140_dev_fd = open("/dev/fips140", O_RDONLY);
if (fips140_dev_fd < 0)
die_errno("failed to open /dev/fips140");
printf("fips140_module_version() => \"%s\"\n", fips140_module_version());
for (i = 0; i < ARRAY_SIZE(services_to_check); i++) {
const char *service = services_to_check[i];
printf("fips140_is_approved_service(\"%s\") => %s\n", service,
booltostr(fips140_is_approved_service(service)));
}
return 0;
}

View File

@@ -71,6 +71,7 @@ SECTIONS {
*(.text..L.cfi.jumptable .text..L.cfi.jumptable.*) *(.text..L.cfi.jumptable .text..L.cfi.jumptable.*)
__cfi_jt_end = .; __cfi_jt_end = .;
*(.text.._end) *(.text.._end)
*(.text.._fips140_unchecked)
} }
#endif #endif
} }