Commit Graph

982459 Commits

Author SHA1 Message Date
Steve Muckle
8a30a2cadd ANDROID: GKI: update virtual device symbol list
No ABI changes expected.

Bug: 202405948
Signed-off-by: Steve Muckle <smuckle@google.com>
Change-Id: I26010314259d1325999fbe9a640532031a44a6cc
2021-10-30 00:17:37 +00:00
Eric Biggers
cf721d6c46 ANDROID: ABI: add new symbols required by fips140.ko
Add KMI_SYMBOL_LIST_ADD_ONLY=1 to build.config.gki.aarch64.fips140, then
regenerate the fips140 symbol list and ABI XML as follows:

    BUILD_CONFIG=common/build.config.gki.aarch64.fips140 build/build_abi.sh --update-symbol-list
    BUILD_CONFIG=common/build.config.gki.aarch64 build/build_abi.sh --update --print-report

Leaf changes summary: 7 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 7 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

7 Added functions:

  [A] 'function int ahash_register_instance(crypto_template*, ahash_instance*)'
  [A] 'function int crypto_grab_spawn(crypto_spawn*, crypto_instance*, const char*, u32, u32)'
  [A] 'function int crypto_register_aeads(aead_alg*, int)'
  [A] 'function int crypto_register_ahashes(ahash_alg*, int)'
  [A] 'function int crypto_register_rng(rng_alg*)'
  [A] 'function crypto_tfm* crypto_spawn_tfm(crypto_spawn*, u32, u32)'
  [A] 'function void crypto_unregister_rng(rng_alg*)'

Bug: 188620248
Change-Id: Ibc066a431decc123f428ecf5ae0b51b1ad838a8a
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-10-29 14:32:49 -07:00
Eric Biggers
482b0323cf ANDROID: fips140: zeroize temporary values from integrity check
FIPS 140-3 requires this for some reason.

Bug: 188620248
Change-Id: I7c286532097e1d8971faf4d8be31b801f9007e3b
Signed-off-by: Eric Biggers <ebiggers@google.com>
(cherry picked from commit c14d52059b)
2021-10-29 13:32:14 -07:00
Eric Biggers
ecf9341134 ANDROID: fips140: remove in-place updating of live algorithms
The lab has confirmed that it is actually fine for users to keep using
non-FIPS code after the module has loaded if they were already using it
beforehand.  So remove the code that tried to prevent this by updating
live algorithms in-place.  Similarly, remove the call to
synchronize_rcu_tasks() which no longer has any purpose.

We still need to move the live algorithms to a private list, so keep
doing that.  Keep appending "+orig" to cra_name as well, and start doing
the same for cra_driver_name too.

Bug: 188620248
Change-Id: I29c9faec7d7314484a03f9729924b2f892552c7c
Signed-off-by: Eric Biggers <ebiggers@google.com>
(cherry picked from commit 54aecb72db)
2021-10-29 13:32:14 -07:00
Eric Biggers
e45108ecff ANDROID: fips140: block crypto operations until tests complete
As per the new guidance from the lab, the module must block crypto
operations until the tests have completed.  It's unclear what this means
exactly (given that technically this is impossible), but let's make some
changes that should be enough to comply with the requirement's intent.

First, register the library functions and update the live algorithms
after the tests rather than before the tests.  This is a trivial change.

Much more problematic is the fact that the algorithms are registered
with the kernel's crypto framework before the tests run, as the tests
depend on the framework.  Unfortunately, the lab believes that the
kernel isn't allowed to enforce the ordering here; the module itself
must.  Moreover, trying to solve this by copying the crypto API
framework into the module proved to be heavily problematic.

Thus, implement an alternate solution: make the module override the tfm
initialization function of every algorithm it registers, so that it can
wait for the tests to complete before allowing the use of any algorithm.
This is sufficient if the user makes a supported sequence of API calls.

Bug: 153614920
Bug: 188620248
Change-Id: I11ffba90c08114dda4e91c4be7ce8b608c4e14c1
Signed-off-by: Eric Biggers <ebiggers@google.com>
(cherry picked from commit 02e48f383b)
2021-10-29 13:32:14 -07:00
Ard Biesheuvel
6b995f5a54 ANDROID: fips140: preserve RELA sections without relying on the module loader
Instead of having a special case in the core kernel's module loader that
treats a module called 'fips140.ko' in a special way, use a host tool to
tweak the ELF metadata of this module so that the RELA data is preserved
and accessible to the module init code.

This is done in the following way:
- each RELA section that we care about (the ones for .text and .rodata
  at the moment) is copied into a new section called .init.rela.<name>
  with the SHF_ALLOC attribute, so that the module loader will copy it
  into __init memory at load time;
- for each such section, an offset/count tuple is added as a global
  variable to the module;
- the count field of those tuples is populated directly by the host tool
  based on the actual size of the RELA section in question;
- the offset field is decorated with a place-relative relocation against
  the start of the copied RELA section via a weak symbol reference,
  which causes an entry to be emitted into the ELF symbol table;
- these ELF symbol table entries are updated by the host tool and turned
  into STT_SECTION type symbols with STB_GLOBAL linkage, carrying the
  correct section index.

With these changes in place, the unmodified module loader will load all
required information into memory in a way that permits the module init
code to locate the relocations, and apply them in reverse.

Bug: 153614920
Bug: 188620248
Change-Id: I07d9704febdf913834502dd09c19aa4a04d983b1
Signed-off-by: Ard Biesheuvel <ardb@google.com>
(cherry picked from commit 502af6e349)
2021-10-29 13:32:14 -07:00
Ard Biesheuvel
e8d56bd78b ANDROID: module: apply special LTO treatment to .text even if CFI is disabled
We currently only emit directives for handling the .text section into
the module linker script if both LTO and CFI are enabled, while for
other sections, we do this even if CFI is not enabled. This is
inconsistent at best, but as it also interferes with the assumption in
the fips140.ko module that the .text._start and .text._end input
sections are placed at the very start and end of the .text section,
which currently can only be relied upon if CFI is enabled.

