Commit Graph

993463 Commits

Author SHA1 Message Date
Prashanth K 87a065fb94 UPSTREAM: usb: dwc3: gadget: Change condition for processing suspend event
Currently we process the suspend interrupt event only if the
device is in configured state. Consider a case where device
is not configured and got suspend interrupt, in that case our
gadget will still use 100mA as composite_suspend didn't happen.
But battery charging specification (BC1.2) expects a downstream
device to draw less than 2.5mA when unconnected OR suspended.

Fix this by removing the condition for processing suspend event,
and thus composite_resume would set vbus draw to 2.

Fixes: 72704f876f ("dwc3: gadget: Implement the suspend entry event handler")
Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://lore.kernel.org/r/1677217619-10261-2-git-send-email-quic_prashk@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 272680990
(cherry picked from commit 4decf4060e
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/ usb-next)

Change-Id: I902b8911debb7c049a4a0128077ea8d931900d1d
Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
2023-03-10 19:28:53 +00:00
fengqi 26638f8e54 ANDROID: GKI: update xiaomi symbol list
Leaf changes summary: 4 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 4 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

4 Added functions:

  [A] 'function int __iio_trigger_register(iio_trigger*, module*)'
  [A] 'function iio_trigger* iio_trigger_alloc(const char*, ...)'
  [A] 'function void iio_trigger_free(iio_trigger*)'
  [A] 'function void iio_trigger_unregister(iio_trigger*)'

Bug: 272669403

Change-Id: Ieb112f091b22e9893e627e0f934c45bd1ca940b2
Signed-off-by: fengqi <fengqi@xiaomi.com>
2023-03-10 17:32:30 +08:00
Pedro Tammela 193b312b2f UPSTREAM: net/sched: tcindex: update imperfect hash filters respecting rcu
commit ee059170b1 upstream.

The imperfect hash area can be updated while packets are traversing,
which will cause a use-after-free when 'tcf_exts_exec()' is called
with the destroyed tcf_ext.

CPU 0:               CPU 1:
tcindex_set_parms    tcindex_classify
tcindex_lookup
                     tcindex_lookup
tcf_exts_change
                     tcf_exts_exec [UAF]

Stop operating on the shared area directly, by using a local copy,
and update the filter with 'rcu_replace_pointer()'. Delete the old
filter version only after a rcu grace period elapsed.

Bug: 272274675
Fixes: 9b0d4446b5 ("net: sched: avoid atomic swap in tcf_exts_change")
Reported-by: valis <sec@valis.email>
Suggested-by: valis <sec@valis.email>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
Link: https://lore.kernel.org/r/20230209143739.279867-1-pctammela@mojatatu.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I02ce525a338242efdb8080e2e2c705d3b59d9a68
2023-03-09 11:27:04 +00:00
Elliot Berman 9a1be9a472 FROMGIT: KVM: arm64: Ignore kvm-arm.mode if !is_hyp_mode_available()
Ignore kvm-arm.mode if !is_hyp_mode_available(). Specifically, we want
to avoid switching kvm_mode to KVM_MODE_PROTECTED if hypervisor mode is
not available. This prevents "Protected KVM" cpu capability being
reported when Linux is booting in EL1 and would not have KVM enabled.
Reasonably though, we should warn if the command line is requesting a
KVM mode at all if KVM isn't actually available. Allow
"kvm-arm.mode=none" to skip the warning since this would disable KVM
anyway.

Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20220920190658.2880184-1-quic_eberman@quicinc.com

Bug: 249052880
(cherry picked from commit b2a4d007c3
 https://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Change-Id: I196649fc00537e563a1fab0a22bf23c5b7abe00d
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
(cherry picked from commit 8015dd49c00e036b214801b34a727b7c98aa84e3)
2023-03-07 19:28:52 +00:00
Marc Zyngier dbcd8cb535 UPSTREAM: KVM: arm64: Allow KVM to be disabled from the command line
Although KVM can be compiled out of the kernel, it cannot be disabled
at runtime. Allow this possibility by introducing a new mode that
will prevent KVM from initialising.

This is useful in the (limited) circumstances where you don't want
KVM to be available (what is wrong with you?), or when you want
to install another hypervisor instead (good luck with that).

Reviewed-by: David Brazdil <dbrazdil@google.com>
Acked-by: Will Deacon <will@kernel.org>
Acked-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Andrew Scull <ascull@google.com>
Link: https://lore.kernel.org/r/20211001170553.3062988-1-maz@kernel.org
(cherry picked from commit b6a68b97af)
Bug: 204960018
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: Ie796c716fc7cece906a8cded0ae4652a828988bb
(cherry picked from commit a621a4e6cb1e249d165f643d511c887c7fc4cdc7)
2023-03-07 19:28:52 +00:00
Ram Muthiah 631630d75f ANDROID: ABI: Cuttlefish Symbol update
The cuttlefish symbol list is out of date. Updating it with
the following steps.

$ BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh
$ BUILD_CONFIG=common-modules/virtual-\
device/build.config.cuttlefish.aarch64 build/build.sh
$ build/abi/extract_symbols out/android12-5.10/dist/ --whitelist \
    common/android/abi_gki_aarch64_virtual_device --additions-only
$ BUILD_CONFIG=common/build.config.gki.aarch64 build/build_abi.sh \
    --update --print-report

Bug: 203806616
Test: Local boot on cuttlefish arm64 android11-gsi
Change-Id: I48fbc598e5a3e4ac8db68c51d699922099da7de8
Signed-off-by: Ram Muthiah <rammuthiah@google.com>
2023-03-07 16:12:59 +00:00
Greg Kroah-Hartman 278dfb09d7 Revert "ANDROID: dma-ops: Add restricted vendor hook"
This reverts commit 9d2ec2e0b6.

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

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

Bug: 263236925
Bug: 203756332
Cc: Beata Michalska <beata.michalska@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I7741910039ac9914e2e2adf974204278d37db94d
2023-03-07 11:26:48 +00:00
Jens Axboe c2e3f757d3 UPSTREAM: io_uring: ensure that io_init_req() passes in the right issue_flags
We can't use 0 here, as io_init_req() is always invoked with the
ctx uring_lock held. Newer kernels have IO_URING_F_UNLOCKED for this,
but previously we used IO_URING_F_NONBLOCK to indicate this as well.

Fixes: 08681391b8 ("io_uring: add missing lock in io_get_file_fixed")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit da24142b1e)
Bug: 268174392
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I762eacf1b49ca8a38d8b77c44db4ca2bc49b2c4c
2023-03-06 18:39:19 +00:00
Udipto Goswami 9abdacf47f FROMGIT: usb: gadget: configfs: Restrict symlink creation is UDC already binded
During enumeration or composition switch,a userspace process
agnostic of the conventions of configs can try to create function
symlinks even after the UDC is bound to current config which is
not correct. Potentially it can create duplicates within the
current config.

Prevent this by adding a check if udc_name already exists, then bail
out of cfg_link.

Following is an example:

Step1:
ln -s X1 ffs.a
-->cfg_link
--> usb_get_function(ffs.a)
	->ffs_alloc

	CFG->FUNC_LIST: <ffs.a>
	C->FUNCTION: <empty>

Step2:
echo udc.name > /config/usb_gadget/g1/UDC
--> UDC_store
	->composite_bind
	->usb_add_function

	CFG->FUNC_LIST: <empty>
	C->FUNCTION: <ffs.a>

Step3:
ln -s Y1 ffs.a
-->cfg_link
-->usb_get_function(ffs.a)
	->ffs_alloc

	CFG->FUNC_LIST: <ffs.a>
	C->FUNCTION: <ffs.a>

both the lists corresponds to the same function instance ffs.a
but the usb_function* pointer is different because in step 3
ffs_alloc has created a new reference to usb_function* for
ffs.a and added it to cfg_list.

Step4:
Now a composition switch involving <ffs.b,ffs.a> is executed.

the composition switch will involve 3 things:
	1. unlinking the previous functions existing
	2. creating new symlinks
	3. writing UDC

However, the composition switch is generally taken care by
userspace process which creates the symlinks in its own
nomenclature(X*) and removes only those.
So it won't be able to remove Y1 which user had created
by own.

Due to this the new symlinks cannot be created for ffs.a
since the entry already exists in CFG->FUNC_LIST.

The state of the CFG->FUNC_LIST is as follows:
	CFG->FUNC_LIST: <ffs.a>

Fixes: 88af8bbe4e ("usb: gadget: the start of the configfs interface")
Signed-off-by: Krishna Kurapati PSSNV <quic_kriskura@quicinc.com>
Signed-off-by: Udipto Goswami <quic_ugoswami@quicinc.com>
Link: https://lore.kernel.org/r/20230201132308.31523-1-quic_ugoswami@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

BUG: 267715065
(cherry picked from commit 89e7252d6c usb-next)

Change-Id: I0f21c75ce0929756efacd0035ae21085ab9742f2
Signed-off-by: Udipto Goswami <quic_ugoswami@quicinc.com>
2023-03-04 05:52:52 +00:00
Bing-Jhong Billy Jheng d415c6e56f UPSTREAM: io_uring: add missing lock in io_get_file_fixed
io_get_file_fixed will access io_uring's context. Lock it if it is
invoked unlocked (eg via io-wq) to avoid a race condition with fixed
files getting unregistered.

No single upstream patch exists for this issue, it was fixed as part
of the file assignment changes that went into the 5.18 cycle.

Signed-off-by: Jheng, Bing-Jhong Billy <billy@starlabs.sg>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 08681391b8)
Bug: 268174392
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I01ec4283589acde1d17318eb76f87ce099ec3fa0
2023-03-03 11:13:02 +00:00
Liujie Xie 52cc662810 ANDROID: ABI: Update oplus symbol list
Leaf changes summary: 12 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 6 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 6 Added variables

6 Added functions:

  [A] 'function int __traceiter_android_vh_mutex_can_spin_on_owner(void*, mutex*, int*)'
  [A] 'function int __traceiter_android_vh_mutex_opt_spin_finish(void*, mutex*, bool)'
  [A] 'function int __traceiter_android_vh_mutex_opt_spin_start(void*, mutex*, bool*, int*)'
  [A] 'function int __traceiter_android_vh_rwsem_can_spin_on_owner(void*, rw_semaphore*, bool*, bool)'
  [A] 'function int __traceiter_android_vh_rwsem_opt_spin_finish(void*, rw_semaphore*, bool, bool)'
  [A] 'function int __traceiter_android_vh_rwsem_opt_spin_start(void*, rw_semaphore*, bool*, int*, bool)'

6 Added variables:

  [A] 'tracepoint __tracepoint_android_vh_mutex_can_spin_on_owner'
  [A] 'tracepoint __tracepoint_android_vh_mutex_opt_spin_finish'
  [A] 'tracepoint __tracepoint_android_vh_mutex_opt_spin_start'
  [A] 'tracepoint __tracepoint_android_vh_rwsem_can_spin_on_owner'
  [A] 'tracepoint __tracepoint_android_vh_rwsem_opt_spin_finish'
  [A] 'tracepoint __tracepoint_android_vh_rwsem_opt_spin_start'

Bug: 267565260
Change-Id: If7f68d800f726ceecfec1f45376d37f9d1772014
Signed-off-by: Liujie Xie <xieliujie@oppo.com>
2023-03-02 18:45:04 +00:00
Liujie Xie d01f7e1269 ANDROID: vendor_hooks: Add hooks for mutex and rwsem optimistic spin
These hooks help us do the following things:
a) Record the number of mutex and rwsem optimistic spin.
b) Monitor the time of mutex and rwsem optimistic spin.
c) Make it possible if oems don't want mutex and rwsem to optimistic spin
for a long time.

Bug: 267565260
Change-Id: I2bee30fb17946be85e026213b481aeaeaee2459f
Signed-off-by: Liujie Xie <xieliujie@oppo.com>
2023-03-02 18:45:04 +00:00
T.J. Mercier d4d05c6e6e ANDROID: dma-buf: heaps: Don't lock unused dmabuf_page_pool mutex
On backports where the dmabuf_page_pool mutex could not be completely
removed because of KMI constraints, we lock the mutex to prevent anyone
from acquiring it. While this is fine for regular builds, lockdep
reports a deadlock because of this behavior. So here we remove the call
to mutex_lock for this unused mutex.

