From patchwork Mon Oct 24 11:30:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9124 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp456339wru; Mon, 24 Oct 2022 06:34:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6g86oYb/PKZDUDDxbIgFwgh7tNV01vhHZ6nu9PTejczADWVQQsFcwts66V+2x+NjT9dPkX X-Received: by 2002:a17:902:b089:b0:178:54cf:d692 with SMTP id p9-20020a170902b08900b0017854cfd692mr33165475plr.1.1666618442984; Mon, 24 Oct 2022 06:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666618442; cv=none; d=google.com; s=arc-20160816; b=I2v1qYhXsOngodzKkxVD4MgBEFPBq+jy73kiW0MYYDY2oq3H95mxwfhlE03ffKV1GX M715UE5v/3fhSZDyAirSCripjEYmrLFrZeGZf7bUbmJ4jmqMOgpe3R8o3m7xmyVi2WlD cXW22s2gJJipcLG7fIV1w01AN8m1Mb/co5er18NIY2BDuYJ8GWipt+mkswana0m99zNm ZpBoQjReJ3VhBr7EDhhMDyfuwp2TBHfQoq79W4YnOGCJD9FeE3FP1bL1u2353tNzY9V9 QIq6gtWwhPRfuDnu2O8I16gc9lW0eKBSjxq086nlLS3dxsti3GG0M1Gb/oEHOqT5uJus mLSg== 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=fwgSJ1TIQV62+eBJg92Oex5SOJMI7JMnkv6lNLcXRSw=; b=O914K3WU7pete1wyRfGjmNKKRrL+TDvGU3jh8IvmiMwFtIXL5BOaXVdnpbp3cHkawo N4Ti+qa0ULVC4+J0uqsgQXU72QdRtV5K+3msA+/vsm59zpw2E+EPRoTO4rpshscQB0hc gPyQa9ks1m2DNuZWnUuxgHzh9hwtAynu0+EeqoWySmHBSYXoW8BOdpmyx0R+LvlrXlZK 2gNNfXYpvFtWNu2kAOtYnySIU6e5+bBtxJaZzrngvNAz4e6DD59Hmg4IK/gUEN1uSfmq QnE0miYzGfkmCly/bWAW2GHQkEult5IhnwkirKsuTxMOfwxZ7FoHWG+JSdhbVyj5c9Tp F/hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=b00ZQz3h; 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 v135-20020a63618d000000b0046ec7beb578si9974174pgb.94.2022.10.24.06.33.41; Mon, 24 Oct 2022 06:34:02 -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=b00ZQz3h; 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 S235876AbiJXNQZ (ORCPT + 99 others); Mon, 24 Oct 2022 09:16:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236097AbiJXNOr (ORCPT ); Mon, 24 Oct 2022 09:14:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06D68A2A8D; Mon, 24 Oct 2022 05:25:45 -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 7FFE1612D2; Mon, 24 Oct 2022 12:25:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BFC2C433D6; Mon, 24 Oct 2022 12:25:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614315; bh=zmCdnqZhVJQJyc3EsuY4FxJn+vF7xfP1KOgUoH30fl8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b00ZQz3hdyF0TjtPu60oGS8NZIXBkxI8YlMcQp0Y+ahE7B2OsYekEUQmPtHUC87Gg RRob5q5cdfyNEq3oJNQ1lHmZIwl/I5VwbFr6DVukerNPB2KtnUZXj3RL83QUWgdwD5 sShIrSnrDWRAJi5U9rRKi83TUwHp6srA57H4CQ5s= 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.10 213/390] fpga: prevent integer overflow in dfl_feature_ioctl_set_irq() Date: Mon, 24 Oct 2022 13:30:10 +0200 Message-Id: <20221024113031.867017383@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@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?1747576100432919417?= X-GMAIL-MSGID: =?utf-8?q?1747576100432919417?= 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 b450870b75ed..eb8a6e329af9 100644 --- a/drivers/fpga/dfl.c +++ b/drivers/fpga/dfl.c @@ -1857,7 +1857,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);