From patchwork Mon Oct 24 11:30:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9386 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp478073wru; Mon, 24 Oct 2022 07:16:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7a8t/NmCV13m26fTsqEbIlmbHlqKw18BeU7vjmDJiraY7iNr47DQkXFGanp1hZc+3bz5NH X-Received: by 2002:a17:906:db07:b0:77b:82cf:54af with SMTP id xj7-20020a170906db0700b0077b82cf54afmr28825814ejb.666.1666621009312; Mon, 24 Oct 2022 07:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666621009; cv=none; d=google.com; s=arc-20160816; b=en9n7I/lsHNyqazwvgMeTeDHZs695OV40JH/SmVUODoyVsaeCcoDPiaETGwkUJNo4D wKGhSXOplH0Orpj7yZJX8RuE3lcl97Szftp7MKpdX3Nma35gL+SVpUYOIZ4/WK4eOsXl JxMU+UAiVwRBPsC2m1rB7UAMs8R2N7WDAzCVBLtmdwyE9UtZvFkwS2c1cVtoAarIepKe O7mrl51psCrO5azW1ROwHF5/W6hg7wIsdasiyFbioXYx2jfn5ArEFoFQrOPqPuqd0bTr IY4I2zgU8ae/YlwThzm82ZMwoJ+QAbITSWn6+1PG05tmRCA9veQGklMZVmQsO93J+d/A XqAg== 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=6tQBrfAK0qfWNJjknCuerIL0TvG9+yiTteKfHSU2HEU=; b=okTEOLrmHeysG49WXhvjWDv4mq18ReTWo5Ix1dYxFDI03m2+ZUb+j1CO2PI7cET5Ho 638xxgZYBpt7lYIFt0NlaxopgckrhwioyHcJwN9VMWUFfwGIVBXu+/uJTNaz6Y7iyX2r SQabgweYOVx1X/8GCUVual4HtiVVusfjEAvs294XpMi4+wR+O7VwhFe6IgVsBwxKM5gV ee/YxNs/Ip40b1++ml3yKZsm8RGz2qves6cG3LR9e8LhDMGdckmz9t96XRd9A+8xE0re aIkrlZ6AiIitKYIivX0+v/Pqe0ZKQ8Iy8d5uzW/40rgE792bbaC2aCYcPaOvVp3XK1WB 1zpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Zf9qic1h; 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 hw8-20020a170907a0c800b00787d0dfe70csi26095195ejc.981.2022.10.24.07.16.24; Mon, 24 Oct 2022 07:16:49 -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=Zf9qic1h; 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 S234236AbiJXOCh (ORCPT + 99 others); Mon, 24 Oct 2022 10:02:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235830AbiJXOBs (ORCPT ); Mon, 24 Oct 2022 10:01:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 984BDBECC1; Mon, 24 Oct 2022 05:47:49 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 8948A61325; Mon, 24 Oct 2022 12:46:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D91BC433C1; Mon, 24 Oct 2022 12:46:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615568; bh=1i8zogkR9T6NCoZU+5CHCQYY7T+Jg21kj+WmzzdA27o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zf9qic1hMXJn58boWXkiebvNZpnxqzgGqh3sRfCoE1u6XZd4E4G+XNSd3GyzM3Ljt okTxBZ/M+LaBK4rgtvvXJYNyPc50+iIddn9iCQalfXDCC4/h1OLduXYA+l1SPXgq1O IjF87lvNbyf4idv9FwG2gHf7SW9Isyvu4h+HvUHA= 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.15 293/530] fpga: prevent integer overflow in dfl_feature_ioctl_set_irq() Date: Mon, 24 Oct 2022 13:30:37 +0200 Message-Id: <20221024113058.328763973@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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?1747578791443366809?= X-GMAIL-MSGID: =?utf-8?q?1747578791443366809?= 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 f86666cf2c6a..c38143ef23c6 100644 --- a/drivers/fpga/dfl.c +++ b/drivers/fpga/dfl.c @@ -1864,7 +1864,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);