From patchwork Sat Oct 22 07:24:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7453 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1098551wrr; Sat, 22 Oct 2022 01:11:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6HOP8iedOik1HBUTsiuhzxNbQAlucH4xUZyqztwFjA515P4xoEvJlVAY2nIT+8n1HHUjiE X-Received: by 2002:a17:90b:3890:b0:20a:9ab0:6fa2 with SMTP id mu16-20020a17090b389000b0020a9ab06fa2mr63861640pjb.49.1666426272595; Sat, 22 Oct 2022 01:11:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666426272; cv=none; d=google.com; s=arc-20160816; b=0fdg2NaDWFArZMy++p4nL9Zs8lQLsHf2uEpqve9ZpejVS7tK8/ljUSPtYtps0gFchK XFUXanOj8D9smwX0hd9G55GIx/VBU4rC5s2kaPoFpCJUmEwc9PyuMYdBXNhxg6zne173 +vwNnpZ4HrElE8p5wVG90QhopGH+BEJw9teic8UeNq809iHbvHitTIxEZmjIYP/R4PuT EHfKCrinD/XVSth/RgakZ6IUCgCOsYtnAZe8C0iHYwu0JqUUSyzL01Oa02JaJAqsRZxo 8V4VP26rZIJRvfshRzP7Z7GbWdXYMca9t/ZfhMvEj1lgfDoGzPhNnksCFxEFe0jyW5WL sHKw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zgOhxCVA+GWC6bDkrHoHwHBw7MqggW9lv+q5t0AaaRM=; b=P0+L3NvgjySJl/NXwONzaLPR6IjPBUpGB7EBRpUw4S0LSWYO8TC8UpNi3YZSXt6/hv CiDdWLakFcFYWdO9miIl/oWrms3Rfv++zHj32YWwlNnUB9rCLohQSEnhHvaWvT+5IO8V Ihu1WfSnmduBIbQYMnWdLcUcDX+DaLMVWOkCx1kbG9oUMQY/RRL2xEajjvEp6AYnS+Hd XkdtRKeinH8yRq3a5JvlnWztEUU4dFZNfpi3sk053ZqMavL+UIrLdng5Yv4waQI5HCJi K7Uo8U+G1JDBDbBLyD0HAHWlIsh3HsFxUtmqh3l1mu5L+p4WdJqduwOTx2SXcKhB+oZ2 eX3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U+BY4A4k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u185-20020a6385c2000000b00463dede6203si1858515pgd.699.2022.10.22.01.10.57; Sat, 22 Oct 2022 01:11:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U+BY4A4k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232406AbiJVIKG (ORCPT + 99 others); Sat, 22 Oct 2022 04:10:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232804AbiJVIGE (ORCPT ); Sat, 22 Oct 2022 04:06:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A89352C2ADE; Sat, 22 Oct 2022 00:52:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id F2A61B82E16; Sat, 22 Oct 2022 07:52:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51BAAC433D7; Sat, 22 Oct 2022 07:52:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425160; bh=eRxJ1kJpepxUkHWp5jwbtxrvWiVTvKzPrLq8OH8PndI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U+BY4A4kr5Z0Zd+82Z3kxunPMiFf9voTuXVAAFc0qeE9E6mUz0CZeddy2YH6mXI16 k8sHERaL78gI/sajzGhJIDWWmolW5zvyWLeWec+nDtrwZdgEyyMGMdKzk5sVqzmP4+ JJPRfwdOqpS7Mx/pq3qSD1iZRsHHwBfC6pQR29WQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Xu Yilun , Sasha Levin Subject: [PATCH 5.19 410/717] fpga: prevent integer overflow in dfl_feature_ioctl_set_irq() Date: Sat, 22 Oct 2022 09:24:49 +0200 Message-Id: <20221022072516.217478075@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747374595247663623?= X-GMAIL-MSGID: =?utf-8?q?1747374595247663623?= From: Dan Carpenter [ Upstream commit 939bc5453b8cbdde9f1e5110ce8309aedb1b501a ] The "hdr.count * sizeof(s32)" multiplication can overflow on 32 bit systems leading to memory corruption. Use array_size() to fix that. Fixes: 322b598be4d9 ("fpga: dfl: introduce interrupt trigger setting API") Signed-off-by: Dan Carpenter Acked-by: Xu Yilun Link: https://lore.kernel.org/r/YxBAtYCM38dM7yzI@kili Signed-off-by: Xu Yilun Signed-off-by: Sasha Levin --- drivers/fpga/dfl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c index 6bff39ff21a0..eabaf495a481 100644 --- a/drivers/fpga/dfl.c +++ b/drivers/fpga/dfl.c @@ -1866,7 +1866,7 @@ long dfl_feature_ioctl_set_irq(struct platform_device *pdev, return -EINVAL; fds = memdup_user((void __user *)(arg + sizeof(hdr)), - hdr.count * sizeof(s32)); + array_size(hdr.count, sizeof(s32))); if (IS_ERR(fds)) return PTR_ERR(fds);