Merge remote branch 'android12-5.10' of https://android.googlesource.com/kernel/common

* android12-5.10: (2274 commits)
  FROMGIT: mm: slub: move sysfs slab alloc/free interfaces to debugfs
  ANDROID: gki - CONFIG_NET_SCH_FQ=y
  ANDROID: GKI: Kconfig.gki: Add GKI_HIDDEN_ETHERNET_CONFIGS
  FROMLIST: media: Kconfig: Fix DVB_CORE can't be selected as module
  ANDROID: Update ABI and symbol list
  Revert "net: usb: cdc_ncm: don't spew notifications"
  ANDROID: Fips 140: move fips symbols entirely in own list
  ANDROID: core of xt_IDLETIMER send_nl_msg support
  ANDROID: start to re-add xt_IDLETIMER send_nl_msg support
  ANDROID: add fips140.ko symbols to module ABI
  ANDROID: inject correct HMAC digest into fips140.ko at build time
  ANDROID: crypto: fips140 - perform load time integrity check
  FROMLIST: crypto: shash - stop comparing function pointers to avoid breaking CFI
  ANDROID: arm64: module: preserve RELA sections for FIPS140 integrity selfcheck
  ANDROID: arm64: simd: omit capability check in may_use_simd()
  ANDROID: kbuild: lto: permit the use of .a archives in LTO modules
  ANDROID: arm64: only permit certain alternatives in the FIPS140 module
  ANDROID: crypto: lib/aes - add vendor hooks for AES library routines
  ANDROID: crypto: lib/sha256 - add vendor hook for sha256() routine
  UPSTREAM: KVM: arm64: Mark the host stage-2 memory pools static
  ...

Conflicts:
	drivers/mmc/core/mmc_ops.c
	drivers/usb/gadget/function/f_uac1.c
	drivers/usb/gadget/function/f_uac2.c
	drivers/usb/gadget/function/f_uvc.c
This commit is contained in:
Tao Huang
2021-06-25 11:32:04 +08:00
2079 changed files with 53577 additions and 32096 deletions

View File

@@ -439,7 +439,7 @@ quiet_cmd_link_multi-m = AR [M] $@
cmd_link_multi-m = \
$(cmd_update_lto_symversions); \
rm -f $@; \
$(AR) cDPrsT $@ $(filter %.o,$^)
$(AR) cDPrsT $@ $(filter %.o %.a,$^)
else
quiet_cmd_link_multi-m = LD [M] $@
cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^)

View File

