Commit Graph

972003 Commits

Author SHA1 Message Date
Kees Cook 6d022d9f96 ANDROID: x86/extable: Do not mark exception callback as CFI
The exception table entries are constructed out of a relative offset
and point to the actual function, not the CFI table entry. For now,
just mark the caller as not checking CFI. The failure is most visible
at boot with CONFIG_DEBUG_RODATA_TEST=y.

Bug: 145210207
Change-Id: Idf6efed424fc95ef20ddd69596478dc813754ce4
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:34:34 +00:00
Sami Tolvanen 5f5334aba7 ANDROID: arm64: disable BTI with CFI for Clang <12
Older versions of Clang didn't generate BTI instructions for the
compiler-generated CFI check functions. As CFI provides a more
fine-grained control-flow checking then BTI, disable BTI when CFI is
enabled and we're using Clang <12.

Bug: 145210207
Change-Id: I248bc761443e4f354cf4dfbfc3db0fc22385ce63
Link: https://bugs.llvm.org/show_bug.cgi?id=46258
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:34:20 +00:00
Sami Tolvanen 2df99b6397 ANDROID: KVM: arm64: disable CFI for hypervisor code
Disable LTO+CFI for code that runs at EL2 to avoid address space
confusion as the CFI jump tables point to EL1 addresses.

Bug: 145210207
Change-Id: I81359ec648b2616e85dfd3bb399327bac980b3fe
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:34:06 +00:00
Sami Tolvanen 4c81c26cdc ANDROID: arm64: add __nocfi to __apply_alternatives
__apply_alternatives makes indirect calls to functions whose address is
taken in assembly code using the alternative_cb macro. With CFI enabled
using non-canonical jump tables, the compiler isn't able to replace the
function reference with the jump table reference, which trips CFI.

Bug: 145210207
Change-Id: I2361b601d987cd25f88aa0b9f37b400ff566febc
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:33:54 +00:00
Sami Tolvanen b1debb369c ANDROID: arm64: add __va_function and __pa_function
We use non-canonical CFI jump tables with CONFIG_CFI_CLANG, which
means the compiler replaces function address references with the
address of the function's CFI jump table entry. This results in
__pa_symbol(function), for example, returning the physical address
of the jump table entry, which can lead to address space confusion
since the jump table itself points to a virtual address. The same
issue happens when passing function pointers to hypervisor code
running at EL2.

This change adds __va_function and __pa_function macros, which use
inline assembly to take the actual function address instead, and
changes the relevant code to use these macros.

Bug: 145210207
Change-Id: Ie3079c10427bde705a2244cfb3cb5fb954e5e065
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:33:37 +00:00
Sami Tolvanen 58f2ba8ac1 ANDROID: arm64: add __nocfi to functions that jump to a physical address
Disable CFI checking for functions that switch to linear mapping and
make an indirect call to a physical address, since the compiler only
understands virtual addresses.

Bug: 145210207
Change-Id: I2bd39c5891d4f2ce033e5ee515cf86d96eb0447f
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:33:21 +00:00
Sami Tolvanen 429733db42 ANDROID: lkdtm: use __va_function
To ensure we take the actual address of a function in kernel text,
use __va_function. Otherwise, with CONFIG_CFI_CLANG, the compiler
may replace the address with a pointer to the CFI jump table, which
can reside inside the module, when compiled with CONFIG_LKDTM=m.

Bug: 145210207
Change-Id: Ie65d3aace55695a5e515436267c048b13ace9002
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:33:01 +00:00
Sami Tolvanen 404303026b FROMLIST: cfg80211: fix callback type mismatches in wext-compat
Instead of casting callback functions to type iw_handler, which trips
indirect call checking with Clang's Control-Flow Integrity (CFI), add
stub functions with the correct function type for the callbacks.

Bug: 145210207
Change-Id: Ief26496449ec985d600dd06b5e190dd21bf8eb4a
Link: https://lore.kernel.org/lkml/20201117205902.405316-1-samitolvanen@google.com/
Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:32:48 +00:00
Sami Tolvanen d54ee8a555 FROMLIST: lib/list_sort: fix function type mismatches
Casting the comparison function to a different type trips indirect call
Control-Flow Integrity (CFI) checking. Remove the additional consts from
cmp_func, and the now unneeded casts.

Bug: 145210207
Change-Id: Iffe0eeec8e7f65a5937513a4bb87e5107faa004e
Link: https://lore.kernel.org/lkml/20200110225602.91663-1-samitolvanen@google.com/
Fixes: 043b3f7b63 ("lib/list_sort: simplify and remove MAX_LIST_LENGTH_BITS")
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:32:31 +00:00
Sami Tolvanen e97c57662c ANDROID: bpf: disable CFI in dispatcher functions
BPF dispatcher functions are patched at runtime to perform direct
instead of indirect calls. Disable CFI for the dispatcher functions
to avoid conflicts.

Bug: 145210207
Change-Id: Iea72f5a9fe09dd5adbb90b0174945707f42594b0
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:32:10 +00:00
Sami Tolvanen db36655a24 ANDROID: kallsyms: cfi: strip hashes from static functions
With ThinLTO and CFI both enabled, LLVM appends a hash to the
names of all static functions. This breaks userspace tools, so
strip out the hash from output.

Bug: 145210207
Change-Id: Icc0173f1d754b378ae81a9f91d84c0814ba26b78
Suggested-by: Jack Pham <jackp@codeaurora.org>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:31:46 +00:00
Sami Tolvanen 0f186b1e6e ANDROID: kthread: cfi: disable callback pointer check with modules
With CFI, a callback function passed to __kthread_queue_delayed_work
from a module can point to a jump table entry defined in the module
instead of the one used in the core kernel, which breaks this test:

  WARN_ON_ONCE(timer->function != kthread_delayed_work_timer_fn);

