Commit Graph

979361 Commits

Author SHA1 Message Date
xieliujie
a2b3afb2f7 ANDROID: android: Add symbols to debug_symbols driver
in our vendor driver, we need the following three kernel variables:
include/linuc/mm.h:
extern unsigned long stack_guard_gap;
extern int sysctl_legacy_va_layout;

include/linux/security.h:
extern unsigned long mmap_min_addr;

Bug: 191439466
Signed-off-by: xieliujie <xieliujie@oppo.com>
Change-Id: I9d1759d8157ddd214475742e417dfb9e870d4b2e
2021-07-14 20:52:01 -07:00
Alan Stern
914a7b14a0 UPSTREAM: USB: UDC core: Add udc_async_callbacks gadget op
The Gadget API has a theoretical race when a gadget driver is unbound.
Although the pull-up is turned off before the driver's ->unbind
callback runs, if the USB cable were to be unplugged at just the wrong
moment there would be nothing to prevent the UDC driver from invoking
the ->disconnect callback after the unbind has finished.  In theory,
other asynchronous callbacks could also happen during the time before
the UDC driver's udc_stop routine is called, and the gadget driver
would not be prepared to handle any of them.

We need a way to tell UDC drivers to stop issuing asynchronous (that is,
->suspend, ->resume, ->disconnect, ->reset, or ->setup) callbacks at
some point after the pull-up has been turned off and before the
->unbind callback runs.  This patch adds a new ->udc_async_callbacks
callback to the usb_gadget_ops structure for precisely this purpose,
and it adds the corresponding support to the UDC core.

Later patches in this series add support for udc_async_callbacks to
several UDC drivers.

Acked-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20210520202144.GC1216852@rowland.harvard.edu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: 192984564
Change-Id: Ib50e7292436fe2067cdd6d9e953549f74a2513a9
(cherry picked from commit 7dc0c55e9f)
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2021-07-14 20:52:01 -07:00
Egor Uleyskiy
9af9ef8dfa ANDROID: vendor_hooks: Add oem data to file struct
Add ANDROID_OEM_DATA(1) to struct file

Bug: 169343953
Signed-off-by: Egor Uleyskiy <e.uleyskiy@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I1afc259f2bd02fee76b20802dda74cbe79658534
2021-07-14 20:52:01 -07:00
Greg Kroah-Hartman
37485a3025 ANDROID: add kabi padding for structures for the android12 release
There are a lot of different structures that need to have a "frozen" abi
for the next 5+ years.  Add padding to a lot of them in order to be able
to handle any future changes that might be needed due to LTS and
security fixes that might come up.

It's a best guess, based on what has happened in the past from the
5.4.0..5.4.129 release (1 1/2 years).  Yes, past changes do not mean
that future changes will also be needed in the same area, but that is a
hint that those areas are both well maintained and looked after, and
there have been previous problems found in them.

Also the list of structures that are being required based on OEM usage
in the android/ symbol lists were consulted as that's a larger list than
what has been changed in the past.

Hopefully we caught everything we need to worry about, only time will
tell...

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I880bbcda0628a7459988eeb49d18655522697664
2021-07-14 20:51:51 -07:00
Greg Kroah-Hartman
429c78f9b0 ANDROID: GKI: device.h: add Android ABI padding to some structures
Try to mitigate potential future driver core api changes by padding to
struct bus_type, struct device_driver, struct class, and struct device.

Based on a patch from Michal Marek <mmarek@suse.cz> from the SLES kernel

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I6892cde6481ba775789f0c02239dcfde3a26b56e
2021-07-14 11:57:54 -07:00
Greg Kroah-Hartman
aea5e1c230 ANDROID: GKI: elevator: add Android ABI padding to some structures
Try to mitigate potential future driver core api changes by adding a
padding to struct elevator_mq_ops and struct elevator_type.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ia4c2667fd5ca9e6dd2e0d30b95a0f8d5eb7921dc
2021-07-14 11:57:41 -07:00
Greg Kroah-Hartman
1b79ef2754 ANDROID: GKI: scsi: add Android ABI padding to some structures
Try to mitigate potential future driver core api changes by adding a
padding to struct scsi_cmnd, struct scsi_device, and struct
scsi_host_template.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ie6a2b91970e8f9063bf00e96a0dff661f77b8e8d
2021-07-14 11:57:26 -07:00
Greg Kroah-Hartman
33175403b9 ANDROID: GKI: workqueue.h: add Android ABI padding to some structures
Try to mitigate potential future driver core api changes by adding a
padding to struct work_struct and struct delayed_work

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I5492a13e2430c1a5775aec52518144b7aa4f3268
2021-07-14 11:57:11 -07:00
Greg Kroah-Hartman
d5c344a498 ANDROID: GKI: sched: add Android ABI padding to some structures
Try to mitigate potential future driver core api changes by adding a
padding to struct user_struct and struct sched_domain.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ie8f685122767b690a116193aefd8c5e3b6ef8f17
2021-07-14 11:56:56 -07:00
Greg Kroah-Hartman
9c4854fa5a ANDROID: GKI: phy: add Android ABI padding to some structures
Try to mitigate potential future driver core api changes by adding a
padding to stuct phy_device and struct phy_driver

