Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp7235382ybh; Thu, 8 Aug 2019 12:15:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMHK8pR62UX5QVZmTAEZSyVI0MP0jfRvI6oAevU5DNovh78TP2//3yOjg96tQ1VrhHZjlv X-Received: by 2002:a65:448a:: with SMTP id l10mr13846387pgq.327.1565291750958; Thu, 08 Aug 2019 12:15:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565291750; cv=none; d=google.com; s=arc-20160816; b=r4tW4OeI1K+Ta3MBMWlXSs/42+zQGXnGdIfXf49NNNbFcgud5i/5egCbJQUiCJpE6t MU+jRo1D/W9Bz9hMc7JVsXpeLSkgBPNx4TVlC0/XyDRoLalWJXlz3VWa/emR9l164Np6 h7Oym30Gej+psxEbL0kM/as+WTNpMp3s+C5m57Q6obHjOghFSv/u/kGpn8k9lhmtgxIE 6FAIIXHAl/I6b+Xa3ZBr0U9tz0nc8iUdpYSeLVRCFtI0gz0XqKDCTfVza0HE9w5VeCSV DxzNcHeserE8y0tVzRouIiu8IW7B+mwZB4n6s64U+6u+JXUqnLE/cm74voD1MHm6jsZZ bBLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fEtRkTc5eUrZrrmDQf2IefjBEzvbNF0GvgSACv6WiOU=; b=tYMk3kKb7sYqnk7vmfmZ088wZwRoL5qezdx1byv8StVFvZsMcfHJDVZlfdfQq45ac2 jVTwNVNzNHY+11fR32yqZgsKHqdDqOrS7obwk9sM+Z4cXtqdWFhVP+7uI1PuViPYTmzb HXWIJyXJpQ1HDpOdhqJVUd2/I3+bIkgan9dwP5cslWDS5UVAPInIRp4Q2OfRwkiSNEao UME8x6DMRs3YDeZ3Yx/B1HDo28hJrxCBhIbYDx0hdsAyfSyTurCsQyVphWztBWRLqCGN y/zRQnXe+rWC7LqRWDGm6O9pdidFGdZ3eTX0fpodzHlZKTcK3HeZJS51Mq3thtUVyo+s vyFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LJbu7nfm; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e17si19221044pgt.192.2019.08.08.12.15.35; Thu, 08 Aug 2019 12:15:50 -0700 (PDT) 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=LJbu7nfm; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405268AbfHHTKT (ORCPT + 99 others); Thu, 8 Aug 2019 15:10:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:44612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405258AbfHHTKR (ORCPT ); Thu, 8 Aug 2019 15:10:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DD66E2173E; Thu, 8 Aug 2019 19:10:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565291416; bh=71bXpPWIS2fJrK8CEpVP4B8xiOQgtraTTJI76LPQ7Ug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LJbu7nfmpnEI8h8SeQ8gKmCgb96OchzalEwTsY5dOcoOUwUGhZCuBIyzztTwsjAe6 usoa1lBrzuoUF0Z9j7AyuE1Bam/6CyAK8Ic4YcwOXzsIBzg/R+JkLdhZO02a0e+E7k jC1xSZo902A10RrwLUZV3zbdE+qSWKMC+NaDiz60= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qian Cai , Tariq Toukan , "David S. Miller" Subject: [PATCH 4.19 24/45] net/mlx5e: always initialize frag->last_in_page Date: Thu, 8 Aug 2019 21:05:10 +0200 Message-Id: <20190808190455.081180292@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190808190453.827571908@linuxfoundation.org> References: <20190808190453.827571908@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qian Cai [ Upstream commit 60d60c8fbd8d1acf25b041ecd72ae4fa16e9405b ] The commit 069d11465a80 ("net/mlx5e: RX, Enhance legacy Receive Queue memory scheme") introduced an undefined behaviour below due to "frag->last_in_page" is only initialized in mlx5e_init_frags_partition() when, if (next_frag.offset + frag_info[f].frag_stride > PAGE_SIZE) or after bailed out the loop, for (i = 0; i < mlx5_wq_cyc_get_size(&rq->wqe.wq); i++) As the result, there could be some "frag" have uninitialized value of "last_in_page". Later, get_frag() obtains those "frag" and check "frag->last_in_page" in mlx5e_put_rx_frag() and triggers the error during boot. Fix it by always initializing "frag->last_in_page" to "false" in mlx5e_init_frags_partition(). UBSAN: Undefined behaviour in drivers/net/ethernet/mellanox/mlx5/core/en_rx.c:325:12 load of value 170 is not a valid value for type 'bool' (aka '_Bool') Call trace: dump_backtrace+0x0/0x264 show_stack+0x20/0x2c dump_stack+0xb0/0x104 __ubsan_handle_load_invalid_value+0x104/0x128 mlx5e_handle_rx_cqe+0x8e8/0x12cc [mlx5_core] mlx5e_poll_rx_cq+0xca8/0x1a94 [mlx5_core] mlx5e_napi_poll+0x17c/0xa30 [mlx5_core] net_rx_action+0x248/0x940 __do_softirq+0x350/0x7b8 irq_exit+0x200/0x26c __handle_domain_irq+0xc8/0x128 gic_handle_irq+0x138/0x228 el1_irq+0xb8/0x140 arch_cpu_idle+0x1a4/0x348 do_idle+0x114/0x1b0 cpu_startup_entry+0x24/0x28 rest_init+0x1ac/0x1dc arch_call_rest_init+0x10/0x18 start_kernel+0x4d4/0x57c Fixes: 069d11465a80 ("net/mlx5e: RX, Enhance legacy Receive Queue memory scheme") Signed-off-by: Qian Cai Reviewed-by: Tariq Toukan Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -420,12 +420,11 @@ static inline u64 mlx5e_get_mpwqe_offset static void mlx5e_init_frags_partition(struct mlx5e_rq *rq) { - struct mlx5e_wqe_frag_info next_frag, *prev; + struct mlx5e_wqe_frag_info next_frag = {}; + struct mlx5e_wqe_frag_info *prev = NULL; int i; next_frag.di = &rq->wqe.di[0]; - next_frag.offset = 0; - prev = NULL; for (i = 0; i < mlx5_wq_cyc_get_size(&rq->wqe.wq); i++) { struct mlx5e_rq_frag_info *frag_info = &rq->wqe.info.arr[0];