Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4590063pja; Thu, 21 Nov 2019 22:25:27 -0800 (PST) X-Google-Smtp-Source: APXvYqyFYO2Zsr0Ps7ZETqQOuy0zA9Fhu4NY1WRM6G+guhv4GRpnthlZxf4blgm6xmTUHfnAC43t X-Received: by 2002:a17:906:f154:: with SMTP id gw20mr19784298ejb.279.1574403927154; Thu, 21 Nov 2019 22:25:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574403927; cv=none; d=google.com; s=arc-20160816; b=MaMCEnyrkajlcuBFwZLGzWDAhiwXZrbqLhmuLvuBPnG+ZBrIo9cGwB2uF5ggXCVOow V/ZZ/QIbGwPWWT9jpSQ01aCOO7+LCNhQ/WDJF1UdWapzf1aw8Fvbkkcjvx6T0xeTMpzz 4+9mkGHrzJFpXpZxy29sw5KMwyR2aLPI+hLUTBtGWVh3FmT8R2Kek6+4OgOBnoxIgY4Y ANeJzfS7AiII2h2nPDFEGWJsj7gCFk0ecIi8Udumyt7JF/LiaoFJOFfWuMcechBWJf5y 0mm/2GyVgVX+hA1ASIQ/OufwsgSAjAyXn+AltrEqStd4BB6RE4rsDZBNAaXIWERaClyR nt2Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6zMpJumrZeKl/PcPDu5UOiYIyd7ngvt/rGADkDbbzjo=; b=wESBFaMYw2qp8DMZFYlHOUuuIofKIx9t2gpqBsc/ZYju0wr3u74nqlikaF9R564cJg 7qpWQh9Me582w5hJQgOOm7vudAj78bF1dv6Qwdi8anxSu9y3jIX++T0wnos13MUtK2lu 8mJXtrTzPCSQNB9QVaqJBqgh6CueN1IuN7Pm/Ka3YUDQ1f0ll9tkwe5tufqZdZnfdx9Q bbUXM6RX8uoE1ikwjoBxQ8lE4SE+cMivZ8JkxJYYvB+sUDQOKgxW90OP2BKXPILeGm4h J43K1CJUC7LyqFyonXVv1WGaPOfQzxuPzXlCmcj06hgHFLcgBxT70xvO+W7lbJ9Oa3h7 NkAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=A907qBrM; 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 y2si4006163ede.431.2019.11.21.22.25.03; Thu, 21 Nov 2019 22:25:27 -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=A907qBrM; 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 S1728334AbfKVFv4 (ORCPT + 99 others); Fri, 22 Nov 2019 00:51:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:57138 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728235AbfKVFvt (ORCPT ); Fri, 22 Nov 2019 00:51:49 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (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 CF6792075B; Fri, 22 Nov 2019 05:51:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401908; bh=su1n9rIFco9QybKw4v3E7bYzZ5i2FUYnqUp43IBNZ6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A907qBrMLNG4Px02DPHe1UMehv1GYrNdEc/+96kM4BjgqxlLpPGbm4NFsHjY4cpkg cGv2vd2TGjFRAUTEhEPzgm1goslZWgxfqbI1dBA95BUPLE2wN/7OKmGJGcslQd1PAO RAkoDiGcuTly8Pd86FcGiURij9/glwLI0PMYEd1E= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Aditya Pakki , Kirill Tkhai , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 139/219] net/net_namespace: Check the return value of register_pernet_subsys() Date: Fri, 22 Nov 2019 00:47:51 -0500 Message-Id: <20191122054911.1750-132-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122054911.1750-1-sashal@kernel.org> References: <20191122054911.1750-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aditya Pakki [ Upstream commit 0eb987c874dc93f9c9d85a6465dbde20fdd3884c ] In net_ns_init(), register_pernet_subsys() could fail while registering network namespace subsystems. The fix checks the return value and sends a panic() on failure. Signed-off-by: Aditya Pakki Reviewed-by: Kirill Tkhai Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/core/net_namespace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index 6dab186d4b8f6..c60123dff8039 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c @@ -913,7 +913,8 @@ static int __init net_ns_init(void) init_net_initialized = true; up_write(&pernet_ops_rwsem); - register_pernet_subsys(&net_ns_ops); + if (register_pernet_subsys(&net_ns_ops)) + panic("Could not register network namespace subsystems"); rtnl_register(PF_UNSPEC, RTM_NEWNSID, rtnl_net_newid, NULL, RTNL_FLAG_DOIT_UNLOCKED); -- 2.20.1