To work around the problem, disable the warning when CFI and modules
are both enabled.

Bug: 145210207
Change-Id: I5b0a60bb69ce8e2bc0d8e4bf6736457b6425b6cf
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:31:11 +00:00
Sami Tolvanen 83eeb88742 ANDROID: workqueue: cfi: disable callback pointer check with modules
With CFI, a callback function passed to __queue_delayed_work from a
module can point to a jump table entry defined in the module instead
of the one used in the core kernel, which breaks this test:

  WARN_ON_ONCE(timer->function != delayed_work_timer_fn);

To work around the problem, disable the warning when CFI and modules
are both enabled.

Bug: 145210207
Change-Id: I2a631ea3da9e401af38accf1001082b93b9b3443
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:30:53 +00:00
Sami Tolvanen a4e9712d70 ANDROID: objtool: Find a destination for jumps beyond the section end
With -ffunction-sections, Clang can generate a jump beyond the end of a
section when the section ends in an unreachable instruction. If the
offset matches the section length, use the last instruction as the jump
destination.

Bug: 145210207
Change-Id: I422b805fe0e857915f0726404d14f62c01629849
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:30:38 +00:00
Sami Tolvanen 66d2edaa08 ANDROID: objtool: Ignore CFI jump tables
Skip checking for the compiler-generated jump table symbols when Clang's
Control-Flow Integrity (CFI) is enabled.

Bug: 145210207
Change-Id: Icd1fad50214016348289ac5980b062708ab9ecd0
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:30:18 +00:00
Sami Tolvanen e135c46cdf ANDROID: export: cfi: fix ksymtab addresses
With CONFIG_CFI_CLANG, LLVM replaces function references with CFI
jump table addresses to allow type checking with indirect calls. This is
unnecessary in ksymtab, so this change uses inline assembly to emit
ksymtab entries that point to the actual function instead when CFI is
enabled.

Bug: 145210207
Change-Id: I894af2c7df476eb00d656c7692a33b25de31e26d
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:30:01 +00:00
Sami Tolvanen 08f67ef189 ANDROID: module: cfi: ensure __cfi_check alignment
On modules with no executable code, LLVM generates a __cfi_check stub,
but won't align it to page size as expected. This change ensures the
function is at the beginning of the .text section and correctly aligned
for the CFI shadow.

Also discard the .eh_frame section, which LLD may emit with CFI_CLANG.

Bug: 145210207
Change-Id: I08923febb549aa64454282cc864ac80dadd717b9
Link: https://bugs.llvm.org/show_bug.cgi?id=46293
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:29:46 +00:00
Sami Tolvanen 6010ce3442 ANDROID: mm: add generic __va_function and __pa_function
We use non-canonical CFI jump tables with CONFIG_CFI_CLANG, which
means the compiler replaces function address references with the
address of the function's CFI jump table entry. This results in
__pa_symbol(function), for example, returning the physical address
of the jump table entry, which can lead to address space confusion
since the jump table itself points to a virtual address.

This change adds generic definitions for __pa/va_function, which
architectures that support CFI can override.

Bug: 145210207
Change-Id: I5b616901d5582478df613a4d28bf2b9c911edb46
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:29:30 +00:00
Sami Tolvanen 7bc9b9d25b ANDROID: cfi: add __cficanonical and fix PREL32 relocations
With non-canonical CFI, the compiler rewrites function references to
point to the CFI jump table for indirect call checking. This won't
happen when the address is taken in assembly, and will result in a CFI
failure if we jump to the address later in C code.

This change adds the __cficanonical attribute, which tells the
compiler to switch to a canonical jump table for the function. With
canonical CFI, the compiler appends a .cfi postfix to the function
name, and points the original symbol to the jump table. This allows
addresses taken in assembly code to be used for indirect calls without
tripping CFI checks.

Bug: 145210207
Change-Id: Iaca9d1d95f59d7169168d89bc10bf71420487a67
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:29:15 +00:00
Sami Tolvanen 2c351bb70a ANDROID: add support for Clang's Control Flow Integrity (CFI)
This change adds the CONFIG_CFI_CLANG option, CFI error handling,
and a faster look-up table for cross module CFI checks.

Bug: 145210207
Change-Id: I68d620ca548a911e2f49ba801bc0531406e679a3
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-01-14 16:28:57 +00:00
Paul Lawrence 3d04fb2c95 ANDROID: Incremental fs: Make data validation failure a warn
Bug: 177234986
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I79b4273a050b8695b5810abd618fcb4437a05ce5
2021-01-14 16:03:13 +00:00
Paul Lawrence 4994a7321f ANDROID: Incremental fs: Free mount info after files are flushed
Bug: 177280103
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I24b0d4bf5353834900f868f65e7510529867b615
2021-01-14 16:03:02 +00:00
Paul Lawrence a3c935a490 ANDROID: Incremental fs: Fix selinux issues
Bug: 177075428
Test: incfs_test passes
      atest GtsIncrementalInstallTestCases has only 8 failures
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I73accfc1982aec1cd7947996c25a23e4a97cfdac
2021-01-14 16:02:51 +00:00
Yurii Zubrytskyi b79605a904 ANDROID: Incremental fs: fix .blocks_written
.blocks_writen file handling was missing some operations:
SELinux xattr handlers, safety checks for it being a
pseudo file etc.

