Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp808058imm; Mon, 21 May 2018 14:53:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqpVMymF7ywf7NazTLw0fMJa6yxtgEhe0vxklAzvZHRToRQ04nEe7tEu8LUqA8PLv4dLa0U X-Received: by 2002:a63:7405:: with SMTP id p5-v6mr16809185pgc.289.1526939621589; Mon, 21 May 2018 14:53:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526939621; cv=none; d=google.com; s=arc-20160816; b=pE92euf0n+OcsXzcZ3RCbM4nnkAvGLsDgXtwXGbXY8CdBC16TRxkxFjPldbC6R61U5 Lz+fZ9adJe4fLNZi0myaOtUIidNKG2Ue5kSu/bQlAhjmHAy8YUrqwIg4lk0X2jqY29lU 7yZQ6N7XXPL0EZACrSs0wFjp92H6tzr3YR+XUlcWF6loFpIbB4wJAEwp6Pki85gouIes ghAYYOds/UmQ8z+sNKKvKgEm2d8UIbf+o6yli9Nmwop9P2Fu39qXSWp6szu0p9pJ2bbf qqkzZLStdP/5wuJ6kcGSUjoYnWfY2mofKc3A6mYkl+Wl3rjYuNkdeBCtrJt6OwlO0m/q c+Ng== 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=k7HynXXsru5C685nrWOFZtB70800dcuLfgYRr6Qyw/Y=; b=F3AqAegX7gHYcmiZDjbYKB0WtkdbVCCof5YW66qUbTmRbLBIMBBsY3/BCQ/ZpxepoV lByoh5M6snGqXY925ABlawLZceC1a2cspzc0Y97ak7h1RNCZ5fWWDoZ0p2WrFKDQMmia 5EiMNDnHeTiU8qabDCMdk6nUcikiTyvTbX5gnEs+PyFXJ2nlxTDBIc88NbIlsicK5+Fg Iqu8dJ/IlkCNn11IXSppXHIAbxIfcVNOVJhwL9/rTvIhIW59D46s9K+BayWU4erkEhFp az1YosBPuKP2TD1RX2OaRGjuZzvzp8060oEvoTyP9UM3xSgWsoZioXAUlkvO/dwr/Pn+ WYEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dysU08PY; 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 p10-v6si14614413plk.295.2018.05.21.14.53.26; Mon, 21 May 2018 14:53:41 -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=dysU08PY; 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 S932096AbeEUVxL (ORCPT + 99 others); Mon, 21 May 2018 17:53:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:37278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754210AbeEUVWY (ORCPT ); Mon, 21 May 2018 17:22:24 -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 D78712086B; Mon, 21 May 2018 21:22:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526937743; bh=UcEBkTZ6LBZn6vrHYhDRgxyqwsMUtQX8MCsQMRJHBm4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dysU08PYSM1oTfmN6FnefvQfgW8WQVdDhS9+9pRkh3wpOw847cL17XD8ufrxcEwZ5 pMEGVXq+mQdr48GR6KeVxBoSuGw3rcLnIDoTAVXTKSbFGvtvjJ1gf4iSOroOxKNntj Xg1zPmP2EMf3G5N+0jZVRnuDcBA98QQRmq5zao4w= 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.16 010/110] ALSA: control: fix a redundant-copy issue Date: Mon, 21 May 2018 23:11:07 +0200 Message-Id: <20180521210504.859966499@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180521210503.823249477@linuxfoundation.org> References: <20180521210503.823249477@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.16-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 @@ -396,8 +396,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: