Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2050384imm; Thu, 24 May 2018 05:06:20 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrQjJtY72NYIHpuJsMW8O6RxSM7DXET04xyIpKLkXeVpxHsndEpTe9lfxjx6y9QzoGivK2F X-Received: by 2002:a65:4146:: with SMTP id x6-v6mr5590817pgp.86.1527163580023; Thu, 24 May 2018 05:06:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527163579; cv=none; d=google.com; s=arc-20160816; b=ehnQ7K/YENCREuWtVF5bbRhp/mM+rTYkA3rr5Wk1+TV9BKvBdTSLh2/2RmCbdwhlxP 3Fg45enLIJ+7vtcneKdL6CEv9A8jpEJpbvRaGEEKfPP34ybQ5hFi85WifEYv+9utsAz+ PrB2Eet45GYyioLX1sKitn+a5v3Mx/sK7nekTxl1gpThrDuQyJNwCdWtPhA0JUDyO96v iyuUBUhy40GUM3HK1iUuE3PFjSTRkqUYXGyI94UBM/IHvH0afpl+23yRf0PrWdPe91oN CvNz88juB4AHb9B7ZLDRbhiAkvIIHlE+8JcOWMUAy2pyrr3X0IEofuxk45Tuj8ga7Uy3 wX5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=ImOpb9IsXwZrPqy2oJryP+YuBx6WNDTXFcUNOGqJAYk=; b=kAlK3EnLVwhh0DKaP9Cho6Yma8IYnvXG6Q1wV2jUbjlt0opfghyUa97hdpn4cz58lQ GgauaEutwthVynN7xxNoN2Wfh5+t9YwgKZJARaHHMoRUTpEqv7950aTHL896A2pikoyH fGcHMKM/K9IyHwNiafsq18BuaitAcZoVTGurLuxcS2aiXcHuvQnygHLNfkJRXVd5cLt5 ApJdCQ02kjK8A+7zUDbeuUrk998nhhXUsqxdK+jokPwbyUt/i/sfXrcRhLVYJUsOjwGO C7TOkkOUFJqn1SG8ScTQxympcDsvrVJcZOVEu1gKIfesPsYIYpNNFZ0AQItBVbtpDzrm 7A0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E0or0X8K; 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 y5-v6si19982089pfe.134.2018.05.24.05.06.04; Thu, 24 May 2018 05:06:19 -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=E0or0X8K; 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 S966653AbeEXJo3 (ORCPT + 99 others); Thu, 24 May 2018 05:44:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:55706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966176AbeEXJoX (ORCPT ); Thu, 24 May 2018 05:44:23 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 B676A2089F; Thu, 24 May 2018 09:44:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155063; bh=1lrNLc8aPYrtSVUMVDOvCmyrbz9/Q37Xs0DXnM+I70M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E0or0X8KnYAYMrMcE3GbB4qkRY3ucSVea6bjvqCZLceOwf93LckwV5maN0G7XdfcH OFfEy79DDWX1JSSeH/DGDWyex5JQTDiyp28405ycnizBXaAdELXCNisMvmKYmcN3Ke /MHl1ajh6qgP3ZzmXq2Zq/Re/o1QUpQ5wnPotV30= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wenwen Wang , Takashi Iwai Subject: [PATCH 4.4 40/92] ALSA: control: fix a redundant-copy issue Date: Thu, 24 May 2018 11:38:17 +0200 Message-Id: <20180524093202.831019751@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093159.286472249@linuxfoundation.org> References: <20180524093159.286472249@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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: Wenwen Wang commit 3f12888dfae2a48741c4caa9214885b3aaf350f9 upstream. In snd_ctl_elem_add_compat(), the fields of the struct 'data' need to be copied from the corresponding fields of the struct 'data32' in userspace. This is achieved by invoking copy_from_user() and get_user() functions. The problem here is that the 'type' field is copied twice. One is by copy_from_user() and one is by get_user(). Given that the 'type' field is not used between the two copies, the second copy is *completely* redundant and should be removed for better performance and cleanup. Also, these two copies can cause inconsistent data: as the struct 'data32' resides in userspace and a malicious userspace process can race to change the 'type' field between the two copies to cause inconsistent data. Depending on how the data is used in the future, such an inconsistency may cause potential security risks. For above reasons, we should take out the second copy. Signed-off-by: Wenwen Wang Cc: Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/core/control_compat.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/sound/core/control_compat.c +++ b/sound/core/control_compat.c @@ -400,8 +400,7 @@ static int snd_ctl_elem_add_compat(struc if (copy_from_user(&data->id, &data32->id, sizeof(data->id)) || copy_from_user(&data->type, &data32->type, 3 * sizeof(u32))) goto error; - if (get_user(data->owner, &data32->owner) || - get_user(data->type, &data32->type)) + if (get_user(data->owner, &data32->owner)) goto error; switch (data->type) { case SNDRV_CTL_ELEM_TYPE_BOOLEAN: