Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2579728imm; Thu, 16 Aug 2018 11:51:10 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyWPC92SV7owWQhv5nIWQueZdjZie0m4cPvmnBXjlKjJ4qQXROQjKaGidD/HkUTsflk3EGy X-Received: by 2002:a17:902:6907:: with SMTP id j7-v6mr30248901plk.323.1534445469985; Thu, 16 Aug 2018 11:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534445469; cv=none; d=google.com; s=arc-20160816; b=QDW06HUf/vlFE+JuhL60kGhFnKLJV67nGvp4CjEYqtL8ajYFmLjTM2WvJ3b6+zQVQa YdzDQdQ3wrqOnE/NCv2U13647qP5kqn8Ba6z6eHC+UDRU1GroEJkXFi1337WxUzb4b6x XyuZE8HovvocplcgJJcEfl7FkxDKoytw9UWDrc/2vA5SfXAb61MIE+2RKH3w4blKdlJO SuoJ4BpJbDjcdszFOBQUxgCLeqCon/pKAZrSmmrfGs3XukP45DgA0ZV+j547MdZ63VQz 42gOtojIYAXqRsh3eqecUs6S+NP83GUg8RGsdZYrvUpEZbC6RN9KYqejGiaJHblfwZXT VTtQ== 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 :arc-authentication-results; bh=HMKD/VkzpADtR7dzR3HyY223WyY8q5/5zjxf7kBQ3gY=; b=ZD2hyW0WKwDtpo7zhCI6YFAZAUWDo8wLtEqowJD29fdQ258GKgMc9J/pGQNTxDB64h lNIVUobulGxtDUHlnmhPbal5zNX5vuN6Ayu2GcHFRbiRo9Yy4UIbwR04xwNd/3vOni9W lz/Di48jAirypAbIPJ68Pq8vFnd91r9hYFqzMqvQDkFzFx1mdKk86A4H71W3PKX00wID A/GHhP9E1NZ5t1vOKHJwt3UYfrAkoOHqZRXa4fstjNwfqDGBJnGh/ez/hoN1AnXEG7he AWihTJTj1lG0XrCxZBJC0wjkjqgA20tNV25p7ceDIYneubTrRnL8ImHsb5Qp//SqZGwz rxQw== ARC-Authentication-Results: i=1; mx.google.com; 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 b7-v6si70680plk.29.2018.08.16.11.50.55; Thu, 16 Aug 2018 11:51:09 -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; 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 S1728644AbeHPVmv (ORCPT + 99 others); Thu, 16 Aug 2018 17:42:51 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:56162 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727674AbeHPVmu (ORCPT ); Thu, 16 Aug 2018 17:42:50 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 5F0A5CEB; Thu, 16 Aug 2018 18:42:42 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Siqi Lin , Erick Reyes Subject: [PATCH 3.18 07/15] ALSA: info: Check for integer overflow in snd_info_entry_write() Date: Thu, 16 Aug 2018 20:41:44 +0200 Message-Id: <20180816171633.819923543@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180816171633.546734046@linuxfoundation.org> References: <20180816171633.546734046@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: Erick Reyes Commit 4adb7bcbcb69 ("ALSA: core: Use seq_file for text proc file reads") heavily refactored ALSA procfs and fixed the overflow as a side-effect, so this fix only applies to kernels < 4.2 and there is no upstream equivalent snd_info_entry_write() resizes the buffer with an unsigned long size argument that gets truncated because resize_info_buffer() takes the size parameter as an unsigned int. On 64-bit kernels, this causes the following copy_to_user() to write out-of-bounds if (pos + count) can't be represented by an unsigned int. Signed-off-by: Siqi Lin Signed-off-by: Erick Reyes Signed-off-by: Greg Kroah-Hartman --- sound/core/info.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/sound/core/info.c +++ b/sound/core/info.c @@ -253,6 +253,7 @@ static ssize_t snd_info_entry_write(stru struct snd_info_buffer *buf; ssize_t size = 0; loff_t pos; + unsigned long realloc_size; data = file->private_data; if (snd_BUG_ON(!data)) @@ -261,7 +262,8 @@ static ssize_t snd_info_entry_write(stru pos = *offset; if (pos < 0 || (long) pos != pos || (ssize_t) count < 0) return -EIO; - if ((unsigned long) pos + (unsigned long) count < (unsigned long) pos) + realloc_size = (unsigned long) pos + (unsigned long) count; + if (realloc_size < (unsigned long) pos || realloc_size > UINT_MAX) return -EIO; switch (entry->content) { case SNDRV_INFO_CONTENT_TEXT: