Received: by 2002:ac8:6216:0:b0:41c:c224:f26f with SMTP id ks22csp87188qtb; Thu, 2 Nov 2023 12:17:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSaimXHNtaHJtpWuwfhIKjXpq2es7/DybBWw4G+Hpwu5O7DNEcRTTDhkc1ESzHjaBJtA1P X-Received: by 2002:a17:903:451:b0:1cc:436d:39dd with SMTP id iw17-20020a170903045100b001cc436d39ddmr10547079plb.65.1698952667451; Thu, 02 Nov 2023 12:17:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698952667; cv=none; d=google.com; s=arc-20160816; b=Zi7HcTTH1rz5dmQ8zYRZmjmQx5aCb7sq7AP9Fh4L1d38UceNbDjmSAuUlVU6lv/DRc ybBeqWE2EroIBXE78WLi0Sd1aJ+lC8GXhiqYXin4feQDFkMGHjTZnv/7z9Q+XtzcO3cP PEAeMlKo9Nm//zloGncTmNFZWj5XjX5Cgm5rqHD9LNgc8JE1JdWtI6LU1viGtJ1f8x98 avuS1C+6w+MfxM4WpfmTlHYb/QyxHVKJ1Wsyz+c8ZpufNHt839+wYu9oG508Lbn09qko QXAixWkX/P59o+kNolHzKDcnytHOsXEGaeRTyChYGIV8C347ZIq3GXx03e0FwaWRGbHV wUjQ== 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=u5dyav2FpjU7LQKMZEdDExBNYby1YISH7oqQq8W6UzE=; fh=Te3nRTDNXAf8lbvn5q/RE4CsfvTDRHrAgMqJw1ISQ20=; b=gAYpIDm09UiPr43MupnX9nfc75AN171WeJ1ngaUrC11jQgmAJvk5IAnYIkwyJbEHrU Srp1E3B8PJBHhLTsDBuLJ0+Pp7f5FjLYIpb9+HXTQUwkU8Cswm0hQuphEcJnall/wjF+ AtIUQa/kHQ18PohMNjCaDo0kJXU6ux+hJUwtCZWwNpYZwY6i71D5GeqSgpypuE7C7jhn q6UF2OEqygmsDuaV1OkV54dyJgapF5rX07Ngz90kOgE1iRIYQkaaJEvmFOc+GBaNY3Nr 0ukPEqJdLuXYZ3KDKb4mZBN0u8JHCN1MWcExTGhw+YmrE30gSAS/TW6WhavUiUJbrOQU q/4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hR8t0C3c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id c9-20020a170902f30900b001c9c83947d1si119385ple.645.2023.11.02.12.17.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 12:17:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hR8t0C3c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id EA04A822B8C2; Thu, 2 Nov 2023 12:17:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345284AbjKBTRj (ORCPT + 99 others); Thu, 2 Nov 2023 15:17:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229686AbjKBTRi (ORCPT ); Thu, 2 Nov 2023 15:17:38 -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 C9F6F186 for ; Thu, 2 Nov 2023 12:16:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698952606; 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=u5dyav2FpjU7LQKMZEdDExBNYby1YISH7oqQq8W6UzE=; b=hR8t0C3cNLigxyUaJFjH6qwfwQ+wPs6+QfvMYTLeqHsR5tnajeSR72RSZOIEfdtlTPFKEo R4anW/34Yd3Xg2u4Ak/SRTg3WDI03JihDHs5v451GzS1T6DFMFvxtuQHQ+OA4zl31Lxbbi a9UOK2uWOyfCouFet/IwBH566+pjVj0= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-471--fFCS7EXNoCL8ekHnHJ62w-1; Thu, 02 Nov 2023 15:16:43 -0400 X-MC-Unique: -fFCS7EXNoCL8ekHnHJ62w-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2c516a92fb2so2774981fa.1 for ; Thu, 02 Nov 2023 12:16:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698952602; x=1699557402; 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=u5dyav2FpjU7LQKMZEdDExBNYby1YISH7oqQq8W6UzE=; b=OZqDGaLl+gsoTfDILut6vK2YVsFOGim5gM8ldLbGMesSMTN4dSgi+lRpfLPD/sLnHR WvP4Dw3LdGd9JYu/66ExPfsSBSTTUYPIBpPBNRECtFIKZMbnyw2ADvmfj4ZZ8ydugHPm a8f5gQfRKP50kjMDO3ef6APflzLwFg/A1hohTd6Y96kLRC2tNNJktu9YC4NRs8wtkcWX 9QnGSJDO1WCdRXh4pZCmfCGyXXf4hlb8d+ENQrnGlSjBNdREnjdo+tYu3kZdMPJNWvuI a7Rv7hDa81MO+ygCco5IDT5sggrPa4Vjm+iNsLZVvgpPsefbIcftQH0SxkLAgwhhnS6P 7XAw== X-Gm-Message-State: AOJu0YzNPcSAi0buvj5Ku87jklLrI1/qEj178L5VW2qhvp2VQT1GwARg zB+BXhCtO8t10wVyV6Z6sHvozr2Mw0sp0VFafMQaQVIpFyKLC9riNsZcRDHvxmBoo9A6/5BAFxf DRCRE67Rm27tfildPsnlXXKCn X-Received: by 2002:a2e:9893:0:b0:2c6:f97c:cf21 with SMTP id b19-20020a2e9893000000b002c6f97ccf21mr1329966ljj.2.1698952601853; Thu, 02 Nov 2023 12:16:41 -0700 (PDT) X-Received: by 2002:a2e:9893:0:b0:2c6:f97c:cf21 with SMTP id b19-20020a2e9893000000b002c6f97ccf21mr1329948ljj.2.1698952601486; Thu, 02 Nov 2023 12:16:41 -0700 (PDT) Received: from pstanner-thinkpadt14sgen1.remote.csb ([2001:9e8:32c5:d600:227b:d2ff:fe26:2a7a]) by smtp.gmail.com with ESMTPSA id bg13-20020a05600c3c8d00b0040644e699a0sm75279wmb.45.2023.11.02.12.16.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 12:16:40 -0700 (PDT) From: Philipp Stanner To: Mauro Carvalho Chehab , Robert Schlabbach , Takashi Iwai , Hyunwoo Kim , Lin Ma , Chen Zhongjin Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Philipp Stanner , Dave Airlie Subject: [PATCH] drivers/media/dvb-core: copy user arrays safely Date: Thu, 2 Nov 2023 20:16:34 +0100 Message-ID: <20231102191633.52592-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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 02 Nov 2023 12:17:45 -0700 (PDT) At several positions in dvb_frontend.c, memdup_user() is utilized to copy userspace arrays. This is done without overflow checks. Use the new wrapper memdup_array_user() to copy the arrays more safely. Suggested-by: Dave Airlie Signed-off-by: Philipp Stanner --- drivers/media/dvb-core/dvb_frontend.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index 9293b058ab99..93d3378a0df4 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -2168,7 +2168,8 @@ static int dvb_frontend_handle_compat_ioctl(struct file *file, unsigned int cmd, if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS)) return -EINVAL; - tvp = memdup_user(compat_ptr(tvps->props), tvps->num * sizeof(*tvp)); + tvp = memdup_array_user(compat_ptr(tvps->props), + tvps->num, sizeof(*tvp)); if (IS_ERR(tvp)) return PTR_ERR(tvp); @@ -2199,7 +2200,8 @@ static int dvb_frontend_handle_compat_ioctl(struct file *file, unsigned int cmd, if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS)) return -EINVAL; - tvp = memdup_user(compat_ptr(tvps->props), tvps->num * sizeof(*tvp)); + tvp = memdup_array_user(compat_ptr(tvps->props), + tvps->num, sizeof(*tvp)); if (IS_ERR(tvp)) return PTR_ERR(tvp); @@ -2379,7 +2381,8 @@ static int dvb_get_property(struct dvb_frontend *fe, struct file *file, if (!tvps->num || tvps->num > DTV_IOCTL_MAX_MSGS) return -EINVAL; - tvp = memdup_user((void __user *)tvps->props, tvps->num * sizeof(*tvp)); + tvp = memdup_array_user((void __user *)tvps->props, + tvps->num, sizeof(*tvp)); if (IS_ERR(tvp)) return PTR_ERR(tvp); @@ -2457,7 +2460,8 @@ static int dvb_frontend_handle_ioctl(struct file *file, if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS)) return -EINVAL; - tvp = memdup_user((void __user *)tvps->props, tvps->num * sizeof(*tvp)); + tvp = memdup_array_user((void __user *)tvps->props, + tvps->num, sizeof(*tvp)); if (IS_ERR(tvp)) return PTR_ERR(tvp); -- 2.41.0