Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3533560pxj; Mon, 24 May 2021 08:50:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYvb04X8EEEYhxF5fnYPi7S/FOwrvjrp/SXAb6hPzj2OyNH2qORVlk+RRPQzXEw8RMSLNW X-Received: by 2002:a05:6e02:1d15:: with SMTP id i21mr17167303ila.2.1621871427944; Mon, 24 May 2021 08:50:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621871427; cv=none; d=google.com; s=arc-20160816; b=Zvy3hcha7vxTmqyujXr8u3mcRLsYwOonTpE3/RhXkYR4VmQAATiOfuYtjfT5TdAnoT 8FU8gjsGbrYYGf48ehnU2FF0dCvoa4UvpC6QNRIYVxGOdtbfNzprVdf0Gn74DcC+Mcd0 h9jqV1DXre6gyPDVWKGyJE0XcowhaSEhm5jtr11C9HEOR1+WZD6oGIhPfnSZyHwqsA19 8gYy/L0J9dZNOHtr9HyuxD0/yDgP3O5FjG3L7kFNesmiY5velReEEaQ6ax3kare+KLm6 aMqZHcw2pMOWEmP4KPmGLWmq2mg1cKSxrilTF8OZjDxyT6TlVMLJw91ei7ge4aw1y6nc pcpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sCsJMqZZL+xnFL11V8XBk8nEY+ZhHqEhpQM9AUF/O8Y=; b=LW6f8TYCVbZk1f7MiN6IGNwZV9x9/idEaGrU9jht5IQ+xpY/Nlroc5ouslV+dpS2Um HdHT9dkyY+j/UOk7PNRzEDXQL/M4uCihWwLq1p9gc0g9EajWkgcb0ZTMCwXXV+c0dSKY dv2U/MYNHEuTGtdDvX9rTXcQjwCYuTBtC8KrJ+MmR27+eQd2ZQI8rVXb20+e2CYhkEBQ stuNTWl5IA5hPiwtOhO/iSQQ7xSxzqk7OS8ZFKNm8PDWVGEBCQOBawVQ7DHAdFHbFAcD 3X2HJZQUVwsNg5mhlXGNcqdI8Cmx8yb1uD6O2V4CDf0RYyhFcEwH7qDRQdyF/44l8+vz gB8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tLtR3aZl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p4si3594184ilc.63.2021.05.24.08.50.15; Mon, 24 May 2021 08:50:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tLtR3aZl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233746AbhEXPu6 (ORCPT + 99 others); Mon, 24 May 2021 11:50:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:33832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234458AbhEXPoT (ORCPT ); Mon, 24 May 2021 11:44:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EE27E61459; Mon, 24 May 2021 15:35:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870547; bh=tywuVpsBa54mstaL/qFQ2+4aWD6/O9g35IwRrgFX5HM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tLtR3aZlqGu3wJydQHFIiSOn9Fp3P+k98vlZx8Srh870fCwJIqQEcNgFeC1eUliDE BSep7yOmhSR8a9eEihOztOYIF3ucsLwv2nlNtz/awVKwJe5CawuCwTFW9MTW85m3K3 1Bj2Wj45ATJZuE+nywCP8WhkTBHgvYpjAQHNAohM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hyeonggon Yoo <42.hyeyoo@gmail.com>, Takashi Iwai Subject: [PATCH 4.19 12/49] ALSA: line6: Fix racy initialization of LINE6 MIDI Date: Mon, 24 May 2021 17:25:23 +0200 Message-Id: <20210524152324.783224297@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.382084875@linuxfoundation.org> References: <20210524152324.382084875@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Takashi Iwai commit 05ca447630334c323c9e2b788b61133ab75d60d3 upstream. The initialization of MIDI devices that are found on some LINE6 drivers are currently done in a racy way; namely, the MIDI buffer instance is allocated and initialized in each private_init callback while the communication with the interface is already started via line6_init_cap_control() call before that point. This may lead to Oops in line6_data_received() when a spurious event is received, as reported by syzkaller. This patch moves the MIDI initialization to line6_init_cap_control() as well instead of the too-lately-called private_init for avoiding the race. Also this reduces slightly more lines, so it's a win-win change. Reported-by: syzbot+0d2b3feb0a2887862e06@syzkallerlkml..appspotmail.com Link: https://lore.kernel.org/r/000000000000a4be9405c28520de@google.com Link: https://lore.kernel.org/r/20210517132725.GA50495@hyeyoo Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Link: https://lore.kernel.org/r/20210518083939.1927-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/line6/driver.c | 4 ++++ sound/usb/line6/pod.c | 5 ----- sound/usb/line6/variax.c | 6 ------ 3 files changed, 4 insertions(+), 11 deletions(-) --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -705,6 +705,10 @@ static int line6_init_cap_control(struct line6->buffer_message = kmalloc(LINE6_MIDI_MESSAGE_MAXLEN, GFP_KERNEL); if (!line6->buffer_message) return -ENOMEM; + + ret = line6_init_midi(line6); + if (ret < 0) + return ret; } else { ret = line6_hwdep_init(line6); if (ret < 0) --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c @@ -420,11 +420,6 @@ static int pod_init(struct usb_line6 *li if (err < 0) return err; - /* initialize MIDI subsystem: */ - err = line6_init_midi(line6); - if (err < 0) - return err; - /* initialize PCM subsystem: */ err = line6_init_pcm(line6, &pod_pcm_properties); if (err < 0) --- a/sound/usb/line6/variax.c +++ b/sound/usb/line6/variax.c @@ -217,7 +217,6 @@ static int variax_init(struct usb_line6 const struct usb_device_id *id) { struct usb_line6_variax *variax = (struct usb_line6_variax *) line6; - int err; line6->process_message = line6_variax_process_message; line6->disconnect = line6_variax_disconnect; @@ -233,11 +232,6 @@ static int variax_init(struct usb_line6 if (variax->buffer_activate == NULL) return -ENOMEM; - /* initialize MIDI subsystem: */ - err = line6_init_midi(&variax->line6); - if (err < 0) - return err; - /* initiate startup procedure: */ variax_startup1(variax); return 0;