Commit graph

886,579 commits

Author SHA1 Message Date
Frankie Chang
7285ca6e97 ANDROID: Add vendor hooks when syscall prctl finished
Add vendor hook when syscall prctl finished for vendor-specific tuning.

Bug: 181819699

Signed-off-by: Frankie Chang <frankie.chang@mediatek.com>
Change-Id: Ica42d80ab4b540045330e9c5b211e0e814eed0ff
(cherry picked from commit 6904f0001e4ec3c637539c18969e46755eaa01f4)
2021-03-09 21:57:07 +00:00
Frankie Chang
4b22a63233 ANDROID: cgroup: Add vendor hook to the cgroup
Add a vendor hook after attaching a task to a cgroup to 
recognize the group_id for performance tuning

Bug: 181917687

Signed-off-by: Frankie Chang <frankie.chang@mediatek.com>
Change-Id: I603afa3d893dd575a7dcb97f83bd9eacb8315bab
(cherry picked from commit bed1e2a75b0000d99a00177272b93e5c8430308b)
2021-03-09 21:56:56 +00:00
Elliot Berman
47c864ead1 ANDROID: db845c: Use FRAGMENT_CONFIG
./build/config.sh provides Kbuild's configuration editor in kernel/build
environment, plus support for editing config fragments. Set
FRAGMENT_CONFIG for ./build/config.sh.

Bug: 169398826
Signed-off-by: Elliot Berman <eberman@codeaurora.org>
[jstultz: Dropped sorting the config fragment]
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: Id09967bb06d0652788d17373ade2619a310c9e87
2021-03-08 19:14:48 +00:00
John Stultz
c037b5c852 ANDROID: abi_gki_aarch64_db845c: Update symbols for boot regression
Commit 28688d32ed ("ANDROID: Incremental fs: Set credentials
before reading/writing") changed the symbols needed to boot,
so update the db845c symbols list

Generated with:
  BUILD_CONFIG=common/build.config.db845c build/build_abi.sh -s
  BUILD_CONFIG=common/build.config.gki.aarch64 build/build_abi.sh -u

Leaf changes summary: 1 artifact 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, 0 Added variable

1 Added function:

  [A] 'function void revert_creds(const cred*)'

Fixes: 28688d32ed ("ANDROID: Incremental fs: Set credentials before reading/writing")
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: Ie077311af0cbc6f6cd302b0b870833286685f565
2021-03-08 19:14:48 +00:00
Frankie Chang
66da798d24 ANDROID: sched: move vendor hook to check scheduling nice value
move hook to collect scheduling information and apply vendor's
tuning before task's scheduling priority is changed

Bug: 163431711

Signed-off-by: Frankie Chang <frankie.chang@mediatek.com>
Change-Id: I61a7ab663316c0fbcb28d1b6e523649a6374b492
(cherry picked from commit 5cf5bc7523bd5608590de487de896c1026161a18)
2021-03-08 09:31:36 +00:00
Greg Kroah-Hartman
32ff5fbcab ANDROID: GKI: bring back icmpv6_send
In 5.4.102 the icmpv6_send() was replaced with an inline function.
Bring it back to provide for modules that used this symbol to preserve
the ABI.

Bug: 161946584
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Id1a914518f6e850f6bb96b5449c15eda3a7a7fd8
2021-03-05 06:50:46 +01:00
Jason A. Donenfeld
797bd53ae8 UPSTREAM: net: icmp: pass zeroed opts from icmp{,v6}_ndo_send before sending
commit ee576c47db60432c37e54b1e2b43a8ca6d3a8dca upstream.

The icmp{,v6}_send functions make all sorts of use of skb->cb, casting
it with IPCB or IP6CB, assuming the skb to have come directly from the
inet layer. But when the packet comes from the ndo layer, especially
when forwarded, there's no telling what might be in skb->cb at that
point. As a result, the icmp sending code risks reading bogus memory
contents, which can result in nasty stack overflows such as this one
reported by a user:

    panic+0x108/0x2ea
    __stack_chk_fail+0x14/0x20
    __icmp_send+0x5bd/0x5c0
    icmp_ndo_send+0x148/0x160

In icmp_send, skb->cb is cast with IPCB and an ip_options struct is read
from it. The optlen parameter there is of particular note, as it can
induce writes beyond bounds. There are quite a few ways that can happen
in __ip_options_echo. For example:

    // sptr/skb are attacker-controlled skb bytes
    sptr = skb_network_header(skb);
    // dptr/dopt points to stack memory allocated by __icmp_send
    dptr = dopt->__data;
    // sopt is the corrupt skb->cb in question
    if (sopt->rr) {
        optlen  = sptr[sopt->rr+1]; // corrupt skb->cb + skb->data
        soffset = sptr[sopt->rr+2]; // corrupt skb->cb + skb->data
	// this now writes potentially attacker-controlled data, over
	// flowing the stack:
        memcpy(dptr, sptr+sopt->rr, optlen);
    }

In the icmpv6_send case, the story is similar, but not as dire, as only
IP6CB(skb)->iif and IP6CB(skb)->dsthao are used. The dsthao case is
worse than the iif case, but it is passed to ipv6_find_tlv, which does
a bit of bounds checking on the value.

This is easy to simulate by doing a `memset(skb->cb, 0x41,
sizeof(skb->cb));` before calling icmp{,v6}_ndo_send, and it's only by
good fortune and the rarity of icmp sending from that context that we've
avoided reports like this until now. For example, in KASAN:

    BUG: KASAN: stack-out-of-bounds in __ip_options_echo+0xa0e/0x12b0
    Write of size 38 at addr ffff888006f1f80e by task ping/89
    CPU: 2 PID: 89 Comm: ping Not tainted 5.10.0-rc7-debug+ #5
    Call Trace:
     dump_stack+0x9a/0xcc
     print_address_description.constprop.0+0x1a/0x160
     __kasan_report.cold+0x20/0x38
     kasan_report+0x32/0x40
     check_memory_region+0x145/0x1a0
     memcpy+0x39/0x60
     __ip_options_echo+0xa0e/0x12b0
     __icmp_send+0x744/0x1700

Actually, out of the 4 drivers that do this, only gtp zeroed the cb for
the v4 case, while the rest did not. So this commit actually removes the
gtp-specific zeroing, while putting the code where it belongs in the
shared infrastructure of icmp{,v6}_ndo_send.

This commit fixes the issue by passing an empty IPCB or IP6CB along to
the functions that actually do the work. For the icmp_send, this was
already trivial, thanks to __icmp_send providing the plumbing function.
For icmpv6_send, this required a tiny bit of refactoring to make it
behave like the v4 case, after which it was straight forward.

Fixes: a2b78e9b2c ("sunvnet: generate ICMP PTMUD messages for smaller port MTUs")
Reported-by: SinYu <liuxyon@gmail.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/netdev/CAF=yD-LOF116aHub6RMe8vB8ZpnrrnoTdqhobEx+bvoA8AsP0w@mail.gmail.com/T/
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Link: https://lore.kernel.org/r/20210223131858.72082-1-Jason@zx2c4.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 9875cb3c09)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I5ca6554f162b3d64d2c4aad80c3382089b2438a4
2021-03-05 06:50:46 +01:00
Leon Romanovsky
899bfe24dc UPSTREAM: ipv6: silence compilation warning for non-IPV6 builds
commit 1faba27f11c8da244e793546a1b35a9b1da8208e upstream.

The W=1 compilation of allmodconfig generates the following warning:

net/ipv6/icmp.c:448:6: warning: no previous prototype for 'icmp6_send' [-Wmissing-prototypes]
  448 | void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
      |      ^~~~~~~~~~

Fix it by providing function declaration for builds with ipv6 as a module.

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 354fb7244f)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I2d4f57e63640c18bf93c103da0a3b72c67152ed6
2021-03-05 06:50:46 +01:00
Eric Dumazet
f1c0684934 UPSTREAM: ipv6: icmp6: avoid indirect call for icmpv6_send()
commit cc7a21b6fbd945f8d8f61422ccd27203c1fafeb7 upstream.

