From fa525f71d007dc73ba36dcda0e21528d3e78032b9021a3102f8fea9826efaf0b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 13 Jul 2015 15:41:56 +0000 Subject: [PATCH] Accepting request 316472 from home:tiwai:branches:multimedia:libs - Backport upstream fixes for aplay signal handling and alsactl possible buffer overflow of readlink(): 0004-aplay-Fix-type-for-signal-flag.patch 0005-aplay-Fix-uninterruptible-aplay.patch 0006-alsactl-terminate-readlink-result-string.patch OBS-URL: https://build.opensuse.org/request/show/316472 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa-utils?expand=0&rev=118 --- 0004-aplay-Fix-type-for-signal-flag.patch | 29 +++++++++++++++ 0005-aplay-Fix-uninterruptible-aplay.patch | 35 +++++++++++++++++++ ...ctl-terminate-readlink-result-string.patch | 35 +++++++++++++++++++ alsa-utils.changes | 9 +++++ alsa-utils.spec | 6 ++++ 5 files changed, 114 insertions(+) create mode 100644 0004-aplay-Fix-type-for-signal-flag.patch create mode 100644 0005-aplay-Fix-uninterruptible-aplay.patch create mode 100644 0006-alsactl-terminate-readlink-result-string.patch diff --git a/0004-aplay-Fix-type-for-signal-flag.patch b/0004-aplay-Fix-type-for-signal-flag.patch new file mode 100644 index 0000000..d978616 --- /dev/null +++ b/0004-aplay-Fix-type-for-signal-flag.patch @@ -0,0 +1,29 @@ +From 9aa5c271f4eb2e3481b4a5076eb025242215ad7f Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Wed, 29 Apr 2015 18:01:07 +0200 +Subject: [PATCH] aplay: Fix type for signal flag + +A flag used in signal handlers has to be a special atomic type, +volatile sig_atomic_t. + +Signed-off-by: Takashi Iwai +--- + aplay/aplay.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/aplay/aplay.c b/aplay/aplay.c +index e58e1bcbdd7e..dfa1a0a95867 100644 +--- a/aplay/aplay.c ++++ b/aplay/aplay.c +@@ -107,7 +107,7 @@ static snd_pcm_stream_t stream = SND_PCM_STREAM_PLAYBACK; + static int mmap_flag = 0; + static int interleaved = 1; + static int nonblock = 0; +-static int in_aborting = 0; ++static volatile sig_atomic_t in_aborting = 0; + static u_char *audiobuf = NULL; + static snd_pcm_uframes_t chunk_size = 0; + static unsigned period_time = 0; +-- +2.4.5 + diff --git a/0005-aplay-Fix-uninterruptible-aplay.patch b/0005-aplay-Fix-uninterruptible-aplay.patch new file mode 100644 index 0000000..9237f9c --- /dev/null +++ b/0005-aplay-Fix-uninterruptible-aplay.patch @@ -0,0 +1,35 @@ +From 46b60827568ca4aad15eeacbc9dcf8597986ca8e Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Wed, 29 Apr 2015 18:01:58 +0200 +Subject: [PATCH] aplay: Fix uninterruptible aplay + +When aplay is invoked to play from stdin, it can't be terminated by +normal signals like SIGTERM or SIGINT. It's because our signal +handler tries to trap as much as possible while the stalling point is +not in the PCM loop but rather the file I/O. + +For fixing this, leave our signal handler once when a signal is +received and snd_pcm_abort() is called. At the next hit, it shall be +handled normally. + +Signed-off-by: Takashi Iwai +--- + aplay/aplay.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/aplay/aplay.c b/aplay/aplay.c +index dfa1a0a95867..459f7dd6f667 100644 +--- a/aplay/aplay.c ++++ b/aplay/aplay.c +@@ -399,7 +399,7 @@ static void signal_handler(int sig) + handle = NULL; + prg_exit(EXIT_FAILURE); + } +- signal(sig, signal_handler); ++ signal(sig, SIG_DFL); + } + + /* call on SIGUSR1 signal. */ +-- +2.4.5 + diff --git a/0006-alsactl-terminate-readlink-result-string.patch b/0006-alsactl-terminate-readlink-result-string.patch new file mode 100644 index 0000000..501daad --- /dev/null +++ b/0006-alsactl-terminate-readlink-result-string.patch @@ -0,0 +1,35 @@ +From 13c826941445a66ece203a09e6739c979ac5900c Mon Sep 17 00:00:00 2001 +From: Tobias Stoeckmann +Date: Sat, 11 Jul 2015 13:23:57 +0200 +Subject: [PATCH] alsactl: terminate readlink result string + +readlink does not guarantee that its result string is nul-terminated. +Instead, increase the buffer by one byte to make sure that we can +add '\0' at the end. + +Signed-off-by: Takashi Iwai +--- + alsactl/init_sysfs.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/alsactl/init_sysfs.c b/alsactl/init_sysfs.c +index 0cbada2e169b..5c789b61b0e5 100644 +--- a/alsactl/init_sysfs.c ++++ b/alsactl/init_sysfs.c +@@ -108,11 +108,11 @@ static char *sysfs_attr_get_value(const char *devpath, const char *attr_name) + + if (S_ISLNK(statbuf.st_mode)) { + /* links return the last element of the target path */ +- char link_target[PATH_SIZE]; ++ char link_target[PATH_SIZE + 1]; + int len; + const char *pos; + +- len = readlink(path_full, link_target, sizeof(link_target)); ++ len = readlink(path_full, link_target, sizeof(link_target) - 1); + if (len > 0) { + link_target[len] = '\0'; + pos = strrchr(link_target, '/'); +-- +2.4.5 + diff --git a/alsa-utils.changes b/alsa-utils.changes index 986c791..49c497d 100644 --- a/alsa-utils.changes +++ b/alsa-utils.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Mon Jul 13 16:41:51 CEST 2015 - tiwai@suse.de + +- Backport upstream fixes for aplay signal handling and alsactl + possible buffer overflow of readlink(): + 0004-aplay-Fix-type-for-signal-flag.patch + 0005-aplay-Fix-uninterruptible-aplay.patch + 0006-alsactl-terminate-readlink-result-string.patch + ------------------------------------------------------------------- Mon Apr 27 21:41:13 CEST 2015 - tiwai@suse.de diff --git a/alsa-utils.spec b/alsa-utils.spec index c608cc9..f7f3f54 100644 --- a/alsa-utils.spec +++ b/alsa-utils.spec @@ -48,6 +48,9 @@ Source1: 01beep.conf Patch1: 0001-amixer-Don-t-set-only-the-first-item-in-sset_enum.patch Patch2: 0002-amixer-expand-local-storage-for-item-name-according-.patch Patch3: 0003-alsa-info-Don-t-try-update-when-wget-isn-t-available.patch +Patch4: 0004-aplay-Fix-type-for-signal-flag.patch +Patch5: 0005-aplay-Fix-uninterruptible-aplay.patch +Patch6: 0006-alsactl-terminate-readlink-result-string.patch # Patch99: alsa-utils-gettext-version-removal.diff BuildRequires: alsa-devel @@ -78,6 +81,9 @@ sed -i -e's/EXTRA_DIST= config.rpath /EXTRA_DIST=/' Makefile.am %patch1 -p1 %patch2 -p1 %patch3 -p1 +%patch4 -p1 +%patch5 -p1 +%patch6 -p1 # %if 0%{?suse_version} < 1020 %patch99 -p1