Received: by 10.223.185.116 with SMTP id b49csp72056wrg; Thu, 15 Feb 2018 16:50:07 -0800 (PST) X-Google-Smtp-Source: AH8x227xLwx0Z/NoaMkDMfXd/fXCwbS6nXeKHSLYAT1D8dUrySGNItQy4Kztig+liW40X3xmCmEg X-Received: by 10.98.50.3 with SMTP id y3mr4272776pfy.98.1518742206870; Thu, 15 Feb 2018 16:50:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518742206; cv=none; d=google.com; s=arc-20160816; b=FlhMMRwJxeITEN5jj8r7O467QnBj8JlFz2nr/Nqnd2csvNl9gXMzDmcZNQQLc4wHvt 8N93tbe0zmM/kJBDkWPB4kGV4SY8Ijxz1Hl/6jaFsBEsEoYJM34085Yba2o3var1NnVP 0Q3fiyAqkUrs5p4BaEpwdFThYoUVXW87VAt56g6mwbw+pYtOC6SbCnZ0o06t8HJPXMtz OcCpDEvldlTxcy/mBWtYcW+9wkJH1ww298lc1hEa2sQmJQsuS7kKFBdPTutgZePU/ZYu RC5LSdayIbOqzPMUTz08eA/L6HE/j/gJ5YsaUgJmot6B+bKAVQEO5ECYKdcEQUfdR33J hzbA== 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=25BgAbMr1kCLBW3JcPFXcNJq1gn8s4ajEmtQmUOfZc4=; b=CS8OguesGHxQxIUIbnbj+EdjN5OFv9S/9KIcV0Z9MLld3u/q3J4TqQUSorexXMcQeg Hn2UDgBkTnfzFjsC9lVNzfBz3G2YwoR6yyeRh8xbWTIDc0cSLzMyUC16j4VXhJGnJhUF CfzbdL3vogiox+zynEV9kAwc8dQGLBK7cAx/80VlXFrvA6xU5LL3OdH9dwIiaAlBSed7 zDkAdlJDPyiRv3P6A+yiwMihZV2Sc9Be1r5Ynp+6rcTphF+0cyctP9GzmlK1Wdl2dCNG 4MpvIF66wBZCF63Csf/k9yQ6kM3QgqNxmY+G362uNcQranCUlwP0nKIy7rvOQNVWXYUG S3gQ== 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 w25si1819150pfk.99.2018.02.15.16.49.50; Thu, 15 Feb 2018 16:50:06 -0800 (PST) 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 S1423800AbeBOPkt (ORCPT + 99 others); Thu, 15 Feb 2018 10:40:49 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:60208 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423764AbeBOPkp (ORCPT ); Thu, 15 Feb 2018 10:40:45 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4690C1168; Thu, 15 Feb 2018 15:40:44 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrey Konovalov , Malcolm Priestley , Mauro Carvalho Chehab , Ben Hutchings Subject: [PATCH 4.15 012/202] media: dvb-usb-v2: lmedm04: Improve logic checking of warm start Date: Thu, 15 Feb 2018 16:15:12 +0100 Message-Id: <20180215151713.469334722@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@linuxfoundation.org> User-Agent: quilt/0.65 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.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Malcolm Priestley commit 3d932ee27e852e4904647f15b64dedca51187ad7 upstream. Warm start has no check as whether a genuine device has connected and proceeds to next execution path. Check device should read 0x47 at offset of 2 on USB descriptor read and it is the amount requested of 6 bytes. Fix for kasan: CONFIG_KASAN_INLINE enabled kasan: GPF could be caused by NULL-ptr deref or user memory access as Reported-by: Andrey Konovalov Signed-off-by: Malcolm Priestley Signed-off-by: Mauro Carvalho Chehab Cc: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/dvb-usb-v2/lmedm04.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) --- a/drivers/media/usb/dvb-usb-v2/lmedm04.c +++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c @@ -494,18 +494,23 @@ static int lme2510_pid_filter(struct dvb static int lme2510_return_status(struct dvb_usb_device *d) { - int ret = 0; + int ret; u8 *data; - data = kzalloc(10, GFP_KERNEL); + data = kzalloc(6, GFP_KERNEL); if (!data) return -ENOMEM; - ret |= usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), - 0x06, 0x80, 0x0302, 0x00, data, 0x0006, 200); - info("Firmware Status: %x (%x)", ret , data[2]); + ret = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), + 0x06, 0x80, 0x0302, 0x00, + data, 0x6, 200); + if (ret != 6) + ret = -EINVAL; + else + ret = data[2]; + + info("Firmware Status: %6ph", data); - ret = (ret < 0) ? -ENODEV : data[2]; kfree(data); return ret; } @@ -1189,6 +1194,7 @@ static int lme2510_get_adapter_count(str static int lme2510_identify_state(struct dvb_usb_device *d, const char **name) { struct lme2510_state *st = d->priv; + int status; usb_reset_configuration(d->udev); @@ -1197,12 +1203,16 @@ static int lme2510_identify_state(struct st->dvb_usb_lme2510_firmware = dvb_usb_lme2510_firmware; - if (lme2510_return_status(d) == 0x44) { + status = lme2510_return_status(d); + if (status == 0x44) { *name = lme_firmware_switch(d, 0); return COLD; } - return 0; + if (status != 0x47) + return -EINVAL; + + return WARM; } static int lme2510_get_stream_config(struct dvb_frontend *fe, u8 *ts_type,