Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp716796pxj; Thu, 10 Jun 2021 10:54:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1/BrpuXkMUmvz+gt8O9m0l2xdrDCABP/kD0Tq/MJsshowGtAfg7lClOyPfb88ud/agBqX X-Received: by 2002:a17:907:e8d:: with SMTP id ho13mr678452ejc.387.1623347652515; Thu, 10 Jun 2021 10:54:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623347652; cv=none; d=google.com; s=arc-20160816; b=o1smKVxhB29XmQlLmtvNJP1E8Ooou9Nie8ecjkox0pNrTvA8K9MYbsSJUt1mfMIQre IziA6qN/wacdWLs4nRBA5onFHADKY1E7MVstsDxAfOZHACdC/ePu3NJyQSVrYRIg2A2Z wuee5Kic2fZ0IQEj1Wsu7AzR77dO/xHOwc5NAdMwjakKGl8p3HkRxymEMdFQVLZVDfTv qWWW6jXiechNY7Y+2gUKnHRqQFaiLtSk/aXA50Yn/qdRLVZfPfk6Scku1lGIxerYW9cB Zn4iiuHKDhLMqKA9joobiLAFRObgapr8kIWyagq5d7l/HhvldACIsdsB/k3SU8AzZzaZ L6mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=RN0qYsW7x/x8Yy4qYypG8zm9voCzEKBe+VyGku27TpA=; b=oT+ulpUjEjGfgUt7J9iy+l7aqaGVGO46D43+vxA56ME5xtur/OJSZnE7o7PxcN6m9/ dQUzL3dFHtl07/41nfSVA53V6T58T/O79VX4YaX1WXIqwI75GxNIO5gfpKGjl4TmE10H o657hoJbB8EmOuEkXfYUr2FyciHYZrjiXGzuBB2bzCtCVTdBp0Tly66RCRB/Da1uRzDg Wk03zP+1OL+t6HClPJ7ZeCRIPC6QodNm4LVuGIoCCz2qvqHtZtKFEKslPDcTqIlfq2dh 95AigtmkokYpj9vP0XVl8Itw0qX4VZvkEmAmOD5b/lrGXX05Lzf8tcnfAQC6ZnGo1Noa FoOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UcqnFRY0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id v22si2787696ejc.505.2021.06.10.10.53.48; Thu, 10 Jun 2021 10:54:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UcqnFRY0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S230358AbhFJRxL (ORCPT + 99 others); Thu, 10 Jun 2021 13:53:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:57590 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229802AbhFJRxK (ORCPT ); Thu, 10 Jun 2021 13:53:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 626B0613CA; Thu, 10 Jun 2021 17:51:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623347473; bh=lCGJRHFmgyGy14hX7d0GCF2ozflAS/+GEcyyj0awbxo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=UcqnFRY0InkyUs9iHJsHROBDaSWwxKwEd0n2YZ577/dS6RTqcloWIirdpUiXfDNRs iACitaJqN+aIg85zx4+RRcytoXb4rkvIf5gKGVvYs1PWjdaeYFuGZIKjaUBjFOyKTU 39839+Bg3u/aBcWokJgdeuwNe7DxBtSIvI45wzCMt8T03uZe5AmCSOSxJpHBjDHRDq ZVMAfULEhDzbPQunKERzicvvjZFjeK5jnbmEkXZVwI0KUUEFkX2YZQznd/O0sjGIdu pqCyYzL8pd2pkI6S1aPix9eTpbiYJcA68QP3hboGewE1K73CdJcCMMmrh9/bHqCeuS OH19NSWVlmc/Q== Date: Thu, 10 Jun 2021 10:51:12 -0700 From: Jakub Kicinski To: Changbin Du Cc: Alexander Viro , "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Cong Wang , David Laight , Christian Brauner Subject: Re: [PATCH v3] net: make get_net_ns return error if NET_NS is disabled Message-ID: <20210610105112.787a0d5f@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20210610153941.118945-1-changbin.du@gmail.com> References: <20210610153941.118945-1-changbin.du@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 10 Jun 2021 23:39:41 +0800 Changbin Du wrote: > There is a panic in socket ioctl cmd SIOCGSKNS when NET_NS is not enabled. > The reason is that nsfs tries to access ns->ops but the proc_ns_operations > is not implemented in this case. > > [7.670023] Unable to handle kernel NULL pointer dereference at virtual address 00000010 > [7.670268] pgd = 32b54000 > [7.670544] [00000010] *pgd=00000000 > [7.671861] Internal error: Oops: 5 [#1] SMP ARM > [7.672315] Modules linked in: > [7.672918] CPU: 0 PID: 1 Comm: systemd Not tainted 5.13.0-rc3-00375-g6799d4f2da49 #16 > [7.673309] Hardware name: Generic DT based system > [7.673642] PC is at nsfs_evict+0x24/0x30 > [7.674486] LR is at clear_inode+0x20/0x9c > > The same to tun SIOCGSKNS command. > > To fix this problem, we make get_net_ns() return -EINVAL when NET_NS is > disabled. Meanwhile move it to right place net/core/net_namespace.c. I'm assuming you went from EOPNOTSUPP to EINVAL to follow what the existing helpers in the header do? Acked-by: Jakub Kicinski Thanks!