From nobody Fri Dec 19 03:41:46 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36927CE79D1 for ; Wed, 20 Sep 2023 12:37:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236036AbjITMh7 (ORCPT ); Wed, 20 Sep 2023 08:37:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236034AbjITMhz (ORCPT ); Wed, 20 Sep 2023 08:37:55 -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 2A44283 for ; Wed, 20 Sep 2023 05:37:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695213421; 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: in-reply-to:in-reply-to:references:references; bh=CkUiTYo02brbH9rdldgLT7YiM95DCTjC6m+zHLs+f1Y=; b=NQ6WtxB5bLM6In9RF2xe4/ErjZ2CauEawMTpsDtqT1BSO0DF/5VG6J8RjC2aR0Eye+R8Jc bmO4h1CcY1G1s2bbKD2DjqppAGDeydxUu3UcfhnNiTde5lEGaXNi6qjqrJJiPTl0pupaoy Dtek3ZX3492u1vAJtBpallfDvzaEViU= Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-531-Of_b6cLRNj-ZPLm5ZtSWDQ-1; Wed, 20 Sep 2023 08:37:00 -0400 X-MC-Unique: Of_b6cLRNj-ZPLm5ZtSWDQ-1 Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-2be48142a6cso15826121fa.1 for ; Wed, 20 Sep 2023 05:36:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695213418; x=1695818218; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CkUiTYo02brbH9rdldgLT7YiM95DCTjC6m+zHLs+f1Y=; b=jE8N/EVWEB1ptVdFEJHg+zGm6nI9v2skLtZal3R1DLgx+f4kHm4iPmeYOqfXGikkep S80PxRgXnm2CW5fry3YqsXh5W76pObbVBhbNQZSUz1nU8odAiQy82a9L/QRi/cC6FxmW 8k5i/2CXtcOH4vZLgeQod+Lkacyuq4jFWkK6BXoJypYNXIvupQfBZP4CNhecZiu9hxbI bU+nLWgqPqykAxl+ZIHMh82yOCiL3glq8+5RRkK4xDL5siteohMtF3Ww254w54Sf7CLl ZVfXFO3iXahNSA2KV+WxKlYvqyk+MFHjYCE62Kr+2/lZByQtFO5ANoiTh5rIeIiynzRH CKUQ== X-Gm-Message-State: AOJu0YypG120nkKftsyO63fV8euV+ui75D7HXt+6V2lli67M7gnYcwz+ gzMtVROfOdoriW2AV9ZVBCwnYjCcmoScHsmblDrhOWx4fxYeCliI5opNl66Wewxg5LKfuWj56eQ wqpgHSqkiN6+z3AEwJUxgpPsH X-Received: by 2002:a05:651c:1693:b0:2c0:196c:e38f with SMTP id bd19-20020a05651c169300b002c0196ce38fmr1921134ljb.1.1695213418530; Wed, 20 Sep 2023 05:36:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHGtYN79a4/Uyeq8meM3+9mCAQ2LGvBXOKnKduArpSa1zP3qsVYH9Wh1PFHrd4S88GImDITZQ== X-Received: by 2002:a05:651c:1693:b0:2c0:196c:e38f with SMTP id bd19-20020a05651c169300b002c0196ce38fmr1921120ljb.1.1695213418185; Wed, 20 Sep 2023 05:36:58 -0700 (PDT) Received: from fedorinator.. ([2a01:599:906:7772:a505:d891:dcff:9565]) by smtp.gmail.com with ESMTPSA id op15-20020a170906bcef00b009ae4ead6c01sm660073ejb.163.2023.09.20.05.36.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 05:36:55 -0700 (PDT) From: Philipp Stanner To: Kees Cook , Andy Shevchenko , Eric Biederman , Christian Brauner , David Disseldorp , Luis Chamberlain , Siddh Raman Pant , Nick Alcock , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Zack Rusin Cc: VMware Graphics Reviewers , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-hardening@vger.kernel.org, Philipp Stanner , David Airlie Subject: [PATCH v3 3/5] kernel: watch_queue: copy user-array safely Date: Wed, 20 Sep 2023 14:36:11 +0200 Message-ID: <20230920123612.16914-5-pstanner@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230920123612.16914-2-pstanner@redhat.com> References: <20230920123612.16914-2-pstanner@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Currently, there is no overflow-check with memdup_user(). Use the new function memdup_array_user() instead of memdup_user() for duplicating the user-space array safely. Suggested-by: David Airlie Signed-off-by: Philipp Stanner Reviewed-by: Kees Cook Reviewed-by: Zack Rusin --- kernel/watch_queue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c index d0b6b390ee42..778b4056700f 100644 --- a/kernel/watch_queue.c +++ b/kernel/watch_queue.c @@ -331,7 +331,7 @@ long watch_queue_set_filter(struct pipe_inode_info *pip= e, filter.__reserved !=3D 0) return -EINVAL; =20 - tf =3D memdup_user(_filter->filters, filter.nr_filters * sizeof(*tf)); + tf =3D memdup_array_user(_filter->filters, filter.nr_filters, sizeof(*tf)= ); if (IS_ERR(tf)) return PTR_ERR(tf); =20 --=20 2.41.0