From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE943C433E0 for ; Tue, 23 Jun 2020 20:56:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B87A620768 for ; Tue, 23 Jun 2020 20:56:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592945768; bh=pC3hyyQkxUMnEIbm46tMZ4mv5JdI1vuRJK1PTOlTq9E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=NCIpbcwf8hpjqtAQLjktPicYsrPJCFq3sJLreGcAW7m+yKIoQDpsI0x7FTUa/rTqo BLdMtqAHVyhYwWmGwKdL2QCLhI0QCJH0UDLTI7JYkKuRnoEA+ETf31z8SrrSzJAwqy KY/dWLOlI+kWIXJzmHo1sO70fD04es0QmOwmcmsc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392255AbgFWUoA (ORCPT ); Tue, 23 Jun 2020 16:44:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:40856 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403935AbgFWUnv (ORCPT ); Tue, 23 Jun 2020 16:43:51 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A2E782053B; Tue, 23 Jun 2020 20:43:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592945032; bh=pC3hyyQkxUMnEIbm46tMZ4mv5JdI1vuRJK1PTOlTq9E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wtXlF43+e2f8dvbKAyX3tBuC3XawFYyTSn6x/YyvbcrcNYJNi7XNSiJp0W5UDH6p/ jKEpCxwg5U4JEznBKFVMgJ+1N4A3xPFof+faWB2Y3t1WFl7CfPEAMan1oIoGWYCX9d lZILWjA9l/+cwANncpfFFe1z/NtRSA+mTPI8M+G4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Takashi Iwai , Sasha Levin Subject: [PATCH 4.14 013/136] ALSA: isa/wavefront: prevent out of bounds write in ioctl Date: Tue, 23 Jun 2020 21:57:49 +0200 Message-Id: <20200623195304.285450650@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195303.601828702@linuxfoundation.org> References: <20200623195303.601828702@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit 7f0d5053c5a9d23fe5c2d337495a9d79038d267b ] The "header->number" comes from the ioctl and it needs to be clamped to prevent out of bounds writes. Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/20200501094011.GA960082@mwanda Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/isa/wavefront/wavefront_synth.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c index 0b1e4b34b2996..13c8e6542a2fc 100644 --- a/sound/isa/wavefront/wavefront_synth.c +++ b/sound/isa/wavefront/wavefront_synth.c @@ -1175,7 +1175,10 @@ wavefront_send_alias (snd_wavefront_t *dev, wavefront_patch_info *header) "alias for %d\n", header->number, header->hdr.a.OriginalSample); - + + if (header->number >= WF_MAX_SAMPLE) + return -EINVAL; + munge_int32 (header->number, &alias_hdr[0], 2); munge_int32 (header->hdr.a.OriginalSample, &alias_hdr[2], 2); munge_int32 (*((unsigned int *)&header->hdr.a.sampleStartOffset), @@ -1206,6 +1209,9 @@ wavefront_send_multisample (snd_wavefront_t *dev, wavefront_patch_info *header) int num_samples; unsigned char *msample_hdr; + if (header->number >= WF_MAX_SAMPLE) + return -EINVAL; + msample_hdr = kmalloc(WF_MSAMPLE_BYTES, GFP_KERNEL); if (! msample_hdr) return -ENOMEM; -- 2.25.1