This CL generalizes pseudo file handling so that all such
files work in a generic way and next time it should be
easier to add all operations at once.

Bug: 175823975
Test: incfs_tests pass
Change-Id: Id2b1936018c81c62c8ab4cdbaa8827e2679b513f
Signed-off-by: Yurii Zubrytskyi <zyy@google.com>
Signed-off-by: Paul Lawrence <paullawrence@google.com>
2021-01-14 16:02:38 +00:00
Laura Abbott 43edfc892e FROMLIST: fs/buffer.c: Revoke LRU when trying to drop buffers
When a buffer is added to the LRU list, a reference is taken which is
not dropped until the buffer is evicted from the LRU list. This is the
correct behavior, however this LRU reference will prevent the buffer
from being dropped. This means that the buffer can't actually be dropped
until it is selected for eviction. There's no bound on the time spent
on the LRU list, which means that the buffer may be undroppable for
very long periods of time. Given that migration involves dropping
buffers, the associated page is now unmigratible for long periods of
time as well. CMA relies on being able to migrate a specific range
of pages, so these types of failures make CMA significantly
less reliable, especially under high filesystem usage.

Rather than waiting for the LRU algorithm to eventually kick out
the buffer, explicitly remove the buffer from the LRU list when trying
to drop it. There is still the possibility that the buffer
could be added back on the list, but that indicates the buffer is
still in use and would probably have other 'in use' indicates to
prevent dropping.

Note: a bug reported by "kernel test robot" lead to a switch from
using xas_for_each() to xa_for_each().

Bug: 174118021
Link: https://lore.kernel.org/linux-mm/cover.1610572007.git.cgoldswo@codeaurora.org/
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Chris Goldsworthy <cgoldswo@codeaurora.org>
Cc: Matthew Wilcox <willy@infradead.org>
Reported-by: kernel test robot <oliver.sang@intel.com>
Change-Id: I4a93c4ed81c57874764d12f3beea1194a30c13b2
2021-01-14 03:04:05 +00:00
Alistair Delva 150d7b683b ANDROID: dm-user: fix typo in channel_free
We loop around from_user, but we dereference to_user. Whoops.

Fixes this trace seen in some cleanup paths:

