Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2235954imm; Thu, 18 Oct 2018 11:09:33 -0700 (PDT) X-Google-Smtp-Source: ACcGV62irARGE7w3LQnq2HKQ6uuCTSAiUIcmWeSIa7LhbA42nsazLC6xS9OaQDVR0lWwcbKaf1C9 X-Received: by 2002:a65:6295:: with SMTP id f21-v6mr29736385pgv.167.1539886173136; Thu, 18 Oct 2018 11:09:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539886173; cv=none; d=google.com; s=arc-20160816; b=XGDM2SUuPpjEpFvzzpsZ+BBvKSypsS2ytWK+ka9N8DnX6D1S97yhCXyftzXbEiPqGx 4TiaOtXgCxyD6StI2KvaCwBhYFRQCY9h/lX9iIczK7qf9KMxfivMbpCH+FDiH62YohX2 w/I97oQNFhvTf07b0JuC2YlzGBZf0z8d6NwNmx+T6nZ49Mpel5LZa9EIBXYYV4aC2Hvb 6Er7E1R3XuA2di/lWt1xspFHbIL7+LNWMLlY63Wy73HCBod1hoLsKNGOFuAuBPkN2Sho BcH/yynY60k2CbhOczcNqHywQrDRZq30hAYvmHyzBNFwBYZEr5yAYTtCPTuAE9DF5XqG 8XuQ== 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:dkim-signature; bh=4UqePl0gPbUpwZ5Ja79kfZF9rwstwhGIBAjeT5QrQog=; b=ciUbp5F3Bnb7+m9QHyRnkdjemQz55KAwRt0FeRjBW6CXzpIhB3TQILjNE3FpDMIroD svklvNM/Pg0HWJjvZ7E65pXy4XfitSMFGFosouZ0pftuM8vUOKQyiAT0SZyOiIgzGIGT YZcEWHzcylq8c7S8PmFwDU/hZVH2W2TUETxShxVRP60EsA1YqjT714N+zeC3FMX5DbCp ke1ZGgbEfATXcJJXOk2HI2oqQKdlSoJJpbj+PSQmhbTF/5AIg7/RIz/holDxVxBHkdRB yJphQoJbFxxw75hhW0hJi8mkoarcqprXXVMhxl+EVWIbsWxa05KyCufhJlqo48Nhqg/j rRKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KXIL11Ji; 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 j20-v6si20208506pgh.535.2018.10.18.11.09.18; Thu, 18 Oct 2018 11:09:33 -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; dkim=pass header.i=@kernel.org header.s=default header.b=KXIL11Ji; 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 S1730616AbeJSCJL (ORCPT + 99 others); Thu, 18 Oct 2018 22:09:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:58546 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729911AbeJSCJL (ORCPT ); Thu, 18 Oct 2018 22:09:11 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AF8E1204FD; Thu, 18 Oct 2018 18:07:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539886023; bh=5Vbl6A0NUE6qRVXTbD3/fBJGtVmAGFMc6/HCqLDyE/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KXIL11JinmolID1IUcsT1GSFa75yJJnrvQ69rOr/5TFJoQlvcPROIYIDR0hif52oB UJuihECtTH8wDRkvSxjb5oS0ofaZFa1tGHhaUmgPvwAfBxf8nJHtZB8TSE+6j6bHu7 bt5zQqwlteqEnYqeeAcjYUmZW7IiBtZkBeflqE1M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jozef Balga , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.4 35/48] media: af9035: prevent buffer overflow on write Date: Thu, 18 Oct 2018 19:55:10 +0200 Message-Id: <20181018175429.813937162@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181018175427.133690306@linuxfoundation.org> References: <20181018175427.133690306@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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jozef Balga [ Upstream commit 312f73b648626a0526a3aceebb0a3192aaba05ce ] When less than 3 bytes are written to the device, memcpy is called with negative array size which leads to buffer overflow and kernel panic. This patch adds a condition and returns -EOPNOTSUPP instead. Fixes bugzilla issue 64871 [mchehab+samsung@kernel.org: fix a merge conflict and changed the condition to match the patch's comment, e. g. len == 3 could also be valid] Signed-off-by: Jozef Balga Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/dvb-usb-v2/af9035.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/media/usb/dvb-usb-v2/af9035.c +++ b/drivers/media/usb/dvb-usb-v2/af9035.c @@ -389,8 +389,10 @@ static int af9035_i2c_master_xfer(struct msg[0].addr == (state->af9033_i2c_addr[1] >> 1)) reg |= 0x100000; - ret = af9035_wr_regs(d, reg, &msg[0].buf[3], - msg[0].len - 3); + ret = (msg[0].len >= 3) ? af9035_wr_regs(d, reg, + &msg[0].buf[3], + msg[0].len - 3) + : -EOPNOTSUPP; } else { /* I2C write */ u8 buf[MAX_XFER_SIZE];