From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34D8635F1A; Fri, 24 Nov 2023 19:11:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="rd+xT49A" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B616EC433C8; Fri, 24 Nov 2023 19:11:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1700853088; bh=KosllX5Bujem8TW41mxUYgZeSZ3rOs6XFXLWyPW1AYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rd+xT49AnYcd0JmyDSSKL5D0rxR3lz8UQOUaPWAiMMoj6XaM+f3BCzmWh8dFLDBOm T4NjzGBfDbinFP8zv0+eViIIsd09JDWTsKnDsRw/IMK4102GliD+rLEEAL7P6fvodj txxegRF17yWth557CIq9WP9OvaMztZH6i8ab4LgY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Airlie , Philipp Stanner , Kees Cook , Zack Rusin , Sasha Levin Subject: [PATCH 5.15 024/297] kernel: watch_queue: copy user-array safely Date: Fri, 24 Nov 2023 17:51:06 +0000 Message-ID: <20231124172000.949913892@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231124172000.087816911@linuxfoundation.org> References: <20231124172000.087816911@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Philipp Stanner [ Upstream commit ca0776571d3163bd03b3e8c9e3da936abfaecbf6 ] 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 Signed-off-by: Dave Airlie Link: https://patchwork.freedesktop.org/patch/msgid/20230920123612.16914-5-pstanner@redhat.com Signed-off-by: Sasha Levin --- 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 54cbaa9711398..ae31bf8d2feb1 100644 --- a/kernel/watch_queue.c +++ b/kernel/watch_queue.c @@ -338,7 +338,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.42.0