If IPv6 is builtin, we do not need an expensive indirect call
to reach icmp6_send().

v2: put inline keyword before the type to avoid sparse warnings.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit e528edf1e5)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I0d19f581c6360b4317e6934972845f6a39203de5
2021-03-05 06:50:46 +01:00
Jason A. Donenfeld
0682eb7280 UPSTREAM: xfrm: interface: use icmp_ndo_send helper
commit 45942ba890e6f35232727a5fa33d732681f4eb9f upstream.

Because xfrmi is calling icmp from network device context, it should use
the ndo helper so that the rate limiting applies correctly.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Cc: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit c30e93eee3)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I404cf4d493272eefd88c28b65712bca5f5e12744
2021-03-05 06:50:46 +01:00
Jason A. Donenfeld
fb836b54d0 UPSTREAM: sunvnet: use icmp_ndo_send helper
commit 67c9a7e1e3ac491b5df018803639addc36f154ba upstream.

Because sunvnet is calling icmp from network device context, it should use
the ndo helper so that the rate limiting applies correctly. While we're
at it, doing the additional route lookup before calling icmp_ndo_send is
superfluous, since this is the job of the icmp code in the first place.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Cc: Shannon Nelson <shannon.nelson@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit e1ec06b833)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ia0ae7b14d4785c83547824563edb019c30cda79f
2021-03-05 06:50:46 +01:00
Jason A. Donenfeld
17060ca408 UPSTREAM: gtp: use icmp_ndo_send helper
commit e0fce6f945a26d4e953a147fe7ca11410322c9fe upstream.

Because gtp is calling icmp from network device context, it should use
the ndo helper so that the rate limiting applies correctly.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Cc: Harald Welte <laforge@gnumonks.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit d8d268ce1a)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I87cecb7368e63ad10a3a6a43d990797997019f92
2021-03-05 06:50:46 +01:00
Jason A. Donenfeld
61e9311bf7 UPSTREAM: icmp: allow icmpv6_ndo_send to work with CONFIG_IPV6=n
commit a8e41f6033a0c5633d55d6e35993c9e2005d872f upstream.

The icmpv6_send function has long had a static inline implementation
with an empty body for CONFIG_IPV6=n, so that code calling it doesn't
need to be ifdef'd. The new icmpv6_ndo_send function, which is intended
for drivers as a drop-in replacement with an identical function
signature, should follow the same pattern. Without this patch, drivers
that used to work with CONFIG_IPV6=n now result in a linker error.

Cc: Chen Zhou <chenzhou10@huawei.com>
Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: 0b41713b6066 ("icmp: introduce helper for nat'd source address in network device context")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit dd28e735df)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I4f30fef204264bd40c432e5e5408495b87e02d03
2021-03-05 06:50:45 +01:00
Jason A. Donenfeld
1188cb33bc UPSTREAM: icmp: introduce helper for nat'd source address in network device context
commit 0b41713b606694257b90d61ba7e2712d8457648b upstream.

This introduces a helper function to be called only by network drivers
that wraps calls to icmp[v6]_send in a conntrack transformation, in case
NAT has been used. We don't want to pollute the non-driver path, though,
so we introduce this as a helper to be called by places that actually
make use of this, as suggested by Florian.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Cc: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 2019554f96)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Iec63f040ae2d82f3dc4bf1cd303a773e2e551b92
2021-03-05 06:50:45 +01:00
Xiaowen Wu
313f089215 ANDROID: ABI: Update allowed list for QCOM
Leaf changes summary: 4 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 3 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 1 Added variable

3 Added functions:

  [A] 'function s32 __i2c_smbus_xfer(i2c_adapter*, u16, unsigned short int, char, u8, int, i2c_smbus_data*)'
  [A] 'function int i2c_get_device_id(const i2c_client*, i2c_device_identity*)'
  [A] 'function s32 i2c_smbus_read_byte(const i2c_client*)'

1 Added variable:

  [A] 'const irq_domain_ops irq_domain_simple_ops'

Bug: 181847974
Change-Id: I2a4de290bab1dfd84b055558bf59ae18922ff0db
Signed-off-by: Xiaowen Wu <wxiaowen@codeaurora.org>
2021-03-04 14:43:14 -08:00
Hemant Kumar
5024508d0f ANDROID: ABI: Update allowed list for QCOM
Leaf changes summary: 1 artifact 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, 0 Added
variable

1 Added function:

  [A] 'function int pcie_capability_clear_and_set_word(pci_dev*, int,
		  u16, u16)'

Bug: 180947505
Change-Id: Ied014fdef72f3b87f32ce4f0e41f1919addbb2d1
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
2021-03-03 19:38:42 -08:00
Michael Specter
cb0830225a ANDROID: Adding kprobes build configs for Cuttlefish
Bug: 181054145
Change-Id: Ibb1362479469eae9c294f71a483e500db05b04e1
Signed-off-by: Michael Specter <mikespecter@google.com>
2021-02-28 04:50:28 +00:00
Paul Lawrence
75c93eb439 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-02-23 07:26:29 -08:00
Paul Lawrence
28688d32ed ANDROID: Incremental fs: Set credentials before reading/writing
Bug: 174692664
Test: incfs_test passes, incremental installs work with ag/13082306
Signed-off-by: Paul Lawrence <paullawrence@google.com>

Change-Id: Ib1c924bbaff759f58f7d83bad8e23d7224ba7ed9
2021-02-23 07:26:18 -08:00
Paul Lawrence
152fd8f044 ANDROID: Incremental fs: Fix memory leak on closing file
Bug: 179271514
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Idc42d02b1df5ac84bdd04e728bfcca5f4cc5d07b
2021-02-23 07:03:08 -08:00
Masaya Takahashi
29b2beadc6 ANDROID: GKI: update Sony KMI symbol list
Update the Sony abi list for ledtrig_transient.ko

Leaf changes summary: 1 artifact 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, 0 Added variable

1 Added function:

  [A] 'function void led_set_brightness_nosleep(led_classdev*, led_brightness)'

Bug: 180692386
Signed-off-by: Masaya Takahashi <masaya.a.takahashi@sony.com>
Change-Id: I097a124fda2b5b48a2d7ad7d92d033eaa571bc21
2021-02-19 20:59:46 +09:00
John Stultz
c382bf8373 ANDROID: ABI updates for db845c (enabling wifi)
Update the db845c abi list after enabling wifi

Generated with:
  BUILD_CONFIG=common/build.config.db845c build/build_abi.sh -u
  build/build_abi.sh -u

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

34 Added functions:

  [A] 'function void __ieee80211_schedule_txq(ieee80211_hw*, ieee80211_txq*, bool)'
  [A] 'function int dev_pm_genpd_set_performance_state(device*, unsigned int)'
  [A] 'function void* device_get_mac_address(device*, char*, int)'
  [A] 'function thermal_cooling_device* devm_thermal_of_cooling_device_register(device*, device_node*, char*, void*, const thermal_cooling_device_ops*)'
  [A] 'function sk_buff* ieee80211_beacon_get_template(ieee80211_hw*, ieee80211_vif*, ieee80211_mutable_offsets*)'
  [A] 'function void ieee80211_beacon_loss(ieee80211_vif*)'
  [A] 'function u8 ieee80211_csa_update_counter(ieee80211_vif*)'
  [A] 'function ieee80211_sta* ieee80211_find_sta_by_ifaddr(ieee80211_hw*, const u8*, const u8*)'
  [A] 'function void ieee80211_iter_chan_contexts_atomic(ieee80211_hw*, void (ieee80211_hw*, ieee80211_chanctx_conf*, void*)*, void*)'
  [A] 'function void ieee80211_iterate_stations_atomic(ieee80211_hw*, void (void*, ieee80211_sta*)*, void*)'
  [A] 'function void ieee80211_manage_rx_ba_offl(ieee80211_vif*, const u8*, unsigned int)'
  [A] 'function ieee80211_txq* ieee80211_next_txq(ieee80211_hw*, u8)'
  [A] 'function void ieee80211_sta_register_airtime(ieee80211_sta*, unsigned char, unsigned int, unsigned int)'
  [A] 'function void ieee80211_tdls_oper_request(ieee80211_vif*, const u8*, nl80211_tdls_operation, u16, gfp_t)'
  [A] 'function sk_buff* ieee80211_tx_dequeue(ieee80211_hw*, ieee80211_txq*)'
  [A] 'function void ieee80211_tx_rate_update(ieee80211_hw*, ieee80211_sta*, ieee80211_tx_info*)'
  [A] 'function void ieee80211_txq_get_depth(ieee80211_txq*, unsigned long int*, unsigned long int*)'
  [A] 'function bool ieee80211_txq_may_transmit(ieee80211_hw*, ieee80211_txq*)'
  [A] 'function void ieee80211_txq_schedule_start(ieee80211_hw*, u8)'
  [A] 'function int pcie_capability_write_word(pci_dev*, int, u16)'
  [A] 'function const char* reg_initiator_name(nl80211_reg_initiator)'
  [A] 'function int rproc_add(rproc*)'
  [A] 'function void rproc_add_subdev(rproc*, rproc_subdev*)'
  [A] 'function rproc* rproc_alloc(device*, const char*, const rproc_ops*, const char*, int)'
  [A] 'function int rproc_coredump_add_custom_segment(rproc*, dma_addr_t, size_t, void (rproc*, rproc_dump_segment*, void*)*, void*)'
  [A] 'function int rproc_coredump_add_segment(rproc*, dma_addr_t, size_t)'
  [A] 'function int rproc_del(rproc*)'
  [A] 'function u32 rproc_elf_get_boot_addr(rproc*, const firmware*)'
  [A] 'function void rproc_free(rproc*)'
  [A] 'function rproc* rproc_get_by_child(device*)'
  [A] 'function void rproc_remove_subdev(rproc*, rproc_subdev*)'
  [A] 'function void rproc_report_crash(rproc*, rproc_crash_type)'
  [A] 'function thermal_cooling_device* thermal_cooling_device_register(const char*, void*, const thermal_cooling_device_ops*)'
  [A] 'function void wiphy_read_of_freq_limits(wiphy*)'

Bug: 146449535
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: I6e3c8a52a394b7f151065f4792d22a5a94c7e8fa
2021-02-18 16:34:56 -08:00
John Stultz
2ae7c28a04 ANDROID: db845c_gki.fragment: Enable wifi on db845c w/ android-5.4
Add config settings to enable wifi via modules on db845c

Bug: 146449535
Change-Id: I81892c4cc48db7839fe99aa5fb0b0a0782cab321
Signed-off-by: John Stultz <john.stultz@linaro.org>
2021-02-18 16:25:02 -08:00
Bjorn Andersson
8f96c722f5 UPSTREAM: arm64: dts: qcom: sdm845: Add APSS watchdog node
commit ef8576789e869b7584684ae81126a465eb1deeb6 upstream.

Add a node describing the watchdog found in the application subsystem.

Reviewed-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
(cherry picked from commit ef8576789e869b7584684ae81126a465eb1deeb6)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: I835d512c13c392e356c5190e865c0617e97041c2
2021-02-18 16:24:28 -08:00
Bjorn Andersson
1d2d51a301 UPSTREAM: arm64: dts: qcom: db845c: Move remoteproc firmware to sdm845
The redistributable firmware should work on any engineering device, so
lets push this to qcom/sdm845, rather than qcom/db845c. Also specify the
path for the modem firmware.

Reviewed-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20191113203951.3704428-1-bjorn.andersson@linaro.org
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
(cherry picked from commit 82b1cc447a2c7c5121ce34f15f9840110ee3499f)
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: Ica785dd7faee17dce933379dbb6ada32a3697bdb
2021-02-18 16:23:58 -08:00
Bjorn Andersson
a09a63360b UPSTREAM: ath10k: qmi: Sleep for a while before assigning MSA memory
commit b70b3a36ec33a2c8d3292f3b33fe2047a8f57b9a upstream.

Unless we sleep for a while before transitioning the MSA memory to WLAN
the MPSS.AT.4.0.c2-01184-SDM845_GEN_PACK-1 firmware triggers a security
violation fairly reliably. Unforutnately recovering from this failure
always results in the entire system freezing.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
(cherry picked from commit b70b3a36ec33a2c8d3292f3b33fe2047a8f57b9a)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: Ie44e86d404f1897b7cc349a03972178374fef89c
2021-02-18 16:23:20 -08:00
Jeffrey Hugo
2d00c82d25 UPSTREAM: soc: qcom: qmi: Return EPROBE_DEFER if no address family
If a client comes up early in the boot process (perhaps was a built-in
driver), qmi_handle_init() will likely fail with a EAFNOSUPPORT since the
underlying ipc router hasn't init'd and registered the address family.
This should not be a fatal error since chances are, the router will come
up later, so recode the error to EPROBE_DEFER so that clients will retry
later.

Signed-off-by: Jeffrey Hugo <jeffrey.l.hugo@gmail.com>
Link: https://lore.kernel.org/r/20191106230511.1290-1-jeffrey.l.hugo@gmail.com
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
(cherry picked from commit 52af26e33e700158e6549f1465fcf9da099fabfa)
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: I26a0dabe9b1f3b8e9cc793f7f52ee8f658ecdce3
2021-02-18 16:22:46 -08:00
Tony Truong
240e180bd8 ANDROID: ABI: Update allowed list for QCOM
Add the following symbols to QCOM allowed-list:
-- pcie_bus_configure_settings

Bug: 180475310
Change-Id: I49ed1ada673a9199370344cf2b89d7369f92d3f2
Signed-off-by: Tony Truong <truong@codeaurora.org>
2021-02-18 14:25:28 +00:00
Masaya Takahashi
224ea2cd2c ANDROID: GKI: update Sony symbol list for texfat
Leaf changes summary: 60 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 60 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

60 Added functions:

  [A] 'function void __bforget(buffer_head*)'
  [A] 'function void __filemap_set_wb_err(address_space*, int)'
  [A] 'function void __pagevec_release(pagevec*)'
  [A] 'function void __sb_end_write(super_block*, int)'
  [A] 'function int __sb_start_write(super_block*, int, bool)'
  [A] 'function int __test_set_page_writeback(page*, bool)'
  [A] 'function int add_to_page_cache_locked(page*, address_space*, unsigned long int, gfp_t)'
  [A] 'function void balance_dirty_pages_ratelimited(address_space*)'
  [A] 'function int blkdev_issue_discard(block_device*, long long unsigned int, long long unsigned int, unsigned int, unsigned long int)'
  [A] 'function void block_invalidatepage(page*, unsigned int, unsigned int)'
  [A] 'function bool capable_wrt_inode_uidgid(const inode*, int)'
  [A] 'function int clear_page_dirty_for_io(page*)'
  [A] 'function int current_umask()'
  [A] 'function dentry* d_splice_alias(inode*, dentry*)'
  [A] 'function void end_page_writeback(page*)'
  [A] 'function int fiemap_check_flags(fiemap_extent_info*, u32)'
  [A] 'function int fiemap_fill_next_extent(fiemap_extent_info*, u64, u64, u64, u32)'
  [A] 'function int file_remove_privs(file*)'
  [A] 'function int file_update_time(file*)'
  [A] 'function int file_write_and_wait_range(file*, loff_t, loff_t)'
  [A] 'function int filemap_fdatawrite(address_space*)'
  [A] 'function int filemap_flush(address_space*)'
  [A] 'function int filemap_write_and_wait(address_space*)'
  [A] 'function int filemap_write_and_wait_range(address_space*, loff_t, loff_t)'
  [A] 'function ssize_t generic_file_direct_write(kiocb*, iov_iter*)'
  [A] 'function ssize_t generic_perform_write(file*, iov_iter*, loff_t)'
  [A] 'function ssize_t generic_write_checks(kiocb*, iov_iter*)'
  [A] 'function page* grab_cache_page_write_begin(address_space*, unsigned long int, unsigned int)'
  [A] 'function inode* igrab(inode*)'
  [A] 'function inode* ilookup5(super_block*, unsigned long int, int (inode*, void*)*, void*)'
  [A] 'function void inode_dio_wait(inode*)'
  [A] 'function int inode_newsize_ok(const inode*, long long int)'
  [A] 'function void inode_set_flags(inode*, unsigned int, unsigned int)'
  [A] 'function void iov_iter_advance(iov_iter*, unsigned long int)'
  [A] 'function unsigned long int iov_iter_alignment(const iov_iter*)'
  [A] 'function long int iov_iter_get_pages(iov_iter*, page**, unsigned long int, unsigned int, unsigned long int*)'
  [A] 'function ssize_t iter_file_splice_write(pipe_inode_info*, file*, loff_t*, size_t, unsigned int)'
  [A] 'function kmem_cache* kmem_cache_create_usercopy(const char*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, void (void*)*)'
  [A] 'function void ktime_get_coarse_real_ts64(timespec64*)'
  [A] 'function void ll_rw_block(int, int, int, buffer_head**)'
  [A] 'function void lru_cache_add_file(page*)'
  [A] 'function void mark_buffer_write_io_error(buffer_head*)'
  [A] 'function void mnt_drop_write_file(file*)'
  [A] 'function unsigned long int page_cache_next_miss(address_space*, unsigned long int, unsigned long int)'
  [A] 'function unsigned long int page_cache_prev_miss(address_space*, unsigned long int, unsigned long int)'
  [A] 'function unsigned int pagevec_lookup_range_tag(pagevec*, address_space*, unsigned long int*, unsigned long int, unsigned int)'
  [A] 'function int param_set_byte(const char*, const kernel_param*)'
  [A] 'function void put_pages_list(list_head*)'
  [A] 'function int redirty_page_for_writepage(writeback_control*, page*)'
  [A] 'function void set_nlink(inode*, unsigned int)'
  [A] 'function int setattr_prepare(dentry*, iattr*)'
  [A] 'function long long unsigned int simple_strtoull(const char*, char**, unsigned int)'
  [A] 'function int sync_inode_metadata(inode*, int)'
  [A] 'function void sync_inodes_sb(super_block*)'
  [A] 'function void tag_pages_for_writeback(address_space*, unsigned long int, unsigned long int)'
  [A] 'function void truncate_setsize(inode*, loff_t)'
  [A] 'function void try_to_writeback_inodes_sb(super_block*, wb_reason)'
  [A] 'function int vfs_fsync_range(file*, long long int, long long int, int)'
  [A] 'function void wait_on_page_bit(page*, int)'
  [A] 'function void writeback_inodes_sb(super_block*, wb_reason)'

Bug: 178455529
Signed-off-by: Masaya Takahashi <masaya.a.takahashi@sony.com>
Change-Id: I39c6be26264b1eba59e3fc0ba2a086dc4f9e1baa
2021-02-18 18:43:30 +09:00
Yongqin Liu
19c89b6bbf ANDROID: GKI: update KMI for db845c with idr_alloc_u32 added
to resolve the idr_alloc_u32 symbol not found problem,
like reported as the following:
    [    9.718675] init: Loading module /lib/modules/qrtr.ko with args ""
    [    9.724987] qcom-pcie 1c08000.pci: 1c08000.pci supply vddpe-3v3 not found, using dummy regulator
    [    9.733909] qcom-pcie 1c08000.pci: host bridge /soc@0/pci@1c08000 ranges:
    [    9.741378] qrtr: Unknown symbol idr_alloc_u32 (err -2)
    [    9.746741] qcom-pcie 1c08000.pci:    IO 0x40200000..0x402fffff -> 0x40200000
    [    9.753958] qcom-pcie 1c08000.pci:   MEM 0x40300000..0x5fffffff -> 0x40300000
    [    9.784507] init: Failed to insmod '/lib/modules/qrtr.ko' with args ''
    [    9.791151] init: LoadWithAliases was unable to load /lib/modules/qrtr.ko
    [    9.798037] init: LoadWithAliases was unable to load qrtr_tun
    [    9.804055] init: Failed to load kernel modules

Add this symbol to the .xml file:

Leaf changes summary: 1 artifact changed (80 filtered out)
Changed leaf types summary: 0 (80 filtered out) leaf types changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 1 Added function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

1 Added function:

  [A] 'function int idr_alloc_u32(idr*, void*, unsigned int*, unsigned long int, unsigned int)'

Test: boot tested with db845c android11 build
Fixes: 4ef63e3654 ("net: qrtr: fix usage of idr in port assignment to socket")
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I62bf3ac2cccbc2fe7ca70986939ba4f593ca86a2
2021-02-17 19:18:53 +01:00
Greg Kroah-Hartman
9394e52285 Merge tag 'android11-5.4.86_r00' from 'android11-5.4-lts' into 'android11-5.4'
This merges the 5.4.86 upstream LTS release into the android11-5.4
branch so that all devices can get the needed important security and
other bugfixes that are in here.  All devices must upgrade to remain
properly secure from known issues.

Bug: 180469075
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I1041e0d08d55a3eb2e0f49b7d2384960f48d9b11
2021-02-17 16:57:46 +01:00
Manaf Meethalavalappu Pallikunhi
d3c11f4ae4 ANDROID: ABI: Update allowed list for QCOM
Leaf changes summary: 1 artifact 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, 0 Added variable

1 Added function:

  [A] 'function int clk_notifier_unregister(clk*, notifier_block*)'

Bug: 180475184
Change-Id: Ifbbdfbb67dd5582144e345d0a2fa45065d0215ba
Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
2021-02-17 15:27:50 +00:00
Raviteja Tamatam
6b4f6cd53f ANDROID: ABI: update allowed list for QCOM
Update the android/abi_gki_aarch64_qcom with recent symbol additions.

No need to update the .xml file, as no new symbol addition.

Bug: 180426964
Signed-off-by: Raviteja Tamatam <travitej@codeaurora.org>
Change-Id: I301d36b0385756d6cfd5924c2655d5b728637a24
2021-02-17 10:08:51 +05:30
Xiaowen Wu
1d9c43fa3b ANDROID: ABI: Update allowed list for QCOM
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 drm_atomic_set_crtc_for_plane(drm_plane_state*, drm_crtc*)'
  [A] 'function void drm_atomic_set_fb_for_plane(drm_plane_state*, drm_framebuffer*)'
  [A] 'function void drm_connector_list_update(drm_connector*)'
  [A] 'function int drm_dp_mst_atomic_check(drm_atomic_state*)'
  [A] 'function void drm_dp_mst_dump_topology(seq_file*, drm_dp_mst_topology_mgr*)'
  [A] 'function bool drm_is_current_master(drm_file*)'
  [A] 'function drm_master* drm_master_get(drm_master*)'
  [A] 'function void drm_master_put(drm_master**)'
  [A] 'function void drm_mode_prune_invalid(drm_device*, list_head*, bool)'
  [A] 'function void drm_mode_sort(list_head*)'
  [A] 'function void drm_rect_rotate(drm_rect*, int, int, unsigned int)'

Bug: 180427255
Change-Id: I18bec99816010ff942849bf1f253b00a773a014e
Signed-off-by: Xiaowen Wu <wxiaowen@codeaurora.org>
2021-02-16 16:36:56 -05:00
Andrey Konovalov
f682b4505d ANDROID: build_config: drop CONFIG_KASAN_PANIC_ON_WARN
CONFIG_KASAN_PANIC_ON_WARN was added in a custom patch for Pixel kernels,
which would make KASAN panic the kernel after the first report regardless
of whether the panic_on_warn parameter is set. (Coincidentally, that patch
also would break instrumentation mode selection for KASAN.)

As that patch was never applied to the common kernel,
CONFIG_KASAN_PANIC_ON_WARN doesn't exist here. This change drops the
non-existent CONFIG_KASAN_PANIC_ON_WARN from build.config.gki_kasan.

Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Change-Id: I9f42bb5f3515f18e2a5774241ea73a59d8883955
2021-02-15 18:29:03 +00:00
Maciej Żenczykowski
0934349866 BACKPORT: bpf: add bpf_ktime_get_boot_ns()
On a device like a cellphone which is constantly suspending
and resuming CLOCK_MONOTONIC is not particularly useful for
keeping track of or reacting to external network events.
Instead you want to use CLOCK_BOOTTIME.

Hence add bpf_ktime_get_boot_ns() as a mirror of bpf_ktime_get_ns()
based around CLOCK_BOOTTIME instead of CLOCK_MONOTONIC.

Signed-off-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
(cherry picked from commit 71d19214776e61b33da48f7c1b46e522c7f78221)
Change-Id: Ifd62c410dcc5112fd1a473a7e1f70231ca514bc0
2021-02-12 01:58:59 -08:00
Kamal Agrawal
2d04a808c6 ANDROID: ABI: update allowed list for QCOM
Update the android/abi_gki_aarch64_qcom with recent symbol additions.

Simple change and no need to update the .xml file, as no new symbol
addition.

Bug: 179747683
Signed-off-by: Neeraja P <neerp@codeaurora.org>
Signed-off-by: Kamal Agrawal <kamaagra@codeaurora.org>
Change-Id: I1d5252ed623f83611a5b064a8e0e33e4f0d188c5
2021-02-09 12:57:28 +05:30
Anson Huang
9533cdc100 BACKPORT: clk: composite: Export clk_hw_register_composite()
Export clk_hw_register_composite() to support user built as module.

ERROR: modpost: "clk_hw_register_composite" [drivers/clk/imx/mxc-clk.ko]
undefined!

(cherry picked from commit d7d7518fdcc8f43da69fb40073273e77f24be24f)
[Jindong: Resolved minor conflict in drivers/clk/clk-composite.c ]
Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Shawn Guo <shawnguo@kernel.org>
Signed-off-by: Jindong Yue <jindong.yue@nxp.com>
Change-Id: I54496d44d4bf6599af3a3ec9c40c02556d55cf17
2021-02-05 21:39:00 +00:00
Jindong Yue
a9cae6eab7 ANDROID: PCI: dwc: Export symbols for ep driver
Several symbols in DesignWare PCI Core driver are used
to support PCIe controller work at Endpoint Mode.
Export them to support such driver built as module.

Bug: 159736148
Signed-off-by: Jindong Yue <jindong.yue@nxp.com>
Change-Id: I2c77bfbfbec750ecdf21f0cd1bbb20fe339a2f0c
2021-02-03 22:20:28 +00:00
Thomas Gleixner
904fb159c9 UPSTREAM: futex: Handle faults correctly for PI futexes
commit 34b1a1ce1458f50ef27c54e28eb9b1947012907a upstream

fixup_pi_state_owner() tries to ensure that the state of the rtmutex,
pi_state and the user space value related to the PI futex are consistent
before returning to user space. In case that the user space value update
faults and the fault cannot be resolved by faulting the page in via
fault_in_user_writeable() the function returns with -EFAULT and leaves
the rtmutex and pi_state owner state inconsistent.

A subsequent futex_unlock_pi() operates on the inconsistent pi_state and
releases the rtmutex despite not owning it which can corrupt the RB tree of
the rtmutex and cause a subsequent kernel stack use after free.

It was suggested to loop forever in fixup_pi_state_owner() if the fault
cannot be resolved, but that results in runaway tasks which is especially
undesired when the problem happens due to a programming error and not due
to malice.

As the user space value cannot be fixed up, the proper solution is to make
the rtmutex and the pi_state consistent so both have the same owner. This
leaves the user space value out of sync. Any subsequent operation on the
futex will fail because the 10th rule of PI futexes (pi_state owner and
user space value are consistent) has been violated.

As a consequence this removes the inept attempts of 'fixing' the situation
in case that the current task owns the rtmutex when returning with an
unresolvable fault by unlocking the rtmutex which left pi_state::owner and
rtmutex::owner out of sync in a different and only slightly less dangerous
way.

Fixes: 1b7558e457 ("futexes: fix fault handling in futex_lock_pi")
Reported-by: gzobqq@gmail.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 34b1a1ce1458f50ef27c54e28eb9b1947012907a)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Iabd44dad5d4b8385b8a20e44d18308708cc3b701
2021-01-29 13:16:10 +01:00
Thomas Gleixner
dddad86240 UPSTREAM: futex: Simplify fixup_pi_state_owner()
commit f2dac39d93987f7de1e20b3988c8685523247ae2 upstream

Too many gotos already and an upcoming fix would make it even more
unreadable.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit f2dac39d93987f7de1e20b3988c8685523247ae2)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I5a97587c0f696d4f4b849f7f106990a5587fa402
2021-01-29 13:16:01 +01:00
Thomas Gleixner
d245cfa173 UPSTREAM: futex: Use pi_state_update_owner() in put_pi_state()
commit 6ccc84f917d33312eb2846bd7b567639f585ad6d upstream

No point in open coding it. This way it gains the extra sanity checks.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 6ccc84f917d33312eb2846bd7b567639f585ad6d)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ic34513518cd4996b3eb4cb82b669d727be522597
2021-01-29 13:15:51 +01:00
Thomas Gleixner
cfe591bb90 UPSTREAM: rtmutex: Remove unused argument from rt_mutex_proxy_unlock()
commit 2156ac1934166d6deb6cd0f6ffc4c1076ec63697 upstream

Nothing uses the argument. Remove it as preparation to use
pi_state_update_owner().

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 2156ac1934166d6deb6cd0f6ffc4c1076ec63697)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I126088d93c5f05db654e508dfd4195e5c1696164
2021-01-29 13:15:42 +01:00
Thomas Gleixner
a60fba3000 UPSTREAM: futex: Provide and use pi_state_update_owner()
commit c5cade200ab9a2a3be9e7f32a752c8d86b502ec7 upstream

Updating pi_state::owner is done at several places with the same
code. Provide a function for it and use that at the obvious places.

This is also a preparation for a bug fix to avoid yet another copy of the
same code or alternatively introducing a completely unpenetratable mess of
gotos.

Originally-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit c5cade200ab9a2a3be9e7f32a752c8d86b502ec7)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I17a67806a035338a55b27eea673d707fc4d8c529
2021-01-29 13:15:27 +01:00
Thomas Gleixner
97500641e2 UPSTREAM: futex: Replace pointless printk in fixup_owner()
commit 04b79c55201f02ffd675e1231d731365e335c307 upstream

If that unexpected case of inconsistent arguments ever happens then the
futex state is left completely inconsistent and the printk is not really
helpful. Replace it with a warning and make the state consistent.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 04b79c55201f02ffd675e1231d731365e335c307)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I32bd64130d9414f65155ecd80646d01eb4374a60
2021-01-29 13:15:18 +01:00
Thomas Gleixner
3a0f91fd81 UPSTREAM: futex: Ensure the correct return value from futex_lock_pi()
commit 12bb3f7f1b03d5913b3f9d4236a488aa7774dfe9 upstream

In case that futex_lock_pi() was aborted by a signal or a timeout and the
task returned without acquiring the rtmutex, but is the designated owner of
the futex due to a concurrent futex_unlock_pi() fixup_owner() is invoked to
establish consistent state. In that case it invokes fixup_pi_state_owner()
which in turn tries to acquire the rtmutex again. If that succeeds then it
does not propagate this success to fixup_owner() and futex_lock_pi()
returns -EINTR or -ETIMEOUT despite having the futex locked.

Return success from fixup_pi_state_owner() in all cases where the current
task owns the rtmutex and therefore the futex and propagate it correctly
through fixup_owner(). Fixup the other callsite which does not expect a
positive return value.

Fixes: c1e2f0eaf0 ("futex: Avoid violating the 10th rule of futex")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 12bb3f7f1b03d5913b3f9d4236a488aa7774dfe9)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I6dfb7407620fdf8293edbfbe54463f0c8ff63a57
2021-01-29 13:15:05 +01:00
Wang Hai
19193ef53a UPSTREAM: Revert "mm/slub: fix a memory leak in sysfs_slab_add()"
commit 757fed1d0898b893d7daa84183947c70f27632f3 upstream.

This reverts commit dde3c6b72a16c2db826f54b2d49bdea26c3534a2.

syzbot report a double-free bug. The following case can cause this bug.

 - mm/slab_common.c: create_cache(): if the __kmem_cache_create() fails,
   it does:

	out_free_cache:
		kmem_cache_free(kmem_cache, s);

 - but __kmem_cache_create() - at least for slub() - will have done

	sysfs_slab_add(s)
		-> sysfs_create_group() .. fails ..
		-> kobject_del(&s->kobj); .. which frees s ...

We can't remove the kmem_cache_free() in create_cache(), because other
error cases of __kmem_cache_create() do not free this.

So, revert the commit dde3c6b72a16 ("mm/slub: fix a memory leak in
sysfs_slab_add()") to fix this.

Reported-by: syzbot+d0bd96b4696c1ef67991@syzkaller.appspotmail.com
Fixes: dde3c6b72a16 ("mm/slub: fix a memory leak in sysfs_slab_add()")
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 757fed1d0898b893d7daa84183947c70f27632f3)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I3743749e527dddde63620ac16a0db66c475ac404
2021-01-29 13:15:03 +01:00
Dan Carpenter
364ec3d27d UPSTREAM: futex: Don't enable IRQs unconditionally in put_pi_state()
commit 1e106aa3509b86738769775969822ffc1ec21bf4 upstream.

The exit_pi_state_list() function calls put_pi_state() with IRQs disabled
and is not expecting that IRQs will be enabled inside the function.

Use the _irqsave() variant so that IRQs are restored to the original state
instead of being enabled unconditionally.

Fixes: 153fbd1226 ("futex: Fix more put_pi_state() vs. exit_pi_state_list() races")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20201106085205.GA1159983@mwanda
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 2192d905df)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I10bc011b54ffc6d66c0a499ecebfa5b2d96d58ce
2021-01-29 13:13:00 +01:00
Mike Galbraith
6f8f2dc71c UPSTREAM: futex: Handle transient "ownerless" rtmutex state correctly
commit 9f5d1c336a10c0d24e83e40b4c1b9539f7dba627 upstream.

Gratian managed to trigger the BUG_ON(!newowner) in fixup_pi_state_owner().
This is one possible chain of events leading to this:

Task Prio       Operation
T1   120	lock(F)
T2   120	lock(F)   -> blocks (top waiter)
T3   50 (RT)	lock(F)   -> boosts T1 and blocks (new top waiter)
XX   		timeout/  -> wakes T2
		signal
T1   50		unlock(F) -> wakes T3 (rtmutex->owner == NULL, waiter bit is set)
T2   120	cleanup   -> try_to_take_mutex() fails because T3 is the top waiter
     			     and the lower priority T2 cannot steal the lock.
     			  -> fixup_pi_state_owner() sees newowner == NULL -> BUG_ON()

The comment states that this is invalid and rt_mutex_real_owner() must
return a non NULL owner when the trylock failed, but in case of a queued
and woken up waiter rt_mutex_real_owner() == NULL is a valid transient
state. The higher priority waiter has simply not yet managed to take over
the rtmutex.

The BUG_ON() is therefore wrong and this is just another retry condition in
fixup_pi_state_owner().

Drop the locks, so that T3 can make progress, and then try the fixup again.

Gratian provided a great analysis, traces and a reproducer. The analysis is
to the point, but it confused the hell out of that tglx dude who had to
page in all the futex horrors again. Condensed version is above.

[ tglx: Wrote comment and changelog ]

Fixes: c1e2f0eaf0 ("futex: Avoid violating the 10th rule of futex")
Reported-by: Gratian Crisan <gratian.crisan@ni.com>
Signed-off-by: Mike Galbraith <efault@gmx.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/87a6w6x7bb.fsf@ni.com
Link: https://lore.kernel.org/r/87sg9pkvf7.fsf@nanos.tec.linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 2716e78a64)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I9ab0878641624448cacb1951506b5accb4c92a00
2021-01-29 13:12:13 +01:00
Mateusz Nosek
4fe499637b UPSTREAM: futex: Fix incorrect should_fail_futex() handling
[ Upstream commit 921c7ebd1337d1a46783d7e15a850e12aed2eaa0 ]

If should_futex_fail() returns true in futex_wake_pi(), then the 'ret'
variable is set to -EFAULT and then immediately overwritten. So the failure
injection is non-functional.

Fix it by actually leaving the function and returning -EFAULT.

The Fixes tag is kinda blury because the initial commit which introduced
failure injection was already sloppy, but the below mentioned commit broke
it completely.

[ tglx: Massaged changelog ]

Fixes: 6b4f4bc9cb ("locking/futex: Allow low-level atomic operations to return -EAGAIN")
Signed-off-by: Mateusz Nosek <mateusznosek0@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20200927000858.24219-1-mateusznosek0@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 2db7590371)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I22198b7a65630cb5649f3e889810783b147bfada
2021-01-29 13:12:05 +01:00