Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1770994imm; Thu, 27 Sep 2018 02:10:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV61Kx3oUD4OQg4oEskMilr9xHvkkY4MoywpSosGuXTjwNfDvV6OAclVBUgw5tFRAzSLlJzlG X-Received: by 2002:a62:38d0:: with SMTP id f199-v6mr10397685pfa.48.1538039423792; Thu, 27 Sep 2018 02:10:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538039423; cv=none; d=google.com; s=arc-20160816; b=pHgYXgizzZdAUYdbNVC4TdxXZyetOcMsHtEi1MyU2lQhxvsi+lafb2DpydyWrvnSGa xXkuUI5Y6U59t3C2cN1MOfcOQuNdt9hbpcvYGSL0/Oo8wbHeXDDLi0oO8ZdrOMaYB94m Z/5RIYy9bqP57nrbyjkAIU+aYjTAKHSZ1x8Q/2mSAXEarhj1MY5gWCClpsOXjiHE7q2s xjC6S0KdY8pXhFjE2eYOUNMyPTx/v2keppLa5QI0QT8T/+pqHIUGynfJazTZNhNoN3ma FpwoFlD2yXCExsw8G9EvHTkyma7N4hZipkKKOsT0GalplEhAs3vd2lDWptz0mFFRUC8X f8Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=0EAZELAlHVCHmTyTQnCqZ1mqMpGPtvHO8qPbfluW8CQ=; b=uciUYXl0sDPRrrjgk5XUMjm0xO6h0P/5MWPJcO/P+5HBAeULhqyiUhCJqO4UWLJrQB uXRsHYbp6o7244QVPmaQFp0YuqhFMhHdaLl36plUwNNsZVrt+k68CDwh5dJgUxI/YC2U lrCQo6tVDZPhPVhWtiOODS9e/6O+78uEH+i6cuiKE54KNsfrSfC/S6mv+3SX4QAfklE5 n2N22yKx0VB9ARGRCFkyMrhWdG94k53mXKQHQC+8nGE55KD0M0vU9c43vB3kxmM2Cia0 x8MGNwjLTq1ItY+zTvpU0YkUPKRHrhRSmxYAeYoo7eQ6TRqCF565lOz7dNwa9/T9QAb8 rRgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y7-v6si1563228plt.112.2018.09.27.02.10.09; Thu, 27 Sep 2018 02:10:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728249AbeI0P0c (ORCPT + 99 others); Thu, 27 Sep 2018 11:26:32 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55040 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727124AbeI0P0c (ORCPT ); Thu, 27 Sep 2018 11:26:32 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4A35310A4; Thu, 27 Sep 2018 09:09:16 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Sakamoto , Takashi Iwai Subject: [PATCH 4.18 31/88] ALSA: bebob: use address returned by kmalloc() instead of kernel stack for streaming DMA mapping Date: Thu, 27 Sep 2018 11:03:12 +0200 Message-Id: <20180927090304.343972149@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180927090300.631426620@linuxfoundation.org> References: <20180927090300.631426620@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Takashi Sakamoto commit 493626f2d87a74e6dbea1686499ed6e7e600484e upstream. When executing 'fw_run_transaction()' with 'TCODE_WRITE_BLOCK_REQUEST', an address of 'payload' argument is used for streaming DMA mapping by 'firewire_ohci' module if 'size' argument is larger than 8 byte. Although in this case the address should not be on kernel stack, current implementation of ALSA bebob driver uses data in kernel stack for a cue to boot M-Audio devices. This often brings unexpected result, especially for a case of CONFIG_VMAP_STACK=y. This commit fixes the bug. Reference: https://bugzilla.kernel.org/show_bug.cgi?id=201021 Reference: https://forum.manjaro.org/t/firewire-m-audio-410-driver-wont-load-firmware/51165 Fixes: a2b2a7798fb6('ALSA: bebob: Send a cue to load firmware for M-Audio Firewire series') Cc: # v3.16+ Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/firewire/bebob/bebob_maudio.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) --- a/sound/firewire/bebob/bebob_maudio.c +++ b/sound/firewire/bebob/bebob_maudio.c @@ -96,17 +96,13 @@ int snd_bebob_maudio_load_firmware(struc struct fw_device *device = fw_parent_device(unit); int err, rcode; u64 date; - __le32 cues[3] = { - cpu_to_le32(MAUDIO_BOOTLOADER_CUE1), - cpu_to_le32(MAUDIO_BOOTLOADER_CUE2), - cpu_to_le32(MAUDIO_BOOTLOADER_CUE3) - }; + __le32 *cues; /* check date of software used to build */ err = snd_bebob_read_block(unit, INFO_OFFSET_SW_DATE, &date, sizeof(u64)); if (err < 0) - goto end; + return err; /* * firmware version 5058 or later has date later than "20070401", but * 'date' is not null-terminated. @@ -114,20 +110,28 @@ int snd_bebob_maudio_load_firmware(struc if (date < 0x3230303730343031LL) { dev_err(&unit->device, "Use firmware version 5058 or later\n"); - err = -ENOSYS; - goto end; + return -ENXIO; } + cues = kmalloc_array(3, sizeof(*cues), GFP_KERNEL); + if (!cues) + return -ENOMEM; + + cues[0] = cpu_to_le32(MAUDIO_BOOTLOADER_CUE1); + cues[1] = cpu_to_le32(MAUDIO_BOOTLOADER_CUE2); + cues[2] = cpu_to_le32(MAUDIO_BOOTLOADER_CUE3); + rcode = fw_run_transaction(device->card, TCODE_WRITE_BLOCK_REQUEST, device->node_id, device->generation, device->max_speed, BEBOB_ADDR_REG_REQ, - cues, sizeof(cues)); + cues, 3 * sizeof(*cues)); + kfree(cues); if (rcode != RCODE_COMPLETE) { dev_err(&unit->device, "Failed to send a cue to load firmware\n"); err = -EIO; } -end: + return err; }