Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2065872imm; Thu, 24 May 2018 05:18:59 -0700 (PDT) X-Google-Smtp-Source: AB8JxZokIWFuus+IAwX4xzDp16B6dPIB5z9RLP+gos2StrKJUfl/Apn5VBesk5tZK3S8Mv1j7jQO X-Received: by 2002:a62:d905:: with SMTP id s5-v6mr7132718pfg.20.1527164339442; Thu, 24 May 2018 05:18:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527164339; cv=none; d=google.com; s=arc-20160816; b=pjQzJ55YBt46x6fTXugAdaBYIYmQlF4mO+cS9PalUoY6yk2Kryvg1VtENAEbdzuOZO Ta3TfN/80/D3MT/Yvv0hlqKpYVkeRDctcHoq9zniXHu/LnCsQRhoc9EVYXp6vvL8GuPC TNVdvGSggSRgJh537oVc5cETriHN2+97QBJUliyFl2FHoskHFFQ/h+C9T/CheQo33o81 GhLGMnIc4fxLo6MCZkD5uSlB2VVy4/+KIlTtCEpv34sJf0QbEhgVe7Uo8fep1vbogW3x g1lvJgAuPEEbmtH3OIAn3h94f5oamIsr41Tk+mDxlnO9mnPOtKbX5EuXfc/5O0g2niZD 11dg== 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=nHkXPnsOx42N3ORI0Y/txcL8i0CWVMA/HmpzW943MeI=; b=KYcTHV0heuP6Ounid2BB0933qOAodJ/69TvNhHAaxDwjP1Of4wkiM+VA8Rh/SLoI5Z ZDbh4VQWNVwAFbJz+m81VR2FWOLUB8j/e9ggrcQtxprRl6f7i0OwzHBuypHHph2qdjJt T78xK6UM4Z0ecdy36O/b46KQuyTnSAT/3J4vCKrQ6je84Ni2OdFVqVtEHpAsg1SRrBF/ ayKIUVqALsYCnKAk8PFxQsgFjDU38i3hW9GiFIiOlv+5EjSxlZ9+QcUQMmlhUEjU4MBQ K+zI8ctqmfDYUIxek3Mz2lhSLqzqh2yftB3ZAfas5tl+R85uCfjL7Q2TKf6N2fZ6XbLe U9hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pUrJWiKO; 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 i1-v6si11726plt.183.2018.05.24.05.18.45; Thu, 24 May 2018 05:18:59 -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=pUrJWiKO; 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 S969935AbeEXMSE (ORCPT + 99 others); Thu, 24 May 2018 08:18:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:53564 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966040AbeEXJlp (ORCPT ); Thu, 24 May 2018 05:41:45 -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 269762089A; Thu, 24 May 2018 09:41:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527154904; bh=NPuPhjl7nxV8RL3wqDhWr7pSaibu+CHfXfHjdpGVxyA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pUrJWiKOTKXEmGNlub6PEOWrmxACnQWYidnel5+Jc3+6T+XTQNv4WUqj0k9i8ajuc J/ZqM9Zv/docH0B+S3TpTM38MxsFHVbd2o3m8DnwByKVv+i088JIstqRPpoO/Hl+Jp uqqrC5y7meKiJscQvcqxWBYfXZb5ndG6HDyCgOgc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wenwen Wang , Takashi Iwai Subject: [PATCH 3.18 30/45] ALSA: control: fix a redundant-copy issue Date: Thu, 24 May 2018 11:38:38 +0200 Message-Id: <20180524093124.446378576@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093120.599252450@linuxfoundation.org> References: <20180524093120.599252450@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 3.18-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: