Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp373756rdf; Fri, 3 Nov 2023 03:32:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHUcjCT+aZ7gky6UJJrlyf61xezu81Ri4ksHjn8LpAPDSB4wwH+p2WFd1hC086Eu12ZI0lR X-Received: by 2002:a05:6a00:24d6:b0:68e:2478:d6c9 with SMTP id d22-20020a056a0024d600b0068e2478d6c9mr20796127pfv.2.1699007521859; Fri, 03 Nov 2023 03:32:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699007521; cv=none; d=google.com; s=arc-20160816; b=Vh7ah1RbMDxJXniZBBWhCqGxRYvTylVi/AUjHZXMSUovPgXAuDMJaseWiDH2/UvuUg KO82NsyMQc7crz2P8gyYY/ErkEs5KEkznBCApKTuTRO+EhRMJdoERW7U4Sf/a1ivus2M 806fJwEi+ceuxn74bMQn72OVbVkOJidHAoziwN6j1aeSE/DPzDC6l4iYvdCTnvERxnID 2ke5GOywRQiVt5eFe8l6/sCdgymzvSc7HexV/JSC6Titp6vSeiXii1w/K0wc/fREGbLt Tkrm26EOaR3/fTb4RZClu5/fN1SNqnZ/k2UyisEyBzWZ+3JFRnFmJ1wuc/GtNSydnrsp VzhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=uSIps0k3efcZmDUdjVIAeH+SdjT29FKbbyRNde29GQE=; fh=DH4yldJs8MRFnDfPpUqTbyP5bCwJRK3t5WF+Oaul0CI=; b=JCvpBLx/CEejVWeHCuSKmtHhmPJsAtP0tf6B208PhdPFFbTk07h0sAL0g1wp+SodJG EroT7cxefr2Ip138lfmrtGXpx3ElJ1uVFB9vn/Fo7+Lc5p2XapE+AwdB6GJbSbUh4Bgy cmsqbX0e7S/GXfP4R2Qge05NlE5u/W3ebT80K4ZBoIMK+EbsOyNM8JF/rVN38n7yHVXZ twOV9K+/lBf2rXptxQhgt8WEv4nsP0GvgV2tEP+u7/1HxBtA9X7DZ1DLOXWNnBycS07n WCLXyRsfmtgmyYEkdrSe6MbKwC923SoFS2utzIWJK+ghO9ow04o+3B42r6M8I6GFCoGX PbsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=t2ca9DYi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id j9-20020a056a00174900b006bf2ef1717csi1330651pfc.255.2023.11.03.03.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 03:32:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=t2ca9DYi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 93A6383AC0D5; Fri, 3 Nov 2023 03:32:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346569AbjKCKbz (ORCPT + 99 others); Fri, 3 Nov 2023 06:31:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346471AbjKCKbw (ORCPT ); Fri, 3 Nov 2023 06:31:52 -0400 X-Greylist: delayed 358 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 03 Nov 2023 03:31:45 PDT Received: from smtp106.ord1d.emailsrvr.com (smtp106.ord1d.emailsrvr.com [184.106.54.106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83E1A18B for ; Fri, 3 Nov 2023 03:31:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1699007147; bh=kNQ6Y9aJJpuP/XuTipt3CdSuES1rKcilf6zf4PyPWLw=; h=Date:Subject:To:From:From; b=t2ca9DYixF48bFpQZ4M3ABJWuhvOTwd+WMLlGhGa4fACFJqU4MDxMk2UOGoLj0Nyj cBDVUn/ZAfuk2+EPVHHjcI5LLwxjDXTCkWip7eVnrihVl+G9uoL7zQsWJNH5R6FRLI X6gxdVe2/1908cILqLKGoYF9uYcDLHzEBAepk0oY= X-Auth-ID: abbotti@mev.co.uk Received: by smtp6.relay.ord1d.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 3B5EBE00DD; Fri, 3 Nov 2023 06:25:46 -0400 (EDT) Message-ID: <51e495a4-98d7-402c-a1e6-5c24c43e3118@mev.co.uk> Date: Fri, 3 Nov 2023 10:25:45 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] drivers/comedi: copy userspace array safely Content-Language: en-GB To: Philipp Stanner , Greg Kroah-Hartman Cc: H Hartley Sweeten , Ivan Orlov , Benjamin Tissoires , linux-kernel@vger.kernel.org, Dave Airlie References: <20231102190848.51376-2-pstanner@redhat.com> <2023110348-drained-tameness-b943@gregkh> <07a220351baa1e6851b90c961aade0ce6d26bcf6.camel@redhat.com> From: Ian Abbott Organization: MEV Ltd. In-Reply-To: <07a220351baa1e6851b90c961aade0ce6d26bcf6.camel@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Classification-ID: 0e0161b1-9789-4e79-b36b-01e1a0233ef7-1-1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 03:32:00 -0700 (PDT) On 2023-11-03 09:11, Philipp Stanner wrote: > On Fri, 2023-11-03 at 06:53 +0100, Greg Kroah-Hartman wrote: >> On Thu, Nov 02, 2023 at 08:08:49PM +0100, Philipp Stanner wrote: >>> comedi_fops.c utilizes memdup_user() to copy a userspace array. This >>> does not check for an overflow. >> >> Is there potential for an overflow today? > > None that I'm aware of, no. This is more about establishing the new > function as the standard for array-copying, thereby improving > readability and maybe robustness in case of future changes. I agree there is no potential for overflow. The chanlist_len in the command is bound checked against the len_chanlist in the comedi subdevice in __comedi_get_user_cmd(), and the len_chanlist value is set by driver code with no user input. So it should be fine barring some rogue comedi driver. >>> Use the new wrapper memdup_array_user() to copy the array more safely. >> >> How about saying something like: >>         "Use the new function memdup_array_user() in case things change >>         in the future which would prevent overflows if something were to >>         change in the size of the structures". >> >> Or something to the affect of "all is good today, but make it easy to be >> correct in the future as well". > > Yes, good idea. I'll send a better wording Feel free to add my reviewed by line: Reviewed-by: Ian Abbott -- -=( Ian Abbott || MEV Ltd. is a company )=- -=( registered in England & Wales. Regd. number: 02862268. )=- -=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=- -=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-