[   11.612684] BUG: unable to handle page fault for address: 0000000000113d62
[   11.612777] #PF: supervisor write access in kernel mode
[   11.612777] #PF: error_code(0x0002) - not-present page
[   11.612777] PGD 0 P4D 0
[   11.612777] Oops: 0002 [#1] PREEMPT SMP PTI
[   11.612777] CPU: 1 PID: 150 Comm: snapuserd Tainted: G           O      5.10.4-android12-0-03442-gf2684370d34d-ab7068937 #1
[   11.612777] Hardware name: ChromiumOS crosvm, BIOS 0
[   11.612777] RIP: 0010:channel_free+0xb0/0x140
[   11.612777] Code: 48 49 8b 5c 24 48 4c 39 fb 74 48 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 4c 8d 73 a0 4d 8b 2c 24 49 83 c5 38 48 8b 43 c8 <c6> 40 1a 0a 48 8b 7b c8 e8 e3 87 bd ff 48 8b 7b c8 e8 1a 71 bd ff
[   11.612777] RSP: 0018:ffff9728c029fc18 EFLAGS: 00010282
[   11.612777] RAX: 0000000000113d48 RBX: ffff8a3941e021d0 RCX: ffff8a3944221080
[   11.612777] RDX: ffff8a39452e5810 RSI: ffff8a39452e5800 RDI: ffff8a39486f9300
[   11.612777] RBP: ffff9728c029fc40 R08: ffff8a3940148500 R09: ffff8a394886a7c0
[   11.612777] R10: ffff8a3944200650 R11: ffffffff86623d30 R12: ffff8a39486f9300
[   11.612777] R13: ffff8a3941749638 R14: ffff8a3941e02170 R15: ffff8a39486f9348
[   11.612777] FS:  0000000000000000(0000) GS:ffff8a396bc80000(0000) knlGS:0000000000000000
[   11.612777] CS:  0010 DS: 002b ES: 002b CR0: 0000000080050033
[   11.612777] CR2: 0000000000113d62 CR3: 000000001820c005 CR4: 0000000000170ee0
[   11.612777] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[   11.612777] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[   11.612777] Call Trace:
[   11.612777]  dev_release+0x22/0x40
[   11.612777]  __fput+0xe0/0x210
[   11.612777]  ____fput+0x9/0x10
[   11.612777]  task_work_run+0x6f/0xb0
[   11.612777]  do_exit+0x332/0xa80
[   11.612777]  do_group_exit+0x8c/0xb0
[   11.612777]  get_signal+0x78d/0x9c0
[   11.612777]  arch_do_signal+0x80/0x260
[   11.612777]  exit_to_user_mode_prepare+0xaa/0xe0
[   11.612777]  syscall_exit_to_user_mode+0x24/0x40
[   11.612777]  __do_fast_syscall_32+0x7d/0x90
[   11.612777]  do_fast_syscall_32+0x34/0x70
[   11.612777]  do_SYSENTER_32+0x1b/0x20
[   11.612777]  entry_SYSENTER_compat_after_hwframe+0x4d/0x5f

Bug: 161496058
Test: launch_cvd ..
Change-Id: I26b244b66121324aef6956d01adcc3ad55c782a9
Signed-off-by: Alistair Delva <adelva@google.com>
2021-01-13 16:59:25 -08:00
Lina Iyer 35e4214e99 ANDROID: PM / Domains: add vendor_hook to disallow domain idle state
In order to debug critical domain and device power issues, it may be
necessary to disallow certain idle states at runtime. Enable a vendor
hook to check if a domain idle state is allowed for powering down the
domain.

Bug: 175718935
Signed-off-by: Lina Iyer <ilina@codeaurora.org>
Change-Id: I403c0c7d272439fb338bbf54a346861559385047
2021-01-13 21:36:28 +00:00
Rick Yiu bdc24c6aec ANDROID: sched: Export available_idle_cpu
Previously idle_cpu is exported which is used by vendor module to check
if a cpu is in idle state, but later we think available_idle_cpu is
better than idle_cpu because it also checks vcpu_is_preempted.

Bug: 171740453
Change-Id: I17ccc4925650431f334a9eb2bbc94a138ab36ae0
Signed-off-by: Rick Yiu <rickyiu@google.com>
Signed-off-by: Will McVicker <willmcvicker@google.com>
2021-01-13 19:47:10 +00:00
Daniel Mentz 7171a5de98 ANDROID: sched: Export sched_domains_mutex for lockdep
If CONFIG_LOCKDEP is enabled, export sched_domains_mutex as it is
indirectly accessed by the macro for_each_domain, and that macro might
be used in module code.

Bug: 176254015
Signed-off-by: Daniel Mentz <danielmentz@google.com>
Change-Id: Ia9f2989de41b2224c63855f2fd129cbeeac4f195
Signed-off-by: Will McVicker <willmcvicker@google.com>
2021-01-13 19:25:54 +00:00
Isaac J. Manjarres 7cfc6861b8 ANDROID: iommu/dma: Add support for DMA_ATTR_SYS_CACHE_ONLY_NWA
IOMMU_SYS_CACHE_ONLY_NWA allows buffers for non-coherent devices
to be mapped with the correct memory attributes so that the buffers
can be cached in the system cache, with a no write allocate cache policy.
However, this property is only usable by drivers that invoke the
IOMMU API directly; it is not usable by drivers that use the DMA API.

Thus, introduce DMA_ATTR_SYS_CACHE_ONLY_NWA, so that drivers for
non-coherent devices that use the DMA API can use it to specify if
they want a buffer to be cached in the system cache.

Bug: 176778547
Change-Id: Ic812a1fb144a58deb4279c2bf121fc6cc4c3b208
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
2021-01-13 18:27:04 +00:00
Isaac J. Manjarres 0b653f27bb ANDROID: iommu/dma: Add support fo DMA_ATTR_SYS_CACHE_ONLY
IOMMU_SYS_CACHE_ONLY allows buffers for non-coherent devices
to be mapped with the correct memory attributes so that the buffers
can be cached in the system cache. However, this property
is only usable by drivers that invoke the IOMMU API directly;
it is not usable by drivers that use the DMA API.

Thus, introduce DMA_ATTR_SYS_CACHE_ONLY, so that drivers for
non-coherent devices that use the DMA API can use it to specify if
they want a buffer to be cached in the system cache.

Bug: 176778547
Change-Id: I849d7a3f36b689afd2f6ee400507223fd6395158
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
2021-01-13 18:26:56 +00:00
Isaac J. Manjarres 261c5080bb ANDROID: arm64: Add support for system cache memory type
Non-coherent devices on systems that support a system or
last level cache may want to request that allocations be
cached in the system cache. For memory that is allocated
by the kernel, and used for DMA with devices, the memory
attributes used for CPU access should match the memory
attributes that will be used for device access.

The memory attributes that need to be programmed into
the MAIR for system cache usage are:

0xf4 - Normal memory, outer write back read/write allocate,
inner non-cacheable.

There is currently no support for this memory attribute for
CPU mappings, so add it.

Bug: 176778547
Change-Id: I3abc7becd408f20ac5499cbbe3c6c6f53f784107
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
2021-01-13 18:26:46 +00:00
Prateek Sood 084fab46dd ANDROID: ftrace: vendor hook for ftrace dump on oops
Add following vendor hooks in ftrace oops path to allow
vendor modules to get ftrace buffer data.

1) android_vh_ftrace_oops_enter
2) android_vh_ftrace_size_check
3) android_vh_ftrace_format_check
4) android_vh_ftrace_dump_buffer
5) android_vh_ftrace_oops_exit

Ftrace dump on oops can be controlled with kernel command
line parameter ftrace_dump_on_oops.

Bug: 177387994
Change-Id: I898026bfc3e5c5c5ab1eaa0e86a019a6a720408e
Signed-off-by: Prateek Sood <prsood@codeaurora.org>
Signed-off-by: Mukesh Ojha <mojha@codeaurora.org>
2021-01-13 17:50:19 +00:00
Prateek Sood 8420cd4a8c ANDROID: irqdesc: Export symbol for vendor modules
Export kstat_irqs_usr and kstat_irqs_cpu symbols for vendor
loadable modules. These symbols are useful for continuous
monitoring of irq stats to detect problems like interrupt
storms.

1) kstat_irqs_usr: it helps in getting total interrupt count
   for an IRQ.

2) kstat_irqs_cpu: it helps in getting per cpu interrupt count
   for an IRQ.

