From patchwork Tue Apr 2 07:51:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 2376181 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 91CAADF2A1 for ; Tue, 2 Apr 2013 07:53:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760622Ab3DBHxR (ORCPT ); Tue, 2 Apr 2013 03:53:17 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:47061 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759947Ab3DBHxQ (ORCPT ); Tue, 2 Apr 2013 03:53:16 -0400 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r327qwId029320 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 2 Apr 2013 07:52:59 GMT Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r327quaI021939 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 2 Apr 2013 07:52:57 GMT Received: from abhmt110.oracle.com (abhmt110.oracle.com [141.146.116.62]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r327quIh009378; Tue, 2 Apr 2013 02:52:56 -0500 Received: from longonot.mountain (/41.202.240.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 02 Apr 2013 00:52:55 -0700 Date: Tue, 2 Apr 2013 10:51:02 +0300 From: Dan Carpenter To: Mauro Carvalho Chehab Cc: Antti Palosaari , Michael Krufky , Peter Senna Tschudin , linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [RFC] [media] dvb-core: check ->msg_len for diseqc_send_master_cmd() Message-ID: <20130402075102.GA11233@longonot.mountain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: ucsinet22.oracle.com [156.151.31.94] Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org I'd like to send this patch except that it "breaks" cx24116_send_diseqc_msg(). The cx24116 driver accepts ->msg_len values up to 24 but it looks like it's just copying 16 bytes past the end of the ->msg[] array so it's already broken. cmd->msg_len is an unsigned char. The comment next to the struct declaration says that valid values are are 3-6. Some of the drivers check that this is true, but most don't and it could cause memory corruption. Some examples of functions which don't check are: ttusbdecfe_dvbs_diseqc_send_master_cmd() cx24123_send_diseqc_msg() ds3000_send_diseqc_msg() etc. Signed-off-by: Dan Carpenter Reviewed-by: Antti Palosaari --- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index 57601c0..3d1eee6 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -2265,7 +2265,13 @@ static int dvb_frontend_ioctl_legacy(struct file *file, case FE_DISEQC_SEND_MASTER_CMD: if (fe->ops.diseqc_send_master_cmd) { - err = fe->ops.diseqc_send_master_cmd(fe, (struct dvb_diseqc_master_cmd*) parg); + struct dvb_diseqc_master_cmd *cmd = parg; + + if (cmd->msg_len >= 3 && cmd->msg_len <= 6) + err = fe->ops.diseqc_send_master_cmd(fe, cmd); + else + err = -EINVAL; + fepriv->state = FESTATE_DISEQC; fepriv->status = 0; }