Inspired by the upstream changes in 5.4.26 and 4.19.111

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I8dbc5f76e9eddfc5741f944168222aedacd0a8bb
2021-07-14 11:56:41 -07:00
Greg Kroah-Hartman
f4872b2353 ANDROID: GKI: fs.h: add Android ABI padding to some structures
Try to mitigate potential future driver core api changes by adding a
padding to a bunch of filesystem structures.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Change-Id: Ida6d98d30f292c980ab07e0250fec5268c4c87ed
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2021-07-14 11:56:26 -07:00
Greg Kroah-Hartman
48cddc7c42 ANDROID: GKI: dentry: add Android ABI padding to some structures
Try to mitigate potential future driver core api changes by adding a
padding to struct dentry and struct dentry_operations.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Idde3c6e99bd4af3a91ba115b8ec148e3e1cdd4a9
2021-07-14 11:56:08 -07:00
Greg Kroah-Hartman
b9081a2925 ANDROID: GKI: bio: add Android ABI padding to some structures
Try to mitigate potential future driver core api changes by adding a
padding to struct bio_integrity_payload and struct bio_set.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I0397ede2e11560ad9422cd7765434fcd4f7a6dd8
2021-07-14 11:55:52 -07:00
Greg Kroah-Hartman
99bf8cf8fa ANDROID: GKI: ufs: add Android ABI padding to some structures
Try to mitigate potential future driver core api changes by adding
padding to struct ufs_hba_crypto_variant_ops, and struct ufs_hba.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ib881e531d87eae1f7a5ca312bd36086d62ccaf94
2021-07-14 11:55:22 -07:00
Minchan Kim
9df147298f ANDROID: Update the generic symbol list
Add a few more symbols.

[A] 'function void lru_cache_disable()'
[A] 'function void lru_cache_enable()'

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: If538f62fca14b7c43e98a786b2fc7766545dc7d6
2021-07-14 11:54:49 -07:00
Minchan Kim
12f48605e8 ANDROID: mm: cma do not sleep for __GFP_NORETRY
Do not sleep for retrying for __GFP_NORERY since it's failfast
mode approach. User could retry the allocation without the flag
by themselves if they see the failure.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: Ic6a857978fda8e353b9ed770d1e0ba1808fd201e
2021-07-14 11:54:49 -07:00
Minchan Kim
0e688e972d ANDROID: mm: cma: skip problematic pageblock
alloc_contig_range is supposed to work on max(MAX_ORDER_NR_PAGES,
or pageblock_nr_pages) granularity aligned range. If it fails
at a page and return error to user, user doesn't know what page
makes the allocation failure and keep retrying another allocation
with new range including the failed page and encountered error
again and again until it could escape the out of the granularity
block. Instead, let's make CMA aware of what pfn was troubled in
previous trial and then continue to work new pageblock out of the
failed page so it doesn't see the repeated error repeatedly.

Currently, this option works for only __GFP_NORETRY case for
safe for existing CMA users.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I0959c9df3d4b36408a68920abbb4d52d31026079
2021-07-14 11:54:49 -07:00
Minchan Kim
9938b82be1 ANDROID: mm: bail out tlb free batching on page zapping when cma is going on
I found sometime cma allocation took a long time to be succeeded
because one of the pages is in the middle of zapping(e.g., munmap, exit)
so alloc_contig_range couldn't migrate the page because it was zero
page mapcount. So, CMA allocator need to wait it until tlb batching
frees the page and the batching free happens on the target process's
context which is quite random, sometimes, very low priority process
on little core. It makes CMA allocation very slow up to several hundreds
millisecond.

To solve the issue, let's make the TLB free batching aware of CMA
progress so whenever cma allocation is going on, TLB free batching
should bail out asap to minimize cma allocation latency.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: Ic76ecff795639085c4372791d922301467563a06
2021-07-14 11:54:49 -07:00
Minchan Kim
c8578a3e90 ANDROID: mm: lru_cache_disable skips lru cache drainnig
lru_cache_disable is not trivial cost since it should run work
from every cores in the system. Thus, repeated call of the
function whenever alloc_contig_range in the cma's allocation loop
is called is expensive.

This patch makes the lru_cache_disable smarter in that it will
not run __lru_add_drain_all since it knows the cache was already
disabled by someone else.
With that, user of alloc_contig_range can disable the lru cache
in advance in their context so that subsequent alloc_contig_range
for user's operation will avoid the costly function call.

This patch moves lru_cache APIs from swap.h to swap.c and export
it for vendor users.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I23da8599c55db49dc80226285972e4cd80dedcff
2021-07-14 11:54:48 -07:00
Minchan Kim
c01ce3b5ef ANDROID: mm: do not try test_page_isoalte if migration fails
Currently, alloc_contig_range expects that even though a page fails
with -EBUSY from __alloc_contig_migrate_range, it want to check
those failed pages in test_pages_isolated again with hope that
those page would be freed soon so cma allocatoin would be succeeded.
However, it depends on the luck and I found sometimes test_page_isolated
constantly fails at the page repeatedly whenever cma_alloc retried.
Rather than burning out CPU to check the page's status in
test_pages_isolated for GFP_NORETRY allocation, just bail out and
relies on the user what they want to do.
Currently, this option works for only __GFP_NORETRY case for safe
of existing other users.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I9211452be06960dc7d8f854537e53b3fc5262c8e
2021-07-14 11:54:48 -07:00
Minchan Kim
675e504598 ANDROID: mm: add cma allocation statistics
alloc_contig_range is the core worker function for CMA allocation
so it has every information to be able to understand allocation
latency. For example, how many pages are migrated, how many time
unmap was needed to migrate pages, how many times it encountered
errors by some reasons.

This patch adds such statistics in the alloc_contig_range and
return it to user so user can use those information to analyize
latency. The cma_alloc is first user for the statistics, which
export the statistics as new trace event(i.e., cma_alloc_info).

It was really usefuli to optimize cma allocation work.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I7be43cc89d11078e2a324d2d06aada6d8e9e1cc9
2021-07-14 11:54:48 -07:00
Vlastimil Babka
b1e4543c27 UPSTREAM: mm, page_alloc: move draining pcplists to page isolation users
Currently, pcplists are drained during set_migratetype_isolate() which
means once per pageblock processed start_isolate_page_range().  This is
somewhat wasteful.  Moreover, the callers might need different guarantees,
and the draining is currently prone to races and does not guarantee that
no page from isolated pageblock will end up on the pcplist after the
drain.

Better guarantees are added by later patches and require explicit actions
by page isolation users that need them.  Thus it makes sense to move the
current imperfect draining to the callers also as a preparation step.

Link: https://lkml.kernel.org/r/20201111092812.11329-7-vbabka@suse.cz
Suggested-by: David Hildenbrand <david@redhat.com>
Suggested-by: Pavel Tatashin <pasha.tatashin@soleen.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit 7612921f23)
Change-Id: I10fc574024606c499ddda325d188d181aff7ceec
2021-07-14 11:54:48 -07:00
Robert Lee
13bc06efd9 ANDROID: ALSA: compress: add vendor hook to support pause in draining
Add a hook to query from vendor's compress driver if it is support pause
in draining and if the platform need to keep in draining state.

Bug: 184020292
Bug: 178992384

Change-Id: Id2e2ff72d7ee66fc633473ec109ed3d8a2baaeff
Signed-off-by: Robert Lee <lerobert@google.com>
2021-07-14 17:10:01 +00:00
Yang Yang
2faed77792 ANDROID: vendor_hooks: add vendor hook in blk_mq_rq_ctx_init()
This vendor hook let us initialize payload of the request.

Bug: 188749221
Change-Id: I51d6a3010ac0ab36066dbe1368158592832112b7
Signed-off-by: Yang Yang <yang.yang@vivo.com>
2021-07-14 14:17:35 +00:00
Mukesh Kumar Savaliya
292baba45a ANDROID: abi_gki_aarch64_qcom: Add I3C core symbols to qcom tree
This change adds I3C core functions being used by Geni Master driver
into the qcom symbol list. Helps fixing the ABI differences.

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

