Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3394144ybp; Sun, 6 Oct 2019 10:59:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPxcL40hg+8lBUOxLltT+hleuK7yuomXqXkHQw23licMJ+PAEoJKLLwSOneOjNphkzO2iq X-Received: by 2002:a05:6402:6c6:: with SMTP id n6mr25054077edy.162.1570384751039; Sun, 06 Oct 2019 10:59:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570384751; cv=none; d=google.com; s=arc-20160816; b=NuSFkcTd6UlqFrail2tzUqlC3MwvW9YvWO5000+mm931sHCscqKkQ2ryTggGF+VyrU VjTywi1FgchVwK8/JLtdWpACCtmQFo4Ii1HV9cU0r9sphg8mSFoRAiQY4+AbHbDwB9P4 LIFW6wljcp4xYy4qgY+nm7kcbkOcdnqTLEVWANA4Cu7iG4YP6pW9FGJlY6xQAPFCdR+F e+0iYFA5idEj1ZskcBi57tfoedvnDNr+7FkuScbXy5ZkNLpl9HcGrJ2TviPL2cYLY7N2 0ywR+xnCNJ9faipFJ0kKcG8sqTRqV0TLIIFoKEKSmUfUDHaWytR1pB20oVTcgkpH+xuc Ku1A== 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=PM1GGlAr2ARxorABpG2mpbZdeXAvMXgBT10qgrW0kTU=; b=uwwdHmWBbdVjUw20FGCN84RYnYEiM4J4n2KjJOzT7lGzdGZbCBoz6K22tmQ9z3cCRh XocpZY+Cw6/n20KcGM1bfZTNOiLVefUvTHZ6MmIzJT3FPlTSCi7IUHsz0YicICjZ1HUT cNGAez2Wj8H3XiHagu+EjHAfpGT7VUfhzZbuiVJdKQu036KBOoeE6C4hAqLm5XwjWrHB IWAgD/6Aki+CFoE5BEmK3U4Z6pbXWMfuuzgNVeQaHoaFDC5N/jHzz3rQ3TYTqOnrJllV Ig1sT6CsSCkWtx94plpXs9bNUsPJT3K76cpXQrc86pSjo4lEnUWMvB5oooNbLpip/LgH cihw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zx1MgU7W; 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 o32si7560811edc.306.2019.10.06.10.58.47; Sun, 06 Oct 2019 10:59:11 -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=zx1MgU7W; 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 S1727876AbfJFR6a (ORCPT + 99 others); Sun, 6 Oct 2019 13:58:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:58482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729091AbfJFRcF (ORCPT ); Sun, 6 Oct 2019 13:32:05 -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 0E0E4214D9; Sun, 6 Oct 2019 17:32:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570383124; bh=lzf4NezQwvnIwgsemkILbMCirg6UhvXpkxXQMME+7bw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zx1MgU7WZsUGNr04bSLfnIDa4IIJ3Bft/25mLaoW7Dn4dwLlJckA0HPlMYpLjXU3g s8p0R5qyMxV/cj/CjajZoo5zppGw82cfRjjkWeQKfdCFUtne/sMVCYdDr162Vm91Q5 PNGQiR06VuabL6Ph/tGCxxfXt8dFYuxu7W7UpKSw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dotan Barak , Sudhakar Dindukurti , Santosh Shilimkar , "David S. Miller" Subject: [PATCH 4.19 096/106] net/rds: Fix error handling in rds_ib_add_one() Date: Sun, 6 Oct 2019 19:21:42 +0200 Message-Id: <20191006171201.744213878@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191006171124.641144086@linuxfoundation.org> References: <20191006171124.641144086@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: Dotan Barak [ Upstream commit d64bf89a75b65f83f06be9fb8f978e60d53752db ] rds_ibdev:ipaddr_list and rds_ibdev:conn_list are initialized after allocation some resources such as protection domain. If allocation of such resources fail, then these uninitialized variables are accessed in rds_ib_dev_free() in failure path. This can potentially crash the system. The code has been updated to initialize these variables very early in the function. Signed-off-by: Dotan Barak Signed-off-by: Sudhakar Dindukurti Acked-by: Santosh Shilimkar Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/rds/ib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/net/rds/ib.c +++ b/net/rds/ib.c @@ -143,6 +143,9 @@ static void rds_ib_add_one(struct ib_dev refcount_set(&rds_ibdev->refcount, 1); INIT_WORK(&rds_ibdev->free_work, rds_ib_dev_free); + INIT_LIST_HEAD(&rds_ibdev->ipaddr_list); + INIT_LIST_HEAD(&rds_ibdev->conn_list); + rds_ibdev->max_wrs = device->attrs.max_qp_wr; rds_ibdev->max_sge = min(device->attrs.max_send_sge, RDS_IB_MAX_SGE); @@ -203,9 +206,6 @@ static void rds_ib_add_one(struct ib_dev device->name, rds_ibdev->use_fastreg ? "FRMR" : "FMR"); - INIT_LIST_HEAD(&rds_ibdev->ipaddr_list); - INIT_LIST_HEAD(&rds_ibdev->conn_list); - down_write(&rds_ib_devices_lock); list_add_tail_rcu(&rds_ibdev->list, &rds_ib_devices); up_write(&rds_ib_devices_lock);