Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2545856iob; Fri, 6 May 2022 05:27:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDxTSYnQYLfnA+T7+AM1vcTT0L/wfAfCR0o+rh9hLWA4YM+agv3t59gNZQCeFYxGPcy8m5 X-Received: by 2002:a17:907:72c2:b0:6f4:ef00:4588 with SMTP id du2-20020a17090772c200b006f4ef004588mr2715072ejc.515.1651840052416; Fri, 06 May 2022 05:27:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651840052; cv=none; d=google.com; s=arc-20160816; b=g8PAi2VGvW6TQQVMqVpxBNtkYvdoU2kKoM69d5nrF8VzkoV81OjSd36eLSqmjCmtZM BLStdTPCFcrIAod+6QxVYdZlcMOkHZluTbTg0Ah0ygLIfbyOW5M5jtGUJAfUFORrFkOb KKUwPLxmJlS7Q5luZM69sAI1xHopdIf514YTAxVZgcuDlaW8thTc7olUG98KNvOx8Vhl r+J0sazEi01BKNf85Fc8zcHir81zK62K7YmpZ33ZAC3d1pW548YzadC4jL4I7VKdCU4S 9ol7MsvXm5JVx1uBdB5JB9OZJW9UYovfVB/F9l0WwpQkzV6FQW8L0M3WPva4zxKTVjDh Cq/g== 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=w0BJ4STfm5HcUIlR7JoHzyYxpomfAgtMY9PuMbYDueY=; b=0SeS5waYsP2C5cgMDEOLZLPi9i2AsQkj+aqamq6JvK05hAdoSRKUzq8leeFMOo7nJy Xq5fXfR7uyfJ37gu5Wg7vdgZNLPLmXUvs2sleOqJSnbAk4nmA+7Vir7OPHHvtQ9KjloV ilFgqrUTgo4+i0UROzGNJ3OpUHAoxm9XQZXcwqWIxdBz2Yew4T7yAbCsErkzPHAD7aRW z7p59kpvkQt4rH2E1dtQHQz8VG2iU+oqMFxs/JT1SWwoylFmxVRHQVxBwfJRHFvEGABR ZxYb4rg+peeFcs8tKJhENPaEg2mx17GjektSSOfKjy0a2vtsYhqpgBXJBryIVJri7iho pVag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BZj+rOLr; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f2-20020a170906824200b006f3a0691af7si4430501ejx.130.2022.05.06.05.27.06; Fri, 06 May 2022 05:27:32 -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=BZj+rOLr; 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 S1355663AbiEDRLr (ORCPT + 99 others); Wed, 4 May 2022 13:11:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355035AbiEDQ7h (ORCPT ); Wed, 4 May 2022 12:59:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF95348E76; Wed, 4 May 2022 09:51:14 -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 15100617C2; Wed, 4 May 2022 16:51:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F068C385A5; Wed, 4 May 2022 16:51:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683073; bh=PbnDXMsiqXRFV37wHPynCfNOIQWwNRS0+/3UQ4ufAPE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BZj+rOLrzBuUxyOdNXPnDgdKZYcFlSBt0nx+8Lv84FizWa65nQTQVXDebT2xvdC/C NJBTjDYvms7RtKLuhh+Tw9knsgN7j/DBRF7OumqE5mQBpmzUJzr0trEm5uSXdo7zTg ZIItlB6Fc5egp0R6c86Yq8RjmKVc76qQ8EfRkUek= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jian Shen , Guangbin Huang , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 077/129] net: hns3: add validity check for message data length Date: Wed, 4 May 2022 18:44:29 +0200 Message-Id: <20220504153027.279669420@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153021.299025455@linuxfoundation.org> References: <20220504153021.299025455@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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,T_SCC_BODY_TEXT_LINE 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 From: Jian Shen [ Upstream commit 7d413735cb18ff73aaba3457b16b08332e8d3cc4 ] Add validity check for message data length in function hclge_send_mbx_msg(), avoid unexpected overflow. Fixes: dde1a86e93ca ("net: hns3: Add mailbox support to PF driver") Signed-off-by: Jian Shen Signed-off-by: Guangbin Huang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index 2ea347b822db..b948fe3ac56b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -91,6 +91,13 @@ static int hclge_send_mbx_msg(struct hclge_vport *vport, u8 *msg, u16 msg_len, enum hclge_cmd_status status; struct hclge_desc desc; + if (msg_len > HCLGE_MBX_MAX_MSG_SIZE) { + dev_err(&hdev->pdev->dev, + "msg data length(=%u) exceeds maximum(=%u)\n", + msg_len, HCLGE_MBX_MAX_MSG_SIZE); + return -EMSGSIZE; + } + resp_pf_to_vf = (struct hclge_mbx_pf_to_vf_cmd *)desc.data; hclge_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_MBX_PF_TO_VF, false); -- 2.35.1