+++ /dev/null
-From 7e4cad98572fb812e680b3f40106c641fbda975c Mon Sep 17 00:00:00 2001
-From: Takashi Iwai <tiwai@suse.de>
-Date: Fri, 25 Jan 2019 17:11:32 +0100
-Subject: ALSA: pcm: Fix tight loop of OSS capture stream
-
-[ Upstream commit e190161f96b88ffae870405fd6c3fdd1d2e7f98d ]
-
-When the trigger=off is passed for a PCM OSS stream, it sets the
-start_threshold of the given substream to the boundary size, so that
-it won't be automatically started. This can be problematic for a
-capture stream, unfortunately, as detected by syzkaller. The scenario
-is like the following:
-
-- In __snd_pcm_lib_xfer() that is invoked from snd_pcm_oss_read()
- loop, we have a check whether the stream was already started or the
- stream can be auto-started.
-- The function at this check returns 0 with trigger=off since we
- explicitly disable the auto-start.
-- The loop continues and repeats calling __snd_pcm_lib_xfer() tightly,
- which may lead to an RCU stall.
-
-This patch fixes the bug by simply allowing the wait for non-started
-stream in the case of OSS capture. For native usages, it's supposed
-to be done by the caller side (which is user-space), hence it returns
-zero like before.
-
-(In theory, __snd_pcm_lib_xfer() could wait even for the native API
- usage cases, too; but I'd like to stay in a safer side for not
- breaking the existing stuff for now.)
-
-Reported-by: syzbot+fbe0496f92a0ce7b786c@syzkaller.appspotmail.com
-Cc: <stable@vger.kernel.org>
-Signed-off-by: Takashi Iwai <tiwai@suse.de>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- sound/core/pcm_lib.c | 9 ++++++++-
- 1 file changed, 8 insertions(+), 1 deletion(-)
-
-diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
-index 40013b26f6719..6c99fa8ac5fa1 100644
---- a/sound/core/pcm_lib.c
-+++ b/sound/core/pcm_lib.c
-@@ -2112,6 +2112,13 @@ int pcm_lib_apply_appl_ptr(struct snd_pcm_substream *substream,
- return 0;
- }
-
-+/* allow waiting for a capture stream that hasn't been started */
-+#if IS_ENABLED(CONFIG_SND_PCM_OSS)
-+#define wait_capture_start(substream) ((substream)->oss.oss)
-+#else
-+#define wait_capture_start(substream) false
-+#endif
-+
- /* the common loop for read/write data */
- snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
- void *data, bool interleaved,
-@@ -2182,7 +2189,7 @@ snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
- err = snd_pcm_start(substream);
- if (err < 0)
- goto _end_unlock;
-- } else {
-+ } else if (!wait_capture_start(substream)) {
- /* nothing to do */
- err = 0;
- goto _end_unlock;
---
-2.20.1
-
+++ /dev/null
-From 665b0aa6e5d99034dc6658cf64ba5a240a084d6f Mon Sep 17 00:00:00 2001
-From: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
-Date: Sat, 25 Aug 2018 16:53:23 -0300
-Subject: ALSA: pcm: Return 0 when size < start_threshold in capture
-
-[ Upstream commit 62ba568f7aef4beb0eda945a2b2a91b7a2b8f215 ]
-
-In __snd_pcm_lib_xfer(), when capture, if state is PREPARED
-and size is less than start_threshold nothing can be done.
-As there is no error, 0 is returned.
-
-Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
-Signed-off-by: Takashi Iwai <tiwai@suse.de>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- sound/core/pcm_lib.c | 13 +++++++++----
- 1 file changed, 9 insertions(+), 4 deletions(-)
-
-diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
-index 4e6110d778bd2..7f71c2449af5e 100644
---- a/sound/core/pcm_lib.c
-+++ b/sound/core/pcm_lib.c
-@@ -2173,11 +2173,16 @@ snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
- goto _end_unlock;
-
- if (!is_playback &&
-- runtime->status->state == SNDRV_PCM_STATE_PREPARED &&
-- size >= runtime->start_threshold) {
-- err = snd_pcm_start(substream);
-- if (err < 0)
-+ runtime->status->state == SNDRV_PCM_STATE_PREPARED) {
-+ if (size >= runtime->start_threshold) {
-+ err = snd_pcm_start(substream);
-+ if (err < 0)
-+ goto _end_unlock;
-+ } else {
-+ /* nothing to do */
-+ err = 0;
- goto _end_unlock;
-+ }
- }
-
- runtime->twake = runtime->control->avail_min ? : 1;
---
-2.20.1
-
+++ /dev/null
-From abe681ee1a80974355b9de46aa5dbcf5a6fc8222 Mon Sep 17 00:00:00 2001
-From: Takashi Iwai <tiwai@suse.de>
-Date: Wed, 6 Feb 2019 07:30:44 +0100
-Subject: ALSA: pcm: Revert capture stream behavior change in blocking mode
-
-[ Upstream commit 00a399cad1a063e7665f06b6497a807db20441fd ]
-
-In the commit 62ba568f7aef ("ALSA: pcm: Return 0 when size <
-start_threshold in capture"), we changed the behavior of
-__snd_pcm_lib_xfer() to return immediately with 0 when a capture
-stream has a high start_threshold. This was intended to be a
-correction of the behavior consistency and looked harmless, but this
-was the culprit of the recent breakage reported by syzkaller, which
-was fixed by the commit e190161f96b8 ("ALSA: pcm: Fix tight loop of
-OSS capture stream").
-
-At the time for the OSS fix, I didn't touch the behavior for ALSA
-native API, as assuming that this behavior actually is good. But this
-turned out to be also broken actually for a similar deployment,
-e.g. one thread goes to a write loop in blocking mode while another
-thread controls the start/stop of the stream manually.
-
-Overall, the original commit is harmful, and it brings less merit to
-keep that behavior. Let's revert it.
-
-Fixes: 62ba568f7aef ("ALSA: pcm: Return 0 when size < start_threshold in capture")
-Fixes: e190161f96b8 ("ALSA: pcm: Fix tight loop of OSS capture stream")
-Cc: <stable@vger.kernel.org>
-Signed-off-by: Takashi Iwai <tiwai@suse.de>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- sound/core/pcm_lib.c | 20 ++++----------------
- 1 file changed, 4 insertions(+), 16 deletions(-)
-
-diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
-index 6c99fa8ac5fa1..6c0b30391ba99 100644
---- a/sound/core/pcm_lib.c
-+++ b/sound/core/pcm_lib.c
-@@ -2112,13 +2112,6 @@ int pcm_lib_apply_appl_ptr(struct snd_pcm_substream *substream,
- return 0;
- }
-
--/* allow waiting for a capture stream that hasn't been started */
--#if IS_ENABLED(CONFIG_SND_PCM_OSS)
--#define wait_capture_start(substream) ((substream)->oss.oss)
--#else
--#define wait_capture_start(substream) false
--#endif
--
- /* the common loop for read/write data */
- snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
- void *data, bool interleaved,
-@@ -2184,16 +2177,11 @@ snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
- snd_pcm_update_hw_ptr(substream);
-
- if (!is_playback &&
-- runtime->status->state == SNDRV_PCM_STATE_PREPARED) {
-- if (size >= runtime->start_threshold) {
-- err = snd_pcm_start(substream);
-- if (err < 0)
-- goto _end_unlock;
-- } else if (!wait_capture_start(substream)) {
-- /* nothing to do */
-- err = 0;
-+ runtime->status->state == SNDRV_PCM_STATE_PREPARED &&
-+ size >= runtime->start_threshold) {
-+ err = snd_pcm_start(substream);
-+ if (err < 0)
- goto _end_unlock;
-- }
- }
-
- avail = snd_pcm_avail(substream);
---
-2.20.1
-
+++ /dev/null
-From 9d970af67299360eaacd6edb37d60730d5d5e2e3 Mon Sep 17 00:00:00 2001
-From: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
-Date: Fri, 7 Sep 2018 16:58:54 -0300
-Subject: ALSA: pcm: Update hardware pointer before start capture
-
-[ Upstream commit 64b6acf60b665fffd419c23886a1cbeeb253cfb4 ]
-
-This ensures the transfer loop won't waste a run to read
-the few frames (if any) between start and hw_ptr update.
-It will wait for the next interrupt with wait_for_avail().
-
-Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
-Signed-off-by: Takashi Iwai <tiwai@suse.de>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- sound/core/pcm_lib.c | 8 +++++---
- 1 file changed, 5 insertions(+), 3 deletions(-)
-
-diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
-index 7f71c2449af5e..40013b26f6719 100644
---- a/sound/core/pcm_lib.c
-+++ b/sound/core/pcm_lib.c
-@@ -2172,6 +2172,10 @@ snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
- if (err < 0)
- goto _end_unlock;
-
-+ runtime->twake = runtime->control->avail_min ? : 1;
-+ if (runtime->status->state == SNDRV_PCM_STATE_RUNNING)
-+ snd_pcm_update_hw_ptr(substream);
-+
- if (!is_playback &&
- runtime->status->state == SNDRV_PCM_STATE_PREPARED) {
- if (size >= runtime->start_threshold) {
-@@ -2185,10 +2189,8 @@ snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
- }
- }
-
-- runtime->twake = runtime->control->avail_min ? : 1;
-- if (runtime->status->state == SNDRV_PCM_STATE_RUNNING)
-- snd_pcm_update_hw_ptr(substream);
- avail = snd_pcm_avail(substream);
-+
- while (size > 0) {
- snd_pcm_uframes_t frames, appl_ptr, appl_ofs;
- snd_pcm_uframes_t cont;
---
-2.20.1
-
media-vim2m-only-cancel-work-if-it-is-for-right-cont.patch
arc-show_regs-lockdep-re-enable-preemption.patch
arc-mm-do_page_fault-fixes-1-relinquish-mmap_sem-if-.patch
-alsa-pcm-return-0-when-size-start_threshold-in-captu.patch
-alsa-pcm-update-hardware-pointer-before-start-captur.patch
-alsa-pcm-fix-tight-loop-of-oss-capture-stream.patch
ib-uverbs-fix-oops-upon-device-disassociation.patch
crypto-ccree-fix-resume-race-condition-on-init.patch
-alsa-pcm-revert-capture-stream-behavior-change-in-bl.patch
crypto-ccree-add-missing-inline-qualifier.patch
drm-vblank-allow-dynamic-per-crtc-max_vblank_count.patch
drm-i915-ilk-fix-warning-when-reading-emon_status-wi.patch