Bug: 269576779
Fixes: d55aeb4029 ("BACKPORT: ANDROID: dma-buf: heaps: replace mutex lock with spinlock")
Change-Id: Ic426b6e435ec4ac7b0355c50ec9ea14d38acfa43
Signed-off-by: T.J. Mercier <tjmercier@google.com>
2023-03-01 01:18:39 +00:00
Patrick Daly 1d05213028 ANDROID: mm/filemap: Fix missing put_page() for speculative page fault
find_get_page() returns a page with increased refcount, assuming a page
exists at the given index. Ensure this refcount is dropped on error.

Bug: 271079833
Fixes: 59d4d125 ("BACKPORT: FROMLIST: mm: implement speculative handling in filemap_fault()")
Change-Id: Idc7b9e3f11f32a02bed4c6f4e11cec9200a5c790
Signed-off-by: Patrick Daly <quic_pdaly@quicinc.com>
(cherry picked from commit 6232eecfa7ca0d8d0ca088da6d0edb2c3a879ff9)
Signed-off-by: Zhenhua Huang <quic_zhenhuah@quicinc.com>
2023-03-01 00:25:11 +00:00
Jim Mattson fda8a58faa UPSTREAM: KVM: VMX: Execute IBPB on emulated VM-exit when guest has IBRS
[ Upstream commit 2e7eab8142 ]

According to Intel's document on Indirect Branch Restricted
Speculation, "Enabling IBRS does not prevent software from controlling
the predicted targets of indirect branches of unrelated software
executed later at the same predictor mode (for example, between two
different user applications, or two different virtual machines). Such
isolation can be ensured through use of the Indirect Branch Predictor
Barrier (IBPB) command." This applies to both basic and enhanced IBRS.

Since L1 and L2 VMs share hardware predictor modes (guest-user and
guest-kernel), hardware IBRS is not sufficient to virtualize
IBRS. (The way that basic IBRS is implemented on pre-eIBRS parts,
hardware IBRS is actually sufficient in practice, even though it isn't
sufficient architecturally.)

For virtual CPUs that support IBRS, add an indirect branch prediction
barrier on emulated VM-exit, to ensure that the predicted targets of
indirect branches executed in L1 cannot be controlled by software that
was executed in L2.

Since we typically don't intercept guest writes to IA32_SPEC_CTRL,
perform the IBPB at emulated VM-exit regardless of the current
IA32_SPEC_CTRL.IBRS value, even though the IBPB could technically be
deferred until L1 sets IA32_SPEC_CTRL.IBRS, if IA32_SPEC_CTRL.IBRS is
clear at emulated VM-exit.

This is CVE-2022-2196.

Bug: 265479180
Fixes: 5c911beff2 ("KVM: nVMX: Skip IBPB when switching between vmcs01 and vmcs02")
Cc: Sean Christopherson <seanjc@google.com>
Signed-off-by: Jim Mattson <jmattson@google.com>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20221019213620.1953281-3-jmattson@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Ic3ac006d834719d41f8a84c7a557d60b82e05197
2023-02-27 12:10:53 +00:00
Luca Weiss 5692e2bb4e UPSTREAM: net: qrtr: combine nameservice into main module
Previously with CONFIG_QRTR=m a separate ns.ko would be built which
wasn't done on purpose and should be included in qrtr.ko.

Rename qrtr.c to af_qrtr.c so we can build a qrtr.ko with both af_qrtr.c
and ns.c.

Bug: 270636606
Change-Id: Ied36534abd1d589a5a1a5853e3440526271440b0
Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Tested-By: Steev Klimaszewski <steev@kali.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://lore.kernel.org/r/20210928171156.6353-1-luca@z3ntu.xyz
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit a365023a76)
Signed-off-by: Srinivasarao Pathipati <quic_spathi@quicinc.com>
2023-02-25 00:36:57 +00:00
Seiya Wang 4b9d11ae5f ANDROID: GKI: Update symbol list for mtk
5 Added functions:

  [A] 'function void netdev_notice(const net_device*, const char*, ...)'
  [A] 'function int usb_driver_set_configuration(usb_device*, int)'
  [A] 'function void usb_enable_lpm(usb_device*)'
  [A] 'function int usb_reset_device(usb_device*)'
  [A] 'function int usb_wait_anchor_empty_timeout(usb_anchor*, unsigned int)'

Bug: 270620523
Signed-off-by: Seiya Wang <seiya.wang@mediatek.com>
Change-Id: I918dc81101c3d66a00fa3147671c0e477c796408
2023-02-24 09:48:37 +00:00
Srinivasarao Pathipati b086cc7361 FROMLIST: rcu-tasks: Fix build error
Fixing below build error that got exposed by 'commit 824c55581d
("UPSTREAM: Enable '-Werror' by default for all kernel builds")'
by making show_rcu_tasks_rude_gp_kthread() function as 'inline'.

 In file included from kernel/rcu/update.c:579:0:
 kernel/rcu/tasks.h:710:13: error: ‘show_rcu_tasks_rude_gp_kthread’ defined but not used [-Werror=unused-function]
  static void show_rcu_tasks_rude_gp_kthread(void) {}

All warnings are treated as errors after picking upstream
'commit 824c55581d ("UPSTREAM: Enable '-Werror' by default
for all kernel builds")' into android[12/13]-5.10 kernels.
In latest Linux kernels this issue won't exist as problematic code got
modified by 'commit 27c0f14483 ("rcutorture: Make grace-period kthread
report match RCU flavor being tested")'.

Even though buggy code present in 5.10 stable kernel, the
'commit 824c55581d ("UPSTREAM: Enable '-Werror' by default for all
kernel builds")' is not present so this fix is not relevant here
and got rejected by community.

Bug: 269057599
Link: https://lore.kernel.org/stable/1676916839-32235-1-git-send-email-quic_c_spathi@quicinc.com/
Fixes: 824c55581d ("UPSTREAM: Enable '-Werror' by default for all kernel builds")
Change-Id: I95f6a7a81883d7a6b0f56068b1eb49dc02788685
Signed-off-by: Srinivasarao Pathipati <quic_spathi@quicinc.com>
2023-02-24 04:26:17 +00:00
Paul Lawrence 7fd4fbe615 ANDROID: incremental fs: Move throttling to outside page lock
Bug: 241479010
Test: incfs_test passes, play confirm behavior in bug is fixed
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ie51f2b76d0873057f54fecf7fcc793c66df20969
2023-02-22 17:37:54 +00:00
Paul Lawrence 5d9b0e83e3 ANDROID: incremental fs: Fix race between truncate and write last block
Also fix race whereby multiple providers writinig the same block would
actually write out the same block.

