Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp838586imu; Tue, 11 Dec 2018 08:19:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/VSn/JPSxZqZCk7Y9YzP/zj00zIHrOMvVG83232SETuxjDJBLDceIeTV+KhTC6Ugj6aF+l0 X-Received: by 2002:a62:710a:: with SMTP id m10mr16843880pfc.69.1544545184443; Tue, 11 Dec 2018 08:19:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544545184; cv=none; d=google.com; s=arc-20160816; b=uj9Yh+uJcJLHlOz6KVM9p4BmWadHLOG3bOqr45jyl4SwYe18HsQA2MLJoFC5No6QgT JRBW1CkDoJNFuXUW0OAacavEAkPsIHHI2MAtMYzUsE3MD/PVPnAEu2On+NpCkEVN9zS6 COoBZtf0Vi1/nnSv94q+GMuuaIruFpw/XT97+0UrNlHZtr1iksKVhoXLE3bV+XH6O14r R4AEMS6c9Q6jR0FwtO++cr1zG9rg0V508W32B+b3t/1kuA5idjik9FD6qotIeYzEQH9I Lj0npGBTkYYYNskZFeoSYlmUQJdGC48iu6sG0Te46T91aGljiheG59APiPCJc+nDM+0I +Sow== 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=R3WaZMNqhIwSqoaNUGza3FEYMPfCTEPjYlKD+4ZMdQY=; b=vRHBtTjgjCBhqRVybqFlv9fxP+ndT3/IUseTerHrQWi+WD3upaj6Krej6KpZ0/2urc fcH3p5NRAn39e2hdCbLPmNs/fD5Qr00qM2ucZ+EBdsH29H4Ls1w2pRFYxBiwmamTHY2V iRjEcu8gLaRaweiE17xm4ECrPWIA3idt0o6zt25AZsshP9mVLUm6HNtpnN+f0HqHObOk UKphdIGGoQ00tNQqLD/LooKB4EoGfMO+gL1EMMtlHEpR/UQqt8k1u2XCCY3wjN5HKh0P 7l2fUS8X7J1d8ht3PjEE2IoKEE4tD6SW4kU5pWuXl4TLSzhUMx+Q5DRCdpHBlTgASubI kIIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hfbGPhwJ; 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 h67si13839826pfb.146.2018.12.11.08.19.29; Tue, 11 Dec 2018 08:19:44 -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; dkim=pass header.i=@kernel.org header.s=default header.b=hfbGPhwJ; 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 S1728626AbeLKPrl (ORCPT + 99 others); Tue, 11 Dec 2018 10:47:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:36140 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728603AbeLKPrj (ORCPT ); Tue, 11 Dec 2018 10:47:39 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 9B52E20989; Tue, 11 Dec 2018 15:47:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544543259; bh=d4AmW7KN32kR5u2SlypY2SHLYWR5bzyMXGJsAOEsvtc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hfbGPhwJohAtg1pqLWFAJJTwqTjt058Y2LQzy1P3HNwEgIBHNcx1M83vnFVG3Oknx XgJ5k56iuKUraVhNGo0HVtMy4l8rshSO5lAvZREbAHl4SBUh9See4emo05xzsUl/EM rZSkpIVJTg3lr+no6lUyW9eAkrlOGP8KQc2JZPT0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hui Peng , Mathias Payer , Takashi Iwai Subject: [PATCH 4.4 73/91] ALSA: usb-audio: Fix UAF decrement if card has no live interfaces in card.c Date: Tue, 11 Dec 2018 16:41:32 +0100 Message-Id: <20181211151612.376935704@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181211151606.026852373@linuxfoundation.org> References: <20181211151606.026852373@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hui Peng commit 5f8cf712582617d523120df67d392059eaf2fc4b upstream. If a USB sound card reports 0 interfaces, an error condition is triggered and the function usb_audio_probe errors out. In the error path, there was a use-after-free vulnerability where the memory object of the card was first freed, followed by a decrement of the number of active chips. Moving the decrement above the atomic_dec fixes the UAF. [ The original problem was introduced in 3.1 kernel, while it was developed in a different form. The Fixes tag below indicates the original commit but it doesn't mean that the patch is applicable cleanly. -- tiwai ] Fixes: 362e4e49abe5 ("ALSA: usb-audio - clear chip->probing on error exit") Reported-by: Hui Peng Reported-by: Mathias Payer Signed-off-by: Hui Peng Signed-off-by: Mathias Payer Cc: Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/card.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -589,9 +589,12 @@ static int usb_audio_probe(struct usb_in __error: if (chip) { + /* chip->active is inside the chip->card object, + * decrement before memory is possibly returned. + */ + atomic_dec(&chip->active); if (!chip->num_interfaces) snd_card_free(chip->card); - atomic_dec(&chip->active); } mutex_unlock(®ister_mutex); return err;