Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1940560iob; Thu, 5 May 2022 11:21:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTWk1R3i2A8Qws4Nf3K1R671khDkDDoSBlsiRjD4Bhu4FUJq/7IX/ZGmQ+77S3xkU9RzI/ X-Received: by 2002:a65:5245:0:b0:39c:ce49:e97d with SMTP id q5-20020a655245000000b0039cce49e97dmr23172113pgp.301.1651774914336; Thu, 05 May 2022 11:21:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651774914; cv=none; d=google.com; s=arc-20160816; b=yycNUlxCcJb7YXSgETqYGwW66Yagel+9K/Ssh5XUOgMdV2NolJfEfDQIX6LZ9JyYi7 3F248ZwOaIN7WvYvb8gMkQdINPi41L5ROYNFsIJX0WXSfRGDGDHymNvMGTWdzk01H973 YjBNDjJX11SIH6FLaSSwf0IhSWhnHCk90siO0jVhzYVOd+qrLzoRKWFBwez5PrJwz85B MpQ/1kSvcCszQ/sMpqC1GIhcCkbhdcuGeBKkO3slNwk4FI4q+s97XpUW0GrnDhbcm+Zi rhmqhRhQirW73HGrty8ZZ2r9058neLKEQ7skcrLIswZkSWUWZgqWnAgq3H3igap0HfHt AZDQ== 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=lkdCzkm5OFkacZOuRoT/vSzZj0C97QvQGOAIi4esx2A=; b=yULoTFbI9RC9mR9j53gf0PE1zn7Sd/YoGZrSSsM+WCFTP727HfqanbgKFBzT3PIf5J UR6SK5/o5CgqQ2bHOwkOw/Nb0AbmzS+iiRXLgTii+IzwjB/OQY+jKcotYqez79RXDdLg wfilY8u8jNb+e5mB3qB57qEhfbM/8+RTluy9fZZ1xxptgKCPdPH5A9q+JW+Jwn2A89fG 6mVLGnMORszYR4miQZt1H/zrVSHv4G65nDXTBR/u00hYBJAKnVIxR/MJLj1PvZdXOzR9 6hICpR5JxOZIrqI08NYO309eDVniwu9RhCQSNolMKi2fRSPMWVMNZVh+obz6KBhNzo6T IH3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=g0UOJwuR; 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 x2-20020a170902ec8200b001569582f24bsi2944960plg.118.2022.05.05.11.21.37; Thu, 05 May 2022 11:21:54 -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=g0UOJwuR; 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 S1356928AbiEDRWU (ORCPT + 99 others); Wed, 4 May 2022 13:22:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356141AbiEDREz (ORCPT ); Wed, 4 May 2022 13:04:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5E095044A; Wed, 4 May 2022 09:53:53 -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 00F90B8278E; Wed, 4 May 2022 16:53:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76E20C385AA; Wed, 4 May 2022 16:53:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683230; bh=JrrDOlBVAfWDdjJZys8Nl/UqHDzlTicg1HmdZAOETbY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g0UOJwuRjgabAa8HNaLagH4gs9FqDJ/DHdXpgl0dChhifIupC7RR9xSzBTRmUqthL yq0LscY+OF/Vb5VorbSBfpfdDtE6rmLsGmP2rRSKsm45xR2XTwUQYANvUhbKsaVSSy OdmbGAHx7rooAXiMZGhphK2mWCXf0FjpyCCWq3+Y= 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.15 095/177] net: hns3: add validity check for message data length Date: Wed, 4 May 2022 18:44:48 +0200 Message-Id: <20220504153101.599292489@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@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 e30bf3027375..c256305a2212 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -93,6 +93,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