So rearrange the #ifdef so that it only covers the .text.__cfi_check
input section. Note that aligning to page size is likely to be redundant
in any case, given that the .text section is laid out first, and module
allocations are page aligned to begin with, so making that part
unconditional is unlikely to make an observeable difference in the
output.

Bug: 153614920
Bug: 188620248
Fixes: 6be141eb36 ("ANDROID: crypto: fips140 - perform load time integrity check")
Change-Id: I3f9ed0ae8fa8fe5693c8d2964566cbb42c101aa7
Signed-off-by: Ard Biesheuvel <ardb@google.com>
(cherry picked from commit 6ae8277450)
2021-10-29 13:32:13 -07:00
Eric Biggers
52b70d491b ANDROID: fips140: use FIPS140_CFLAGS when compiling fips140-selftests.c
These flags are supposed to be used when building all source files for
the module.

Bug: 188620248
Fixes: b7397e89db ("ANDROID: fips140: add power-up cryptographic self-tests")
Change-Id: I41cacff040c8a8a0065dd3cfc537303f1ff18335
Signed-off-by: Eric Biggers <ebiggers@google.com>
(cherry picked from commit 422bc2feb7)
2021-10-29 13:32:13 -07:00
Eric Biggers
e5b14396f9 ANDROID: fips140: take into account AES-GCM not being approvable
Unfortunately, the AES-GCM implementations won't actually be able to be
FIPS-approved.  One consequence of this is that the "cmac" template will
need to be tested with all underlying "aes" implementations, as the
equivalent test with "gcm" won't count as fulfilling the requirement to
test all AES implementations in an authenticated mode when supported.
Update the self-tests and comments accordingly.

Bug: 153614920
Bug: 188620248
Change-Id: I874b0718a5ff9d4e2dea2353448266e87f3f0d0b
Signed-off-by: Eric Biggers <ebiggers@google.com>
(cherry picked from commit a9765fb6dc)
2021-10-29 13:32:13 -07:00
Eric Biggers
960ebb2b56 ANDROID: fips140: add jitterentropy to fips140 module
Although jitterentropy doesn't necessarily need to be part of
fips140.ko, it does need to have the SP800-90B health tests enabled, and
that requires that it be compiled with the fips_enabled flag set.  The
easiest way to do this is just to include a copy of it in fips140.ko.

Bug: 153614920
Bug: 188620248
Change-Id: I9dc0281e07e08e0650e3d340897c697722ad3b1a
Signed-off-by: Eric Biggers <ebiggers@google.com>
(cherry picked from commit cae2421105)
2021-10-29 13:32:13 -07:00
Eric Biggers
2ee56aad31 ANDROID: fips140: add AES-CMAC
AES-CMAC is a FIPS allowed algorithm, and fips140.ko already has
arm64 implementations of it.  Meanwhile, GKI includes both these arm64
implementations as well as the "cmac" template.  Add the "cmac" template
to fips140.ko too and add a self-test for AES-CMAC, so that we can
include AES-CMAC in the set of algorithms which will be certified.

As with a number of the other algorithms, the criteria for which
algorithms need to be in the certified set are still not particularly
clear, but the latest guidance we've received is to error on the side of
including algorithms.

Bug: 153614920
Bug: 188620248
Change-Id: I6c1d9281fe848a7101d5ef94ab48e5a41bbcc6f8
Signed-off-by: Eric Biggers <ebiggers@google.com>
(cherry picked from commit 038dc9f2cc)
2021-10-29 13:32:13 -07:00
Eric Biggers
2b5843ae2d ANDROID: fips140: add AES-CBC-CTS
AES-CBC-CTS is a FIPS allowed algorithm, and fips140.ko already has
arm64 implementations of it.  Meanwhile, GKI includes both these arm64
implementations as well as the "cts" template.  Add the "cts" template
to fips140.ko too and add a self-test for AES-CBC-CTS, so that we can
include AES-CBC-CTS in the set of algorithms which will be certified.

There appears to be no support for CBC-CTS mode in pycryptodome or
python-cryptography, so I manually added the test vector.

As with a number of the other algorithms, the criteria for which
algorithms need to be in the certified set are still not particularly
clear, but the latest guidance we've received is to error on the side of
including algorithms.  Android uses AES-CBC-CTS for filenames
encryption, which may be relevant (though arguably this use case doesn't
actually require a FIPS approved algorithm).

Bug: 153614920
Bug: 188620248
Change-Id: I53ffbd1d38493592eeaf471bc0007978ec400878
Signed-off-by: Eric Biggers <ebiggers@google.com>
(cherry picked from commit e2cfdfbc51)
2021-10-29 13:32:13 -07:00
Eric Biggers
1be58af077 ANDROID: fips140: remove non-prediction-resistant DRBG test
The lab has confirmed that this test is not required.

Bug: 153614920
Bug: 188620248
Change-Id: Ie55031beacd00f093db3a7ba30fe0844a2ce363b
Signed-off-by: Eric Biggers <ebiggers@google.com>
(cherry picked from commit ea902862ea)
2021-10-29 13:32:13 -07:00
Eric Biggers
17ccefe140 ANDROID: fips140: use full 16-byte IV
By using the initial_value parameter when creating the pycryptodome
AES-CTR instance, we can use any 16-byte IV, like the other AES modes.
Therefore, there's no need for the last 4 bytes of the IV to be 0.
This doesn't really matter, but it seems nice to avoid this quirk.

Bug: 153614920
Bug: 188620248
Change-Id: If33de260b1119f2b3e004164199b08364781ab23
Signed-off-by: Eric Biggers <ebiggers@google.com>
(cherry picked from commit fa5a44b364)
2021-10-29 13:32:13 -07:00
Eric Biggers
b397a0387c ANDROID: fips140: test all implementations
Test all implementations of each algorithm rather than just the highest
priority implementation.  This aligns with the revised guidance we have
received from the lab.

We can still skip some tests in some cases, as per the FIPS 140-2
Implementation Guidance document.  See the comments for details.