Bug: 177393442
Change-Id: I6f65c5759cd096db391e1c41e4260aa4ebc40fb4
Signed-off-by: Prateek Sood <prsood@codeaurora.org>
Signed-off-by: Mukesh Ojha <mojha@codeaurora.org>
2021-01-13 16:06:17 +00:00
Greg Kroah-Hartman 7eadb0006a Merge 5.10.7 into android12-5.10
Changes in 5.10.7
	i40e: Fix Error I40E_AQ_RC_EINVAL when removing VFs
	iavf: fix double-release of rtnl_lock
	net/sched: sch_taprio: ensure to reset/destroy all child qdiscs
	net: mvpp2: Add TCAM entry to drop flow control pause frames
	net: mvpp2: prs: fix PPPoE with ipv6 packet parse
	net: systemport: set dev->max_mtu to UMAC_MAX_MTU_SIZE
	ethernet: ucc_geth: fix use-after-free in ucc_geth_remove()
	ethernet: ucc_geth: set dev->max_mtu to 1518
	ionic: account for vlan tag len in rx buffer len
	atm: idt77252: call pci_disable_device() on error path
	net: mvpp2: Fix GoP port 3 Networking Complex Control configurations
	net: stmmac: dwmac-meson8b: ignore the second clock input
	ibmvnic: fix login buffer memory leak
	ibmvnic: continue fatal error reset after passive init
	net: ethernet: mvneta: Fix error handling in mvneta_probe
	qede: fix offload for IPIP tunnel packets
	virtio_net: Fix recursive call to cpus_read_lock()
	net/ncsi: Use real net-device for response handler
	net: ethernet: Fix memleak in ethoc_probe
	net-sysfs: take the rtnl lock when storing xps_cpus
	net-sysfs: take the rtnl lock when accessing xps_cpus_map and num_tc
	net-sysfs: take the rtnl lock when storing xps_rxqs
	net-sysfs: take the rtnl lock when accessing xps_rxqs_map and num_tc
	net: ethernet: ti: cpts: fix ethtool output when no ptp_clock registered
	tun: fix return value when the number of iovs exceeds MAX_SKB_FRAGS
	e1000e: Only run S0ix flows if shutdown succeeded
	e1000e: bump up timeout to wait when ME un-configures ULP mode
	Revert "e1000e: disable s0ix entry and exit flows for ME systems"
	e1000e: Export S0ix flags to ethtool
	bnxt_en: Check TQM rings for maximum supported value.
	net: mvpp2: fix pkt coalescing int-threshold configuration
	bnxt_en: Fix AER recovery.
	ipv4: Ignore ECN bits for fib lookups in fib_compute_spec_dst()
	net: sched: prevent invalid Scell_log shift count
	net: hns: fix return value check in __lb_other_process()
	erspan: fix version 1 check in gre_parse_header()
	net: hdlc_ppp: Fix issues when mod_timer is called while timer is running
	bareudp: set NETIF_F_LLTX flag
	bareudp: Fix use of incorrect min_headroom size
	vhost_net: fix ubuf refcount incorrectly when sendmsg fails
	r8169: work around power-saving bug on some chip versions
	net: dsa: lantiq_gswip: Enable GSWIP_MII_CFG_EN also for internal PHYs
	net: dsa: lantiq_gswip: Fix GSWIP_MII_CFG(p) register access
	CDC-NCM: remove "connected" log message
	ibmvnic: fix: NULL pointer dereference.
	net: usb: qmi_wwan: add Quectel EM160R-GL
	selftests: mlxsw: Set headroom size of correct port
	stmmac: intel: Add PCI IDs for TGL-H platform
	selftests/vm: fix building protection keys test
	block: add debugfs stanza for QUEUE_FLAG_NOWAIT
	workqueue: Kick a worker based on the actual activation of delayed works
	scsi: ufs: Fix wrong print message in dev_err()
	scsi: ufs-pci: Fix restore from S4 for Intel controllers
	scsi: ufs-pci: Ensure UFS device is in PowerDown mode for suspend-to-disk ->poweroff()
	scsi: ufs-pci: Fix recovery from hibernate exit errors for Intel controllers
	scsi: ufs-pci: Enable UFSHCD_CAP_RPM_AUTOSUSPEND for Intel controllers
	scsi: block: Introduce BLK_MQ_REQ_PM
	scsi: ide: Do not set the RQF_PREEMPT flag for sense requests
	scsi: ide: Mark power management requests with RQF_PM instead of RQF_PREEMPT
	scsi: scsi_transport_spi: Set RQF_PM for domain validation commands
	scsi: core: Only process PM requests if rpm_status != RPM_ACTIVE
	local64.h: make <asm/local64.h> mandatory
	lib/genalloc: fix the overflow when size is too big
	depmod: handle the case of /sbin/depmod without /sbin in PATH
	scsi: ufs: Clear UAC for FFU and RPMB LUNs
	kbuild: don't hardcode depmod path
	Bluetooth: revert: hci_h5: close serdev device and free hu in h5_close
	scsi: block: Remove RQF_PREEMPT and BLK_MQ_REQ_PREEMPT
	scsi: block: Do not accept any requests while suspended
	crypto: ecdh - avoid buffer overflow in ecdh_set_secret()
	crypto: asym_tpm: correct zero out potential secrets
	powerpc: Handle .text.{hot,unlikely}.* in linker script
	Staging: comedi: Return -EFAULT if copy_to_user() fails
	staging: mt7621-dma: Fix a resource leak in an error handling path
	usb: gadget: enable super speed plus
	USB: cdc-acm: blacklist another IR Droid device
	USB: cdc-wdm: Fix use after free in service_outstanding_interrupt().
	usb: typec: intel_pmc_mux: Configure HPD first for HPD+IRQ request
	usb: dwc3: meson-g12a: disable clk on error handling path in probe
	usb: dwc3: gadget: Restart DWC3 gadget when enabling pullup
	usb: dwc3: gadget: Clear wait flag on dequeue
	usb: dwc3: ulpi: Use VStsDone to detect PHY regs access completion
	usb: dwc3: ulpi: Replace CPU-based busyloop with Protocol-based one
	usb: dwc3: ulpi: Fix USB2.0 HS/FS/LS PHY suspend regression
	usb: chipidea: ci_hdrc_imx: add missing put_device() call in usbmisc_get_init_data()
	USB: xhci: fix U1/U2 handling for hardware with XHCI_INTEL_HOST quirk set
	usb: usbip: vhci_hcd: protect shift size
	usb: uas: Add PNY USB Portable SSD to unusual_uas
	USB: serial: iuu_phoenix: fix DMA from stack
	USB: serial: option: add LongSung M5710 module support
	USB: serial: option: add Quectel EM160R-GL
	USB: yurex: fix control-URB timeout handling
	USB: usblp: fix DMA to stack
	ALSA: usb-audio: Fix UBSAN warnings for MIDI jacks
	usb: gadget: select CONFIG_CRC32
	USB: Gadget: dummy-hcd: Fix shift-out-of-bounds bug
	usb: gadget: f_uac2: reset wMaxPacketSize
	usb: gadget: function: printer: Fix a memory leak for interface descriptor
	usb: gadget: u_ether: Fix MTU size mismatch with RX packet size
	USB: gadget: legacy: fix return error code in acm_ms_bind()
	usb: gadget: Fix spinlock lockup on usb_function_deactivate
	usb: gadget: configfs: Preserve function ordering after bind failure
	usb: gadget: configfs: Fix use-after-free issue with udc_name
	USB: serial: keyspan_pda: remove unused variable
	hwmon: (amd_energy) fix allocation of hwmon_channel_info config
	mm: make wait_on_page_writeback() wait for multiple pending writebacks
	x86/mm: Fix leak of pmd ptlock
	KVM: x86/mmu: Use -1 to flag an undefined spte in get_mmio_spte()
	KVM: x86/mmu: Get root level from walkers when retrieving MMIO SPTE
	kvm: check tlbs_dirty directly
	KVM: x86/mmu: Ensure TDP MMU roots are freed after yield
	x86/resctrl: Use an IPI instead of task_work_add() to update PQR_ASSOC MSR
	x86/resctrl: Don't move a task to the same resource group
	blk-iocost: fix NULL iocg deref from racing against initialization
	ALSA: hda/via: Fix runtime PM for Clevo W35xSS
	ALSA: hda/conexant: add a new hda codec CX11970
	ALSA: hda/realtek - Fix speaker volume control on Lenovo C940
	ALSA: hda/realtek: Add mute LED quirk for more HP laptops
	ALSA: hda/realtek: Enable mute and micmute LED on HP EliteBook 850 G7
	ALSA: hda/realtek: Add two "Intel Reference board" SSID in the ALC256.
	iommu/vt-d: Move intel_iommu info from struct intel_svm to struct intel_svm_dev
	btrfs: qgroup: don't try to wait flushing if we're already holding a transaction
	btrfs: send: fix wrong file path when there is an inode with a pending rmdir
	Revert "device property: Keep secondary firmware node secondary by type"
	dmabuf: fix use-after-free of dmabuf's file->f_inode
	arm64: link with -z norelro for LLD or aarch64-elf
	drm/i915: clear the shadow batch
	drm/i915: clear the gpu reloc batch
	bcache: fix typo from SUUP to SUPP in features.h
	bcache: check unsupported feature sets for bcache register
	bcache: introduce BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE for large bucket
	net/mlx5e: Fix SWP offsets when vlan inserted by driver
	ARM: dts: OMAP3: disable AES on N950/N9
	netfilter: x_tables: Update remaining dereference to RCU
	netfilter: ipset: fix shift-out-of-bounds in htable_bits()
	netfilter: xt_RATEEST: reject non-null terminated string from userspace
	netfilter: nft_dynset: report EOPNOTSUPP on missing set feature
	dmaengine: idxd: off by one in cleanup code
	x86/mtrr: Correct the range check before performing MTRR type lookups
	KVM: x86: fix shift out of bounds reported by UBSAN
	xsk: Fix memory leak for failed bind
	rtlwifi: rise completion at the last step of firmware callback
	scsi: target: Fix XCOPY NAA identifier lookup
	Linux 5.10.7

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I1a7c195af35831fe362b027fe013c0c7e4dc20ea
2021-01-13 10:29:42 +01:00
Greg Kroah-Hartman 0290a41d05 Merge 5.10.6 into android12-5.10
Changes in 5.10.6
	Revert "drm/amd/display: Fix memory leaks in S3 resume"
	Revert "mtd: spinand: Fix OOB read"
	rtc: pcf2127: move watchdog initialisation to a separate function
	rtc: pcf2127: only use watchdog when explicitly available
	dt-bindings: rtc: add reset-source property
	kdev_t: always inline major/minor helper functions
	Bluetooth: Fix attempting to set RPA timeout when unsupported
	ALSA: hda/realtek - Modify Dell platform name
	ALSA: hda/hdmi: Fix incorrect mutex unlock in silent_stream_disable()
	drm/i915/tgl: Fix Combo PHY DPLL fractional divider for 38.4MHz ref clock
	scsi: ufs: Allow an error return value from ->device_reset()
	scsi: ufs: Re-enable WriteBooster after device reset
	RDMA/core: remove use of dma_virt_ops
	RDMA/siw,rxe: Make emulated devices virtual in the device tree
	fuse: fix bad inode
	perf: Break deadlock involving exec_update_mutex
	rwsem: Implement down_read_killable_nested
	rwsem: Implement down_read_interruptible
	exec: Transform exec_update_mutex into a rw_semaphore
	mwifiex: Fix possible buffer overflows in mwifiex_cmd_802_11_ad_hoc_start
	Linux 5.10.6

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Id4c57a151a1e8f2162163d2337b6055f04edbe9b
2021-01-13 10:28:55 +01:00
Todd Kjos cb5a049748 ANDROID: fix 0-day bot build-break in fair.c
Fix an issue for non-GKI builds found by the 0-day test bot:

kernel/sched/fair.c: In function 'select_task_rq_fair':
>> kernel/sched/fair.c:6766:6: error: implicit declaration of function
	'trace_android_rvh_select_task_rq_fair_enabled';
	did you mean 'trace_android_rvh_select_task_rq_fair'?
    6766 |  if (trace_android_rvh_select_task_rq_fair_enabled())
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |      trace_android_rvh_select_task_rq_fair
   cc1: some warnings being treated as errors

Reported-by: kernel test robot <lkp@intel.com>
Fixes: c7ba09ce6a ("ANDROID: sched/fair: Sync task util for strf hook")
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: I1b15b9ada83dc5b2678cef3910a7aedc0d19f174
2021-01-13 08:52:54 +00:00
Lina Iyer de93734e22 ANDROID: cpuidle: export cpuidle_driver_state_disabled
Export cpuidle_driver_state_disabled() so that CPU idle states may be
disabled at runtime for debugging CPU and cluster idle states.

Bug: 175718935
Signed-off-by: Lina Iyer <ilina@codeaurora.org>
Change-Id: Id9038074d64fb6c0444d9aca68420414c3223e93
2021-01-13 02:35:14 +00:00
Mahesh Kumar Kalikot Veetil f50aeaf27c ANDROID: kbuild: handle excessively long argument lists
Modules with a large number of compilation units may be
exceeding AR and LD command argument list. Handle this gracefully by
writing the long argument list in a file. The command line options
read from file are inserted in place of the original @file option.

