Commit Graph

988471 Commits

Author SHA1 Message Date
Ryan Roberts
3de7d142cf BACKPORT: KVM: arm64: Fix bad dereference on MTE-enabled systems
enter_exception64() performs an MTE check, which involves dereferencing
vcpu->kvm. While vcpu has already been fixed up to be a HYP VA pointer,
kvm is still a pointer in the kernel VA space.

This only affects nVHE configurations with MTE enabled, as in other
cases, the pointer is either valid (VHE) or not dereferenced (!MTE).

Fix this by first converting kvm to a HYP VA pointer.

Fixes: ea7fc1bb1c ("KVM: arm64: Introduce MTE VM feature")
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Reviewed-by: Steven Price <steven.price@arm.com>
[maz: commit message tidy-up]
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20221027120945.29679-1-ryan.roberts@arm.com
(cherry picked from commit b6bcdc9f6b)
[willdeacon@: Fixed conflict with aosp/2038249 rework moving MTE feature
 check into caller]
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 233587962
Bug: 233588291
Change-Id: Id0aac0fc38dff2569081910af7468ecf97b6eca3
2022-11-08 13:42:11 +00:00
Carlos Llamas
b684150a44 FROMLIST: binder: fix UAF of alloc->vma in race with munmap()
In commit 720c241924 ("ANDROID: binder: change down_write to
down_read") binder assumed the mmap read lock is sufficient to protect
alloc->vma inside binder_update_page_range(). This used to be accurate
until commit dd2283f260 ("mm: mmap: zap pages with read mmap_sem in
munmap"), which now downgrades the mmap_lock after detaching the vma
from the rbtree in munmap(). Then it proceeds to teardown and free the
vma with only the read lock held.

This means that accesses to alloc->vma in binder_update_page_range() now
will race with vm_area_free() in munmap() and can cause a UAF as shown
in the following KASAN trace:

  ==================================================================
  BUG: KASAN: use-after-free in vm_insert_page+0x7c/0x1f0
  Read of size 8 at addr ffff16204ad00600 by task server/558

  CPU: 3 PID: 558 Comm: server Not tainted 5.10.150-00001-gdc8dcf942daa #1
  Hardware name: linux,dummy-virt (DT)
  Call trace:
   dump_backtrace+0x0/0x2a0
   show_stack+0x18/0x2c
   dump_stack+0xf8/0x164
   print_address_description.constprop.0+0x9c/0x538
   kasan_report+0x120/0x200
   __asan_load8+0xa0/0xc4
   vm_insert_page+0x7c/0x1f0
   binder_update_page_range+0x278/0x50c
   binder_alloc_new_buf+0x3f0/0xba0
   binder_transaction+0x64c/0x3040
   binder_thread_write+0x924/0x2020
   binder_ioctl+0x1610/0x2e5c
   __arm64_sys_ioctl+0xd4/0x120
   el0_svc_common.constprop.0+0xac/0x270
   do_el0_svc+0x38/0xa0
   el0_svc+0x1c/0x2c
   el0_sync_handler+0xe8/0x114
   el0_sync+0x180/0x1c0

  Allocated by task 559:
   kasan_save_stack+0x38/0x6c
   __kasan_kmalloc.constprop.0+0xe4/0xf0
   kasan_slab_alloc+0x18/0x2c
   kmem_cache_alloc+0x1b0/0x2d0
   vm_area_alloc+0x28/0x94
   mmap_region+0x378/0x920
   do_mmap+0x3f0/0x600
   vm_mmap_pgoff+0x150/0x17c
   ksys_mmap_pgoff+0x284/0x2dc
   __arm64_sys_mmap+0x84/0xa4
   el0_svc_common.constprop.0+0xac/0x270
   do_el0_svc+0x38/0xa0
   el0_svc+0x1c/0x2c
   el0_sync_handler+0xe8/0x114
   el0_sync+0x180/0x1c0

  Freed by task 560:
   kasan_save_stack+0x38/0x6c
   kasan_set_track+0x28/0x40
   kasan_set_free_info+0x24/0x4c
   __kasan_slab_free+0x100/0x164
   kasan_slab_free+0x14/0x20
   kmem_cache_free+0xc4/0x34c
   vm_area_free+0x1c/0x2c
   remove_vma+0x7c/0x94
   __do_munmap+0x358/0x710
   __vm_munmap+0xbc/0x130
   __arm64_sys_munmap+0x4c/0x64
   el0_svc_common.constprop.0+0xac/0x270
   do_el0_svc+0x38/0xa0
   el0_svc+0x1c/0x2c
   el0_sync_handler+0xe8/0x114
   el0_sync+0x180/0x1c0

  [...]
  ==================================================================

To prevent the race above, revert back to taking the mmap write lock
inside binder_update_page_range(). One might expect an increase of mmap
lock contention. However, binder already serializes these calls via top
level alloc->mutex. Also, there was no performance impact shown when
running the binder benchmark tests.

Note this patch is specific to stable branches 5.4 and 5.10. Since in
newer kernel releases binder no longer caches a pointer to the vma.
Instead, it has been refactored to use vma_lookup() which avoids the
issue described here. This switch was introduced in commit a43cfc87ca
("android: binder: stop saving a pointer to the VMA").

Bug: 254837884
Link: https://lore.kernel.org/all/20221104175450.306810-1-cmllamas@google.com/
Fixes: dd2283f260 ("mm: mmap: zap pages with read mmap_sem in munmap")
Reported-by: Jann Horn <jannh@google.com>
Cc: <stable@vger.kernel.org> # 5.10.x
Cc: Minchan Kim <minchan@kernel.org>
Cc: Yang Shi <yang.shi@linux.alibaba.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Signed-off-by: Carlos Llamas <cmllamas@google.com>
Change-Id: Ieabadbfa30f99812da9c226cf1ddd5e60f62c607
2022-11-04 18:09:22 +00:00
Minchan Kim
9ffd177dce ANDROID: Update the ABI representation
1 function symbol(s) added
  'int __traceiter_android_vh_shrink_lruvec_blk_plug(void *, bool *)'

1 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_shrink_lruvec_blk_plug'

Bug: 255471591
Bug: 238728493
Change-Id: I8746bbe2f7ccc09e366deed6aa00bc4834643084
Signed-off-by: Minchan Kim <minchan@google.com>
2022-11-03 19:40:25 +00:00
Minchan Kim
89fed37332 ANDROID: vendor hook to control blk_plug for shrink_lruvec
Add vendor hook to contorl blk plugging for shrink_lruvec.

Bug: 255471591
Bug: 238728493
Change-Id: Iba2603ff2e1b62cf2ee8fd6969d8ccd71416a288
Signed-off-by: Minchan Kim <minchan@google.com>
2022-11-03 19:40:25 +00:00
Jann Horn
c0ce22abf7 UPSTREAM: mm: Fix TLB flush for not-first PFNMAP mappings in unmap_region()
This is a stable-specific patch.
I botched the stable-specific rewrite of
commit b67fbebd4c ("mmu_gather: Force tlb-flush VM_PFNMAP vmas"):
As Hugh pointed out, unmap_region() actually operates on a list of VMAs,
and the variable "vma" merely points to the first VMA in that list.
So if we want to check whether any of the VMAs we're operating on is
PFNMAP or MIXEDMAP, we have to iterate through the list and check each VMA.

Bug: 245812080
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 3998dc50eb)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I115183f65fc7df5d33264e6211adcd2ec531d996
2022-11-03 16:42:11 +00:00
Herbert Xu
75c194cf1a UPSTREAM: af_key: Do not call xfrm_probe_algs in parallel
[ Upstream commit ba953a9d89 ]

When namespace support was added to xfrm/afkey, it caused the
previously single-threaded call to xfrm_probe_algs to become
multi-threaded.  This is buggy and needs to be fixed with a mutex.

Bug: 245674737
Reported-by: Abhishek Shah <abhishek.shah@columbia.edu>
Fixes: 283bc9f35b ("xfrm: Namespacify xfrm state/policy locks")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Change-Id: I71fb89a999447862a6c4b1ff754378bb0452ad3a
Signed-off-by: Lee Jones <joneslee@google.com>
2022-11-03 15:26:32 +00:00
Jann Horn
8812ab3f9d UPSTREAM: mm: Force TLB flush for PFNMAP mappings before unlink_file_vma()
commit b67fbebd4c upstream.

Some drivers rely on having all VMAs through which a PFN might be
accessible listed in the rmap for correctness.
However, on X86, it was possible for a VMA with stale TLB entries
to not be listed in the rmap.

This was fixed in mainline with
commit b67fbebd4c ("mmu_gather: Force tlb-flush VM_PFNMAP vmas"),
but that commit relies on preceding refactoring in
commit 18ba064e42 ("mmu_gather: Let there be one tlb_{start,end}_vma()
implementation") and commit 1e9fdf21a4 ("mmu_gather: Remove per arch
tlb_{start,end}_vma()").

This patch provides equivalent protection without needing that
refactoring, by forcing a TLB flush between removing PTEs in
unmap_vmas() and the call to unlink_file_vma() in free_pgtables().

Bug: 245812080
[This is a stable-specific rewrite of the upstream commit!]
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I8f539ff0365fb9b5d10fddb84082d5995348b897
2022-11-03 15:25:08 +00:00
Fuad Tabba
4e97b7ff2b ANDROID: KVM: arm64: Donate memory per vcpu for each vcpu shadow state
Memory donated to the hypervisor needs to be contiguous, which
might be difficult to find. To improve the odds of finding
contiguous memory, break up vcpu state donations per vcpu.

Bug: 232070947
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: Iff19b2e2b6ca58b1e6ef38c4b0f16c80dae34ab9
2022-11-03 02:20:01 +00:00
Fuad Tabba
6a7700c5b5 ANDROID: KVM: arm64: Initialize shadow vcpus with separate hypercalls
This is done as the first step towards donating memory per vcpu
in future patches without having to spend potentially too much
time in one hypercall.

Moreover, this has the nice effect of removing the need for
stashing the host vcpus in the memory donated for the pgd.

Bug: 232070947
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: I491c358fa29dd62ffc45347d6288696c846d5fc3
2022-11-03 02:20:01 +00:00
Fuad Tabba
0b7f3b9652 ANDROID: KVM: arm64: Refactor unpinning host vcpu
Factor out unpinning a single host vcpu from unpin_host_vcpus(),
since it will be used in a future patch in the error path.

No functional change intended.

Bug: 232070947
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: I321e41ae624b2daae8fc917432be0673e32235aa
2022-11-03 02:20:01 +00:00
Fuad Tabba
d345371dd2 ANDROID: KVM: arm64: Separate functions for shadow vm and vcpu init
Facilitates future patches that move the initialization of the
shadow vcpu to a separate hyp call.

Removed unused parameter (vcpu_array/pgd) from
init_shadow_structs().

No functional change intended.

Bug: 232070947
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: I5c3116e7558d958c03ea28dc5610122696a1fca2
2022-11-03 02:20:01 +00:00
Fuad Tabba
66be6be8fb ANDROID: KVM: arm64: Refactor code for reclaiming guest memory into a function
Tidies up code and enables the reuse of this function.

No functional change intended.

Bug: 232070947
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: I3a93dd0284e3c177b12d0cabf5e99747dceb0fb4
2022-11-03 02:20:01 +00:00
Minchan Kim
232bdcbd66 ANDROID: pass argument in zap_pte_range vendor hooks
We need to carry on state from zap_pte_range_tlb_start to
zap_pte_range_tlb_end.

The new param on the function stack will keep the function
trace_android_vh_zap_pte_range_tlb_start called or not and
pass the state to trace_android_vh_zap_pte_range_tlb_end.

Thus, trace_android_vh_zap_pte_range_tlb_end will know
the trace_android_vh_zap_pte_range_tlb_start was called.
If it was called, trace_android_vh_zap_pte_range_tlb_end
will do action to make pair. Otherwise, just skip it.

Bug: 238728493
Bug: 256549265
Change-Id: I95706d51da66f916ede626686483523f3b68dacb
Signed-off-by: Minchan Kim <minchan@google.com>
2022-11-02 15:53:39 +00:00
Kever Yang
a83ef907f0 ANDROID: GKI: Add for rockchip platform basic symbol
52 function symbol(s) added
  'int __clk_mux_determine_rate(struct clk_hw *, struct clk_rate_request *)'
  'int __genphy_config_aneg(struct phy_device *, bool)'
  'int __kfifo_to_user(struct __kfifo *, void *, unsigned long int, unsigned int *)'
  'unsigned int _bcd2bin(unsigned char)'
  'unsigned char _bin2bcd(unsigned int)'
  'void clk_bulk_put(int, struct clk_bulk_data *)'
  'struct clk_hw * clk_hw_register_composite(struct device *, const char *, const char * const *, int, struct clk_hw *, const struct clk_ops *, struct clk_hw *, const struct clk_ops *, struct clk_hw *, const struct clk_ops *, unsigned long int)'
  'struct clk * clk_register_divider_table(struct device *, const char *, const char *, unsigned long int, void *, u8, u8, u8, const struct clk_div_table *, spinlock_t *)'
  'struct clk * clk_register_mux_table(struct device *, const char *, const char * const *, u8, unsigned long int, void *, u8, u32, u8, u32 *, spinlock_t *)'
  'struct opp_table * dev_pm_opp_register_set_opp_helper(struct device *, int(*)(struct dev_pm_set_opp_data *))'
  'struct opp_table * dev_pm_opp_set_prop_name(struct device *, const char *)'
  'void dev_pm_opp_unregister_set_opp_helper(struct opp_table *)'
  'int devfreq_event_disable_edev(struct devfreq_event_dev *)'
  'int devfreq_event_enable_edev(struct devfreq_event_dev *)'
  'struct devfreq_event_dev * devfreq_event_get_edev_by_phandle(struct device *, const char *, int)'
  'int devfreq_event_get_edev_count(struct device *, const char *)'
  'int devfreq_event_get_event(struct devfreq_event_dev *, struct devfreq_event_data *)'
  'struct devfreq_event_dev * devm_devfreq_event_add_edev(struct device *, struct devfreq_event_desc *)'
  'int devm_devfreq_register_opp_notifier(struct device *, struct devfreq *)'
  'int down_write_trylock(struct rw_semaphore *)'
  'int genphy_resume(struct phy_device *)'
  'int genphy_soft_reset(struct phy_device *)'
  'int genphy_suspend(struct phy_device *)'
  's32 i2c_smbus_read_i2c_block_data(const struct i2c_client *, u8, u8, u8 *)'
  's32 i2c_smbus_write_i2c_block_data(const struct i2c_client *, u8, u8, const u8 *)'
  'struct iio_poll_func * iio_alloc_pollfunc(irqreturn_t(*)(int, void *), irqreturn_t(*)(int, void *), int, struct iio_dev *, const char *, ...)'
  'void iio_buffer_init(struct iio_buffer *)'
  'void iio_buffer_put(struct iio_buffer *)'
  'void iio_dealloc_pollfunc(struct iio_poll_func *)'
  'void iio_device_attach_buffer(struct iio_dev *, struct iio_buffer *)'
  's64 iio_get_time_ns(const struct iio_dev *)'
  'int iio_push_to_buffers(struct iio_dev *, void *)'
  'void iio_trigger_notify_done(struct iio_trigger *)'
  'int match_string(const char * const *, size_t, const char *)'
  'int mdiobus_read(struct mii_bus *, int, u32)'
  'int mdiobus_write(struct mii_bus *, int, u32, u16)'
  'unsigned int of_clk_get_parent_count(const struct device_node *)'
  'struct nvmem_cell * of_nvmem_cell_get(struct device_node *, const char *)'
  'int phy_drivers_register(struct phy_driver *, int, struct module *)'
  'void phy_drivers_unregister(struct phy_driver *, int)'
  'int pm_clk_add(struct device *, const char *)'
  'int pm_clk_add_clk(struct device *, struct clk *)'
  'int pm_clk_create(struct device *)'
  'void pm_clk_destroy(struct device *)'
  'int pm_clk_resume(struct device *)'
  'int pm_clk_suspend(struct device *)'
  'unsigned int regulator_get_linear_step(struct regulator *)'
  'int regulator_register_notifier(struct regulator *, struct notifier_block *)'
  'int regulator_unregister_notifier(struct regulator *, struct notifier_block *)'
  'int reset_controller_register(struct reset_controller_dev *)'
  'int scmi_driver_register(struct scmi_driver *, struct module *, const char *)'
  'void scmi_driver_unregister(struct scmi_driver *)'

7 variable symbol(s) added
  'const struct clk_ops clk_divider_ops'
  'const struct clk_ops clk_divider_ro_ops'
  'const struct clk_ops clk_fractional_divider_ops'
  'const struct clk_ops clk_gate_ops'
  'const struct clk_ops clk_mux_ops'
  'const struct clk_ops clk_mux_ro_ops'
  'struct workqueue_struct * system_freezable_wq'

Bug: 239396464
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I568d224fbebb463f44bf73d2dd286823286c106a
Signed-off-by: Giuliano Procida <gprocida@google.com>
2022-11-02 15:52:56 +00:00
Giuliano Procida
05c1e5a6fd ANDROID: GKI: Add Bazel rockchip symbol list entry
Bug: 239396464
Fixes: 788ba5e9de ("ANDROID: GKI: Add build for rockchip platform")
Change-Id: Ided3414a57a745e18b253bd4f5fb34b0738e364e
Signed-off-by: Giuliano Procida <gprocida@google.com>
2022-11-02 15:52:56 +00:00
Peter Collingbourne
56e639d3ff ANDROID: sched: check on_rq in freezer_should_skip()
In aosp/1979327 we attempted to prevent tasks with pending signals and
PF_FREEZER_SKIP from being immediately rescheduled, because such tasks
would crash the kernel if run while no capable CPUs were online. This was
implemented by declining to immediately reschedule them unless various
conditions were met. However, this ended up causing signals to fail to
be delivered if the signal was received while a task is processing a
syscall, such as futex(2), that will block with PF_FREEZER_SKIP set,
as the kernel relies on a check for TIF_SIGPENDING after setting the
task state to TASK_INTERRUPTIBLE in order to deliver such a signal.

This patch is an alternative solution to the original problem that
avoids introducing the signal delivery bug. It works by changing
how freezer_should_skip() is implemented. Instead of just checking
PF_FREEZER_SKIP, we also use the on_rq field to check whether the task
is not on a runqueue. In this way we ensure that a task that will be
immediately rescheduled will not return true from freezer_should_skip(),
and the task will block the freezer unless it is actually taken off
the runqueue.

Signed-off-by: Peter Collingbourne <pcc@google.com>
Bug: 202918514
Bug: 251700836
Change-Id: I3f9b705ce9ad2ca1d2df959f43cf05bef78560f8
2022-11-01 19:26:12 -07:00
Ziyi Cui
90a47b6250 ANDROID: Update the ABI representation
4 function symbol(s) added
  'int __traceiter_irq_handler_entry(void *, int, struct irqaction *)'
  'int __traceiter_irq_handler_exit(void *, int, struct irqaction *, int)'
  'int __traceiter_softirq_entry(void *, unsigned int)'
  'int __traceiter_softirq_exit(void *, unsigned int)'

4 variable symbol(s) added
  'struct tracepoint __tracepoint_irq_handler_entry'
  'struct tracepoint __tracepoint_irq_handler_exit'
  'struct tracepoint __tracepoint_softirq_entry'
  'struct tracepoint __tracepoint_softirq_exit'

Bug: 227809911
Signed-off-by: Ziyi Cui <ziyic@google.com>
Change-Id: I1ec50c7785362cce699327d59ff34c4d46a53c41
2022-11-01 12:59:14 -07:00
Fuad Tabba
14c8176992 ANDROID: KVM: arm64: Only unpin a vCPU SVE state if set
This avoid unpinning NULL state.

Bug: 256125458
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: I9d346e0705a69b69704fd30ab09635548763229e
2022-11-01 11:19:53 +00:00
Chungkai Mei
559e6700c3 ANDROID: Update the ABI representation
2 function symbol(s) added
  'int __traceiter_android_vh_binder_restore_priority(void *, struct binder_transaction *, struct task_struct *)'
  'int __traceiter_android_vh_binder_set_priority(void *, struct binder_transaction *, struct task_struct *)'

2 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_binder_restore_priority'
  'struct tracepoint __tracepoint_android_vh_binder_set_priority'

Bug: 226003124
Change-Id: I4129848ba6537d398cc7a2aab5960c65b280b9a4
Signed-off-by: Chungkai Mei <chungkai@google.com>
2022-10-31 18:36:00 +00:00
Jaegeuk Kim
9966a706d1 FROMGIT: f2fs: let's avoid to get cp_rwsem twice by f2fs_evict_inode by d_invalidate
f2fs_unlink
 -> f2fs_lock_op
 -> d_invalidate
  -> shrink_dentry_list
   -> iput_final
    -> f2fs_evict_inode
     -> f2fs_lock_op

Bug: 253968159
Reviewed-by: Chao Yu <chao@kernel.org>
Tested-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Change-Id: I281afd7ffa0c66509ec5984fd7774ccd4ddef1f4
(cherry picked from commit 14dc00a0e2 git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev)
2022-10-28 23:47:25 +00:00
Minchan Kim
86d2835139 ANDROID: Update the ABI representation
3 function symbol(s) added
  'int __traceiter_android_vh_do_madvise_blk_plug(void *, int, bool *)'
  'int __traceiter_android_vh_reclaim_pages_plug(void *, bool *)'
  'int __traceiter_android_vh_shrink_inactive_list_blk_plug(void *, bool *)'

3 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_do_madvise_blk_plug'
  'struct tracepoint __tracepoint_android_vh_reclaim_pages_plug'
  'struct tracepoint __tracepoint_android_vh_shrink_inactive_list_blk_plug'

Bug: 255471591
Change-Id: I4021425fea85fead6c2e85b057b33efeccbf2f6f
Signed-off-by: Minchan Kim <minchan@google.com>
2022-10-28 04:17:39 +00:00
Minchan Kim
a17e132ec4 ANDROID: vendor hook to control blk_plug for memory reclaim
Add vendor hook to contorl blk plugging.

Bug: 255471591
Bug: 238728493
Change-Id: I96b73cec14f0d2fea46a4828526e6ae5aa5c71b7
Signed-off-by: Minchan Kim <minchan@google.com>
2022-10-28 04:16:44 +00:00
Rick Yiu
1c741865f4 ANDROID: Update the ABI representation
5 function symbol(s) added
  'int __traceiter_android_rvh_prepare_prio_fork(void *, struct task_struct *)'
  'int __traceiter_android_rvh_set_user_nice(void *, struct task_struct *, long int *, bool *)'
  'int __traceiter_android_rvh_setscheduler(void *, struct task_struct *)'
  'void check_preempt_curr(struct rq *, struct task_struct *, int)'
  'void resched_curr(struct rq *)'

3 variable symbol(s) added
  'struct tracepoint __tracepoint_android_rvh_prepare_prio_fork'
  'struct tracepoint __tracepoint_android_rvh_set_user_nice'
  'struct tracepoint __tracepoint_android_rvh_setscheduler'

Bug: 245675204
Signed-off-by: Rick Yiu <rickyiu@google.com>
Change-Id: Ic17fa9f74255dc887ccd650c73aea42d217d0b06
2022-10-27 19:43:11 +00:00
Johannes Berg
6c543641c6 UPSTREAM: wifi: mac80211: fix MBSSID parsing use-after-free
Commit ff05d4b45d upstream.
This is a different version of the commit, changed to store
the non-transmitted profile in the elems, and freeing it in
the few places where it's relevant, since that is only the
case when the last argument for parsing (the non-tx BSSID)
is non-NULL.

When we parse a multi-BSSID element, we might point some
element pointers into the allocated nontransmitted_profile.
However, we free this before returning, causing UAF when the
relevant pointers in the parsed elements are accessed.

Fix this by not allocating the scratch buffer separately but
as part of the returned structure instead, that way, there
are no lifetime issues with it.

The scratch buffer introduction as part of the returned data
here is taken from MLO feature work done by Ilan.

This fixes CVE-2022-42719.

Bug: 253642087
Fixes: 5023b14cf4 ("mac80211: support profile split between elements")
Co-developed-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I68b07f5850a7ef363d631043d01f58a08aea9274
2022-10-25 11:57:57 +01:00
Johannes Berg
187e6dad2a UPSTREAM: wifi: mac80211: don't parse mbssid in assoc response
This is simply not valid and simplifies the next commit.
I'll make a separate patch for this in the current main
tree as well.

Bug: 254180332
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
(cherry picked from commit 353b5c8d4b)
Change-Id: Ie554c036923c94b125035141a3bffafc129a5aa6
2022-10-25 11:57:51 +01:00
Johannes Berg
12bd079b61 UPSTREAM: mac80211: mlme: find auth challenge directly
There's no need to parse all elements etc. just to find the
authentication challenge - use cfg80211_find_elem() instead.
This also allows us to remove WLAN_EID_CHALLENGE handling
from the element parsing entirely.

Bug: 254180332
Link: https://lore.kernel.org/r/20210920154009.45f9b3a15722.Ice3159ffad03a007d6154cbf1fb3a8c48489e86f@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
(cherry picked from commit 66dacdbc2e)
Change-Id: Ife49cbad96bb43064449d93b8f8ada9db24be540
2022-10-25 11:57:43 +01:00
Johannes Berg
13c3ed22fe UPSTREAM: wifi: cfg80211: update hidden BSSes to avoid WARN_ON
commit c90b93b5b7 upstream.

When updating beacon elements in a non-transmitted BSS,
also update the hidden sub-entries to the same beacon
elements, so that a future update through other paths
won't trigger a WARN_ON().

The warning is triggered because the beacon elements in
the hidden BSSes that are children of the BSS should
always be the same as in the parent.

Bug: 254180332
Reported-by: Sönke Huster <shuster@seemoo.tu-darmstadt.de>
Tested-by: Sönke Huster <shuster@seemoo.tu-darmstadt.de>
Fixes: 0b8fb8235b ("cfg80211: Parsing of Multiple BSSID information in scanning")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Iea4669ba97b926dfa67e9592b3a263d3f18508e5
2022-10-24 16:51:23 +01:00
Johannes Berg
4bff45998e UPSTREAM: wifi: mac80211: fix crash in beacon protection for P2P-device
commit b2d03cabe2 upstream.

If beacon protection is active but the beacon cannot be
decrypted or is otherwise malformed, we call the cfg80211
API to report this to userspace, but that uses a netdev
pointer, which isn't present for P2P-Device. Fix this to
call it only conditionally to ensure cfg80211 won't crash
in the case of P2P-Device.

This fixes CVE-2022-42722.

Bug: 253642089
Reported-by: Sönke Huster <shuster@seemoo.tu-darmstadt.de>
Fixes: 9eaf183af7 ("mac80211: Report beacon protection failures to user space")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Ie3336b950136e26debbe835f97ad450d03f6baad
2022-10-24 16:51:22 +01:00
Johannes Berg
7e9ccb517a UPSTREAM: wifi: mac80211_hwsim: avoid mac80211 warning on bad rate
commit 1833b6f46d upstream.

If the tool on the other side (e.g. wmediumd) gets confused
about the rate, we hit a warning in mac80211. Silence that
by effectively duplicating the check here and dropping the
frame silently (in mac80211 it's dropped with the warning).

Bug: 254180332
Reported-by: Sönke Huster <shuster@seemoo.tu-darmstadt.de>
Tested-by: Sönke Huster <shuster@seemoo.tu-darmstadt.de>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Ieb3a258b998aca815efc5d09492ce66e461b5b88
2022-10-24 16:51:22 +01:00
Johannes Berg
88b3da7668 UPSTREAM: wifi: cfg80211: avoid nontransmitted BSS list corruption
commit bcca852027 upstream.

If a non-transmitted BSS shares enough information (both
SSID and BSSID!) with another non-transmitted BSS of a
different AP, then we can find and update it, and then
try to add it to the non-transmitted BSS list. We do a
search for it on the transmitted BSS, but if it's not
there (but belongs to another transmitted BSS), the list
gets corrupted.

Since this is an erroneous situation, simply fail the
list insertion in this case and free the non-transmitted
BSS.

This fixes CVE-2022-42721.

Bug: 253642088
Reported-by: Sönke Huster <shuster@seemoo.tu-darmstadt.de>
Tested-by: Sönke Huster <shuster@seemoo.tu-darmstadt.de>
Fixes: 0b8fb8235b ("cfg80211: Parsing of Multiple BSSID information in scanning")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: If83261f8b711f5ad0ce922abea2c35fedbc36c39
2022-10-24 16:51:22 +01:00
Johannes Berg
1e18328c84 UPSTREAM: wifi: cfg80211: fix BSS refcounting bugs
commit 0b7808818c upstream.

There are multiple refcounting bugs related to multi-BSSID:
 - In bss_ref_get(), if the BSS has a hidden_beacon_bss, then
   the bss pointer is overwritten before checking for the
   transmitted BSS, which is clearly wrong. Fix this by using
   the bss_from_pub() macro.

 - In cfg80211_bss_update() we copy the transmitted_bss pointer
   from tmp into new, but then if we release new, we'll unref
   it erroneously. We already set the pointer and ref it, but
   need to NULL it since it was copied from the tmp data.

 - In cfg80211_inform_single_bss_data(), if adding to the non-
   transmitted list fails, we unlink the BSS and yet still we
   return it, but this results in returning an entry without
   a reference. We shouldn't return it anyway if it was broken
   enough to not get added there.

This fixes CVE-2022-42720.

Bug: 253642015
Reported-by: Sönke Huster <shuster@seemoo.tu-darmstadt.de>
Tested-by: Sönke Huster <shuster@seemoo.tu-darmstadt.de>
Fixes: a3584f56de ("cfg80211: Properly track transmitting and non-transmitting BSS")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I408bf72ca59b6ffbe2aba460f3e9326bf1c94eec
2022-10-24 16:51:19 +01:00
Johannes Berg
d56839bb09 UPSTREAM: wifi: cfg80211: ensure length byte is present before access
commit 567e14e39e upstream.

When iterating the elements here, ensure the length byte is
present before checking it to see if the entire element will
fit into the buffer.

Longer term, we should rewrite this code using the type-safe
element iteration macros that check all of this.

Bug: 254180332
Fixes: 0b8fb8235b ("cfg80211: Parsing of Multiple BSSID information in scanning")
Reported-by: Soenke Huster <shuster@seemoo.tu-darmstadt.de>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I6ece37c57ca56462566adbcac6def6b35dc5b799
2022-10-24 16:48:42 +01:00
Johannes Berg
d96c2b5944 UPSTREAM: wifi: cfg80211/mac80211: reject bad MBSSID elements
commit 8f033d2bec upstream.

Per spec, the maximum value for the MaxBSSID ('n') indicator is 8,
and the minimum is 1 since a multiple BSSID set with just one BSSID
doesn't make sense (the # of BSSIDs is limited by 2^n).

Limit this in the parsing in both cfg80211 and mac80211, rejecting
any elements with an invalid value.

This fixes potentially bad shifts in the processing of these inside
the cfg80211_gen_new_bssid() function later.

I found this during the investigation of CVE-2022-41674 fixed by the
previous patch.

Bug: 253641805
Fixes: 0b8fb8235b ("cfg80211: Parsing of Multiple BSSID information in scanning")
Fixes: 78ac51f815 ("mac80211: support multi-bssid")
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I7aa0b1a425fcf3a7797e83afa8ad6dd68b283b48
2022-10-24 16:48:42 +01:00
Johannes Berg
4ae8e2c20f UPSTREAM: wifi: cfg80211: fix u8 overflow in cfg80211_update_notlisted_nontrans()
commit aebe9f4639 upstream.

In the copy code of the elements, we do the following calculation
to reach the end of the MBSSID element:

	/* copy the IEs after MBSSID */
	cpy_len = mbssid[1] + 2;

This looks fine, however, cpy_len is a u8, the same as mbssid[1],
so the addition of two can overflow. In this case the subsequent
memcpy() will overflow the allocated buffer, since it copies 256
bytes too much due to the way the allocation and memcpy() sizes
are calculated.

Fix this by using size_t for the cpy_len variable.

This fixes CVE-2022-41674.

Bug: 253641805
Reported-by: Soenke Huster <shuster@seemoo.tu-darmstadt.de>
Tested-by: Soenke Huster <shuster@seemoo.tu-darmstadt.de>
Fixes: 0b8fb8235b ("cfg80211: Parsing of Multiple BSSID information in scanning")
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I70d3a1188609751797cbabe905028d92d1700f17
2022-10-24 16:48:42 +01:00
Minchan Kim
6e0df30312 ANDROID: Update the ABI representation
2 function symbol(s) added
  'int __traceiter_android_vh_bh_lru_install(void *, struct page *, bool *)'
  'int __traceiter_android_vh_skip_lru_disable(void *, bool *)'

2 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_bh_lru_install'
  'struct tracepoint __tracepoint_android_vh_skip_lru_disable'

Bug: 238728493
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I8969b67398496e69a816ad8cd5af081e2e90dbff
2022-10-21 09:49:34 -07:00
Minchan Kim
74e2ea264c ANDROID: vendor hook to control bh_lru and lru_cache_disable
Add vendor hook for bh_lru and lru_cache_disable

Bug: 238728493
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I81bfad317cf6e8633186ebb3238644306d7a102d
2022-10-21 09:18:15 -07:00
Minchan Kim
f45d10e83b ANDROID: Update the ABI representation
3 function symbol(s) added
  'int __traceiter_android_vh_zap_pte_range_tlb_end(void *, void *)'
  'int __traceiter_android_vh_zap_pte_range_tlb_force_flush(void *, struct page *, bool *)'
  'int __traceiter_android_vh_zap_pte_range_tlb_start(void *, void *)'

3 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_zap_pte_range_tlb_end'
  'struct tracepoint __tracepoint_android_vh_zap_pte_range_tlb_force_flush'
  'struct tracepoint __tracepoint_android_vh_zap_pte_range_tlb_start'

Bug: 238728493
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: Ic05e935faca01f8241af395726145966237708b4
2022-10-20 16:04:14 +00:00
Minchan Kim
d257ef6764 ANDROID: vendor hook for TLB batching control
Add vendor hook for flushing TLB batching in zap_pte_range.

Bug: 238728493
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: If2de5f070dd7b76624961f5a91440bf69a99ca2d
2022-10-20 16:04:14 +00:00
Helge Deller
2823b3889d UPSTREAM: fbcon: Prevent that screen size is smaller than font size
commit e64242caef upstream.

We need to prevent that users configure a screen size which is smaller than the
currently selected font size. Otherwise rendering chars on the screen will
access memory outside the graphics memory region.

This patch adds a new function fbcon_modechange_possible() which
implements this check and which later may be extended with other checks
if necessary.  The new function is called from the FBIOPUT_VSCREENINFO
ioctl handler in fbmem.c, which will return -EINVAL if userspace asked
for a too small screen size.

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: stable@vger.kernel.org # v5.4+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: b81212828a
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: I6ac4cce2aeea4dcca222ea2b395cc2baa1008894
2022-10-19 18:49:37 +00:00
Helge Deller
739b963eb8 UPSTREAM: fbcon: Disallow setting font bigger than screen size
commit 65a01e601d upstream.

Prevent that users set a font size which is bigger than the physical screen.
It's unlikely this may happen (because screens are usually much larger than the
fonts and each font char is limited to 32x32 pixels), but it may happen on
smaller screens/LCD displays.

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: stable@vger.kernel.org # v4.14+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: b81212828a
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: I47e139779ab835a16d0b6b060e798ad35cad9f9b
2022-10-19 18:49:37 +00:00
Helge Deller
cf3742cba4 UPSTREAM: fbmem: Check virtual screen sizes in fb_set_var()
commit 6c11df58fd upstream.

Verify that the fbdev or drm driver correctly adjusted the virtual
screen sizes. On failure report the failing driver and reject the screen
size change.

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: stable@vger.kernel.org # v5.4+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: b81212828a
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: Ia1a16bfbda7f62f1707a5a54ba774a058698a4e3
2022-10-19 18:49:37 +00:00
Kever Yang
788ba5e9de ANDROID: GKI: Add build for rockchip platform
This patch add build entry for rockchip platform

Bug: 239396464
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Change-Id: I12a8619505ece318d3c890ab1253798f88780a9e
2022-10-19 16:30:31 +00:00
Minchan Kim
90db4c38b9 ANDROID: Update the ABI representation
1 function symbol(s) added
  'int __traceiter_android_vh_pagevec_drain(void *, struct page *, bool *)'

1 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_pagevec_drain'

Bug: 251881967
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I8a45e6aba2fbbc6a05ec7086f4ce009c57fe15ff
2022-10-18 15:03:17 -07:00
Minchan Kim
2f8253b7e6 ANDROID: vendor hook to control pagevec flush
The pagevec batching causes lru_add_drain_all which is too expensive
sometimes. This patch adds a new vendor hook to drain the pagevec
immediately depending on the page's type.

Bug: 251881967
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: Id17e14e69197993ddad511a40c96e51674c02834
2022-10-18 15:02:45 -07:00
David Brazdil
992b5f98ca ANDROID: KVM: arm64: s2mpu: Add SysMMU_SYNC timeout
The SysMMU_SYNC provides an invalidation-complete signal to the
hypervisor. Currently the hypervisor will wait indefinitely for the SYNC
to set the SYNC_COMP_COMPLETE bit. In practice, this case deadlock as
the hypervisor holds the host lock while waiting for the SYNC.

To avoid deadlock, adjust the algorithm to time out after a given number
of reads of the SYNC_COMP register (new constant SYNC_TIMEOUT_BASE).
This can be a small number as most attempts succeed after a single read
of the SFR.

If the wait-loop times out, the hypervisor will try again, multiplying
the maximum number of SFR reads with SYNC_TIMEOUT_MULTIPLIER each time.
This number was selected to grow quickly, in case there is a lot of DMA
traffic that would be slowing down the SYNC request.

Finally, if the hardware does not set the bit even after
SYNC_MAX_RETRIES, the algorithm will give up to avoid deadlock. The
value was selected so that the worst-case time spent in
__wait_for_invalidation_complete() remains tolerable.

Bug: 250727777
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I00098753bcc46a894943bbdb3a61acc3a8e5e5d2
2022-10-17 10:00:03 +00:00
Quentin Perret
19424168db ANDROID: KVM: arm64: Force CMOs with FWB when reclaiming guest pages
__clean_dcache_guest_page() is optimized to elide cache maintenance
operations on CPUs with FWB. The underlying assumption is that FWB is
always used by KVM when available. Although correct in the normal KVM
world, pKVM actively disables FWB for the host stage-2. As such,
omitting CMOs when guest memory is being reclaimed may provide a
malicious host with the ability to read the content of the recently
reclaimed pages.

Fix this by using the lower level kvm_flush_dcache_to_poc() helper
directly from the reclaim path.

Bug: 243501419
Reported-by: Will Deacon <willdeacon@google.com>
Signed-off-by: Quentin Perret <qperret@google.com>
Change-Id: I8e96ef7a8ccab2a59d3df46cd4d1a73190a2f457
2022-10-14 18:30:15 +00:00
Quentin Perret
f177a280b1 ANDROID: KVM: arm64: Fix MMIO guard map error handling
Pierre-Clément reports that the error codes returned by the MMIO guard
map hypercall may end up being incorrectly reported as positive to
callers who interpret them a signed 64-bit integers, as specified in the
SMCCC.

Fix this by storing the return value in a 64-bit variable instead.

Bug: 253586500
Reported-by: Pierre-Clément Tosi <ptosi@google.com>
Signed-off-by: Quentin Perret <qperret@google.com>
Change-Id: I3092856ec1a1fd1648a75c9e4ad4bfebd8830d14
2022-10-14 13:42:37 +00:00
Johannes Weiner
32bef95f91 UPSTREAM: psi: Fix psi state corruption when schedule() races with cgroup move
4117cebf1a ("psi: Optimize task switch inside shared cgroups")
introduced a race condition that corrupts internal psi state. This
manifests as kernel warnings, sometimes followed by bogusly high IO
pressure:

  psi: task underflow! cpu=1 t=2 tasks=[0 0 0 0] clear=c set=0
  (schedule() decreasing RUNNING and ONCPU, both of which are 0)

  psi: incosistent task state! task=2412744:systemd cpu=17 psi_flags=e clear=3 set=0
  (cgroup_move_task() clearing MEMSTALL and IOWAIT, but task is MEMSTALL | RUNNING | ONCPU)

What the offending commit does is batch the two psi callbacks in
schedule() to reduce the number of cgroup tree updates. When prev is
deactivated and removed from the runqueue, nothing is done in psi at
first; when the task switch completes, TSK_RUNNING and TSK_IOWAIT are
updated along with TSK_ONCPU.

However, the deactivation and the task switch inside schedule() aren't
atomic: pick_next_task() may drop the rq lock for load balancing. When
this happens, cgroup_move_task() can run after the task has been
physically dequeued, but the psi updates are still pending. Since it
looks at the task's scheduler state, it doesn't move everything to the
new cgroup that the task switch that follows is about to clear from
it. cgroup_move_task() will leak the TSK_RUNNING count in the old
cgroup, and psi_sched_switch() will underflow it in the new cgroup.

A similar thing can happen for iowait. TSK_IOWAIT is usually set when
a p->in_iowait task is dequeued, but again this update is deferred to
the switch. cgroup_move_task() can see an unqueued p->in_iowait task
and move a non-existent TSK_IOWAIT. This results in the inconsistent
task state warning, as well as a counter underflow that will result in
permanent IO ghost pressure being reported.

Fix this bug by making cgroup_move_task() use task->psi_flags instead
of looking at the potentially mismatching scheduler state.

[ We used the scheduler state historically in order to not rely on
  task->psi_flags for anything but debugging. But that ship has sailed
  anyway, and this is simpler and more robust.

  We previously already batched TSK_ONCPU clearing with the
  TSK_RUNNING update inside the deactivation call from schedule(). But
  that ordering was safe and didn't result in TSK_ONCPU corruption:
  unlike most places in the scheduler, cgroup_move_task() only checked
  task_current() and handled TSK_ONCPU if the task was still queued. ]

bug: b/253347377

Fixes: 4117cebf1a ("psi: Optimize task switch inside shared cgroups")
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20210503174917.38579-1-hannes@cmpxchg.org
(cherry picked from commit d583d360a6)
Change-Id: Id0a292058d4bffb716d8e1496f72139e8d435410
2022-10-13 17:59:37 +00:00
Pat Tjin
e4c738dd13 ANDROID: Update the ABI representation
4 function symbol(s) added
  'int __hid_register_driver(struct hid_driver *, struct module *, const char *)'
  'int hid_hw_start(struct hid_device *, unsigned int)'
  'int hid_open_report(struct hid_device *)'
  'void hid_unregister_driver(struct hid_driver *)'

Bug: 246795245
Signed-off-by: Pat Tjin <pattjin@google.com>
Change-Id: Ic9a4187a7215e5678b8196fad4d4350802d77a10
2022-10-12 19:01:24 +00:00
Lee Jones
07e046b996 BACKPORT: HID: steam: Prevent NULL pointer dereference in steam_{recv,send}_report
commit cd11d1a611 upstream.

It is possible for a malicious device to forgo submitting a Feature
Report.  The HID Steam driver presently makes no prevision for this
and de-references the 'struct hid_report' pointer obtained from the
HID devices without first checking its validity.  Let's change that.

Bug: 223455965
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: linux-input@vger.kernel.org
Fixes: c164d6abf3 ("HID: add driver for Valve Steam Controller")
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Ica12507b87309a7c46b4cab6fcfe4499cd96f45d
2022-10-11 11:25:48 +01:00