Note that multiple_providers_test started failing when incfs was ported
to 5.15, and these fixes are needed to make the test reliable

Bug: 264703896
Test: incfs-test passes, specifically multiple_providers_test. Ran 100
      times
Change-Id: I05ad5b2b2f62cf218256222cecb79bbe9953bd97
Signed-off-by: Paul Lawrence <paullawrence@google.com>
2023-02-22 17:36:34 +00:00
Prashanth K 6a8037d4eb UPSTREAM: usb: gadget: u_serial: Add null pointer check in gserial_resume
Consider a case where gserial_disconnect has already cleared
gser->ioport. And if a wakeup interrupt triggers afterwards,
gserial_resume gets called, which will lead to accessing of
gser->ioport and thus causing null pointer dereference.Add
a null pointer check to prevent this.

Added a static spinlock to prevent gser->ioport from becoming
null after the newly added check.

Fixes: aba3a8d01d ("usb: gadget: u_serial: add suspend resume callbacks")
Cc: stable <stable@kernel.org>
Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/1676309438-14922-1-git-send-email-quic_prashk@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 270271430
(cherry picked from commit 5ec63fdbca
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/ usb-next)

Change-Id: Ib54ccfc7921fd399d538d93d13d6fe8beef0fb39
Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
2023-02-22 12:34:00 +05:30
Greg Kroah-Hartman f0be4b9779 Revert "ANDROID: GKI: loadavg: Export for get_avenrun"
This reverts commit 64ea6f3273.

The symbol get_avenrun is not used by any external modules, so remove
the export as it is useless.  If this is needed, the original commit can
be added back and the symbol added to the relevant symbol list.

Bug: 158067689
Bug: 203756332
Cc: Abhilasha Rao <abhilasha.hv@samsung.corp-partner.google.com>
Cc: Todd Kjos <tkjos@google.com>
Change-Id: I394d074a6cd4afaaf8eb97d528e039bc168e2fe1
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-21 20:17:41 +00:00
Sarannya S 781e1c83ef ANDROID: ABI: Update allowed list for QCOM
Add __xa_alloc_cyclic to the symbol list. This function will be used in qrtr
for cyclic port id allocation.

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

1 Added function:

  [A] 'function int __xa_alloc_cyclic(xarray*, u32*, void*, xa_limit, u32*, gfp_t)'

Bug: 269687040
Change-Id: I9543ad1320e79daa781f0075decd74612bc694a1
Signed-off-by: Sarannya S <quic_sarannya@quicinc.com>
2023-02-21 20:16:59 +00:00
Chun-Hung Wu 579f8bf863 ANDROID: Update symbol list for mtk
Leaf changes summary: 1 artifact changed (2 filtered out)
Changed leaf types summary: 0 (1 filtered out) leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 1 Added function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed (1 filtered out), 0 Added variable

1 Added function:

  [A] 'function void arm64_noalias_setup_dma_ops(device*)'

Bug: 223346425
Change-Id: I34405abbdd5bc7dd3f2e19718a5dd483ac01c95e
Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com>
2023-02-21 17:56:57 +00:00
Baokun Li 80b27def69 UPSTREAM: ext4: add inode table check in __ext4_get_inode_loc to aovid possible infinite loop
commit eee22187b5 upstream.

In do_writepages, if the value returned by ext4_writepages is "-ENOMEM"
and "wbc->sync_mode == WB_SYNC_ALL", retry until the condition is not met.

In __ext4_get_inode_loc, if the bh returned by sb_getblk is NULL,
the function returns -ENOMEM.

In __getblk_slow, if the return value of grow_buffers is less than 0,
the function returns NULL.

When the three processes are connected in series like the following stack,
an infinite loop may occur:

do_writepages					<--- keep retrying
 ext4_writepages
  mpage_map_and_submit_extent
   mpage_map_one_extent
    ext4_map_blocks
     ext4_ext_map_blocks
      ext4_ext_handle_unwritten_extents
       ext4_ext_convert_to_initialized
        ext4_split_extent
         ext4_split_extent_at
          __ext4_ext_dirty
           __ext4_mark_inode_dirty
            ext4_reserve_inode_write
             ext4_get_inode_loc
              __ext4_get_inode_loc		<--- return -ENOMEM
               sb_getblk
                __getblk_gfp
                 __getblk_slow			<--- return NULL
                  grow_buffers
                   grow_dev_page		<--- return -ENXIO
                    ret = (block < end_block) ? 1 : -ENXIO;

In this issue, bg_inode_table_hi is overwritten as an incorrect value.
As a result, `block < end_block` cannot be met in grow_dev_page.
Therefore, __ext4_get_inode_loc always returns '-ENOMEM' and do_writepages
keeps retrying. As a result, the writeback process is in the D state due
to an infinite loop.

Add a check on inode table block in the __ext4_get_inode_loc function by
referring to ext4_read_inode_bitmap to avoid this infinite loop.

Cc: stable@kernel.org
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Link: https://lore.kernel.org/r/20220817132701.3015912-3-libaokun1@huawei.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: 264629802
Bug: 264632463
Change-Id: Id3bb71336059cac33f16fca383e783add3a01295
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
2023-02-20 17:28:48 +00:00
Cong Wang a4d6d4d1e7 UPSTREAM: net_sched: reject TCF_EM_SIMPLE case for complex ematch module
[ Upstream commit 9cd3fd2054 ]

When TCF_EM_SIMPLE was introduced, it is supposed to be convenient
for ematch implementation:

https://lore.kernel.org/all/20050105110048.GO26856@postel.suug.ch/

"You don't have to, providing a 32bit data chunk without TCF_EM_SIMPLE
set will simply result in allocating & copy. It's an optimization,
nothing more."

So if an ematch module provides ops->datalen that means it wants a
complex data structure (saved in its em->data) instead of a simple u32
value. We should simply reject such a combination, otherwise this u32
could be misinterpreted as a pointer.

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Reported-and-tested-by: syzbot+4caeae4c7103813598ae@syzkaller.appspotmail.com
Reported-by: Jun Nie <jun.nie@linaro.org>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Cong Wang <cong.wang@bytedance.com>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Bug: 262113355
Bug: 262114215
Change-Id: I03be57351f76f699d4635cf31178e0f3a19e61a5
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
2023-02-20 17:28:31 +00:00
Jens Axboe fb952695c8 UPSTREAM: io_uring/rw: remove leftover debug statement
commit 5c61795ea9 upstream.

