From patchwork Mon Jan 18 13:35:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Boichat X-Patchwork-Id: 8054801 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 739A8BEEE5 for ; Mon, 18 Jan 2016 13:35:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AB3AA20451 for ; Mon, 18 Jan 2016 13:35:46 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 2C35B20445 for ; Mon, 18 Jan 2016 13:35:45 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id C39B52652B7; Mon, 18 Jan 2016 14:35:43 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id AD7F92606C9; Mon, 18 Jan 2016 14:35:19 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id C7B6226512B; Mon, 18 Jan 2016 14:35:18 +0100 (CET) Received: from mail-pf0-f182.google.com (mail-pf0-f182.google.com [209.85.192.182]) by alsa0.perex.cz (Postfix) with ESMTP id 220782606C9 for ; Mon, 18 Jan 2016 14:35:11 +0100 (CET) Received: by mail-pf0-f182.google.com with SMTP id n128so158071372pfn.3 for ; Mon, 18 Jan 2016 05:35:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UuLdF3Zn8PHpq//jc/FkSu5cJwBtKMq6JYa8yTHY0HY=; b=ieGmU4FQ//2mA9HWeZmppbi0mY3NfQS6K/Lxax6gsdtJdHE7mXI8FXMjU9QaUntMG4 QDqjMrEkotUAb5vrIvrS8DX7JiMPciQMCOyHS6ibD1l2rzXsxQi8HQxuD6DPZb5pK3YC dTBcZ0DURAtjqqViVX30VUDMW3nUZg5hCC6vo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UuLdF3Zn8PHpq//jc/FkSu5cJwBtKMq6JYa8yTHY0HY=; b=XdEHFZ2wfm0Apn0Zm+gTG8tcKmRoMnDcru+thJhuSyXE9NKI0GO9JLgRY0Nk0C8C8O Gifxh33V8XSKcmv/AsqqMihRhtjn1C4+Akufc23J2as0ziZpyydH7wLcCnM1URaclZFt lOWCOmcrqnLDu+RzVxU7PTg4e9B6CaNWmWgwhQFVIRZBHNqaL7DaHh9ZF+gOCyUIRK71 5sH4Tnq0bB8GTuuhdDGtrD4zuZjexWrRD0LwuEkm11gLSImaEDFJCP4gkvghanyab4jz ySRVkD1yizydeqBIik1HqjvjgBxO7wNVqC+urMLL0mBNkFzOftbnfeEN5+rZF4nCdYzY Z5DQ== X-Gm-Message-State: ALoCoQlHQ/mkoK2NfJEycMGjsnrruoCA/wA7UeGsIz50NEcar+gcAzMlQ1sA50SqyYMhf7Fgr5THYDr3FrXlpfyPkCsgaHXfag== X-Received: by 10.98.42.81 with SMTP id q78mr35989868pfq.142.1453124110229; Mon, 18 Jan 2016 05:35:10 -0800 (PST) Received: from drinkcat.tpe.corp.google.com ([172.30.210.53]) by smtp.gmail.com with ESMTPSA id a62sm25278416pfj.40.2016.01.18.05.35.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Jan 2016 05:35:09 -0800 (PST) From: Nicolas Boichat To: Takashi Iwai Date: Mon, 18 Jan 2016 21:35:01 +0800 Message-Id: <1453124101-3402-2-git-send-email-drinkcat@chromium.org> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 In-Reply-To: <1453124101-3402-1-git-send-email-drinkcat@chromium.org> References: <1453124101-3402-1-git-send-email-drinkcat@chromium.org> Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Nicolas Boichat , Pierre-Louis Bossart Subject: [alsa-devel] [PATCH 2/2] ALSA: seq: Fix snd_seq_call_port_info_ioctl in compat mode X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP This reverts one hunk of commit ef44a1ec6eee ("ALSA: sound/core: use memdup_user()"), which replaced a number of kmalloc followed by memcpy with memdup calls. In this case, we are copying from a struct snd_seq_port_info32 to a struct snd_seq_port_info, but the latter is 4 bytes longer than the 32-bit version, so we need to separate kmalloc and copy calls. Signed-off-by: Nicolas Boichat --- sound/core/seq/seq_compat.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sound/core/seq/seq_compat.c b/sound/core/seq/seq_compat.c index 81f7c10..6517590 100644 --- a/sound/core/seq/seq_compat.c +++ b/sound/core/seq/seq_compat.c @@ -49,11 +49,12 @@ static int snd_seq_call_port_info_ioctl(struct snd_seq_client *client, unsigned struct snd_seq_port_info *data; mm_segment_t fs; - data = memdup_user(data32, sizeof(*data32)); - if (IS_ERR(data)) - return PTR_ERR(data); + data = kmalloc(sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; - if (get_user(data->flags, &data32->flags) || + if (copy_from_user(data, data32, sizeof(*data32)) || + get_user(data->flags, &data32->flags) || get_user(data->time_queue, &data32->time_queue)) goto error; data->kernel = NULL;