Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2971112imu; Sun, 9 Dec 2018 13:59:46 -0800 (PST) X-Google-Smtp-Source: AFSGD/WQi/FRf3V7zvW1h+P0mprwV7i22jdU2k3J3RygEbaSt88E96/IDyE7zma4wTcxyqQqbt0n X-Received: by 2002:a17:902:a83:: with SMTP id 3mr9201324plp.276.1544392786004; Sun, 09 Dec 2018 13:59:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544392785; cv=none; d=google.com; s=arc-20160816; b=U4Hz2lBAqRPZ0U78UOwj1SzWLYPMlU0rf8IwMnXIsjVCvsJket/jd97He0htHtzZ6V LttcIVlcLAvcnUdtaL28+N3cWFAAKPqt/4hWU4fL3fZpdxU6XToa3+WX+BRJGsMuWIaf 5wKUUWuSOBCdxQTWQEI2BMfTI4hR//JHCAXYDhJIn6+yOPQCyhBUbird3uGtm8+XGWZm 47w1cwsmk/yyUBhh5CUK2yIUDX7mo2ahRcOpzacfB5C358FY9KQDcwJo/PHc4YVs7kId jnGCxEVs1G4GT0gWwn30QPL6BCFkOj+L+qVRABcPoPurpWvgyI5CE5S7GMSidNpbFlis ZCvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=YStu9h7DCOS8bumaVpGoWj+mk2OnZUprfG+a+M35Biw=; b=UoVchKqj3KY+UIIE67Nj1STlgiezJgUhbsDows9s5+f9BSWbBcRFnqH5QT5/BUPxmc X/Drv4xbjJlCbcOG2WGvx7PWoq0zYWU4X37ch+9RfAz2jjhsnfbofGmaWTP13z5FMF0F RSgHFU3Uk5mWveKIzCEA5cJQxllpJ6L03X5LlZ6ioU1U+2fUH5n/H3Xl6r0RxoU168LM XXRlTRn7v7QduiLt+Eww62Yi1r53lJT8w/A69KmiXqzqydCaKfqfIsF3apqJmumAdRta ZUgE865SxhK0TpFBYAkYopVI9wN4I5e0ChYqGY182LV+suZMM8y+huz1+JZzWGTp4S4p 2iMg== 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 j3si8170783plk.199.2018.12.09.13.59.30; Sun, 09 Dec 2018 13:59:45 -0800 (PST) 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 S1726925AbeLIV6M (ORCPT + 99 others); Sun, 9 Dec 2018 16:58:12 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:36280 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726762AbeLIVzj (ORCPT ); Sun, 9 Dec 2018 16:55:39 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW730-0002ii-BF; Sun, 09 Dec 2018 21:55:35 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72h-0003YY-Bv; Sun, 09 Dec 2018 21:55:15 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Takashi Iwai" , "Takashi Sakamoto" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 227/328] ALSA: bebob: use address returned by kmalloc() instead of kernel stack for streaming DMA mapping In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 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') Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai Signed-off-by: Ben Hutchings --- 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; }