]> www.infradead.org Git - users/jedix/linux-maple.git/commit
ALSA: seq: Fix leak of pool buffer at concurrent writes
authorTakashi Iwai <tiwai@suse.de>
Mon, 15 Feb 2016 15:20:24 +0000 (16:20 +0100)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 26 May 2016 22:45:04 +0000 (15:45 -0700)
commitee60544d54e5c109519244d6377a1f4e69d2afd6
tree9cb49c37f56d22e94f6e9edfbfe7d37aa8f71a9d
parent11c80661cf9a493adcfe549bb942b318099de592
ALSA: seq: Fix leak of pool buffer at concurrent writes

Orabug: 23330863

[ Upstream commit d99a36f4728fcbcc501b78447f625bdcce15b842 ]

When multiple concurrent writes happen on the ALSA sequencer device
right after the open, it may try to allocate vmalloc buffer for each
write and leak some of them.  It's because the presence check and the
assignment of the buffer is done outside the spinlock for the pool.

The fix is to move the check and the assignment into the spinlock.

(The current implementation is suboptimal, as there can be multiple
 unnecessary vmallocs because the allocation is done before the check
 in the spinlock.  But the pool size is already checked beforehand, so
 this isn't a big problem; that is, the only possible path is the
 multiple writes before any pool assignment, and practically seen, the
 current coverage should be "good enough".)

The issue was triggered by syzkaller fuzzer.

BugLink: http://lkml.kernel.org/r/CACT4Y+bSzazpXNvtAr=WXaL8hptqjHwqEyFA+VN2AWEx=aurkg@mail.gmail.com
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Tested-by: Dmitry Vyukov <dvyukov@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
(cherry picked from commit d26d8b485d21ecc9e466b2a1e02c5962e46624de)

Signed-off-by: Dan Duval <dan.duval@oracle.com>
sound/core/seq/seq_memory.c