From nobody Fri Dec 19 03:45:01 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 77DDCEEB566 for ; Fri, 8 Sep 2023 20:04:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344480AbjIHUEP (ORCPT ); Fri, 8 Sep 2023 16:04:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344482AbjIHUEN (ORCPT ); Fri, 8 Sep 2023 16:04:13 -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 4844D10CF for ; Fri, 8 Sep 2023 13:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694203393; 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=R2kuY7QrN77OjYcmiIgmsp8RgTy5tijHIGRui0VqTUY=; b=FVtUIV6tsX+mNwu0dPRU6/krl9z5hF9660WzUhQAK5v5pfb1taPidTii67cjZRQlB36Opz N+VKXKxTwg38ubSiFAI1yy6hyWdSyAD3Z7LrfcGoLSuQKA4NOSmveGTGWAGYLY8TfIMfNB qIVcvn0Vo93t4/92WiM7XdHw3ws5SLQ= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-235-5Ue3-Wm7Nv-F8iB9xFRzZQ-1; Fri, 08 Sep 2023 16:03:11 -0400 X-MC-Unique: 5Ue3-Wm7Nv-F8iB9xFRzZQ-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-76f1cc68e65so58231985a.1 for ; Fri, 08 Sep 2023 13:03:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694203391; x=1694808191; 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=R2kuY7QrN77OjYcmiIgmsp8RgTy5tijHIGRui0VqTUY=; b=xCB3WEIkUMV0O43N0o/F6lHYOcZDVxHt9vFNmc9RK62SMyd4OL4XJzg2/IBL7xJayq ID0qgJQ5HJrRS4Rzl1S+quNQCXKi7b0cRmOk6n81fg/CfYYLeP/ktZQ+3qERJRu0tfKo VXfuOc2Ysh6ngJmYsAWIG/D1XedwFc2P/D5114wv8GKK/e3fgMgxrXmzaiMNlnRu1/0+ r7zUrWlZ4TrPiqIMdh25axxNoFdRzvzVu7Qw99swcg5/dXh8SF2KwlgrTv8phtVTG/VI 4QM4A7Oo9U1EAXwsr2HWLk983vEOZK7rSyENVTHxwk7D22IBoA6jKr0+VSEZylPv7L7m 9S3Q== X-Gm-Message-State: AOJu0YxzojJqkikR9Kks/8+XJ/J8dHwJIghtGk1HLkduUk78/HIDLOK6 F+jbR6pYCDFBshfIhKdRVpnpAmKYHAm7eWwYSk1CzUELNvZSUbUhWZE/Ar1Z0LIh7qtKu0DV58x Y22QgmjSjS7e8XXZcvOZwa7On X-Received: by 2002:a05:620a:46a6:b0:75b:23a1:69ee with SMTP id bq38-20020a05620a46a600b0075b23a169eemr3480476qkb.5.1694203391480; Fri, 08 Sep 2023 13:03:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGuCpViWH7IrGzpUqlTBi1h+iY/5ABj5ubmz/i5MJtwSQDaqOps3aQUe1r5isWfpnPKjPasBg== X-Received: by 2002:a05:620a:46a6:b0:75b:23a1:69ee with SMTP id bq38-20020a05620a46a600b0075b23a169eemr3480460qkb.5.1694203391259; Fri, 08 Sep 2023 13:03:11 -0700 (PDT) Received: from fedorinator.redhat.com ([2001:9e8:32da:e500:513e:fbe9:e455:ae67]) by smtp.gmail.com with ESMTPSA id c17-20020ae9e211000000b0076f15f2918fsm825920qkc.63.2023.09.08.13.03.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 13:03:10 -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 v2 3/5] kernel: watch_queue: copy user-array safely Date: Fri, 8 Sep 2023 21:59:42 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: 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 --- 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