Skip to content

Commit 29159a4

Browse files
committed
ALSA: pcm: Abort properly at pending signal in OSS read/write loops
The loops for read and write in PCM OSS emulation have no proper check of pending signals, and they keep processing even after user tries to break. This results in a very long delay, often seen as RCU stall when a huge unprocessed bytes remain queued. The bug could be easily triggered by syzkaller. As a simple workaround, this patch adds the proper check of pending signals and aborts the loop appropriately. Reported-by: [email protected] Cc: <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 898dfe4 commit 29159a4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sound/core/oss/pcm_oss.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,10 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
13811381
tmp != runtime->oss.period_bytes)
13821382
break;
13831383
}
1384+
if (signal_pending(current)) {
1385+
tmp = -ERESTARTSYS;
1386+
goto err;
1387+
}
13841388
}
13851389
mutex_unlock(&runtime->oss.params_lock);
13861390
return xfer;
@@ -1466,6 +1470,10 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
14661470
bytes -= tmp;
14671471
xfer += tmp;
14681472
}
1473+
if (signal_pending(current)) {
1474+
tmp = -ERESTARTSYS;
1475+
goto err;
1476+
}
14691477
}
14701478
mutex_unlock(&runtime->oss.params_lock);
14711479
return xfer;

0 commit comments

Comments
 (0)