14 Added functions:

  [A] 'function i3c_generic_ibi_pool* i3c_generic_ibi_alloc_pool(i3c_dev_desc*, const i3c_ibi_setup*)'
  [A] 'function void i3c_generic_ibi_free_pool(i3c_generic_ibi_pool*)'
  [A] 'function i3c_ibi_slot* i3c_generic_ibi_get_free_slot(i3c_generic_ibi_pool*)'
  [A] 'function void i3c_generic_ibi_recycle_slot(i3c_generic_ibi_pool*, i3c_ibi_slot*)'
  [A] 'function int i3c_master_add_i3c_dev_locked(i3c_master_controller*, u8)'
  [A] 'function int i3c_master_disec_locked(i3c_master_controller*, u8, u8)'
  [A] 'function int i3c_master_do_daa(i3c_master_controller*)'
  [A] 'function int i3c_master_enec_locked(i3c_master_controller*, u8, u8)'
  [A] 'function int i3c_master_entdaa_locked(i3c_master_controller*)'
  [A] 'function int i3c_master_get_free_addr(i3c_master_controller*, u8)'
  [A] 'function void i3c_master_queue_ibi(i3c_dev_desc*, i3c_ibi_slot*)'
  [A] 'function int i3c_master_register(i3c_master_controller*, device*, const i3c_master_controller_ops*, bool)'
  [A] 'function int i3c_master_set_info(i3c_master_controller*, const i3c_device_info*)'
  [A] 'function int i3c_master_unregister(i3c_master_controller*)'

Bug: 193223418
Change-Id: I8cbcba99e3843bc0e06c772954a7120f7ee33148
Signed-off-by: Mukesh Kumar Savaliya <msavaliy@codeaurora.org>
Signed-off-by: Giuliano Procida <gprocida@google.com>
2021-07-14 13:42:44 +00:00
Yang Yang
eecc725a8e ANDROID: vendor_hooks: add vendor hook in blk_mq_alloc_rqs()
This vendor hook let us attach oem data as payload to the request.
The payload is used by oem driver for debugging purpose.

Bug: 188749221
Change-Id: Iac598bd9cce836dac0efe9198a3e7752928f351a
Signed-off-by: Yang Yang <yang.yang@vivo.com>
2021-07-14 12:27:45 +00:00
chunhui.li
9c2958f454 ANDROID: GKI: Export put_task_stack symbol
We need dump task->stack in kernel module for debug usage,
call try_get_task_stack to lock task->stack, and
try_get_task_stack/put_task_stack should call in pairs,
but put_task_stack is not exported

Bug: 192990535
Change-Id: Ifb2f3d16f93039bffeb3e822bc066e42e2d21d13
Signed-off-by: chunhui.li <chunhui.li@mediatek.com>
2021-07-14 09:14:16 +00:00
Guru Das Srinagesh
288805c86a ANDROID: abi_gki_aarch64_qcom: Add idr_alloc_u32
Add idr_alloc_u32 to the qcom symbol list.

Bug: 193461266
Change-Id: I7415a67a51041c0f7595f9b5c6d96615f3eecc41
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
2021-07-14 07:32:46 +00:00
JJ Lee
e8516fd3af ANDROID: sound: usb: add vendor hook for cpu suspend support
Add vendor hook android_vh_sound_check_support_cpu_suspend
to allow ACPU to suspend during USB playback/capture,
if this is supported.

Bug: 192206510
Change-Id: Ia8d4c335db27de5fcefab13cab653fd1ae34f691
Signed-off-by: JJ Lee <leejj@google.com>
2021-07-14 04:05:24 +00:00
Minchan Kim
d820d22b5d ANDROID: mm: page_pinner: use EXPORT_SYMBOL_GPL
GKI requires EXPORT_SYMBOL_GPL so change it.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: Iba310d0a78f6ddb1e7980177fe7c624d0a0f254a
2021-07-14 03:38:32 +00:00
Chanho Park
efc09793ea ANDROID: GKI: update allowed GKI symbol for Exynosauto SoC
- Removed 2 functions no longer used from Exynosauto SoC

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

2 Removed functions:

  [D] 'function int of_get_drm_display_mode(device_node*, drm_display_mode*, u32*, int)'
  [D] 'function int ufshcd_init(ufs_hba*, void*, unsigned int)'

5 Added functions:

  [A] 'function dma_status dma_sync_wait(dma_chan*, dma_cookie_t)'
  [A] 'function dmaengine_unmap_data* dmaengine_get_unmap_data(device*, int, gfp_t)'
  [A] 'function int drm_connector_set_path_property(drm_connector*, const char*)'
  [A] 'function int drm_helper_probe_detect(drm_connector*, drm_modeset_acquire_ctx*, bool)'
  [A] 'function int of_graph_get_endpoint_count(const device_node*)'