This debug statement was never meant to go into the upstream release,
kill it off before it ends up in a release. It was just part of the
testing for the initial version of the patch.

Fixes: 2ec33a6c3c ("io_uring/rw: ensure kiocb_end_write() is always called")
Change-Id: Iee9f436c34cc137a7ab934aafa3aa0c584369418
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: 268174392
(cherry picked from commit e699cce29a)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 18:04:23 +00:00
Jens Axboe ca331f289a UPSTREAM: io_uring/rw: ensure kiocb_end_write() is always called
commit 2ec33a6c3c upstream.

A previous commit moved the notifications and end-write handling, but
it is now missing a few spots where we also want to call both of those.
Without that, we can potentially be missing file notifications, and
more importantly, have an imbalance in the super_block writers sem
accounting.

Fixes: b000145e99 ("io_uring/rw: defer fsnotify calls to task context")
Reported-by: Dave Chinner <david@fromorbit.com>
Link: https://lore.kernel.org/all/20221010050319.GC2703033@dread.disaster.area/
Change-Id: Iaaa509f5dadcae04f58c929901225bc968b35d52
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: 268174392
(cherry picked from commit 3d5f181bda)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 18:04:23 +00:00
Pavel Begunkov d54d41716d UPSTREAM: io_uring: fix double poll leak on repolling
commit c0737fa9a5 upstream.

We have re-polling for partial IO, so a request can be polled twice. If
it used two poll entries the first time then on the second
io_arm_poll_handler() it will find the old apoll entry and NULL
kmalloc()'ed second entry, i.e. apoll->double_poll, so leaking it.

Fixes: 10c873334f ("io_uring: allow re-poll if we made progress")
Change-Id: If720ddcd7e488c0c336533d8dde00864689648ca
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/fee2452494222ecc7f1f88c8fb659baef971414a.1655852245.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: 268174392
(cherry picked from commit c1a279d79e)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 18:04:23 +00:00
Alviro Iskandar Setiawan fc978be7b2 UPSTREAM: io_uring: Clean up a false-positive warning from GCC 9.3.0
commit 0d7c1153d9 upstream.

In io_recv(), if import_single_range() fails, the @flags variable is
uninitialized, then it will goto out_free.

After the goto, the compiler doesn't know that (ret < min_ret) is
always true, so it thinks the "if ((flags & MSG_WAITALL) ..."  path
could be taken.

The complaint comes from gcc-9 (Debian 9.3.0-22) 9.3.0:
```
  fs/io_uring.c:5238 io_recvfrom() error: uninitialized symbol 'flags'
```
Fix this by bypassing the @ret and @flags check when
import_single_range() fails.

Reasons:
 1. import_single_range() only returns -EFAULT when it fails.
 2. At that point, @flags is uninitialized and shouldn't be read.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reported-by: "Chen, Rong A" <rong.a.chen@intel.com>
Link: https://lore.gnuweeb.org/timl/d33bb5a9-8173-f65b-f653-51fc0681c6d6@intel.com/
Cc: Pavel Begunkov <asml.silence@gmail.com>
Suggested-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Fixes: 7297ce3d59 ("io_uring: improve send/recv error handling")
Change-Id: Ifd324b3213a0682dae11177c93a5b8272516c2cd
Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gmail.com>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Link: https://lore.kernel.org/r/20220207140533.565411-1-ammarfaizi2@gnuweeb.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: 268174392
(cherry picked from commit ddaaadf22b)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 18:04:23 +00:00
Stefan Metzmacher 827f8fcb29 UPSTREAM: io_uring/net: fix fast_iov assignment in io_setup_async_msg()
commit 3e4cb6ebbb upstream.

I hit a very bad problem during my tests of SENDMSG_ZC.
BUG(); in first_iovec_segment() triggered very easily.
The problem was io_setup_async_msg() in the partial retry case,
which seems to happen more often with _ZC.

iov_iter_iovec_advance() may change i->iov in order to have i->iov_offset
being only relative to the first element.

Which means kmsg->msg.msg_iter.iov is no longer the
same as kmsg->fast_iov.

But this would rewind the copy to be the start of
async_msg->fast_iov, which means the internal
state of sync_msg->msg.msg_iter is inconsitent.

I tested with 5 vectors with length like this 4, 0, 64, 20, 8388608
and got a short writes with:
- ret=2675244 min_ret=8388692 => remaining 5713448 sr->done_io=2675244
- ret=-EAGAIN => io_uring_poll_arm
- ret=4911225 min_ret=5713448 => remaining 802223  sr->done_io=7586469
- ret=-EAGAIN => io_uring_poll_arm
- ret=802223  min_ret=802223  => res=8388692

While this was easily triggered with SENDMSG_ZC (queued for 6.1),
it was a potential problem starting with 7ba89d2af1
in 5.18 for IORING_OP_RECVMSG.
And also with 4c3c09439c in 5.19
for IORING_OP_SENDMSG.

However 257e84a537 introduced the critical
code into io_setup_async_msg() in 5.11.

Fixes: 7ba89d2af1 ("io_uring: ensure recv and recvmsg handle MSG_WAITALL correctly")
Fixes: 257e84a537 ("io_uring: refactor sendmsg/recvmsg iov managing")
Cc: stable@vger.kernel.org
Change-Id: I72c459fdbae2938d176126ed2f17eea990c42d49
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/b2e7be246e2fb173520862b0c7098e55767567a2.1664436949.git.metze@samba.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: 268174392
(cherry picked from commit fc2491562a)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 18:01:23 +00:00
Jens Axboe 403642c036 UPSTREAM: io_uring: io_kiocb_update_pos() should not touch file for non -1 offset
commit 6f83ab22ad upstream.

-1 tells use to use the current position, but we check if the file is
a stream regardless of that. Fix up io_kiocb_update_pos() to only
dip into file if we need to. This is both more efficient and also drops
12 bytes of text on aarch64 and 64 bytes on x86-64.