The usage is well documented at
https://www.gnu.org/software/make/manual/html_node/File-Function.html

Bug: 175420573
Change-Id: I3f9b8b9c59b9ba0c01ddd00d39fc3bbc62fda832
Signed-off-by: Mahesh Kumar Kalikot Veetil <mkalikot@codeaurora.org>
Signed-off-by: Jeff Johnson <jjohnson@codeaurora.org>
2021-01-13 01:21:18 +00:00
Mahesh Kumar Kalikot Veetil 631b20dd6c ANDROID: kbuild: simplify cmd_mod
Modules with a large number of compilation units can exceed execv
argument list resulting in E2BIG (Argument list too long) error.

Fix this by replacing shell 'echo > file' into a more native
$(file op filename[,text]) option.

Bug: 175420575
Change-Id: I9bc495482f16f2c9b4e05a4cb5b2283ff0c0439d
Signed-off-by: Mahesh Kumar Kalikot Veetil <mkalikot@codeaurora.org>
Signed-off-by: Jeff Johnson <jjohnson@codeaurora.org>
2021-01-13 01:21:09 +00:00
Jaegeuk Kim b51f784248 FROMLIST: scsi: ufs: WB is only available on LUN #0 to #7
Kernel stack violation when getting unit_descriptor/wb_buf_alloc_units from
rpmb lun. The reason is the unit descriptor length is different per LU.

The lengh of Normal LU is 45, while the one of rpmb LU is 35.

int ufshcd_read_desc_param(struct ufs_hba *hba, ...)
{
	param_offset=41;
	param_size=4;
	buff_len=45;
	...
	buff_len=35 by rpmb LU;

	if (is_kmalloc) {
		/* Make sure we don't copy more data than available */
		if (param_offset + param_size > buff_len)
			param_size = buff_len - param_offset;
			--> param_size = 250;
		memcpy(param_read_buf, &desc_buf[param_offset], param_size);
		--> memcpy(param_read_buf, desc_buf+41, 250);

[  141.868974][ T9174] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: wb_buf_alloc_units_show+0x11c/0x11c
	}
}

Bug: 174701661
Link: https://lore.kernel.org/linux-scsi/20210111095927.1830311-1-jaegeuk@kernel.org/
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I25205d465daa25b4bd330876ad05fcfd01195a56
2021-01-12 16:51:36 -08:00
Jaegeuk Kim 68d8e3f0ae FROMGIT: scsi: ufs: Fix tm request when non-fatal error happens
When non-fatal error like line-reset happens, ufshcd_err_handler() starts
to abort tasks by ufshcd_try_to_abort_task(). When it tries to issue a task
management request, we hit two warnings:

WARNING: CPU: 7 PID: 7 at block/blk-core.c:630 blk_get_request+0x68/0x70
WARNING: CPU: 4 PID: 157 at block/blk-mq-tag.c:82 blk_mq_get_tag+0x438/0x46c

After fixing the above warnings we hit another tm_cmd timeout which may be
caused by unstable controller state:

__ufshcd_issue_tm_cmd: task management cmd 0x80 timed-out

Then, ufshcd_err_handler() enters full reset, and kernel gets stuck. It
turned out ufshcd_print_trs() printed too many messages on console which
requires CPU locks. Likewise hba->silence_err_logs, we need to avoid too
verbose messages. This is actually not an error case.

