Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2281201rdb; Sun, 3 Dec 2023 09:51:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFNIkYr1BPvC+0wOSA+ZHUMqYp4f1ylehfht0a+iMHACAta+3HJWp1X7hDPrDwUJQfZIqvo X-Received: by 2002:a17:902:6a89:b0:1d0:5218:a7e9 with SMTP id n9-20020a1709026a8900b001d05218a7e9mr2554289plk.53.1701625864693; Sun, 03 Dec 2023 09:51:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701625864; cv=none; d=google.com; s=arc-20160816; b=bmb2Nu/5Y8bVsJyqX4t3S30jW+lfCCbJr5ghZ5PWSVV7PuH1pUMcWKEdFbrAhgNoQ9 immX2Ixj6MgZZ7NM8BCfUYow22b5l7ZceVlhsLvh6m3+jWU/XBfAyPrOPLZN8USAVg9b D5FDEfN3mDV8g7poWxZ9ww+B7UpyDdmV7K2Azv83ephI7LnQPD/B4nHeL1tDCuAqLrMn LRax9H4WyyyfsRuNusF3hUjlT19OOs8OO/N/QLA6lbyiabqm8RhLa0n2nlK4b8n0PnaF QxxpNiyISowrOFFWgRdVHA4el8Kveorz5L/sx4tz0FNTzPS9Z0Pai3e66BVoSEt37zRI VdUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=PZcqgfs/CQtOQh2cLTm0SgQUK8AKS2y9lLHuT9cmzls=; fh=cOhTH+43Zz1KwFwVIIQ2HnizQS8KZIP9ZzKGkenQHus=; b=SlQDR91KGBzdLF8r/1XtO/BooWOUkj3MjGMO2Lk6Jnbcj7jdh64ICJlIBWb1cF01XH XV9+jNm7gAGa2HQDttM+0+qdMNdUeSrMYnb8YhHpNoaXWMgLHN/O+JpBP9v2ZdLQvJXQ tShuRxbF2VtvNgwqYyXObnf7RYGpIPm7q/W0LtdcxnxAY5PPGmFsbrpF8jP1pszbJTbI cFgnngeh3J3+6d1pyCqq50TOIT3GzLitXM2ZogK86FqPp5hgI0gNCtd+jtA6SVimSQXy gz4Q+Fe9+ZwRjKxexHqapmlCFrdghyxAYz6P1el7RuZZxbkYJpvc9qBNUqmExVHCwjAI 4dGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="A7Y/TuEp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id mq7-20020a17090b380700b00285be1801d8si6855780pjb.101.2023.12.03.09.51.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 09:51:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="A7Y/TuEp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id ECFE7807C85B; Sun, 3 Dec 2023 09:50:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229772AbjLCRuQ (ORCPT + 99 others); Sun, 3 Dec 2023 12:50:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjLCRuP (ORCPT ); Sun, 3 Dec 2023 12:50:15 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 056BCD3 for ; Sun, 3 Dec 2023 09:50:22 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A9D5C433C8; Sun, 3 Dec 2023 17:50:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701625821; bh=KaCBA7aWetgNynrDp9I/L5TG0YXmHua23gxLEqwslEw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=A7Y/TuEpYv7g7QuAjMRI8Pgilq10cC6gmaahN0JJV8K4PcZgm5SOqgVtdyu3VEXqp 6iM8eukVtdjbPI+a2jeunwaut2pyMLHEaS3ryk43p74agXW/oFyY8J3IuUg0fN46Ms LS4DikhG8FmNVdryCKzC6wY1FXXavqZzCWoHRAJn1sQTFh+VKK6VW2kyE4uJWIoP2E 7FWJs0s0aqlCyZUt7qeRhPAbuwqIbZE0UwchkYuO9iUmB0P1t26l91qfSae2rn/pBe vAdoca4MJ0wd9M4Se4RRPH8HHJlWFUlBulORCqW/YJhYfh3X0/tycYDEJDV1XpSz2e 2PFfZ/EDXmL7g== Date: Sun, 3 Dec 2023 17:50:15 +0000 From: Simon Horman To: Shifeng Li Cc: saeedm@nvidia.com, leon@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, ogerlitz@mellanox.com, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, dinghui@sangfor.com.cn, lishifeng1992@126.com Subject: Re: [PATCH] net/mlx5e: Fix slab-out-of-bounds in mlx5_query_nic_vport_mac_list() Message-ID: <20231203175015.GP50400@kernel.org> References: <20231130094656.894412-1-lishifeng@sangfor.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231130094656.894412-1-lishifeng@sangfor.com.cn> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sun, 03 Dec 2023 09:50:40 -0800 (PST) On Thu, Nov 30, 2023 at 01:46:56AM -0800, Shifeng Li wrote: > Out_sz that the size of out buffer is calculated using query_nic_vport > _context_in structure when driver query the MAC list. However query_nic > _vport_context_in structure is smaller than query_nic_vport_context_out. > When allowed_list_size is greater than 96, calling ether_addr_copy() will > trigger an slab-out-of-bounds. > > [ 1170.055866] BUG: KASAN: slab-out-of-bounds in mlx5_query_nic_vport_mac_list+0x481/0x4d0 [mlx5_core] > [ 1170.055869] Read of size 4 at addr ffff88bdbc57d912 by task kworker/u128:1/461 > [ 1170.055870] > [ 1170.055932] Workqueue: mlx5_esw_wq esw_vport_change_handler [mlx5_core] > [ 1170.055936] Call Trace: > [ 1170.055949] dump_stack+0x8b/0xbb > [ 1170.055958] print_address_description+0x6a/0x270 > [ 1170.055961] kasan_report+0x179/0x2c0 > [ 1170.056061] mlx5_query_nic_vport_mac_list+0x481/0x4d0 [mlx5_core] > [ 1170.056162] esw_update_vport_addr_list+0x2c5/0xcd0 [mlx5_core] > [ 1170.056257] esw_vport_change_handle_locked+0xd08/0x1a20 [mlx5_core] > [ 1170.056377] esw_vport_change_handler+0x6b/0x90 [mlx5_core] > [ 1170.056381] process_one_work+0x65f/0x12d0 > [ 1170.056383] worker_thread+0x87/0xb50 > [ 1170.056390] kthread+0x2e9/0x3a0 > [ 1170.056394] ret_from_fork+0x1f/0x40 > > Fixes: e16aea2744ab ("net/mlx5: Introduce access functions to modify/query vport mac lists") > Cc: Ding Hui > Signed-off-by: Shifeng Li Hi, I am unsure how you calculated the 96 figure above. But in any case I agree that the cited patch introduced the mismatch that you describe. Reviewed-by: Simon Horman