Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1485935rdb; Wed, 20 Sep 2023 10:21:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZIf/uWQR4I7YrLLYVmynSh9Un6FN1TUroqKmW7OLzaAUqJelQ+ruYI9J1NkOkdib2w3Ut X-Received: by 2002:a05:6358:50cc:b0:143:21e8:11f2 with SMTP id m12-20020a05635850cc00b0014321e811f2mr4130245rwm.11.1695230469424; Wed, 20 Sep 2023 10:21:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695230469; cv=none; d=google.com; s=arc-20160816; b=Dz6F3X+yu4Yr+aC4LiF3sfC3lz8rzrggrBwkTURj+mXw63t/poLsmHiWhgANHyDxO/ bItVfn1P3iKKx0DKpo3k344+M9SeUytZqW7HA/8LhHeOdPJ5zldwSJAazygPNejI1ZPN b/KZIJXT6KZ35K/LKUmiPHXQkg/V5NuOChUBsrNe9n4enbIEELMbnhEdMYIeKZP1O8og kbh3+ViLvjHZXyt6Ouy0/gv6O81gIcEmANhF+t5DD3HhgcBm/jVPWBsj2MxEs+Dwgwd3 7e15KeEnTb322kk0JIIZnS2zNYPy27HqFJyMrDczl3Rr0mDf86CGB384nHe4VdVjubQV j2vw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CkUiTYo02brbH9rdldgLT7YiM95DCTjC6m+zHLs+f1Y=; fh=a4j0VewvT2hKE5plEC9nWvrQHtBT6GynD5BDsGrJ0BA=; b=uqccq7iI+frpF83YdNGL3mjwVYGX6x9hIS2u8Vwf0T074CEqvnGV+AicLyHYm1+yNP PHi48YuMFCnETwUB2g6adsMXJD7kCqRtl1iwLaMW3bVc3AYxzjFiPJY9MPFOEJ2vJflv oa0DlSgXGUfn4yg6dmx/9erTDLgALukFngIQQ8aOHKrU1bydplbq8yXqrYYaEw7zl9Cc 2gJ1SwMApC/peP1hRssg+HIyOaXhl/MX26ccNJSdJ7erFXtcQps80xXjO7X+gkbF3ivV yWwvUJvQEXaPSim29czBYvsQHkiaOiGT4ri1j7anofWjij6VwMsPuKxZT+c4QKWDhnLP mGNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NQ6WtxB5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id l5-20020a633e05000000b0056c2892bfb9si4459425pga.644.2023.09.20.10.21.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 10:21:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NQ6WtxB5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 088A78042382; Wed, 20 Sep 2023 05:38:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236039AbjITMh6 (ORCPT + 99 others); Wed, 20 Sep 2023 08:37:58 -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-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: 8bit X-Spam-Status: No, score=-0.9 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 20 Sep 2023 05:38:09 -0700 (PDT) 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 *pipe, filter.__reserved != 0) return -EINVAL; - tf = memdup_user(_filter->filters, filter.nr_filters * sizeof(*tf)); + tf = memdup_array_user(_filter->filters, filter.nr_filters, sizeof(*tf)); if (IS_ERR(tf)) return PTR_ERR(tf); -- 2.41.0