Bug: 193391505
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
Change-Id: Iba127a26dc84f1399042ec6048bbd5a9ceaeebe8
2021-07-14 09:47:55 +09:00
Chanho Park
67e3e39eb1 ANDROID: GKI: sync allowed list for exynosauto SoC
This patch is for updating GKI allowed symbol list without adding any
new symbol. Next patch will introduce newly added symbols for Exynosauto
SoC GKI vendor modules.

Bug: 193391505
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
Change-Id: I53206b12887add9ff40003dd09f6ff1afa5c027a
2021-07-14 09:47:54 +09:00
Eric Biggers
d25e256373 ANDROID: ABI: add new symbols required by fips140.ko
fips140.ko now uses more crypto API functions due to self-tests being
added, so add them to the symbol list and update the ABI representation.

Generated by running:

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

... then adding the relevant portion only, and then:

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

Leaf changes summary: 2 artifacts changed (1 filtered out)
Changed leaf types summary: 0 (1 filtered out) 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 void crypto_cipher_decrypt_one(crypto_cipher*, u8*, const u8*)'
  [A] 'function int crypto_rng_reset(crypto_rng*, const u8*, unsigned int)'

Bug: 153614920
Bug: 188620248
Change-Id: Ic51a3d2c33718d2da41a6b6a9f9578a00322e9d6
Signed-off-by: Eric Biggers <ebiggers@google.com>
[ardb: refresh]
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-07-13 21:37:36 +00:00
Eric Biggers
50661975be ANDROID: fips140: add/update module help text
Add some help text for CONFIG_CRYPTO_FIPS140_MOD, add a comment for
CONFIG_CRYPTO_FIPS140, and update the file comment for fips140-module.c.
In particular, mention that the module also does self-tests, and that it
is also intended to meet NIAP requirements -- not just FIPS.

Bug: 153614920
Bug: 188620248
Change-Id: If2c316e54fba2c4594e70a14a5a8fa1dba3589a1
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-07-13 21:37:35 +00:00
Eric Biggers
b7397e89db ANDROID: fips140: add power-up cryptographic self-tests
Make fips140.ko run a suite of known answer self-tests at load time to
demonstrate the correct operation of cryptographic functionality, as
required by FIPS 140-2/3 and NIAP FPT_TST_EXT.1.1.

Bug: 153614920
Bug: 173104584
Bug: 188620248
Test: Built and loaded fips140.ko on a HiKey960, and on a Pixel device.
Change-Id: I38e5c8052ff57ddfe44624beb626d38b7706b0a4
Co-developed-by: Elena Petrova <lenaptr@google.com>
Signed-off-by: Elena Petrova <lenaptr@google.com>
[ebiggers: Rewrote most of lenaptr@'s original patch.  Added some
 missing tests, removed some unnecessary tests in accordance with the
 FIPS 140-2 IG, changed most test vectors and added a script to generate
 them, removed an unnecessary kconfig option, changed implementation of
 error injection, and many other improvements.]
Signed-off-by: Eric Biggers <ebiggers@google.com>
[ardb: add generation of AES-CTR test vector and the associated runtime
 selftest]
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-07-13 21:37:35 +00:00
Ard Biesheuvel
bd7d13c36e ANDROID: arm64: disable LSE when building the FIPS140 module
The arm64 LSE atomics implementation uses both alternatives patching and
jump label patching, both of which need to be selectively disabled when
building the FIPS140 module, or the hashing of the .text section no
longer works.

We already disable jump labels in generic code, but this uncovers a
rather nasty circular include dependency, as the jump label fallback
code uses atomics, which are provided by the LSE code if enabled.

So let's disable LSE as well when building the FIPS140 module: this does
not have any impact on the code, as no code patching goes on in this
module anyway, but it avoids #include hell.

Bug: 153614920
Bug: 188620248
Change-Id: Ia3d823fa3a309777f0c955d619ae8b139dc74061
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-07-13 21:37:35 +00:00
Eric Biggers
1061ef0493 ANDROID: jump_label: disable jump labels in fips140.ko
The fips140 module doesn't support jump labels, as they would invalidate
the hash of the .text section.  So when building the module, switch to
the generic implementation that does not rely on arch-specific code
patching support.

This fixes a failure in check_fips140_module_hmac() caused by the module
containing a call to crypto_alg_put(), which is an inline function that
calls refcount_dec_and_test(), which on arm64 uses a jump label.

Note that the optimized definition of struct static_key is retained, to
ensure ABI compatibility across the FIPS140 module boundary.  To ensure
that static keys and their associated jump labels remain in a consistent
state, the fips140 module will not be able to manipulate static keys,
but only to check their state.