Bug: 175693074
Bug: 175170490
(cherry picked from commit eeb1b55b6e git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git fixes)
Link: https://lore.kernel.org/r/20210107185316.788815-3-jaegeuk@kernel.org
Fixes: 69a6c269c0 ("scsi: ufs: Use blk_{get,put}_request() to allocate and free TMFs")
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Change-Id: Ie05496f7a5ef1192d19ee08f9f7f91ee8ebb31cd
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2021-01-12 16:51:36 -08:00
Jaegeuk Kim 317f8ff627 FROMGIT: scsi: ufs: Fix livelock of ufshcd_clear_ua_wluns()
When gate_work/ungate_work experience an error during hibern8_enter or exit
we can livelock:

 ufshcd_err_handler()
   ufshcd_scsi_block_requests()
   ufshcd_reset_and_restore()
     ufshcd_clear_ua_wluns() -> stuck
   ufshcd_scsi_unblock_requests()

In order to avoid this, ufshcd_clear_ua_wluns() can be called per recovery
flows such as suspend/resume, link_recovery, and error_handler.

Bug: 175391270
(cherry picked from commit 4ee7ee530b git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git fixes)
Link: https://lore.kernel.org/r/20210107185316.788815-2-jaegeuk@kernel.org
Fixes: b56c9e4cdf ("FROMLIST: scsi: ufs: fix livelock of ufshcd_clear_ua_wluns")
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Change-Id: I16f41f552a0e4d6c93592b73cf7489fa1197a987
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2021-01-12 16:51:35 -08:00
Prasad Sodagudi ae3a19c232 ANDROID: arm64: Export show_regs for vendor module usage
Export show_regs for vendor module usage to print cpu back trace
from trace_android_vh_ipi_stop vendor hook.

Bug: 177348820
Change-Id: Idcbe887dfc02626d4af1a4cb53dafe3d5a2ba1dd
Signed-off-by: Prasad Sodagudi <psodagud@codeaurora.org>
2021-01-13 00:50:17 +00:00
Mayank Rana 3e5779195f FROMGIT: usb: typec: ucsi: Add support for USB role switch
UCSI already conveys the information about a port's connection
status, whether it is operating in UFP or DFP mode, and whether the
partner supports USB data or not. This information can be used to
notify a dual-role controller to start up its host or peripheral
mode accordingly. Add optional support for this by querying each
port's fwnode to look for an associated USB role switch device.
If present, call usb_role_switch_set() with the determined data
role upon Connect Change or Connector Partner Change updates.

Bug: 177215430
(cherry picked from commit 89795852c9
 git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing)
Change-Id: I83106abd1c5122d9ca89e5854e82aa988f5b528f
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Link: https://lore.kernel.org/r/20210111215520.18476-1-jackp@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-12 23:26:46 +00:00
Vijayanand Jitta e46a1a5e37 ANDROID: mm: Export vmalloc_nr_pages
Export vmalloc_nr_pages which is used as part
of meminfo collection from minidump module.

Bug: 177031593
Change-Id: I4c80fe2a0712658ec46b49064fda670da84b3732
Signed-off-by: Vijayanand Jitta <vjitta@codeaurora.org>
2021-01-12 22:44:08 +00:00
Shaleen Agrawal b92945e2eb ANDROID: Sched: Add export symbols for sched features
Export symbols needed to implement vendor scheduler value-adds to modify
sched features.

Bug: 177050087
Change-Id: Ibe14d2019403be68b7ceeee47425b2473ccb51fe
Signed-off-by: Shaleen Agrawal <shalagra@codeaurora.org>
2021-01-12 22:01:04 +00:00
Stephen Dickey 5ada76d056 ANDROID: sched/pause: prevent wake up paused cpus
When used for qos or other reasons, wake up idle
cpus will wake cpus en-mass.  Cpus that are paused
should not be woken up like this.

Update to use active_mask, so that paused cpus are
ignored for general cpu wakeup operations.

Bug: 161210528
Change-Id: I10721e75497a8902f8ec998ded4e2eb094770f38
Signed-off-by: Stephen Dickey <dickey@codeaurora.org>
2021-01-12 22:00:14 +00:00
Stephen Dickey d9ffca8412 ANDROID: irq/proc: use active cpus for allowed irq affinity
With the introduction of pause, irqs should avoid
paused cpus.  Previously, when userspace set the
irq affinity, it was only filtered toward online cpus.
A cpu can be paused but online, and irqs should avoid.

Check the cpu_active_mask instead of the online mask
when writing the irq affinity, such that the subset
of cpus allowed doesn't include inactive cpus.

Bug: 161210528
Change-Id: I359a452cc97ad58ad85e9613a29d144ffcd51567
Signed-off-by: Stephen Dickey <dickey@codeaurora.org>
2021-01-12 22:00:03 +00:00
Can Guo ecd1443038 FROMGIT: scsi: ufs: Correct the lun used in eh_device_reset_handler() callback
Users can initiate resets to specific SCSI device/target/host through
IOCTL. When this happens, the SCSI cmd passed to eh_device/target/host
_reset_handler() callbacks is initialized with a request whose tag is -1.
In this case it is not right for eh_device_reset_handler() callback to
count on the LUN get from hba->lrb[-1]. Fix it by getting LUN from the SCSI
device associated with the SCSI cmd.

Link: https://lore.kernel.org/r/1609157080-26283-1-git-send-email-cang@codeaurora.org
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

Bug: 177042238
(cherry picked from commit 35fc4cd344
git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git 5.11/scsi-fixes)
Change-Id: I7bd7602581b97f76442e179b5264ee2891d923a9
Signed-off-by: Can Guo <cang@codeaurora.org>
2021-01-12 21:58:16 +00:00