Fixes: b4aec40015 ("io_uring: do not recalculate ppos unnecessarily")
Change-Id: I5c22ce8122b0e1f0ad423a5b3aa520ee416feff1
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: 268174392
(cherry picked from commit 89a77271d2)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 17:57:16 +00:00
Jens Axboe 0c50a117bf UPSTREAM: io_uring/rw: defer fsnotify calls to task context
commit b000145e99 upstream.

We can't call these off the kiocb completion as that might be off
soft/hard irq context. Defer the calls to when we process the
task_work for this request. That avoids valid complaints like:

stack backtrace:
CPU: 1 PID: 0 Comm: swapper/1 Not tainted 6.0.0-rc6-syzkaller-00321-g105a36f3694e #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2022
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_usage_bug kernel/locking/lockdep.c:3961 [inline]
 valid_state kernel/locking/lockdep.c:3973 [inline]
 mark_lock_irq kernel/locking/lockdep.c:4176 [inline]
 mark_lock.part.0.cold+0x18/0xd8 kernel/locking/lockdep.c:4632
 mark_lock kernel/locking/lockdep.c:4596 [inline]
 mark_usage kernel/locking/lockdep.c:4527 [inline]
 __lock_acquire+0x11d9/0x56d0 kernel/locking/lockdep.c:5007
 lock_acquire kernel/locking/lockdep.c:5666 [inline]
 lock_acquire+0x1ab/0x570 kernel/locking/lockdep.c:5631
 __fs_reclaim_acquire mm/page_alloc.c:4674 [inline]
 fs_reclaim_acquire+0x115/0x160 mm/page_alloc.c:4688
 might_alloc include/linux/sched/mm.h:271 [inline]
 slab_pre_alloc_hook mm/slab.h:700 [inline]
 slab_alloc mm/slab.c:3278 [inline]
 __kmem_cache_alloc_lru mm/slab.c:3471 [inline]
 kmem_cache_alloc+0x39/0x520 mm/slab.c:3491
 fanotify_alloc_fid_event fs/notify/fanotify/fanotify.c:580 [inline]
 fanotify_alloc_event fs/notify/fanotify/fanotify.c:813 [inline]
 fanotify_handle_event+0x1130/0x3f40 fs/notify/fanotify/fanotify.c:948
 send_to_group fs/notify/fsnotify.c:360 [inline]
 fsnotify+0xafb/0x1680 fs/notify/fsnotify.c:570
 __fsnotify_parent+0x62f/0xa60 fs/notify/fsnotify.c:230
 fsnotify_parent include/linux/fsnotify.h:77 [inline]
 fsnotify_file include/linux/fsnotify.h:99 [inline]
 fsnotify_access include/linux/fsnotify.h:309 [inline]
 __io_complete_rw_common+0x485/0x720 io_uring/rw.c:195
 io_complete_rw+0x1a/0x1f0 io_uring/rw.c:228
 iomap_dio_complete_work fs/iomap/direct-io.c:144 [inline]
 iomap_dio_bio_end_io+0x438/0x5e0 fs/iomap/direct-io.c:178
 bio_endio+0x5f9/0x780 block/bio.c:1564
 req_bio_endio block/blk-mq.c:695 [inline]
 blk_update_request+0x3fc/0x1300 block/blk-mq.c:825
 scsi_end_request+0x7a/0x9a0 drivers/scsi/scsi_lib.c:541
 scsi_io_completion+0x173/0x1f70 drivers/scsi/scsi_lib.c:971
 scsi_complete+0x122/0x3b0 drivers/scsi/scsi_lib.c:1438
 blk_complete_reqs+0xad/0xe0 block/blk-mq.c:1022
 __do_softirq+0x1d3/0x9c6 kernel/softirq.c:571
 invoke_softirq kernel/softirq.c:445 [inline]
 __irq_exit_rcu+0x123/0x180 kernel/softirq.c:650
 irq_exit_rcu+0x5/0x20 kernel/softirq.c:662
 common_interrupt+0xa9/0xc0 arch/x86/kernel/irq.c:240

Fixes: f63cf5192f ("io_uring: ensure that fsnotify is always called")
Link: https://lore.kernel.org/all/20220929135627.ykivmdks2w5vzrwg@quack3/
Reported-by: syzbot+dfcc5f4da15868df7d4d@syzkaller.appspotmail.com
Reported-by: Jan Kara <jack@suse.cz>
Change-Id: Ia16078bdf53c6b2536cacb7aafa03a4ec1079a94
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Bug: 268174392
(cherry picked from commit ea2e6286e3)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 17:57:16 +00:00
Dylan Yudaken b29c357309 UPSTREAM: io_uring: do not recalculate ppos unnecessarily
commit b4aec40015 upstream.

There is a slight optimisation to be had by calculating the correct pos
pointer inside io_kiocb_update_pos and then using that later.

It seems code size drops by a bit:
000000000000a1b0 0000000000000400 t io_read
000000000000a5b0 0000000000000319 t io_write

vs
000000000000a1b0 00000000000003f6 t io_read
000000000000a5b0 0000000000000310 t io_write

Change-Id: I19d8cdb6ea88d8fc4625e521363d5a8f638dfdcb
Signed-off-by: Dylan Yudaken <dylany@fb.com>
Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Bug: 268174392
(cherry picked from commit e90cfb9699)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 17:57:16 +00:00
Dylan Yudaken 84e34d2ef5 UPSTREAM: io_uring: update kiocb->ki_pos at execution time
commit d34e1e5b39 upstream.

Update kiocb->ki_pos at execution time rather than in io_prep_rw().
io_prep_rw() happens before the job is enqueued to a worker and so the
offset might be read multiple times before being executed once.

Ensures that the file position in a set of _linked_ SQEs will be only
obtained after earlier SQEs have completed, and so will include their
incremented file position.

Change-Id: I3c5abbf6a337ec1958fd6600c5feb44fb61a5772
Signed-off-by: Dylan Yudaken <dylany@fb.com>
Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Bug: 268174392
(cherry picked from commit ea528ecac3)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 17:57:16 +00:00
Dylan Yudaken b543e0d210 UPSTREAM: io_uring: remove duplicated calls to io_kiocb_ppos
commit af9c45eceb upstream.

io_kiocb_ppos is called in both branches, and it seems that the compiler
does not fuse this. Fusing removes a few bytes from loop_rw_iter.