Bug: 153614920
Bug: 188620248
Change-Id: Ie834bbf2eed5d09bfae7f387b711a934bedf390d
Signed-off-by: Eric Biggers <ebiggers@google.com>
[ardb: disable jump labels in generic code not in arm64 arch code]
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-07-13 21:37:35 +00:00
Rocco Yue
dcf509fea7 ANDROID: ipv6: add vendor hook for gen ipv6 link-local addr
This patch provides an ipv6 vendor hook which can be used to
disable kernel auto generate the ipv6 link-local address.

The reasons why the kernel does not need to automatically
generate the ipv6 link-local address are as follows:

(1) In the 3GPP TS 29.061, here is a description as follows:
"in order to avoid any conflict between the link-local address
of the MS and that of the GGSN, the Interface-Identifier used
by the MS to build its link-local address shall be assigned by
the GGSN. The GGSN ensures the uniqueness of this Interface-
Identifier. The MT shall then enforce the use of this
Interface-Identifier by the TE"

In other words, in the cellular network, GGSN determines whether
to reply a solicited RA message by identifying the low 64 bits
of the source address of the received RS message. Therefore,
cellular network device's ipv6 link-local address should be set
as the format of fe80::(GGSN assigned IID).

For example: When using a new kernel and ARPHRD_RAWIP, kernel
will generate an EUI64 format ipv6 link-local address, and the
Linux kernel will uses this link-local address to send RS message.
The result is that the GGSN will not reply to the RS message with
a solicited RA message.

For mobile operators that don't need to support RFC7217, setting
addr_gen_mode == 1 is sufficient, it can avoid the above issue,
but when the addr_gen_mode is changed to the
IN6_ADDR_GEN_MODE_STABLE_PRIVACY, the above problem still exist.
The detail as follows:

(2) For some other mobile operators that need to support RFC7217,
the mobile device's addr_gen_mode will be switched to the
IN6_ADDR_GEN_MODE_STABLE_PRIVACY, instead of using
IN6_ADDR_GEN_MODE_NONE.
The purpose is: in the IN6_ADDR_GEN_MODE_STABLE_PRIVACY mode,
kernel can gererate a stable privacy global ipv6 address after
receiveing RA, and network processes can use this global address
to communicate with the outside network.

Of course, mobile operators that need to support RFC7217 should
also meet the requirement of 3GPP TS 29.061, that is, MT should
use IID assigned by the GGSN to build its ipv6 link-local address
and use this address to send RS. We don't want the kernel to
automatically generate an ipv6 link-local address when
addr_gen_mode == 2. Otherwise, using the stable privacy ipv6
link-local address automatically generated by the kernel to send
RS message, GGSN will not be able to respond to the RS and reply
a RA message.

Therefore, after this patch, the kernel can determine whether to
disable the automatic ipv6 link-local address generation by judging
the net device name.

Bug: 190685002
Change-Id: I93420cacd96789769edc7214fb8a2dd1455ce374
Signed-off-by: Rocco Yue <rocco.yue@mediatek.com>
2021-07-13 18:13:57 +00:00
Bart Van Assche
018332e871 ANDROID: Revert "scsi: block: Do not accept any requests while suspended"
Commit "block: Do not accept any requests while suspended" broke the UFS
driver. In the upstream kernel this has been fixed by commit b294ff3e34
("scsi: ufs: core: Enable power management for wlun"). Backporting that
commit or backporting the entire v5.14-rc1 UFS driver is too risky.
Hence revert the block layer patch that is incompatible with the v5.10
UFS driver power management code.

This reverts commit d55d15a332.

Bug: 193181075
Change-Id: Ic50d4e1df98d7ed393bf9797787225ae22e5d7a3
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-07-13 10:52:35 -07:00
Charan Teja Reddy
2ad2c3a25b ANDROID: abi_gki_aarch64_qcom: whitelist vm_event_states
Add vm_event_states, which is an already exported symbol, to the list of
whitelisted symbols. No message with 'Leaf changes summary:' is printed
to add to this commit message.

Bug: 187798288
Change-Id: I3c6d39d5b2838ac7fa64db152cca5685b9f43238
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
2021-07-13 17:43:47 +00:00
Liujie Xie
7bcfde2601 ANDROID: ashmem: Export is_ashmem_file
Export is_ashmem_file function which will be used
by the minidump module to get ashmem info.

Bug: 193397560
Change-Id: I5b7816ad4775e5cf2c4f41c28b1c8dacc2c85b7e
Signed-off-by: liuhailong <liuhailong@oppo.com>
Signed-off-by: Liujie Xie <xieliujie@oppo.com>
2021-07-13 15:48:06 +00:00
Ray Chi
dd139186ef ANDROID: usb: gadget: fix NULL pointer dereference in android_setup
This is a possibility in android_setup when using cdev leading
to a NULL pointer dereference in spin_lock_irqsave. Using the
spinlock of gadget item to prevent the condition.