To align with the new scope of the tests, the fips140.broken_alg module
parameter now must specify an implementation (e.g. "sha256-ce") rather
than an algorithm (e.g. "sha256").

No change to the DRBG tests is required, as it turns out the module only
includes HMAC_DRBG.  However, clarify the comment about the DRBG tests.

On a Pixel device, this increases the running time of the fips140 tests
from 0.5ms to 3.1 ms (very roughly; there's a lot of variation).  This
is still very fast, so it isn't expected to be a problem.

Bug: 153614920
Bug: 173104584
Bug: 188620248
Change-Id: I555b535dd45f0164b7744a2c9338c501bb88de86
Signed-off-by: Eric Biggers <ebiggers@google.com>
(cherry picked from commit abe0780696)
2021-10-29 13:32:12 -07:00
Bicycle Tsai
82c940e0e1 ANDROID: Update symbol list for mtk
Generated with:
BUILD_CONFIG=common/build.config.gki.aarch64 build/build_abi.sh --update

Leaf changes summary: 2 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 1 Added
function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 1 Added
variable

1 Added function:

  [A] 'function int
__traceiter_android_vh_snd_soc_card_get_comp_chain(void*, bool*)'

1 Added variable:

  [A] 'tracepoint __tracepoint_android_vh_snd_soc_card_get_comp_chain'

Bug: 198732156
Signed-off-by: Bicycle Tsai <bicycle.tsai@mediatek.com>
Change-Id: I1327ec4b1ba8df264007ebdeab86c15785d5a46a
2021-10-29 23:37:17 +08:00
Bicycle Tsai
8d68a30fe1 ANDROID: ASoC: soc-pcm: Get all BEs along DAPM path
dpcm_end_walk_at_be() stops the graph walk when first BE is found for
the given FE component. In a component model we may want to connect
multiple DAIs from different components.

android_vh_snd_soc_card_get_comp_chain can be registered here
to allows DAI/component chaining.

Later PCM operations can be called for all these listed components for a
valid DAPM path.

ALSA machine driver can setup component_chaining like below code slice.

static void my_board_component_chaining_hook(void *data, bool *ret)
{
        *ret = true;
}

static int my_board_dev_probe(struct platform_device *pdev)
{

        register_trace_android_vh_snd_soc_card_get_comp_chain(
                my_board_component_chaining_hook, NULL);

        return 0;
}

static int my_board_dev_remove(struct platform_device *pdev)
{
        unregister_trace_android_vh_snd_soc_card_get_comp_chain(
                my_board_component_chaining_hook, NULL);

        return 0;
}

static struct platform_driver my_board_driver = {
        ...
        .probe = my_board_dev_probe,
        .remove = my_board_dev_remove,
        ...
};

Bug: 198732156
Signed-off-by: Bicycle Tsai <bicycle.tsai@mediatek.com>
Change-Id: Ife5df291d40af9ec83d57462b6a08aba95d9119d
2021-10-29 22:04:59 +08:00
Giuliano Procida
ea440234c7 ANDROID: GKI: refresh XML following ANDROID_KABI_USE change
The ABI diff is essentially bogus, but included here for completeness.

Leaf changes summary: 1 artifact changed
Changed leaf types summary: 1 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 0 Added function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

'struct xhci_hcd at xhci.h:1756:1' changed:
  type size hasn't changed
  1 data member deletion:
    'union {xhci_vendor_ops* vendor_ops; struct {u64 android_kabi_reserved1;} __UNIQUE_ID_android_kabi_hide322; union {};}', at offset 59392 (in bits) at xhci.h:1935:1
  18 impacted interfaces

Bug: 210255585
Change-Id: Ic646e0edd2ab19fcd9b7b88b6e6a604299fc4824
Signed-off-by: Giuliano Procida <gprocida@google.com>
2021-10-29 11:11:40 +01:00
Greg Kroah-Hartman
f8b361d17d ANDROID: GKI: rework the ANDROID_KABI_USE() macro to not use __UNIQUE()
The __UNIQUE_ID() macro causes problems as it turns out to not be
deterministic across different compiler runs as it relies on the
__COUNTER__ macro which could have been used on other .h files previous
to this .h file being included.

This shows up specifically when building with "LTO=thin" vs. "LTO=full"
as different build paths seem to be triggered.

As the structure name isn't really needed at all here, we were just
including it for older compilers that could not handle anonymous
structures in a union, just drop the whole thing which resolves the abi
naming issue.

Bug: 210255585
Reported-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I6b9449fa9d26ffc5d66b2f0f3b41e2d5f3003f68
2021-10-29 10:57:02 +01:00
Woody Lin
ad8da78c87 UPSTREAM: sched/scs: Reset the shadow stack when idle_task_exit
Commit f1a0a376ca ("sched/core: Initialize the idle task with
preemption disabled") removed the init_idle() call from
idle_thread_get(). This was the sole call-path on hotplug that resets
the Shadow Call Stack (scs) Stack Pointer (sp).

Not resetting the scs-sp leads to scs overflow after enough hotplug
cycles. Therefore add an explicit scs_task_reset() to the hotplug code
to make sure the scs-sp does get reset on hotplug.

Fixes: f1a0a376ca ("sched/core: Initialize the idle task with preemption disabled")
Signed-off-by: Woody Lin <woodylin@google.com>
[peterz: Changelog]
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>
Link: https://lore.kernel.org/r/20211012083521.973587-1-woodylin@google.com
(cherry picked from commit 63acd42c0d)
Bug: 201047587
Bug: 201771367
Change-Id: I9e48270f8d4c698c140cc3f427cadae636acb6d7
2021-10-29 01:25:30 +00:00
Tengfei Fan
74782dd0ce ANDROID: cpuhp/pause: add function define if not define CONFIG_CPUSETS
Add define of cpuset_update_active_cpus_affine() for fix compile error
when not define CONFIG_CPUSETS.

Bug: 204347727
Fixes: 09bd9e940e ("ANDROID: cpuhp/pause: schedule cpu_hotplug_work on
resume cpu")
Change-Id: Icf79df5e22233d15e4e8257a5f54176efbcd975b
Signed-off-by: Tengfei Fan <quic_tengfan@quicinc.com>
Signed-off-by: Maria Yu <quic_aiquny@quicinc.com>
2021-10-28 15:12:01 +00:00
Liangliang Li
75a5637ccf ANDROID: GKI: Add a symbol to vendor symbol list
Functions changes summary: 0 Removed, 0 Changed (2375 filtered out), 2 Added functions
Variables changes summary: 0 Removed, 0 Changed (24 filtered out), 2 Added variables

2 Added functions:

  [A] 'function int __traceiter_android_vh_filemap_fault_cache_page(void*, vm_fault*, page*)'
  [A] 'function int __traceiter_android_vh_filemap_fault_get_page(void*, vm_fault*, page**, bool*)'

2 Added variables:

  [A] 'tracepoint __tracepoint_android_vh_filemap_fault_cache_page'
  [A] 'tracepoint __tracepoint_android_vh_filemap_fault_get_page'

Bug: 204163778

Change-Id: I579eedf59470f5c806e28abe7148a99e52b1ff90
Signed-off-by: Liangliang Li <liliangliang@vivo.com>
2021-10-28 02:01:57 +00:00
Jaegeuk Kim
1c0e68339c ANDROID: f2fs: fix potential deadlock by android ftrace
sb_internal#2 --> &s->s_dquot.dqio_sem --> fs_reclaim

  Possible unsafe locking scenario:

        CPU0                    CPU1
        ----                    ----
   lock(fs_reclaim);
                                lock(&s->s_dquot.dqio_sem);
                                lock(fs_reclaim);
   lock(sb_internal#2);

 *** DEADLOCK ***

 3 locks held by kswapd0/133:
  #0: ffffffda597c93a8 (fs_reclaim){+.+.}-{0:0}, at: __fs_reclaim_acquire+0x4/0x50
  #1: ffffffda597bc890 (shrinker_rwsem){++++}-{3:3}, at: shrink_slab+0xa0/0x19c
  #2: ffffff80d5fb90e0 (&type->s_umount_key#50){.+.+}-{3:3}, at: super_cache_scan+0x40/0x1dc

stack backtrace:
 CPU: 7 PID: 133 Comm: kswapd0 Tainted: G        W  O      5.10.43-android12-9-g4665ec64f3df #1
 Hardware name: MT6879(ENG) (DT)
 Call trace:
  dump_backtrace.cfi_jt+0x0/0x8
  show_stack+0x1c/0x2c
  dump_stack_lvl+0xd8/0x16c
  print_circular_bug+0x2d4/0x2d8
  check_noncircular+0x190/0x1a4
  validate_chain+0xc54/0x2d34
  __lock_acquire+0x7e4/0xed4
  lock_acquire+0x114/0x394
  f2fs_evict_inode+0x1a0/0x8b8
  evict+0xd4/0x2f8
  iput+0x1c0/0x258
  dentry_unlink_inode+0x16c/0x1dc
  __dentry_kill+0x128/0x280
  shrink_dentry_list+0x6c/0x420
  prune_dcache_sb+0x5c/0x90
  super_cache_scan+0x13c/0x1dc
  do_shrink_slab+0x1e0/0x388
  shrink_slab+0xf4/0x19c
  shrink_node_memcgs+0x80/0x25c
  shrink_node+0x324/0x710
  balance_pgdat+0x3a8/0x6a8
  kswapd+0x484/0x594
  kthread+0x15c/0x1ac
  ret_from_fork+0x10/0x30

Bug: 201025620
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: Idaa303eb7c681a56ad5d4e1f6dddbda71f7fece4
2021-10-27 18:37:38 +00:00
Dan Vacura
8d5dd0a5a4 ANDROID: gki_defconfig: enable CONFIG_USB_CONFIGFS_F_UVC
Enable the UVC function driver to allow USB gadgets
to connect as a standard video device to a host.

Bug: 200712777
Signed-off-by: Dan Vacura <w36195@motorola.com>
Change-Id: Ia037f8560664f9e98f28f3fede609764d5d5699d
2021-10-27 12:55:32 +00:00
Jiewen Wang
d4091df63c ANDROID: GKI: Update symbols list for vivo
Add symbol to symbol list for oem module.

Functions changes summary: 0 Removed, 0 Changed (2375 filtered out), 1
Added functions
Variables changes summary: 0 Removed, 0 Changed (24 filtered out), 1
Added variables

1 Added function:

  [A] 'function int __traceiter_android_vh_shrink_slab_bypass(void*,
gfp_t, int, mem_cgroup*, int, bool*)'

1 Added variable:

  [A] 'tracepoint __tracepoint_android_vh_shrink_slab_bypass'

Bug: 204278767
Change-Id: I075f034ddad2657435429a9f712322a3a207caa6
Signed-off-by: Jiewen Wang <jiewen.wang@vivo.com>
2021-10-27 17:37:32 +08:00
Giuliano Procida
a451a6c447 ANDROID: GKI: Add missing symbol list whitespace
The missing leading whitespace in android/abi_gki_aarch64_galaxy
caused its symbols to be dropped from the distribution
abi_symbollist file and the distribution vmlinux binary.

Bug: 203852249
Change-Id: I7854401e0a55ad89beacde588c24f1d1698e9e17
Signed-off-by: Giuliano Procida <gprocida@google.com>
2021-10-27 07:45:39 +00:00
Greg Kroah-Hartman
a32d8ee384 Revert "ANDROID: mpam: add vendor hook to record MPAM"
This reverts commit 1aa1f6a7cf.

The hook android_vh_mpam_set is not used by any vendor, so remove
it to help with merge issues with future LTS releases.

If this is needed by any real user, it can easily be reverted to add it
back and then the symbol should be added to the abi list at the same
time to prevent it from being removed again later.

Bug: 203756332
Bug: 165333282
Cc: C-J.Chen <C-J.Chen@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I18356743538df7d41a00f54479bf2a0bc3a62e06
2021-10-27 08:05:03 +02:00
Aaron Ding
2ccbb92f7f ANDROID: userfaultfd: Fix merge resolution: validate_range()
On the android12-5.10 branch, commit 4a5cf92412 ("BACKPORT: FROMGIT:
userfaultfd: add UFFDIO_CONTINUE ioctl") added a new call site for the
function validate_range(). Meanwhile, on the 5.10 stable branch, commit
0b591c020d ("userfaultfd: do not untag user pointers") changed the
function signature of validate_range() and updated all call sites
accordingly. However, since these two commits happened on different
branches, the new call site in userfaultfd_continue() has not been
updated accordingly. This has arguably been missed in the merge commit
66379c1ee5 ("Merge tag 'android12-5.10.66_r00' into
android12-5.10").

This patch fixes the following build breakage

./common/fs/userfaultfd.c:1875:32: error: incompatible pointer to integer conversion passing '__u64 *' (aka 'unsigned long long *') to parameter of type '__u64' (aka 'unsigned long long'); remove & [-Werror,-Wint-conversion]

        ret = validate_range(ctx->mm, &uffdio_continue.range.start,
                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./common/fs/userfaultfd.c:1245:14: note: passing argument to parameter 'start' here
                                          __u64 start, __u64 len)
                                                ^
1 error generated.

Fixes: 66379c1ee5 ("Merge tag 'android12-5.10.66_r00' into android12-5.10")
Signed-off-by: Aaron Ding <aaronding@google.com>
Signed-off-by: Daniel Mentz <danielmentz@google.com>
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Change-Id: I7ad40df213897314c439480f22a2ef4712e84025
(cherry picked from commit 5ec931a853)
2021-10-26 21:43:22 +00:00
Tengfei Fan
09bd9e940e ANDROID: cpuhp/pause: schedule cpu_hotplug_work on resume cpu
Resume cpu need to run cpuset_hotplug_workfn which need take
about several milliseconds, and even more if the system have
more tasks.
This isn't suitable to run in the main task context of resume
cpu.
Due to the cpu which is resuming only have active mask,
but still not rebuild sched domain, make this slow
work run on resuming cpu can not take extra overload to
previous active cpus.

Bug: 203839955
Fixes: 1d3a64fbd2 ("ANDROID: cpu/hotplug: rebuild sched
domains immediately")
Change-Id: Ia7bdd077f982950c02696c3598a41b2482046220
Signed-off-by: Tengfei Fan <quic_tengfan@quicinc.com>
Signed-off-by: Maria Yu <quic_aiquny@quicinc.com>
2021-10-26 19:57:45 +00:00
Liujie Xie
2a813b466b ANDROID: GKI: Update symbols to abi_gki_aarch64_oplus
Update symbols to symbol list externed by oem modules.

Leaf changes summary: 10 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 5 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 5 Added variables

5 Added functions:

  [A] 'function int __traceiter_android_vh_mem_cgroup_alloc(void*, mem_cgroup*)'
  [A] 'function int __traceiter_android_vh_mem_cgroup_css_offline(void*, cgroup_subsys_state*, mem_cgroup*)'
  [A] 'function int __traceiter_android_vh_mem_cgroup_css_online(void*, cgroup_subsys_state*, mem_cgroup*)'
  [A] 'function int __traceiter_android_vh_mem_cgroup_free(void*, mem_cgroup*)'
  [A] 'function int __traceiter_android_vh_mem_cgroup_id_remove(void*, mem_cgroup*)'

5 Added variables:

  [A] 'tracepoint __tracepoint_android_vh_mem_cgroup_alloc'
  [A] 'tracepoint __tracepoint_android_vh_mem_cgroup_css_offline'
  [A] 'tracepoint __tracepoint_android_vh_mem_cgroup_css_online'
  [A] 'tracepoint __tracepoint_android_vh_mem_cgroup_free'
  [A] 'tracepoint __tracepoint_android_vh_mem_cgroup_id_remove'

Bug: 193384408
Change-Id: Ia5112f375626f04481b0042ec808c67f78891086
Signed-off-by: Liujie Xie <xieliujie@oppo.com>
2021-10-26 23:54:35 +08:00
Jiewen Wang
a8c611fa24 ANDROID: GKI: Update symbols list for vivo
Add symbol to symbol list for oem module.

Functions changes summary: 0 Removed, 0 Changed, 2 Added functions
Variables changes summary: 0 Removed, 0 Changed, 2 Added variables

2 Added functions:

  [A] 'function int __traceiter_android_vh_mmap_region(void*,
vm_area_struct*, unsigned long int)'
  [A] 'function int __traceiter_android_vh_try_to_unmap_one(void*,
vm_area_struct*, page*, unsigned long int, bool)'

2 Added variables:

  [A] 'tracepoint __tracepoint_android_vh_mmap_region'
  [A] 'tracepoint __tracepoint_android_vh_try_to_unmap_one'

Bug: 204157239
Change-Id: I52791ae530d94afc0016a845c3649c67fbe37613
Signed-off-by: Jiewen Wang <jiewen.wang@vivo.com>
2021-10-26 17:37:27 +08:00
Bicycle Tsai
16493a3c87 Revert "BACKPORT: ASoC: soc-pcm: Get all BEs along DAPM path"
This reverts commit c82dbcbec1.

Reason for revert: use vendor_hook approach instead of adding a new field.

Change-Id: I001dafc1b90cfe4567a13f538c2f8d25a0929504
Signed-off-by: Bicycle Tsai <bicycle.tsai@mediatek.corp-partner.google.com>
2021-10-26 11:13:09 +08:00
Jack Pham
a84e45d3c3 FROMGIT: usb: dwc3: gadget: Skip resizing EP's TX FIFO if already resized
Some functions may dynamically enable and disable their endpoints
regularly throughout their operation, particularly when Set Interface
is employed to switch between Alternate Settings.  For instance the
UAC2 function has its respective endpoints for playback & capture
associated with AltSetting 1, in which case those endpoints would not
get enabled until the host activates the AltSetting.  And they
conversely become disabled when the interfaces' AltSetting 0 is
chosen.

With the DWC3 FIFO resizing algorithm recently added, every
usb_ep_enable() call results in a call to resize that EP's TXFIFO,
but if the same endpoint is enabled again and again, this incorrectly
leads to FIFO RAM allocation exhaustion as the mechanism did not
account for the possibility that endpoints can be re-enabled many
times.

Example log splat:

	dwc3 a600000.dwc3: Fifosize(3717) > RAM size(3462) ep3in depth:217973127
	configfs-gadget gadget: u_audio_start_capture:521 Error!
	dwc3 a600000.dwc3: request 000000000be13e18 was not queued to ep3in

Add another bit DWC3_EP_TXFIFO_RESIZED to dep->flags to keep track of
whether an EP had already been resized in the current configuration.
If so, bail out of dwc3_gadget_resize_tx_fifos() to avoid the
calculation error resulting from accumulating the EP's FIFO depth
repeatedly.  This flag is retained across multiple ep_disable() and
ep_enable() calls and is cleared when GTXFIFOSIZn is reset in
dwc3_gadget_clear_tx_fifos() upon receiving the next Set Config.

Fixes: 9f607a309f ("usb: dwc3: Resize TX FIFOs to meet EP bursting requirements")
Reviewed-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Link: https://lore.kernel.org/r/20211021180129.27938-1-jackp@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

(cherry picked from commit 876a75cb52
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Bug: 204047971
Change-Id: Ia104c2fa9be36182a23a7e6f923e499ef3bcc3b1
Signed-off-by: Jack Pham <quic_jackp@quicinc.com>
2021-10-25 12:02:09 -07:00
Wesley Cheng
168de6b1d9 FROMGIT: usb: dwc3: gadget: Change to dev_dbg() when queuing to inactive gadget/ep
Since function drivers will still be active until dwc3_disconnect_gadget()
is called, some applications will continue to queue packets to DWC3
gadget.  This can lead to a flood of messages regarding failed ep queue,
as the endpoint is in the process of being disabled.  Change the log
level to debug, so that it can be enabled when debugging issues.

Signed-off-by: Wesley Cheng <wcheng@codeaurora.org>
Link: https://lore.kernel.org/r/20211018192647.32121-1-wcheng@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

(cherry picked from commit b851f7c7b8
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Bug: 203763122
Change-Id: I5120890fa12f707ae54da551db9aab02dded0063
Signed-off-by: Wesley Cheng <wcheng@codeaurora.org>
2021-10-25 18:34:33 +00:00
Woogeun Lee
6cb41901ea ANDROID: ABI: update allowed list for galaxy
Leaf changes summary: 11 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 10 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 1 Added variable

10 Added functions:

  [A] 'function int blkcg_activate_policy(request_queue*, const blkcg_policy*)'
  [A] 'function void blkcg_deactivate_policy(request_queue*, const blkcg_policy*)'
  [A] 'function int blkcg_policy_register(blkcg_policy*)'
  [A] 'function void blkcg_policy_unregister(blkcg_policy*)'
  [A] 'function blkcg_gq* blkg_lookup_slowpath(blkcg*, request_queue*, bool)'
  [A] 'function cgroup_subsys_state* css_next_descendant_pre(cgroup_subsys_state*, cgroup_subsys_state*)'
  [A] 'function int dump_align(coredump_params*, int)'
  [A] 'function int dump_emit(coredump_params*, void*, int)'
  [A] 'function cgroup_subsys_state* kthread_blkcg()'
  [A] 'function cgroup_subsys_state* of_css(kernfs_open_file*)'

1 Added variable:

  [A] 'blkcg blkcg_root'

Bug: 203800167

Signed-off-by: Woogeun Lee <woogeun.lee@samsung.com>
Change-Id: Ide71cb03541352a83466b922951bb9be4aba585f
2021-10-25 17:58:38 +00:00
Guangming Cao
48e5c07fe0 ANDROID: dma_heap: add dma_parms for uncached heap
In system_heap_do_allocate, we will use uncached heap device to call
dma_map_sgtable & dma_unmap_sgtable to do implicitly flush.

However, device of uncached heap is not set dma_parms, default value(64KB)
is too small for dma_heap buffer, it will cause some warning log below when
CONFIG_DMA_API_DEBUG_SG is enabled.

warning log sample:
 |DMA-API: dma_heap system-uncached: mapping sg segment longer than device claims to support [len=1048576] [max=65536]
 |WARNING: CPU: 4 PID: 576 at kernel/dma/debug.c:1173 debug_dma_map_sg+0x214/0x438
 |......

Bug: 199986022
Change-Id: I97076de329f4a50d035d43d69cb17606064c3151
Signed-off-by: Guangming Cao <Guangming.Cao@mediatek.com>
2021-10-25 17:34:19 +00:00
Kever Yang
a0345d4590 ANDROID: GKI: rockchip: Enable symbols for pinctrl and rk8xx
Leaf changes summary: 2 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 2 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

2 Added functions:

  [A] 'function pinctrl_gpio_range* pinctrl_find_gpio_range_from_pin(pinctrl_dev*, unsigned int)'
  [A] 'function int spi_write_then_read(spi_device*, void*, unsigned int, void*, unsigned int)'

Bug: 194515348
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Change-Id: I97054044d799ddfdc969c4c616a2121187c41e77
2021-10-25 14:47:35 +08:00
Kever Yang
8e9111c2b2 ANDROID: GKI: rockchip: Enable symbols for typec
Leaf changes summary: 11 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 11 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

11 Added functions:

  [A] 'function int __typec_altmode_register_driver(typec_altmode_driver*, module*)'
  [A] 'function fwnode_handle* fwnode_create_software_node(const property_entry*, const fwnode_handle*)'
  [A] 'function tcpm_port* tcpm_register_port(device*, tcpc_dev*)'
  [A] 'function void tcpm_unregister_port(tcpm_port*)'
  [A] 'function typec_port* typec_altmode2port(typec_altmode*)'
  [A] 'function int typec_altmode_enter(typec_altmode*, u32*)'
  [A] 'function int typec_altmode_exit(typec_altmode*)'
  [A] 'function int typec_altmode_notify(typec_altmode*, unsigned long int, void*)'
  [A] 'function void typec_altmode_unregister_driver(typec_altmode_driver*)'
  [A] 'function int typec_altmode_vdm(typec_altmode*, const u32, const u32*, int)'
  [A] 'function int typec_get_negotiated_svdm_version(typec_port*)'

Bug: 194515348
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Change-Id: Iced97aa635613a36cde1af500edda173e12a2ca6
2021-10-25 09:50:49 +08:00
Kever Yang
28edc30761 ANDROID: GKI: rockchip: Add build script
Add build script for rockchip platform.

Bug: 194515348
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Change-Id: Id848456a233114bb270d1715a7262788bb467b58
2021-10-25 08:57:33 +08:00
Liangliang Li
9329ddc34d ANDROID: GKI: Add some symbols to symbol list to support vendor module
Add symbol to symbol list for oem module.

Functions changes summary: 0 Removed, 0 Changed (4125 filtered out), 0 Added functions
Variables changes summary: 0 Removed, 0 Changed (404 filtered out), 5 Added variables

5 Added variables:

  [A] 'tracepoint __tracepoint_android_rvh_tcp_recvmsg'
  [A] 'tracepoint __tracepoint_android_rvh_tcp_recvmsg_stat'
  [A] 'tracepoint __tracepoint_android_rvh_tcp_sendmsg_locked'
  [A] 'tracepoint __tracepoint_android_rvh_udp_recvmsg'
  [A] 'tracepoint __tracepoint_android_rvh_udp_sendmsg'

Bug: 203861645
Change-Id: I13ac74ea48f26ec1ea4a9dd4fc01aded1b04e106
Signed-off-by: Liangliang Li <liliangliang@vivo.com>
2021-10-22 21:34:18 +00:00
Bean Huo
bd4a84253c UPSTREAM: core: Add L2P entry swap quirk for Micron UFS
For Micron UFS devices the L2P entry need to be byteswapped before sending
an HPB READ command to the UFS device. Add the quirk
UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ to address this.

Link: https://lore.kernel.org/r/20210804182128.458356-2-huobean@gmail.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

(cherry picked from commit 63522bf3ac)
Signed-off-by: Luca Porzio <porzio@gmail.com>
Change-Id: I69cfa43c5439e8cace4fe5b2760a38b43d734621
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-10-21 10:55:52 -07:00
Yee Lee
44b339535e ANDROID: gki_defconfig: remove CONFIG_UBSAN_MISC entry
CONFIG_UBSAN_MISC is seperated to individual options and
no longer existed in configuration. Hence, remove the
entry from gki_defconfig. The other UBSAN configs are
unset to align with android-mainline.

Bug: 199373673
Ref: https://android-review.googlesource.com/c/kernel/common/+/1584824
Signed-off-by: Yee Lee <yee.lee@mediatek.com>
Change-Id: I9f525fcd386eb7cc2503afb130a5230b5e730bee
2021-10-21 08:33:14 -07:00
Andrey Ryabinin
71f70987f9 UPSTREAM: ubsan: remove overflow checks
Since GCC 8.0 -fsanitize=signed-integer-overflow doesn't work with
-fwrapv.  -fwrapv makes signed overflows defines and GCC essentially
disables ubsan checks.  On GCC < 8.0 -fwrapv doesn't have influence on
-fsanitize=signed-integer-overflow setting, so it kinda works but
generates false-positves and violates uaccess rules:

lib/iov_iter.o: warning: objtool: iovec_from_user()+0x22d: call to
__ubsan_handle_add_overflow() with UACCESS enabled

Disable signed overflow checks to avoid these problems.  Remove unsigned
overflow checks as well.  Unsigned overflow appeared as side effect of
commit cdf8a76fda ("ubsan: move cc-option tests into Kconfig"), but it
never worked (kernel doesn't boot).  And unsigned overflows are allowed by
C standard, so it just pointless.

Link: https://lkml.kernel.org/r/20210209232348.20510-1-ryabinin.a.a@gmail.com
Signed-off-by: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Bug: 199373673
(cherry picked from commit 6aaa31aeb9)
Signed-off-by: Yee Lee <yee.lee@mediatek.com>
Change-Id: I7f0e9d7a4d7c69c21e42bd21070c5d265bddbff1
2021-10-21 08:33:13 -07:00
Arnd Bergmann
65a04c1a8e UPSTREAM: ubsan: disable unsigned-overflow check for i386
Building ubsan kernels even for compile-testing introduced these
warnings in my randconfig environment:

  crypto/blake2b_generic.c:98:13: error: stack frame size of 9636 bytes in function 'blake2b_compress' [-Werror,-Wframe-larger-than=]
  static void blake2b_compress(struct blake2b_state *S,

  crypto/sha512_generic.c:151:13: error: stack frame size of 1292 bytes in function 'sha512_generic_block_fn' [-Werror,-Wframe-larger-than=]
  static void sha512_generic_block_fn(struct sha512_state *sst, u8 const *src,

  lib/crypto/curve25519-fiat32.c:312:22: error: stack frame size of 2180 bytes in function 'fe_mul_impl' [-Werror,-Wframe-larger-than=]
  static noinline void fe_mul_impl(u32 out[10], const u32 in1[10], const u32 in2[10])

  lib/crypto/curve25519-fiat32.c:444:22: error: stack frame size of 1588 bytes in function 'fe_sqr_impl' [-Werror,-Wframe-larger-than=]
  static noinline void fe_sqr_impl(u32 out[10], const u32 in1[10])

Further testing showed that this is caused by
-fsanitize=unsigned-integer-overflow, but is isolated to the 32-bit x86
architecture.

The one in blake2b immediately overflows the 8KB stack area
architectures, so better ensure this never happens by disabling the
option for 32-bit x86.

Link: https://lkml.kernel.org/r/20210112202922.2454435-1-arnd@kernel.org
Link: https://lore.kernel.org/lkml/20201230154749.746641-1-arnd@kernel.org/
Fixes: d0a3ac549f ("ubsan: enable for all*config builds")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Marco Elver <elver@google.com>
Cc: George Popescu <georgepope@android.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Bug: 199373673
(cherry picked from commit 251b5497c5)
Signed-off-by: Yee Lee <yee.lee@mediatek.com>
Change-Id: I1855d47cb0525cdbf523fced4cbb75189dbb6f32
2021-10-21 08:33:13 -07:00
Kees Cook
7611578ecb UPSTREAM: ubsan: expand tests and reporting
Expand the UBSAN tests to include some additional UB cases.  Notably the
out-of-bounds enum loading appears not to work.  Also include per-test
reporting, including the relevant CONFIG_UBSAN...  Kconfigs.

Link: https://lkml.kernel.org/r/20201203004437.389959-8-keescook@chromium.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: George Popescu <georgepope@android.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Marco Elver <elver@google.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: Nathan Chancellor <natechancellor@gmail.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Bug: 199373673
(cherry picked from commit 4a26f49b7b)
Signed-off-by: Yee Lee <yee.lee@mediatek.com>
Change-Id: I7fb1fdd9301a54d30d8defdecf00300cd8bdcf30
2021-10-21 08:33:13 -07:00
Kees Cook
fca16257ca UPSTREAM: ubsan: remove UBSAN_MISC in favor of individual options
Make each UBSAN option individually selectable and remove UBSAN_MISC which
no longer has any purpose.  Add help text for each Kconfig, and include a
reference to the Clang sanitizer documentation.  Disable unsigned overflow
by default (not available with GCC and makes x86 unbootable with Clang).
Disable unreachable when objtool is in use (redundant and confuses things:
instrumentation appears at unreachable locations).

Link: https://lkml.kernel.org/r/20201203004437.389959-7-keescook@chromium.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: George Popescu <georgepope@android.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Marco Elver <elver@google.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: Nathan Chancellor <natechancellor@gmail.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Bug: 199373673
(cherry picked from commit c637693b20)
Signed-off-by: Yee Lee <yee.lee@mediatek.com>
Change-Id: I23c9578641db66e1514ff4c37874864298a12767
2021-10-21 08:33:13 -07:00
Kees Cook
c2985e13dd UPSTREAM: ubsan: enable for all*config builds
With UBSAN_OBJECT_SIZE disabled for GCC, only UBSAN_ALIGNMENT remained a
noisy UBSAN option.  Disable it for COMPILE_TEST so the rest of UBSAN can
be used for full all*config builds or other large combinations.

[sfr@canb.auug.org.au: add .data..Lubsan_data*/.data..Lubsan_type* sections explicitly]
  Link: https://lkml.kernel.org/r/20201208230157.42c42789@canb.auug.org.au

Link: https://lore.kernel.org/lkml/CAHk-=wgXW=YLxGN0QVpp-1w5GDd2pf1W-FqY15poKzoVfik2qA@mail.gmail.com/
Link: https://lkml.kernel.org/r/20201203004437.389959-6-keescook@chromium.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: George Popescu <georgepope@android.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Marco Elver <elver@google.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: Nathan Chancellor <natechancellor@gmail.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Bug: 199373673
(cherry picked from commit d0a3ac549f)
Signed-off-by: Yee Lee <yee.lee@mediatek.com>
Change-Id: I5c7f60627993e4fa4e866dfa27a459cc8e4674d9
2021-10-21 08:33:13 -07:00
Kees Cook
5eb5780afe UPSTREAM: ubsan: disable UBSAN_TRAP for all*config
Doing all*config builds attempts to build as much as possible. UBSAN_TRAP
effectively short-circuits lib/usban.c, so it should be disabled for
COMPILE_TEST so that the lib/ubsan.c code gets built.

Link: https://lkml.kernel.org/r/20201203004437.389959-5-keescook@chromium.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: George Popescu <georgepope@android.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Marco Elver <elver@google.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Bug: 199373673
(cherry picked from commit 79791378a1)
Signed-off-by: Yee Lee <yee.lee@mediatek.com>
Change-Id: I550630279775ddf4d1129d7cfa717152c103b24a
2021-10-21 08:33:13 -07:00
Kees Cook
c108d79a12 UPSTREAM: ubsan: disable object-size sanitizer under GCC
GCC's -fsanitize=object-size (as part of CONFIG_UBSAN_MISC) greatly
increases stack utilization.  Do not allow this under GCC.

Link: https://lkml.kernel.org/r/20201203004437.389959-4-keescook@chromium.org
Link: https://lore.kernel.org/lkml/CAHk-=wjPasyJrDuwDnpHJS2TuQfExwe=px-SzLeN8GFMAQJPmQ@mail.gmail.com/
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: George Popescu <georgepope@android.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Marco Elver <elver@google.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Bug: 199373673
(cherry picked from commit 61e0349f70)
Signed-off-by: Yee Lee <yee.lee@mediatek.com>
Change-Id: If7f5ecfe7a8bc47ff9a8300026bf2a0744cd7507
2021-10-21 08:33:12 -07:00
Kees Cook
9ecd3c915d UPSTREAM: ubsan: move cc-option tests into Kconfig
Instead of doing if/endif blocks with cc-option calls in the UBSAN
Makefile, move all the tests into Kconfig and use the Makefile to collect
the results.

Link: https://lkml.kernel.org/r/20201203004437.389959-3-keescook@chromium.org
Link: https://lore.kernel.org/lkml/CAHk-=wjPasyJrDuwDnpHJS2TuQfExwe=px-SzLeN8GFMAQJPmQ@mail.gmail.com/
Signed-off-by: Kees Cook <keescook@chromium.org>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: George Popescu <georgepope@android.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Marco Elver <elver@google.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Bug: 199373673
(cherry picked from commit cdf8a76fda)
Signed-off-by: Yee Lee <yee.lee@mediatek.com>
Change-Id: Ib192ad08af1aabd92f4a04cda2494ae3518c5028
2021-10-21 08:33:12 -07:00