Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5215101ybl; Tue, 27 Aug 2019 00:56:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEb8G1wIy1AgaAHRt8mc/JbArRL5KW9J9T+E0yr8yweqKH+2XyI6tlS/befuo/svWnLKb2 X-Received: by 2002:a65:608e:: with SMTP id t14mr20090561pgu.373.1566892564006; Tue, 27 Aug 2019 00:56:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566892563; cv=none; d=google.com; s=arc-20160816; b=p+ViDOAhJsxl7s8wXY18J4+cbOJeA5tw0mlHlrfbP8r0hIqPtjH6eJJARp/RzDrRuj ompohpauvKG9MlIbSKrACSk61phaIPlo4qjTSLTzVllDF29Ihy2ML9tPrx2wMR+xbjhD tMDWCsdB3ygHsBVurap5Fh3vB/DokcBpCP0tBL1fSfpOucUpYvJJ2/vB6mQvQqtfCtp6 EI+tA8lLTJMv1Dlvi8nDohFqs5DIJPXw4cN6nvsidG3+hyEvvl4gDZMq8X1isYK2W/iP tvsq7f19EhrXQ/lkw1GB8TSdX6VwuEoNAfMsZ2S8+ZCpOakXHXKJze1WV/44Z2sYA1Lr dblA== 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:dkim-signature; bh=Bo/LI5jha+aya91CYXA4Sgxa+vhQNBBDo3Ng4mEI+7M=; b=EKxZ3SjLzyGQrm+olygb18GBTmi/RJ84yB+q7X4gClcAZ32Q/sLSxvYefvhfvgaz1Q BRjISLmabS2naRG2iKGfltJlqTmYG5watF4m4EX8H2cmMafuRRU4bZLcwhe7mZGk2Dnx IRB2rvXU2WcS+/f8zz56u+DbPN4mpVLHNurkTRjwttLY+1A3p7cXp9VCQ/mEA2UiQALz re4AXnTlWDOY8lr3jQBn/2lRuXX/3AIr2dTzf5c+dYRHclkjk5jq5gTX+2pKs3L5124y mJnf01Z1iZI19aBe0mz17y9Xb5QFbsXATg2Tl1d+Qs/WRE/jdc6sGpcKRRZDTB7YN/Ha /9hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VEGLLcms; 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 n14si10464901plp.304.2019.08.27.00.55.49; Tue, 27 Aug 2019 00:56:03 -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; dkim=pass header.i=@kernel.org header.s=default header.b=VEGLLcms; 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 S1729988AbfH0HyI (ORCPT + 99 others); Tue, 27 Aug 2019 03:54:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:45712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729374AbfH0HyI (ORCPT ); Tue, 27 Aug 2019 03:54:08 -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 8FF2C2173E; Tue, 27 Aug 2019 07:54:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566892447; bh=CHPUc+8YmOyDGILc8fRBA/IrdQfyFvT+TJty6ANtTvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VEGLLcmsvs1mhAebduK7WPKZXZGBdt1HNMri8KMFkiVYeY6ajBnL5YSuFnCclzesy XTU9NVkH3a0ps9YlR26evAzOmyn3lC3p7jbTCCW/oeijlf2uYQHoJsqBIoZMFxJZVj iNH2ispCBmVpF7XCM/IliyUyN/TK93b8bkhqXI6c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Juliana Rodrigueiro , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 16/62] isdn: hfcsusb: Fix mISDN driver crash caused by transfer buffer on the stack Date: Tue, 27 Aug 2019 09:50:21 +0200 Message-Id: <20190827072701.285285273@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827072659.803647352@linuxfoundation.org> References: <20190827072659.803647352@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 [ Upstream commit d8a1de3d5bb881507602bc02e004904828f88711 ] Since linux 4.9 it is not possible to use buffers on the stack for DMA transfers. During usb probe the driver crashes with "transfer buffer is on stack" message. This fix k-allocates a buffer to be used on "read_reg_atomic", which is a macro that calls "usb_control_msg" under the hood. Kernel 4.19 backtrace: usb_hcd_submit_urb+0x3e5/0x900 ? sched_clock+0x9/0x10 ? log_store+0x203/0x270 ? get_random_u32+0x6f/0x90 ? cache_alloc_refill+0x784/0x8a0 usb_submit_urb+0x3b4/0x550 usb_start_wait_urb+0x4e/0xd0 usb_control_msg+0xb8/0x120 hfcsusb_probe+0x6bc/0xb40 [hfcsusb] usb_probe_interface+0xc2/0x260 really_probe+0x176/0x280 driver_probe_device+0x49/0x130 __driver_attach+0xa9/0xb0 ? driver_probe_device+0x130/0x130 bus_for_each_dev+0x5a/0x90 driver_attach+0x14/0x20 ? driver_probe_device+0x130/0x130 bus_add_driver+0x157/0x1e0 driver_register+0x51/0xe0 usb_register_driver+0x5d/0x120 ? 0xf81ed000 hfcsusb_drv_init+0x17/0x1000 [hfcsusb] do_one_initcall+0x44/0x190 ? free_unref_page_commit+0x6a/0xd0 do_init_module+0x46/0x1c0 load_module+0x1dc1/0x2400 sys_init_module+0xed/0x120 do_fast_syscall_32+0x7a/0x200 entry_SYSENTER_32+0x6b/0xbe Signed-off-by: Juliana Rodrigueiro Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/isdn/hardware/mISDN/hfcsusb.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/isdn/hardware/mISDN/hfcsusb.c b/drivers/isdn/hardware/mISDN/hfcsusb.c index 163bc482b2a78..87588198d68fc 100644 --- a/drivers/isdn/hardware/mISDN/hfcsusb.c +++ b/drivers/isdn/hardware/mISDN/hfcsusb.c @@ -1701,13 +1701,23 @@ hfcsusb_stop_endpoint(struct hfcsusb *hw, int channel) static int setup_hfcsusb(struct hfcsusb *hw) { + void *dmabuf = kmalloc(sizeof(u_char), GFP_KERNEL); u_char b; + int ret; if (debug & DBG_HFC_CALL_TRACE) printk(KERN_DEBUG "%s: %s\n", hw->name, __func__); + if (!dmabuf) + return -ENOMEM; + + ret = read_reg_atomic(hw, HFCUSB_CHIP_ID, dmabuf); + + memcpy(&b, dmabuf, sizeof(u_char)); + kfree(dmabuf); + /* check the chip id */ - if (read_reg_atomic(hw, HFCUSB_CHIP_ID, &b) != 1) { + if (ret != 1) { printk(KERN_DEBUG "%s: %s: cannot read chip id\n", hw->name, __func__); return 1; -- 2.20.1