Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp405564rdf; Fri, 3 Nov 2023 04:32:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG4GKobzyxcD0wdOEvClQJLDPRJvpOb6blV75M4dC5beEGXwnC0S2NrRGLAsQdpNKHoqBH9 X-Received: by 2002:a05:6a20:da84:b0:17b:1f76:86ee with SMTP id iy4-20020a056a20da8400b0017b1f7686eemr3758687pzb.16.1699011134399; Fri, 03 Nov 2023 04:32:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699011134; cv=none; d=google.com; s=arc-20160816; b=JxyWfz6mNIxfo6eX0awcT5epiSRnxlq6+B/84S3LiHxINkixvk0zGaylegKAAIz6WE jLgqcf4EINlFLtAYqGB92zk9uYD/dLwVXkEaH6BS7ZPjdSaPKtSobMXvJzZBDktFywPQ ArUdqDJMzIQe16TbWZHYoAUmMoDGMkPOM/heWYnU5kU1FV44pvjj4dIVOqseWfbP0GoA 4fZqKeDBT3E9vsWDnnYjYWK/DvOiaUukeDsItXGrGS7/ivLn7Av2TY9QzJ051/QfxdGH Z5LViT0uzW7JmNC9jJBcb7L3R+r+VraovyRazt2bf9XC3K4sjIGLqZwWm9YPUvU1ULCD 0rNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=1e9VakvLuO9AJ2KzUAGqzMN6gS+iv5oxh/hyIPNBpX4=; fh=IdOvGYA4BSRQ5HNARyYWXJNk4CXpyfxdBRxth1vmpeg=; b=SQBd5MMae18BUbZUNUot6Ihg5t7NcNhO+RKBJ57MskNAadoE+FOs0GMWw2cnS6YRr0 h+5vGiZpqSUOdUS0U/7qvaDzkzlznvtrPGkD9CAdxPgIG0eIsMVdqFl58K3ebFpLlxrb /ocu5k4DXxz90rJwvMARTDsMEg5Ub+2Wp2fUxz+sENQJKfXWdWtVVEukaAGSXIlA+554 bP3RGM8OJyuj2GfWcVdcDqCh3vD+FhUNV/kbEbTRQoiKJCN3QcY8P1IqUD6XKvdj6iI+ E3YGBlV/94h6FEEDFlMdrF1NV6HWa70jBzKch6dYUDnhBWJWojA97xfHiK///InhQEEE Ul/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VPiziRgl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id c11-20020a056a000acb00b006c31b7eedecsi1406937pfl.7.2023.11.03.04.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 04:32:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VPiziRgl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id EDE25826AC4B; Fri, 3 Nov 2023 04:32:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229963AbjKCLbz (ORCPT + 99 others); Fri, 3 Nov 2023 07:31:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230435AbjKCLbx (ORCPT ); Fri, 3 Nov 2023 07:31:53 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DA59134 for ; Fri, 3 Nov 2023 04:31:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699011065; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=1e9VakvLuO9AJ2KzUAGqzMN6gS+iv5oxh/hyIPNBpX4=; b=VPiziRglnQ4IkAVuNueRsVqzmxi2d/C65MM74dZTBer0hcfcx0SQUP7/lMB/LCgxaHsAN0 7OHqgM80yD024zSTRqxAHs92wGxpGq9OqLrAEidOVyW5zthgoNkct4t4Bs9ieh2fLQbI0D 81hBhsNWTid9c2ft9Q0M7SB2gL9q4Aw= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-541-_oZGRi8XOgSflYrTojT5zQ-1; Fri, 03 Nov 2023 07:31:03 -0400 X-MC-Unique: _oZGRi8XOgSflYrTojT5zQ-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-53f8893ddbdso385662a12.1 for ; Fri, 03 Nov 2023 04:31:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699011062; x=1699615862; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1e9VakvLuO9AJ2KzUAGqzMN6gS+iv5oxh/hyIPNBpX4=; b=JcWqkKdbSEgeUeVBhOAOPteucKZ3b1l3wuD7pSYth6SqLq2hE2JFGuJ/ZSiSef0bLS cCR5rkvOSB78e4Z804a1sVvsa0bTFNyOsiln98DUehBUbgmgm4xA6rnvBvqxntRmioel d9O+IKEzEG9R0p+PdmrWzoPKNsWOUCz1MHm8HKH9ahgIsFWUxtX4xPYPiywOQn1+JWNL OCeXUi1JtuTNcvfoi+rmHW/PFnnkaTGhcjzZZfBtdTXyrzgn38Pz2OoVQvMKVjiIHPfz nwbztXkny2hjYTUdZ4dKCRR5/JkI15Bi0MMAD82rTfPYZfd10eanb4IT1dWwoPhE0/UL JYgA== X-Gm-Message-State: AOJu0Yxu90neSdTHj5wuKrq42Zju+Wt1+eu6/Z5MJ3VJpkJWwcj/x7oi qFYmI7xpq596+xEOjbWbL1xLQnWYyvvn6BuaT1q+tAPgtAgwMSflWnyYSmy3l7CPxQHtG+XC3op QJoiCuXMw2dhwkC6s2B0Kf1sx X-Received: by 2002:a05:6402:e9b:b0:542:a609:167f with SMTP id h27-20020a0564020e9b00b00542a609167fmr18233539eda.1.1699011062604; Fri, 03 Nov 2023 04:31:02 -0700 (PDT) X-Received: by 2002:a05:6402:e9b:b0:542:a609:167f with SMTP id h27-20020a0564020e9b00b00542a609167fmr18233521eda.1.1699011062295; Fri, 03 Nov 2023 04:31:02 -0700 (PDT) Received: from pstanner-thinkpadt14sgen1.fritz.box ([2001:9e8:32d1:5200:227b:d2ff:fe26:2a7a]) by smtp.gmail.com with ESMTPSA id f11-20020a50d54b000000b0054351b5a768sm864607edj.82.2023.11.03.04.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 04:31:02 -0700 (PDT) From: Philipp Stanner To: Ian Abbott , H Hartley Sweeten , Greg Kroah-Hartman , Philipp Stanner , Ivan Orlov , Benjamin Tissoires Cc: linux-kernel@vger.kernel.org, Dave Airlie Subject: [PATCH v2] drivers/comedi: use standard array-copy-function Date: Fri, 3 Nov 2023 12:29:33 +0100 Message-ID: <20231103112932.75795-2-pstanner@redhat.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Fri, 03 Nov 2023 04:32:12 -0700 (PDT) comedi_fops.c utilizes memdup_user() to copy a userspace array. The new function memdup_array_user() provides a standardized way to copy userspace-arrays. It makes it easier to see that an array is being copied and, additionally, performs a generic overflow-check which might help make the code more robust in case of changes in the future. Replace memdup_user() with memdup_array_user(). Suggested-by: Dave Airlie Signed-off-by: Philipp Stanner Reviewed-by: Ian Abbott --- Changes in v2: - Rephrase commit message so that it doesn't sound as if an actual overflow is being fixed here. (Greg K-H) - Add Reviewed-by from Ian Abbott --- drivers/comedi/comedi_fops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/comedi/comedi_fops.c b/drivers/comedi/comedi_fops.c index 1548dea15df1..1b481731df96 100644 --- a/drivers/comedi/comedi_fops.c +++ b/drivers/comedi/comedi_fops.c @@ -1714,8 +1714,8 @@ static int __comedi_get_user_chanlist(struct comedi_device *dev, lockdep_assert_held(&dev->mutex); cmd->chanlist = NULL; - chanlist = memdup_user(user_chanlist, - cmd->chanlist_len * sizeof(unsigned int)); + chanlist = memdup_array_user(user_chanlist, + cmd->chanlist_len, sizeof(unsigned int)); if (IS_ERR(chanlist)) return PTR_ERR(chanlist); -- 2.41.0