Bug: 189800931
Signed-off-by: Ray Chi <raychi@google.com>
Change-Id: Idc4cbcaed7dc6e1e35e8a63de84c1415fb83ef5e
2021-07-13 11:08:58 +00:00
Suren Baghdasaryan
07f65598af ANDROID: GKI: Disable kmem cgroup accounting
Disable cgroup kernel memory accounting to avoid unnecessary overhead.

Bug: 191223209
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I483aa83c707996bf1d363c0dfc56e7816a5d8e2f
2021-07-12 18:35:13 -07:00
Suren Baghdasaryan
309aa7e7a2 FROMLIST: mm, memcg: inline swap-related functions to improve disabled memcg config
Inline mem_cgroup_try_charge_swap, mem_cgroup_uncharge_swap and
cgroup_throttle_swaprate functions to perform mem_cgroup_disabled static
key check inline before calling the main body of the function. This
minimizes the memcg overhead in the pagefault and exit_mmap paths when
memcgs are disabled using cgroup_disable=memory command-line option.
This change results in ~1% overhead reduction when running PFT test [1]
comparing {CONFIG_MEMCG=n} against {CONFIG_MEMCG=y, cgroup_disable=memory}
configuration on an 8-core ARM64 Android device.

[1] https://lkml.org/lkml/2006/8/29/294 also used in mmtests suite

Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>

Link: https://lore.kernel.org/patchwork/patch/1458908/
Bug: 191223209
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I18d59090ec908037b39324d1f1bb511d06e9c690
2021-07-12 18:34:30 -07:00
Suren Baghdasaryan
3ae8e2f183 BACKPORT: FROMLIST: mm, memcg: inline mem_cgroup_{charge/uncharge} to improve disabled memcg config
Inline mem_cgroup_{charge/uncharge} and mem_cgroup_uncharge_list functions
functions to perform mem_cgroup_disabled static key check inline before
calling the main body of the function. This minimizes the memcg overhead
in the pagefault and exit_mmap paths when memcgs are disabled using
cgroup_disable=memory command-line option.
This change results in ~0.4% overhead reduction when running PFT test [1]
comparing {CONFIG_MEMCG=n} against {CONFIG_MEMCG=y, cgroup_disable=memory}
configuration on an 8-core ARM64 Android device.

[1] https://lkml.org/lkml/2006/8/29/294 also used in mmtests suite

Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>

Conflicts:
        include/linux/memcontrol.h
        mm/memcontrol.c

1. Trivial merge conflicts in memcontrol.h
2. Did not need to rename __mem_cgroup_charge into memcg_charge as in the
upstream version since in 5.10 __mem_cgroup_charge did not exist

Link: https://lore.kernel.org/patchwork/patch/1458907/
Bug: 191223209
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I9aad72aeabec2fe01f7218d629ec545c47b5d2c3
2021-07-12 18:32:52 -07:00
Suren Baghdasaryan
f73d029485 FROMLIST: mm, memcg: add mem_cgroup_disabled checks in vmpressure and swap-related functions
Add mem_cgroup_disabled check in vmpressure, mem_cgroup_uncharge_swap and
cgroup_throttle_swaprate functions. This minimizes the memcg overhead in
the pagefault and exit_mmap paths when memcgs are disabled using
cgroup_disable=memory command-line option.
This change results in ~2.1% overhead reduction when running PFT test [1]
comparing {CONFIG_MEMCG=n, CONFIG_MEMCG_SWAP=n} against {CONFIG_MEMCG=y,
CONFIG_MEMCG_SWAP=y, cgroup_disable=memory} configuration on an 8-core
ARM64 Android device.

[1] https://lkml.org/lkml/2006/8/29/294 also used in mmtests suite

Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>

Link: https://lore.kernel.org/patchwork/patch/1458906/
Bug: 191223209
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ic1fc75eb1e4d7a9848cf641b9f232ad3262c490b
2021-07-12 18:26:15 -07:00
Alex Shi
669df367a9 UPSTREAM: mm/memcg: bail early from swap accounting if memcg disabled
Patch series "bail out early for memcg disable".

These 2 patches are indepenedent from per memcg lru lock, and may
encounter unexpected warning, so let's move out them from per memcg
lru locking patchset.

This patch (of 2):

We could bail out early when memcg wasn't enabled.