@@ -2,6 +2,8 @@
CFLAGS_KASAN_NOSANITIZE := -fno-builtin
KASAN_SHADOW_OFFSET ?= $(CONFIG_KASAN_SHADOW_OFFSET)
cc-param = $(call cc-option, -mllvm -$(1), $(call cc-option, --param $(1)))
ifdef CONFIG_KASAN_STACK
stack_enable := 1
else
@@ -18,8 +20,6 @@ endif
CFLAGS_KASAN_MINIMAL := -fsanitize=kernel-address
cc-param = $(call cc-option, -mllvm -$(1), $(call cc-option, --param $(1)))
# -fasan-shadow-offset fails without -fsanitize
CFLAGS_KASAN_SHADOW := $(call cc-option, -fsanitize=kernel-address \
-fasan-shadow-offset=$(KASAN_SHADOW_OFFSET), \
@@ -42,14 +42,14 @@ endif # CONFIG_KASAN_GENERIC
ifdef CONFIG_KASAN_SW_TAGS
ifdef CONFIG_KASAN_INLINE
instrumentation_flags := -mllvm -hwasan-mapping-offset=$(KASAN_SHADOW_OFFSET)
instrumentation_flags := $(call cc-param,hwasan-mapping-offset=$(KASAN_SHADOW_OFFSET))
else
instrumentation_flags := -mllvm -hwasan-instrument-with-calls=1
instrumentation_flags := $(call cc-param,hwasan-instrument-with-calls=1)
endif
CFLAGS_KASAN := -fsanitize=kernel-hwaddress \
-mllvm -hwasan-instrument-stack=$(stack_enable) \
-mllvm -hwasan-use-short-granules=0 \
$(call cc-param,hwasan-instrument-stack=$(stack_enable)) \
$(call cc-param,hwasan-use-short-granules=0) \
$(instrumentation_flags)
endif # CONFIG_KASAN_SW_TAGS

View File

@@ -58,6 +58,23 @@ quiet_cmd_ld_ko_o = LD [M] $@
-T scripts/module.lds -o $@ $(filter %.o, $^); \
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
ifdef CONFIG_CFI_CLANG
# LLVM can drops jump table symbols from the final binary. Add them
# back to make stack traces and other symbol output readable.
cmd_ld_ko_o += ; \
$(srctree)/scripts/generate_cfi_kallsyms.pl --module \
$@ > $(@:.ko=.lds); \
if [ -s $(@:.ko=.lds) ]; then \
$(LD) -r $(KBUILD_LDFLAGS) \
$(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
-T $(@:.ko=.lds) \
-o $(@:.ko=.tmp.ko) $@; \
mv -f $(@:.ko=.tmp.ko) $@; \
else \
rm -f $(@:.ko=.lds); \
fi
endif
$(modules): %.ko: %$(prelink-ext).o %.mod.o scripts/module.lds FORCE
+$(call if_changed,ld_ko_o)

View File

@@ -70,9 +70,22 @@ else
ifeq ($(KBUILD_EXTMOD),)
input-symdump := $(mixed-build-prefix)vmlinux.symvers
output-symdump := Module.symvers
output-symdump := modules-only.symvers
module_srcpath := $(srctree)
quiet_cmd_cat = GEN $@
cmd_cat = cat $(real-prereqs) > $@
ifneq ($(wildcard $(mixed-build-prefix)vmlinux.symvers),)
__modpost: Module.symvers
Module.symvers: $(mixed-build-prefix)vmlinux.symvers modules-only.symvers FORCE
$(call if_changed,cat)
targets += Module.symvers
endif
else
# set src + obj - they may be used in the modules's Makefile

View File

@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
#
# Copyright 2004 Matt Mackall <mpm@selenic.com>
#

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (C) Google LLC, 2018

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (C) Google LLC, 2020

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-2.0
# Manipulate options in a .config file from the command line

View File

@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
#
# diffconfig - a tool to compare .config files.

View File

@@ -19,7 +19,26 @@ esac
# We need access to CONFIG_ symbols
. include/config/auto.conf
ksym_wl=/dev/null
needed_symbols=
# Special case for modversions (see modpost.c)
if [ -n "$CONFIG_MODVERSIONS" ]; then
needed_symbols="$needed_symbols module_layout"
fi
# With CONFIG_LTO_CLANG, LLVM bitcode has not yet been compiled into a binary
# when the .mod files are generated, which means they don't yet contain
# references to certain symbols that will be present in the final binaries.
if [ -n "$CONFIG_LTO_CLANG" ]; then
# intrinsic functions
needed_symbols="$needed_symbols memcpy memmove memset"
# ftrace
needed_symbols="$needed_symbols _mcount"
# stack protector symbols
needed_symbols="$needed_symbols __stack_chk_fail __stack_chk_guard"
fi
ksym_wl=
if [ -n "$CONFIG_UNUSED_KSYMS_WHITELIST" ]; then
# Use 'eval' to expand the whitelist path and check if it is relative
eval ksym_wl="$CONFIG_UNUSED_KSYMS_WHITELIST"
@@ -40,16 +59,14 @@ cat > "$output_file" << EOT
EOT
[ -f modules.order ] && modlist=modules.order || modlist=/dev/null
sed 's/ko$/mod/' $modlist |
xargs -n1 sed -n -e '2{s/ /\n/g;/^$/!p;}' -- |
cat - "$ksym_wl" |
{
sed 's/ko$/mod/' $modlist | xargs -n1 sed -n -e '2p'
echo "$needed_symbols"
[ -n "$ksym_wl" ] && cat "$ksym_wl"
} | sed -e 's/ /\n/g' | sed -n -e '/^$/!p' |
# Remove the dot prefix for ppc64; symbol names with a dot (.) hold entry
# point addresses.
sed -e 's/^\.//' |
sort -u |
sed -e 's/\(.*\)/#define __KSYM_\1 1/' >> "$output_file"
# Special case for modversions (see modpost.c)
if [ -n "$CONFIG_MODVERSIONS" ]; then
echo "#define __KSYM_module_layout 1" >> "$output_file"
fi

308
scripts/generate_cfi_kallsyms.pl Executable file
View File

@@ -0,0 +1,308 @@
#!/usr/bin/env perl
# SPDX-License-Identifier: GPL-2.0
#
# Generates a list of Control-Flow Integrity (CFI) jump table symbols
# for kallsyms.
#
# Copyright (C) 2021 Google LLC
use strict;
use warnings;
## parameters
my $ismodule = 0;
my $file;
foreach (@ARGV) {
if ($_ eq '--module') {
$ismodule = 1;
} elsif (!defined($file)) {
$file = $_;
} else {
die "$0: usage $0 [--module] binary";
}
}
## environment
my $readelf = $ENV{'READELF'} || die "$0: ERROR: READELF not set?";
my $objdump = $ENV{'OBJDUMP'} || die "$0: ERROR: OBJDUMP not set?";
my $nm = $ENV{'NM'} || die "$0: ERROR: NM not set?";
## jump table addresses
my $cfi_jt = {};
## text symbols
my $text_symbols = {};
## parser state
use constant {
UNKNOWN => 0,
SYMBOL => 1,
HINT => 2,
BRANCH => 3,
RELOC => 4
};
## trims leading zeros from a string
sub trim_zeros {
my ($n) = @_;
$n =~ s/^0+//;
$n = 0 if ($n eq '');
return $n;
}
## finds __cfi_jt_* symbols from the binary to locate the start and end of the
## jump table
sub find_cfi_jt {
open(my $fh, "\"$readelf\" --symbols \"$file\" 2>/dev/null | grep __cfi_jt_ |")
or die "$0: ERROR: failed to execute \"$readelf\": $!";
while (<$fh>) {
chomp;
my ($addr, $name) = $_ =~ /\:.*([a-f0-9]{16}).*\s__cfi_jt_(.*)/;
if (defined($addr) && defined($name)) {
$cfi_jt->{$name} = $addr;
}
}
close($fh);
die "$0: ERROR: __cfi_jt_start symbol missing" if !exists($cfi_jt->{"start"});
die "$0: ERROR: __cfi_jt_end symbol missing" if !exists($cfi_jt->{"end"});
}
my $last = UNKNOWN;
my $last_symbol;
my $last_hint_addr;
my $last_branch_addr;
my $last_branch_target;
my $last_reloc_target;
sub is_symbol {
my ($line) = @_;
my ($addr, $symbol) = $_ =~ /^([a-f0-9]{16})\s<([^>]+)>\:/;
if (defined($addr) && defined($symbol)) {
$last = SYMBOL;
$last_symbol = $symbol;
return 1;
}
return 0;
}
sub is_hint {
my ($line) = @_;
my ($hint) = $_ =~ /^\s*([a-f0-9]+)\:.*\s+hint\s+#/;
if (defined($hint)) {
$last = HINT;
$last_hint_addr = $hint;
return 1;
}
return 0;
}
sub find_text_symbol {
my ($target) = @_;
my ($symbol, $expr, $offset) = $target =~ /^(\S*)([-\+])0x([a-f0-9]+)?$/;
if (!defined($symbol) || !defined(!$expr) || !defined($offset)) {
return $target;
}
if ($symbol =~ /^\.((init|exit)\.)?text$/ && $expr eq '+') {
$offset = trim_zeros($offset);
my $actual = $text_symbols->{"$symbol+$offset"};
if (!defined($actual)) {
die "$0: unknown symbol at $symbol+0x$offset";
}
$symbol = $actual;
}
return $symbol;
}
sub is_branch {
my ($line) = @_;
my ($addr, $instr, $branch_target) = $_ =~
/^\s*([a-f0-9]+)\:.*(b|jmpq?)\s+0x[a-f0-9]+\s+<([^>]+)>/;
if (defined($addr) && defined($instr) && defined($branch_target)) {
if ($last eq HINT) {
$last_branch_addr = $last_hint_addr;
} else {
$last_branch_addr = $addr;
}
$last = BRANCH;
$last_branch_target = find_text_symbol($branch_target);
return 1;
}
return 0;
}
sub is_branch_reloc {
my ($line) = @_;
if ($last ne BRANCH) {
return 0;
}
my ($addr, $type, $reloc_target) = /\s*([a-f0-9]{16})\:\s+R_(\S+)\s+(\S+)$/;
if (defined($addr) && defined($type) && defined($reloc_target)) {
$last = RELOC;
$last_reloc_target = find_text_symbol($reloc_target);
return 1;
}
return 0;
}
## walks through the jump table looking for branches and prints out a jump
## table symbol for each branch if one is missing
sub print_missing_symbols {
my @symbols;
open(my $fh, "\"$objdump\" -d -r " .
"--start-address=0x" . $cfi_jt->{"start"} .
" --stop-address=0x" . $cfi_jt->{"end"} .
" \"$file\" 2>/dev/null |")
or die "$0: ERROR: failed to execute \"$objdump\": $!";
while (<$fh>) {
chomp;
if (is_symbol($_) || is_hint($_)) {
next;
}
my $cfi_jt_symbol;
if (is_branch($_)) {
if ($ismodule) {
next; # wait for the relocation
}
$cfi_jt_symbol = $last_branch_target;
} elsif (is_branch_reloc($_)) {
$cfi_jt_symbol = $last_reloc_target;
} else {
next;
}
# ignore functions with a canonical jump table
if ($cfi_jt_symbol =~ /\.cfi$/) {
next;
}
$cfi_jt_symbol .= ".cfi_jt";
$cfi_jt->{$last_branch_addr} = $cfi_jt_symbol;
if (defined($last_symbol) && $last_symbol eq $cfi_jt_symbol) {
next; # already exists
}
# print out the symbol
if ($ismodule) {
push(@symbols, "\t\t$cfi_jt_symbol = . + 0x$last_branch_addr;");
} else {
push(@symbols, "$last_branch_addr t $cfi_jt_symbol");
}
}
close($fh);
if (!scalar(@symbols)) {
return;
}
if ($ismodule) {
print "SECTIONS {\n";
# With -fpatchable-function-entry, LLD isn't happy without this
print "\t__patchable_function_entries : { *(__patchable_function_entries) }\n";
print "\t.text : {\n";
}
foreach (@symbols) {
print "$_\n";
}
if ($ismodule) {
print "\t}\n}\n";
}
}
## reads defined text symbols from the file
sub read_symbols {
open(my $fh, "\"$objdump\" --syms \"$file\" 2>/dev/null |")
or die "$0: ERROR: failed to execute \"$nm\": $!";
while (<$fh>) {
chomp;
# llvm/tools/llvm-objdump/objdump.cpp:objdump::printSymbol
my ($addr, $debug, $section, $ref, $symbol) = $_ =~
/^([a-f0-9]{16})\s.{5}(.).{2}(\S+)\s[a-f0-9]{16}(\s\.\S+)?\s(.*)$/;
if (defined($addr) && defined($section) && defined($symbol)) {
if (!($section =~ /^\.((init|exit)\.)?text$/)) {
next;
}
# skip arm mapping symbols
if ($symbol =~ /^\$[xd]\.\d+$/) {
next;
}
if (defined($debug) && $debug eq "d") {
next;
}
$addr = trim_zeros($addr);
$text_symbols->{"$section+$addr"} = $symbol;
}
}
close($fh);
}
## prints out the remaining symbols from nm -n, filtering out the unnecessary
## __typeid__ symbols aliasing the jump table symbols we added
sub print_kallsyms {
open(my $fh, "\"$nm\" -n \"$file\" 2>/dev/null |")
or die "$0: ERROR: failed to execute \"$nm\": $!";
while (<$fh>) {
chomp;
my ($addr, $symbol) = $_ =~ /^([a-f0-9]{16})\s.\s(.*)$/;
if (defined($addr) && defined($symbol)) {
# drop duplicate __typeid__ symbols
if ($symbol =~ /^__typeid__.*_global_addr$/ &&
exists($cfi_jt->{$addr})) {
next;
}
}
print "$_\n";
}
close($fh);
}
## main
find_cfi_jt();
if ($ismodule) {
read_symbols();
print_missing_symbols();
} else {
print_missing_symbols();
print_kallsyms();
}

View File

@@ -1,4 +1,4 @@
#!/usr/bin/perl
#!/usr/bin/env perl
# SPDX-License-Identifier: GPL-2.0
use strict;

View File

@@ -504,8 +504,8 @@ static int get_mext_match(const char *match_str, match_f flag)
else if (flag == FIND_NEXT_MATCH_UP)
--match_start;
match_start = (match_start + items_num) % items_num;
index = match_start;
index = (index + items_num) % items_num;
while (true) {
char *str = k_menu_items[index].str;
if (strcasestr(str, match_str) != NULL)

View File

@@ -260,7 +260,15 @@ kallsyms()
fi
info KSYMS ${2}
${NM} -n ${1} | scripts/kallsyms ${kallsymopt} > ${2}
if [ -n "${CONFIG_CFI_CLANG}" ]; then
${PERL} ${srctree}/scripts/generate_cfi_kallsyms.pl ${1} | \
sort -n > .tmp_kallsyms
else
${NM} -n ${1} > .tmp_kallsyms
fi
scripts/kallsyms ${kallsymopt} < .tmp_kallsyms > ${2}
}
# Perform one step in kallsyms generation, including temporary linking of
@@ -298,6 +306,7 @@ cleanup()
{
rm -f .btf.*
rm -f .tmp_System.map
rm -f .tmp_kallsyms
rm -f .tmp_initcalls.lds
rm -f .tmp_symversions.lds
rm -f .tmp_vmlinux*

View File

@@ -1,5 +0,0 @@
memcpy
memmove
memset
__stack_chk_fail
__stack_chk_guard

View File

@@ -2482,19 +2482,6 @@ fail:
fatal("parse error in symbol dump file\n");
}
/* For normal builds always dump all symbols.
* For external modules only dump symbols
* that are not read from kernel Module.symvers.
**/
static int dump_sym(struct symbol *sym)
{
if (!external_module)
return 1;
if (sym->module->from_dump)
return 0;
return 1;
}
static void write_dump(const char *fname)
{
struct buffer buf = { };
@@ -2505,7 +2492,7 @@ static void write_dump(const char *fname)
for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {
symbol = symbolhash[n];
while (symbol) {
if (dump_sym(symbol)) {
if (!symbol->module->from_dump) {
namespace = symbol->namespace;
buf_printf(&buf, "0x%08x\t%s\t%s\t%s\t%s\n",
symbol->crc, symbol->name,

View File

@@ -33,6 +33,7 @@ SECTIONS {
__patchable_function_entries : { *(__patchable_function_entries) }
#ifdef CONFIG_LTO_CLANG
/*
* With CONFIG_LTO_CLANG, LLD always enables -fdata-sections and
* -ffunction-sections, which increases the size of the final module.
@@ -49,8 +50,10 @@ SECTIONS {
}
.rodata : {
*(.rodata.._start)
*(.rodata .rodata.[0-9a-zA-Z_]*)
*(.rodata..L*)
*(.rodata.._end)
}
#ifdef CONFIG_CFI_CLANG
@@ -59,10 +62,16 @@ SECTIONS {
* .text section, and that the section is aligned to page size.
*/
.text : ALIGN(PAGE_SIZE) {
*(.text.._start)
*(.text.__cfi_check)
*(.text .text.[0-9a-zA-Z_]* .text..L.cfi*)
*(.text .text.[0-9a-zA-Z_]*)
__cfi_jt_start = .;
*(.text..L.cfi.jumptable .text..L.cfi.jumptable.*)
__cfi_jt_end = .;
*(.text.._end)
}
#endif
#endif
}
/* bring in arch-specific sections */

View File

@@ -395,7 +395,7 @@ if ($arch eq "x86_64") {
$mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$";
} elsif ($arch eq "riscv") {
$function_regex = "^([0-9a-fA-F]+)\\s+<([^.0-9][0-9a-zA-Z_\\.]+)>:";
$mcount_regex = "^\\s*([0-9a-fA-F]+):\\sR_RISCV_CALL\\s_mcount\$";
$mcount_regex = "^\\s*([0-9a-fA-F]+):\\sR_RISCV_CALL(_PLT)?\\s_?mcount\$";
$type = ".quad";
$alignment = 2;
} elsif ($arch eq "nds32") {

View File

@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python
# SPDX-License-Identifier: GPL-2.0-only
#
# show_deltas: Read list of printk messages instrumented with

View File

@@ -1,4 +1,4 @@
#!/usr/bin/perl
#!/usr/bin/env perl
# SPDX-License-Identifier: GPL-2.0-or-later
use strict;

View File

@@ -1,4 +1,4 @@
#!/usr/bin/perl
#!/usr/bin/env perl
# SPDX-License-Identifier: GPL-2.0
#
# Author: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

View File

@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python
# SPDX-License-Identifier: GPL-2.0-only
"""