Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1778224imm; Thu, 27 Sep 2018 02:18:36 -0700 (PDT) X-Google-Smtp-Source: ACcGV625GnCIISHHTiCMyL8Hl7b7ha6S1qLcI2UdkwkQbhEU4YIKGV/tSS54wCGneIE54V6/4VSN X-Received: by 2002:a62:cd3:: with SMTP id 80-v6mr10458360pfm.184.1538039916807; Thu, 27 Sep 2018 02:18:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538039916; cv=none; d=google.com; s=arc-20160816; b=doV7RN3ULLtOePJwfbfl0WvZdbktopGqIbICtYJaPVP0Qy567MnTCJUK3M93oaXzqR S6DKdmnS0Em4EbJB/lfffulosH8hVlDYWvNYh14QS7APojQhjAy21Vwd7ptTngNTQIck wKRhOEOsD82X0OPTfSpXwRf2o/G3/Ij7dznsoAUGhqarxDKkUoXglCaYw8zPoO/vWw6h yH4KQu/Krv4PDxtT8uQeR/HM1KtLaVRFdG2msOrVE9+vQo/K/aqAzjthm5/BePU5fRo+ hJuH66L5I52IL9OpmvRcMQzJgpTFYynx52VC26stUITPTW+I+tkxbEXGzcU7AFJbn/8e BpzQ== 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=QtIKyetG7si54ZLd3DhBqTw+8nVQxYUtS8FMrjnrXFA=; b=fTe0bAB2zk0eSx2/NXJJV4tjYALBZB7NPKoBpxpPFoMyt6Ubw7yjI+dsI0zhIR2pfR Dh9ZVHO7T+0+MoDkO83C9SIUd9qnZ/U6OrcTg+HbyAZ1KDBoY7bto16QdWGcHnt1IcQ2 6n4Je/YO9O0iQG/bNRJHtaFCGTEdsfLmV+bEi8iv3rTVpyx8PI5P7/zyKaVRcTXUnRwp 5TX2A0KtPvVF76hv53RWeJhZRzihU5+THJ4v/kzaih07d0PkL+rUjGDwAfKRHcPMK77W opeAzKo7urtGafaW9D9EdAnDZQyAs1blhQVNNS+PY+jbeW++/LPSaRTO9TmyqZ/bNZ3f qNUw== 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 p3-v6si1503868pld.329.2018.09.27.02.18.21; Thu, 27 Sep 2018 02:18:36 -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 S1728436AbeI0Peu (ORCPT + 99 others); Thu, 27 Sep 2018 11:34:50 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:56048 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726944AbeI0Pet (ORCPT ); Thu, 27 Sep 2018 11:34:49 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4003B1115; Thu, 27 Sep 2018 09:17:30 +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.14 19/64] ALSA: bebob: use address returned by kmalloc() instead of kernel stack for streaming DMA mapping Date: Thu, 27 Sep 2018 11:03:36 +0200 Message-Id: <20180927090252.531361548@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180927090249.801943776@linuxfoundation.org> References: <20180927090249.801943776@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.14-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; }