Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2474048imm; Mon, 24 Sep 2018 05:07:31 -0700 (PDT) X-Google-Smtp-Source: ACcGV63aVl9AYfAJRdLJoMoJsik6e0TtLBaq4tZNjlGJhEN5EwUu2FLr30KX+opkS/kIMLT84xgm X-Received: by 2002:a63:5204:: with SMTP id g4-v6mr9287021pgb.274.1537790851530; Mon, 24 Sep 2018 05:07:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537790851; cv=none; d=google.com; s=arc-20160816; b=x/uA/I8UscNTvNG+IwFr0uT7bcKAfZhWSMBINLP6xNj8qyCFCHloPYmJWD9ldW6Chx omoRRVMH0TaBKiPokVYJldE11IflDZmRPayljlUC+IE96SKe8gxjaY962ZWdLvpcLJxD A/JwacPp4tO8CSxr6dsJ5i4Oo1KHrBIqqwN5G6QRVpF6DcKx7WMsC2WR0oG24gavMMVT 3hIGlKh/9G2yROXa9ku8wC3VCNVYVLuIN8mjLUfGj8m+1YTAh9FMBSXGk0gMmpPHEJWr 77l4v4vb8SZ6CNZ9YmC6lv6R7rTJpt0qBb0D8Uw4+M98x+x1P28cZ9OeN9QsUiMU+v9B hzfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=e6drtprkODNJ2lZM0BOicxdHz03ReZMQEw6XVhrGd9U=; b=d1tWu0usc83nUJKYTz6cAXKjPIBIXCa5JMGVVuCZ4f2cm7QzuamFABq0lZiR55TMCE QDcxDP0aFWAHr22GWF7t9Cpu2UHETA7OHEtPEfQV5V8jlWcyb4U/A3uZsA8HN7pavzM2 L8pNFEV13YRplXDDXlYYP1SlZhVhl8kd0WtiCd1SypTO7vS5iScbW165BpsLPd3jBxNO SqsAl6SyENrNl6+1f6Wt0g6v7fdgENAxtFuZ1RpDM30isvXsdb7Z4EQwN6NgIThBGe0f rCSR9vG1AcnmqjxKxQQAm0aIAWhuwcyDSTeGGwdSy0rBEcvbnr53F5J/LKqsBa7wneEB gQUw== 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 x61-v6si36244513plb.216.2018.09.24.05.07.16; Mon, 24 Sep 2018 05:07:31 -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 S1730854AbeIXSGa (ORCPT + 99 others); Mon, 24 Sep 2018 14:06:30 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:53844 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728763AbeIXSG3 (ORCPT ); Mon, 24 Sep 2018 14:06:29 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3D9191074; Mon, 24 Sep 2018 12:04:42 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ben Hutchings Subject: [PATCH 4.9 066/111] USB: yurex: Fix buffer over-read in yurex_write() Date: Mon, 24 Sep 2018 13:52:33 +0200 Message-Id: <20180924113111.544445463@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.337261320@linuxfoundation.org> References: <20180924113103.337261320@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ben Hutchings commit 7e10f14ebface44a48275c8d6dc1caae3668d5a9 upstream. If the written data starts with a digit, yurex_write() tries to parse it as an integer using simple_strtoull(). This requires a null- terminator, and currently there's no guarantee that there is one. (The sample program at https://github.com/NeoCat/YUREX-driver-for-Linux/blob/master/sample/yurex_clock.pl writes an integer without a null terminator. It seems like it must have worked by chance!) Always add a null byte after the written data. Enlarge the buffer to allow for this. Cc: stable@vger.kernel.org Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/yurex.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/usb/misc/yurex.c +++ b/drivers/usb/misc/yurex.c @@ -431,13 +431,13 @@ static ssize_t yurex_write(struct file * { struct usb_yurex *dev; int i, set = 0, retval = 0; - char buffer[16]; + char buffer[16 + 1]; char *data = buffer; unsigned long long c, c2 = 0; signed long timeout = 0; DEFINE_WAIT(wait); - count = min(sizeof(buffer), count); + count = min(sizeof(buffer) - 1, count); dev = file->private_data; /* verify that we actually have some data to write */ @@ -456,6 +456,7 @@ static ssize_t yurex_write(struct file * retval = -EFAULT; goto error; } + buffer[count] = 0; memset(dev->cntl_buffer, CMD_PADDING, YUREX_BUF_SIZE); switch (buffer[0]) {