Link: https://lkml.kernel.org/r/1604283436-18880-1-git-send-email-alex.shi@linux.alibaba.com
Link: https://lkml.kernel.org/r/1604283436-18880-2-git-send-email-alex.shi@linux.alibaba.com
Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
Reviewed-by: Roman Gushchin <guro@fb.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Hugh Dickins <hughd@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit 76358ab547)
Bug: 191223209
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Id3ea83d209cc4c98e3f1616b7d1044cfb1079c75
2021-07-12 18:04:48 -07:00
Kalesh Singh
1f0c32a667 UPSTREAM: procfs/dmabuf: add inode number to /proc/*/fdinfo
And 'ino' field to /proc/<pid>/fdinfo/<FD> and
/proc/<pid>/task/<tid>/fdinfo/<FD>.

The inode numbers can be used to uniquely identify DMA buffers in user
space and avoids a dependency on /proc/<pid>/fd/* when accounting
per-process DMA buffer sizes.

Link: https://lkml.kernel.org/r/20210308170651.919148-2-kaleshsingh@google.com
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Christian König <christian.koenig@amd.com>
Cc: Jann Horn <jannh@google.com>
Cc: Jeff Vander Stoep <jeffv@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Hridya Valsaraju <hridya@google.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Kalesh Singh <kaleshsingh@google.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Alexey Gladkov <gladkov.alexey@gmail.com>
Cc: Szabolcs Nagy <szabolcs.nagy@arm.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Michel Lespinasse <walken@google.com>
Cc: Bernd Edlinger <bernd.edlinger@hotmail.de>
Cc: Andrei Vagin <avagin@gmail.com>
Cc: Helge Deller <deller@gmx.de>
Cc: James Morris <jamorris@linux.microsoft.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit 3845f256a8)

Bug: 159126739
Bug: 167141117
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Change-Id: Id07beac3edcc95c0b42805e24e5486965acbb46e
2021-07-12 22:38:22 +00:00
Kalesh Singh
0c8c125f57 UPSTREAM: procfs: allow reading fdinfo with PTRACE_MODE_READ
Android captures per-process system memory state when certain low memory
events (e.g a foreground app kill) occur, to identify potential memory
hoggers.  In order to measure how much memory a process actually consumes,
it is necessary to include the DMA buffer sizes for that process in the
memory accounting.  Since the handle to DMA buffers are raw FDs, it is
important to be able to identify which processes have FD references to a
DMA buffer.

Currently, DMA buffer FDs can be accounted using /proc/<pid>/fd/* and
/proc/<pid>/fdinfo -- both are only readable by the process owner, as
follows:

  1. Do a readlink on each FD.
  2. If the target path begins with "/dmabuf", then the FD is a dmabuf FD.
  3. stat the file to get the dmabuf inode number.
  4. Read/ proc/<pid>/fdinfo/<fd>, to get the DMA buffer size.

Accessing other processes' fdinfo requires root privileges.  This limits
the use of the interface to debugging environments and is not suitable for
production builds.  Granting root privileges even to a system process
increases the attack surface and is highly undesirable.

Since fdinfo doesn't permit reading process memory and manipulating
process state, allow accessing fdinfo under PTRACE_MODE_READ_FSCRED.

Link: https://lkml.kernel.org/r/20210308170651.919148-1-kaleshsingh@google.com
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Suggested-by: Jann Horn <jannh@google.com>
Acked-by: Christian König <christian.koenig@amd.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Alexey Gladkov <gladkov.alexey@gmail.com>
Cc: Andrei Vagin <avagin@gmail.com>
Cc: Bernd Edlinger <bernd.edlinger@hotmail.de>
Cc: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Hridya Valsaraju <hridya@google.com>
Cc: James Morris <jamorris@linux.microsoft.com>
Cc: Jeff Vander Stoep <jeffv@google.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Kees Cook <keescook@chromium.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Michel Lespinasse <walken@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Szabolcs Nagy <szabolcs.nagy@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit 7bc3fa0172)

Bug: 159126739
Bug: 167141117
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Change-Id: I842b689670f731138592f45c7124ef446d9aa59a
2021-07-12 22:38:16 +00:00
Kalesh Singh
2e0476a465 Revert "FROMLIST: procfs: Allow reading fdinfo with PTRACE_MODE_READ"
Revert submission 1578844

Reason for revert: Will be replaced by upstream version
Reverted Changes:
Ic9c551998:FROMLIST: BACKPORT: procfs/dmabuf: Add inode numbe...
I41407760c:FROMLIST: procfs: Allow reading fdinfo with PTRACE...

Bug: 159126739
Bug: 167141117
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Change-Id: Iede4e9a65f87dad1ca0c6ecdeb42de47af4b37c8
2021-07-12 22:38:09 +00:00