Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2212500imm; Thu, 7 Jun 2018 07:09:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKILPvVBcy+2LMJghcSiuqMQYhqaXBJoTgxPbbespg2uRzxyL983xqokux9rec9bA5y2+2mb X-Received: by 2002:a17:902:d807:: with SMTP id a7-v6mr2218502plz.92.1528380590657; Thu, 07 Jun 2018 07:09:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528380590; cv=none; d=google.com; s=arc-20160816; b=jIEaPNlgD6oftBqDt+SP4CdmJNfO4H/fz84kjKmqhJBD9WZkvzUWUHM0sj8cqs0eJf YYFHa8mUmAV7lKDG6XPrKS9KQpe4E5PqzIsFnucJLYKm8dmcsz7sO5lxBvdQSRoj2PCB I9uFxMOrljOYciLR4Xr0GIIghWARcI2z5NxpArmPTKzDiD1NPIiypOUtiNmTdv/rFduU qZFyXoUOIqSQtWOhkgN01/6te7eKqt+n281+RcUGMdCPGRMoSX0YD64TPCNHAop123d8 P1SOnsluAUR1xvfjoihCr5OFZLQJz5B0MB2FON24/fqIKXNXnpMqwREtSbhSIARq9aMi 7OXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=pOY0VeCw++yo4onD2pzcWduI4huzHfdcA6G1BknsCe8=; b=gKMjelra1iigwqRwTgESY/Z/87cH0ENtL0i+t4uLLkxsJlmqRBPJfBXQb6C7exbcAE lBBbq6hi4D333bipGEL25AIS0nhegJfX2iSQVZl49nWfhkCtrf1HQEknf48Okn9NDBkn K/0rW2EsPJ/H11a43J2Qw8cfqr96N4FDny4efCeGBiXvdaJ3SSRj3gOx5NPZHd+hgvFT m+qdAapTVCvMNqqYEbcR7Vde8xs4qUWDMF6/tvkIPXABrtzorcu3n9XkoU1qBvMY6ja3 /FSNvc9w9mxvciIwy5yuMD5aKbrd7dF5pVzfw2EeuXL+P5XaUWZYBYphKq/C90Mo1OxO MBwQ== 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 s14-v6si53133978plp.589.2018.06.07.07.09.35; Thu, 07 Jun 2018 07:09:50 -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 S932981AbeFGOJA (ORCPT + 99 others); Thu, 7 Jun 2018 10:09:00 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39098 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932872AbeFGOI6 (ORCPT ); Thu, 7 Jun 2018 10:08:58 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvay-0005Zp-85; Thu, 07 Jun 2018 15:08:56 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvax-0002gY-5w; Thu, 07 Jun 2018 15:08:55 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Malcolm Priestley" , "Mauro Carvalho Chehab" , "Andrey Konovalov" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 007/410] media: dvb-usb-v2: lmedm04: Improve logic checking of warm start In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 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 Signed-off-by: Ben Hutchings --- 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 @@ -434,18 +434,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; } @@ -1228,6 +1233,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); @@ -1236,12 +1242,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,