Before:
$ nm -S fs/io_uring.o | grep loop_rw_iter
0000000000002430 0000000000000124 t loop_rw_iter

After:
$ nm -S fs/io_uring.o | grep loop_rw_iter
0000000000002430 000000000000010d t loop_rw_iter

Change-Id: Ibd662d59697d9cb1e484319050f6e5f960f6ac5c
Signed-off-by: Dylan Yudaken <dylany@fb.com>
Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Bug: 268174392
(cherry picked from commit 076f872314)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 17:56:56 +00:00
Jens Axboe 9166f5418a UPSTREAM: io_uring: ensure that cached task references are always put on exit
commit e775f93f2a upstream.

io_uring caches task references to avoid doing atomics for each of them
per request. If a request is put from the same task that allocated it,
then we can maintain a per-ctx cache of them. This obviously relies
on io_uring always pruning caches in a reliable way, and there's
currently a case off io_uring fd release where we can miss that.

One example is a ring setup with IOPOLL, which relies on the task
polling for completions, which will free them. However, if such a task
submits a request and then exits or closes the ring without reaping
the completion, then ring release will reap and put. If release happens
from that very same task, the completed request task refs will get
put back into the cache pool. This is problematic, as we're now beyond
the point of pruning caches.

Manually drop these caches after doing an IOPOLL reap. This releases
references from the current task, which is enough. If another task
happens to be doing the release, then the caching will not be
triggered and there's no issue.

Cc: stable@vger.kernel.org
Fixes: e98e49b2bb ("io_uring: extend task put optimisations")
Reported-by: Homin Rhee <hominlab@gmail.com>
Change-Id: I9495121af065424141fa9c39840ab9aa91f45c72
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Bug: 268174392
(cherry picked from commit e9c6556708)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 17:56:56 +00:00
Pavel Begunkov fee5372abf UPSTREAM: io_uring: fix CQ waiting timeout handling
commit 12521a5d5c upstream.

Jiffy to ktime CQ waiting conversion broke how we treat timeouts, in
particular we rearm it anew every time we get into
io_cqring_wait_schedule() without adjusting the timeout. Waiting for 2
CQEs and getting a task_work in the middle may double the timeout value,
or even worse in some cases task may wait indefinitely.

Cc: stable@vger.kernel.org
Fixes: 228339662b ("io_uring: don't convert to jiffies for waiting on timeouts")
Change-Id: If8605a13266ae2b49b1f7d7cd5ee092f9ffd2805
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/f7bffddd71b08f28a877d44d37ac953ddb01590d.1672915663.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Bug: 268174392
(cherry picked from commit e0140e9da3)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 17:56:56 +00:00
Pavel Begunkov a4d056e350 UPSTREAM: io_uring: lock overflowing for IOPOLL
commit 544d163d65 upstream.

syzbot reports an issue with overflow filling for IOPOLL:

WARNING: CPU: 0 PID: 28 at io_uring/io_uring.c:734 io_cqring_event_overflow+0x1c0/0x230 io_uring/io_uring.c:734
CPU: 0 PID: 28 Comm: kworker/u4:1 Not tainted 6.2.0-rc3-syzkaller-16369-g358a161a6a9e #0
Workqueue: events_unbound io_ring_exit_work
Call trace:
 io_cqring_event_overflow+0x1c0/0x230 io_uring/io_uring.c:734
 io_req_cqe_overflow+0x5c/0x70 io_uring/io_uring.c:773
 io_fill_cqe_req io_uring/io_uring.h:168 [inline]
 io_do_iopoll+0x474/0x62c io_uring/rw.c:1065
 io_iopoll_try_reap_events+0x6c/0x108 io_uring/io_uring.c:1513
 io_uring_try_cancel_requests+0x13c/0x258 io_uring/io_uring.c:3056
 io_ring_exit_work+0xec/0x390 io_uring/io_uring.c:2869
 process_one_work+0x2d8/0x504 kernel/workqueue.c:2289
 worker_thread+0x340/0x610 kernel/workqueue.c:2436
 kthread+0x12c/0x158 kernel/kthread.c:376
 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:863

There is no real problem for normal IOPOLL as flush is also called with
uring_lock taken, but it's getting more complicated for IOPOLL|SQPOLL,
for which __io_cqring_overflow_flush() happens from the CQ waiting path.

Reported-and-tested-by: syzbot+6805087452d72929404e@syzkaller.appspotmail.com
Cc: stable@vger.kernel.org # 5.10+
Change-Id: I3449b2ea1b71ff2f04f119741751b42870386923
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Bug: 268174392
(cherry picked from commit de77faee28)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 17:56:56 +00:00
Jens Axboe 0dfe72e890 UPSTREAM: io_uring: check for valid register opcode earlier
[ Upstream commit 343190841a ]

We only check the register opcode value inside the restricted ring
section, move it into the main io_uring_register() function instead
and check it up front.

Change-Id: I4b5f782dad48eb0e7f04d5956cc087494e02b2ec
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Bug: 268174392
(cherry picked from commit 78e8151f04)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 17:56:56 +00:00
Dylan Yudaken 1b735b5eb2 UPSTREAM: io_uring: fix async accept on O_NONBLOCK sockets
commit a73825ba70 upstream.

Do not set REQ_F_NOWAIT if the socket is non blocking. When enabled this
causes the accept to immediately post a CQE with EAGAIN, which means you
cannot perform an accept SQE on a NONBLOCK socket asynchronously.

By removing the flag if there is no pending accept then poll is armed as
usual and when a connection comes in the CQE is posted.

Change-Id: I0fae3f75c7fbbf44f85da7d83f48c4cfed1fcae9
Signed-off-by: Dylan Yudaken <dylany@fb.com>
Link: https://lore.kernel.org/r/20220324143435.2875844-1-dylany@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Bug: 268174392
(cherry picked from commit aa4c9b3e45)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 17:56:56 +00:00
Jens Axboe 63bf975936 UPSTREAM: io_uring: allow re-poll if we made progress
commit 10c873334f upstream.

We currently check REQ_F_POLLED before arming async poll for a
notification to retry. If it's set, then we don't allow poll and will
punt to io-wq instead. This is done to prevent a situation where a buggy
driver will repeatedly return that there's space/data available yet we
get -EAGAIN.

