Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7279327imu; Wed, 14 Nov 2018 14:46:03 -0800 (PST) X-Google-Smtp-Source: AJdET5eBquY1whjp61Qz+YvdxEzqgX2LB9ndteB6xdQ7eobg3sjF9sZhrtarfQD8gzIZ/wcsW6G+ X-Received: by 2002:a62:27c4:: with SMTP id n187-v6mr3775809pfn.3.1542235562993; Wed, 14 Nov 2018 14:46:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542235562; cv=none; d=google.com; s=arc-20160816; b=rsg/EmEdeJCFpjBsq8rB6YyWPTjnVxbmaTBgYr9t0UofjpR02vr7fpPxHqhO2LuZ0J LGUq0FbuR2hB+xRHjPG2j2T2gcGQQd41qtFxwBwRlmt1nmQPAwcLj7arGXE4dewM7PJU HfA3joMdg3O3r8iOz7Rzhc7Xr2zSyPnsgzYNV6e3oBamAOsfYHGDpdfeIRnUsX/lPjvf HT1LQL9N1cGtyPLpmFlUIfoTFhEecxEFNM8gyeu+GVAGd1KyX21/dB8ufAZ4OjXuoHRQ f5cDXaz/FWau6oGGmHCKPa8/t5Txt6BYwyxydp1yjB15cRzRZVc6lRnjUeUTNXUK+6Yq y5UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=ZmbrelISXnaj1ugfAdyxIHK1wXvm1DXyer83hnZFXUc=; b=ardMm1w9pVmQme2Hjjm5aq2ciA5K2zEzfpZMfuZKhbco9N43473qpIG2Lsr5VZHUg5 Hr3OYrNdrr+3xVYBQuCxLB5ljgG5m6uS5DFjT1nJhSQP34Ki0Nz+jvckjzVg23hUmdw1 XqDgG6J/0Yu/QlZyiLMa8UfB7PpN2TlXK2G0dsMbaXaViCEQRAtqMHuM27PuVaZeEtZL s4HZ5ZpvX4LL72TiZn2socZ6keVH8OkdTrWmXvuzuZg4wD2DClSsQ+7L6XedSikkzGWM EZb/igTX3RMr5wlr58PFb2fCapVkHPiuoq6gBm1AaEea2thixLNFhd6uByiKKQB29hFk k4ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vZ6Ewy3T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j187-v6si5646277pfc.194.2018.11.14.14.45.48; Wed, 14 Nov 2018 14:46:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vZ6Ewy3T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728909AbeKOItf (ORCPT + 99 others); Thu, 15 Nov 2018 03:49:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:34392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728508AbeKOI1R (ORCPT ); Thu, 15 Nov 2018 03:27:17 -0500 Received: from sasha-vm.mshome.net (unknown [64.114.255.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A752D2251D; Wed, 14 Nov 2018 22:22:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542234134; bh=ybq5z4CJIjjwP3Ly8cWfft/zWljMttEEYvw3K0fh6ik=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vZ6Ewy3T9ORmcReLfETxhI2COj+8zSXlyQaovn1qHNRq/xBynO3l0POdkCFa/Lubh w8qoS23nF5ix6ziaKlSwQItwfOjODjT786VfdMYdtKH6Xv1zhNVhqmpc7kkPuOZdEH 7Yl49XZ7A9SU4eCtbDcYZ++hJAyS38yZdKLXeqxQ= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Yunsheng Lin , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL 4.19 26/73] net: hns3: Fix for out-of-bounds access when setting pfc back pressure Date: Wed, 14 Nov 2018 17:21:20 -0500 Message-Id: <20181114222207.98701-26-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181114222207.98701-1-sashal@kernel.org> References: <20181114222207.98701-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunsheng Lin [ Upstream commit e8ccbb7d2f53c62e14b889faaa3f6f809b657278 ] The vport should be initialized to hdev->vport for each bp group, otherwise it will cause out-of-bounds access and bp setting not correct problem. [ 35.254124] BUG: KASAN: slab-out-of-bounds in hclge_pause_setup_hw+0x2a0/0x3f8 [hclge] [ 35.254126] Read of size 2 at addr ffff803b6651581a by task kworker/0:1/14 [ 35.254132] CPU: 0 PID: 14 Comm: kworker/0:1 Not tainted 4.19.0-rc7-hulk+ #85 [ 35.254133] Hardware name: Huawei D06/D06, BIOS Hisilicon D06 UEFI RC0 - B052 (V0.52) 09/14/2018 [ 35.254141] Workqueue: events work_for_cpu_fn [ 35.254144] Call trace: [ 35.254147] dump_backtrace+0x0/0x2f0 [ 35.254149] show_stack+0x24/0x30 [ 35.254154] dump_stack+0x110/0x184 [ 35.254157] print_address_description+0x168/0x2b0 [ 35.254160] kasan_report+0x184/0x310 [ 35.254162] __asan_load2+0x7c/0xa0 [ 35.254170] hclge_pause_setup_hw+0x2a0/0x3f8 [hclge] [ 35.254177] hclge_tm_init_hw+0x794/0x9f0 [hclge] [ 35.254184] hclge_tm_schd_init+0x48/0x58 [hclge] [ 35.254191] hclge_init_ae_dev+0x778/0x1168 [hclge] [ 35.254196] hnae3_register_ae_dev+0x14c/0x298 [hnae3] [ 35.254206] hns3_probe+0x88/0xa8 [hns3] [ 35.254210] local_pci_probe+0x7c/0xf0 [ 35.254212] work_for_cpu_fn+0x34/0x50 [ 35.254214] process_one_work+0x4d4/0xa38 [ 35.254216] worker_thread+0x55c/0x8d8 [ 35.254219] kthread+0x1b0/0x1b8 [ 35.254222] ret_from_fork+0x10/0x1c [ 35.254224] The buggy address belongs to the page: [ 35.254228] page:ffff7e00ed994400 count:1 mapcount:0 mapping:0000000000000000 index:0x0 compound_mapcount: 0 [ 35.273835] flags: 0xfffff8000008000(head) [ 35.282007] raw: 0fffff8000008000 dead000000000100 dead000000000200 0000000000000000 [ 35.282010] raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000 [ 35.282012] page dumped because: kasan: bad access detected [ 35.282014] Memory state around the buggy address: [ 35.282017] ffff803b66515700: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe [ 35.282019] ffff803b66515780: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe [ 35.282021] >ffff803b66515800: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe [ 35.282022] ^ [ 35.282024] ffff803b66515880: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe [ 35.282026] ffff803b66515900: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe [ 35.282028] ================================================================== [ 35.282029] Disabling lock debugging due to kernel taint [ 35.282747] hclge driver initialization finished. Fixes: 67bf2541f4b9 ("net: hns3: Fixes the back pressure setting when sriov is enabled") Signed-off-by: Yunsheng Lin Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c index 5db70a1451c5..48235dc2dd56 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c @@ -1167,14 +1167,14 @@ static int hclge_pfc_setup_hw(struct hclge_dev *hdev) */ static int hclge_bp_setup_hw(struct hclge_dev *hdev, u8 tc) { - struct hclge_vport *vport = hdev->vport; - u32 i, k, qs_bitmap; - int ret; + int i; for (i = 0; i < HCLGE_BP_GRP_NUM; i++) { - qs_bitmap = 0; + u32 qs_bitmap = 0; + int k, ret; for (k = 0; k < hdev->num_alloc_vport; k++) { + struct hclge_vport *vport = &hdev->vport[k]; u16 qs_id = vport->qs_offset + tc; u8 grp, sub_grp; @@ -1184,8 +1184,6 @@ static int hclge_bp_setup_hw(struct hclge_dev *hdev, u8 tc) HCLGE_BP_SUB_GRP_ID_S); if (i == grp) qs_bitmap |= (1 << sub_grp); - - vport++; } ret = hclge_tm_qs_bp_cfg(hdev, tc, i, qs_bitmap); -- 2.17.1