Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp114613ybm; Thu, 28 May 2020 17:39:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxW+0pqlbkC8krjbORU50VfDVefKcephgpoifPtXgivgOUI19Dv8KMHd6YLxzYk8OZHZdjy X-Received: by 2002:a05:6402:1d10:: with SMTP id dg16mr5657709edb.309.1590712768197; Thu, 28 May 2020 17:39:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590712768; cv=none; d=google.com; s=arc-20160816; b=D66rjf1XKpHBwL5rml8PDzsTPhyRb24FB1dyWobCitRa5a+ToblR1LJCawrdsvbjlC qY/bhYGCi3OTnSPwRUHOLUn09ofFH5Z0d+IfrbiZMOPvlzSAgr5HEfCtlAivJ/fMMR95 eObBjOQyPF2rzfRA7ttpKs6bqjuSm0HU3NUS/C/tgzlkMEkF94uwe51CJkTE2XxEDlJD ZHS7wT/Qa1IJ5YfBk2E/Q9bqHkqETrI2BqWR7TIQW4nfE6BpTodm/mtpe7WRkm7AHqnS 064utEpd426xbeJ2G41OlPhTrn4nilz0ZPZ3ASLGmq+SiUzRRAVx+KriNXQsbeDRg7Aa r8qQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=AGQSVkcY/hWWxCtwNfKaFpvsBIhshLNm+YDo0bla5s0=; b=enC8deeRPDdlOOl1H70wEp/OuqBnEmiA3sSV3V6cIQV5SL+O131T9Ej64bjkPRg/UN 2nyJQ77FF8U8CWhTYqWm3LF/hHHcMAeOWRc2rUkK7XMIsMtIG1sxr0uMIgFXMFE1P6mm +n31dHoXm5ilA4mDTiD2FjiONBhDLf1SvIlOm2BQ466gWdU2uDb2SUE+6GQgcv+2zrKJ cnuITZccuWsEjnDwuxhidf1ohpMt8PyVn4C0L6lQ5n9QHqdeuBWpYo2hcKQpgu5INzeZ vDTwoJ9jGPJgFYic71k63KDTaCCvNPZodYk4p7ZGpe5AzpIx+9ehyGHNxYjMaEAXQr00 d+MA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lr24si4706485ejb.383.2020.05.28.17.39.05; Thu, 28 May 2020 17:39:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438157AbgE2Afo (ORCPT + 99 others); Thu, 28 May 2020 20:35:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728817AbgE2AfQ (ORCPT ); Thu, 28 May 2020 20:35:16 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 565A5C08C5CA; Thu, 28 May 2020 17:35:16 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.93 #3 (Red Hat Linux)) id 1jeSzR-00HFRI-R0; Fri, 29 May 2020 00:35:13 +0000 From: Al Viro To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Ian Abbott Subject: [PATCH 07/10] comedi: lift copy_from_user() into callers of __comedi_get_user_cmd() Date: Fri, 29 May 2020 01:35:10 +0100 Message-Id: <20200529003512.4110852-7-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200529003512.4110852-1-viro@ZenIV.linux.org.uk> References: <20200529003419.GX23230@ZenIV.linux.org.uk> <20200529003512.4110852-1-viro@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro Signed-off-by: Al Viro --- drivers/staging/comedi/comedi_fops.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index d80a416e70b2..e85a143057a1 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1649,17 +1649,11 @@ static int do_insn_ioctl(struct comedi_device *dev, } static int __comedi_get_user_cmd(struct comedi_device *dev, - struct comedi_cmd __user *arg, struct comedi_cmd *cmd) { struct comedi_subdevice *s; lockdep_assert_held(&dev->mutex); - if (copy_from_user(cmd, arg, sizeof(*cmd))) { - dev_dbg(dev->class_dev, "bad cmd address\n"); - return -EFAULT; - } - if (cmd->subdev >= dev->n_subdevices) { dev_dbg(dev->class_dev, "%d no such subdevice\n", cmd->subdev); return -ENODEV; @@ -1757,8 +1751,13 @@ static int do_cmd_ioctl(struct comedi_device *dev, lockdep_assert_held(&dev->mutex); + if (copy_from_user(&cmd, arg, sizeof(cmd))) { + dev_dbg(dev->class_dev, "bad cmd address\n"); + return -EFAULT; + } + /* get the user's cmd and do some simple validation */ - ret = __comedi_get_user_cmd(dev, arg, &cmd); + ret = __comedi_get_user_cmd(dev, &cmd); if (ret) return ret; @@ -1866,8 +1865,13 @@ static int do_cmdtest_ioctl(struct comedi_device *dev, lockdep_assert_held(&dev->mutex); + if (copy_from_user(&cmd, arg, sizeof(cmd))) { + dev_dbg(dev->class_dev, "bad cmd address\n"); + return -EFAULT; + } + /* get the user's cmd and do some simple validation */ - ret = __comedi_get_user_cmd(dev, arg, &cmd); + ret = __comedi_get_user_cmd(dev, &cmd); if (ret) return ret; -- 2.11.0