However, if we already transferred data, then it should be safe to rely
on poll again. Gate the check on whether or not REQ_F_PARTIAL_IO is
also set.

Change-Id: I36b6d16ac43202fdf9ae5eea64f9dfbcfbe7fee5
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Bug: 268174392
(cherry picked from commit 4bc17e6381)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 17:56:56 +00:00
Jens Axboe a64d6ea01b UPSTREAM: io_uring: support MSG_WAITALL for IORING_OP_SEND(MSG)
commit 4c3c09439c upstream.

Like commit 7ba89d2af1 for recv/recvmsg, support MSG_WAITALL for the
send side. If this flag is set and we do a short send, retry for a
stream of seqpacket socket.

Change-Id: If67a4462576af1b683d53d2dc0d46e44c9dd8863
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Bug: 268174392
(cherry picked from commit f901b4bfd0)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 17:56:56 +00:00
Jens Axboe cf7ef78842 UPSTREAM: io_uring: add flag for disabling provided buffer recycling
commit 8a3e8ee564 upstream.

If we need to continue doing this IO, then we don't want a potentially
selected buffer recycled. Add a flag for that.

Set this for recv/recvmsg if they do partial IO.

Change-Id: If9381bd6a5695c8c85c7a51c3adccc0dc09f8999
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Bug: 268174392
(cherry picked from commit 96ccba4a1a)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 17:56:56 +00:00
Jens Axboe 45b2a34e21 UPSTREAM: io_uring: ensure recv and recvmsg handle MSG_WAITALL correctly
commit 7ba89d2af1 upstream.

We currently don't attempt to get the full asked for length even if
MSG_WAITALL is set, if we get a partial receive. If we do see a partial
receive, then just note how many bytes we did and return -EAGAIN to
get it retried.

The iov is advanced appropriately for the vector based case, and we
manually bump the buffer and remainder for the non-vector case.

Cc: stable@vger.kernel.org
Reported-by: Constantine Gavrilov <constantine.gavrilov@gmail.com>
Change-Id: I618bde7c86b29f6053dd8cd19682f2916e57dd54
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Bug: 268174392
(cherry picked from commit aadd9b0930)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 17:56:56 +00:00
Pavel Begunkov 4b912a635e UPSTREAM: io_uring: improve send/recv error handling
commit 7297ce3d59 upstream.

Hide all error handling under common if block, removes two extra ifs on
the success path and keeps the handling more condensed.

Change-Id: If6864c8ddd06bc853cef6b543fc06cf99d9ad147
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/5761545158a12968f3caf30f747eea65ed75dfc1.1637524285.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Bug: 268174392
(cherry picked from commit abdc16c836)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 17:56:56 +00:00
Jens Axboe ef0c71d0f1 UPSTREAM: io_uring: don't gate task_work run on TIF_NOTIFY_SIGNAL
commit 46a525e199 upstream.

This isn't a reliable mechanism to tell if we have task_work pending, we
really should be looking at whether we have any items queued. This is
problematic if forward progress is gated on running said task_work. One
such example is reading from a pipe, where the write side has been closed
right before the read is started. The fput() of the file queues TWA_RESUME
task_work, and we need that task_work to be run before ->release() is
called for the pipe. If ->release() isn't called, then the read will sit
forever waiting on data that will never arise.

Fix this by io_run_task_work() so it checks if we have task_work pending
rather than rely on TIF_NOTIFY_SIGNAL for that. The latter obviously
doesn't work for task_work that is queued without TWA_SIGNAL.

Reported-by: Christiano Haesbaert <haesbaert@haesbaert.org>
Cc: stable@vger.kernel.org
Link: https://github.com/axboe/liburing/issues/665
Change-Id: I042b07491afac06692639d91bdf7dd21a2405651
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Bug: 268174392
(cherry picked from commit 2fd232bbd6)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-17 17:56:56 +00:00
Robin Murphy 1531e1fb8d BACKPORT: iommu: Avoid races around device probe
We currently have 3 different ways that __iommu_probe_device() may be
called, but no real guarantee that multiple callers can't tread on each
other, especially once asynchronous driver probe gets involved. It would
likely have taken a fair bit of luck to hit this previously, but commit
57365a04c9 ("iommu: Move bus setup to IOMMU device registration") ups
the odds since now it's not just omap-iommu that may trigger multiple
bus_iommu_probe() calls in parallel if probing asynchronously.

Add a lock to ensure we can't try to double-probe a device, and also
close some possible race windows to make sure we're truly robust against
trying to double-initialise a group via two different member devices.

Reported-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Tested-by: Brian Norris <briannorris@chromium.org>
Fixes: 57365a04c9 ("iommu: Move bus setup to IOMMU device registration")
Link: https://lore.kernel.org/r/1946ef9f774851732eed78760a78ec40dbc6d178.1667591503.git.robin.murphy@arm.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>

Bug: 269232600
(cherry picked from commit 01657bc14a)
Change-Id: Ie87f8f7a7b90431c3a2682923961885ce7b239f3
Signed-off-by: Zhenhua Huang <quic_zhenhuah@quicinc.com>
2023-02-17 16:22:47 +00:00
Jens Axboe 60944bdddc UPSTREAM: io_uring/io-wq: only free worker if it was allocated for creation
commit e6db6f9398 upstream.

We have two types of task_work based creation, one is using an existing
worker to setup a new one (eg when going to sleep and we have no free
workers), and the other is allocating a new worker. Only the latter
should be freed when we cancel task_work creation for a new worker.

Fixes: af82425c6a ("io_uring/io-wq: free worker if task_work creation is canceled")
Reported-by: syzbot+d56ec896af3637bdb7e4@syzkaller.appspotmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: 268174392
(cherry picked from commit a88a0d16e1)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I75c9b22dce02151b2687cf90d6c5b74c08d0f04b
2023-02-17 12:39:32 +00:00
Jens Axboe ac06912075 UPSTREAM: io_uring/io-wq: free worker if task_work creation is canceled
commit af82425c6a upstream.

If we cancel the task_work, the worker will never come into existance.
As this is the last reference to it, ensure that we get it freed
appropriately.

Cc: stable@vger.kernel.org
Reported-by: 진호 <wnwlsgh98@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: 268174392
(cherry picked from commit b912ed1363)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Iacfd7a5db15c417fd1f02c85e414e3137e8729ec
2023-02-17 12:38:37 +00:00