From patchwork Fri Feb 4 04:37:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucian Adrian Grijincu X-Patchwork-Id: 81802 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 63B17B70B3 for ; Fri, 4 Feb 2011 15:39:33 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753778Ab1BDEiG (ORCPT ); Thu, 3 Feb 2011 23:38:06 -0500 Received: from mail-ey0-f174.google.com ([209.85.215.174]:46255 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753240Ab1BDEiC (ORCPT ); Thu, 3 Feb 2011 23:38:02 -0500 Received: by mail-ey0-f174.google.com with SMTP id 27so1089008eye.19 for ; Thu, 03 Feb 2011 20:38:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:in-reply-to:references; bh=IFsSMnZmd+vr4cy6zvZgigP96PBVpIyOOr+F2Ii2HB0=; b=H9xlsPal9scVnpSOamWspLTHYB27an2jAZmchBFDjk6RMZUIjsoquUxc71K+ly62mG BBESqo20eQuzWc0hQPjRgURcRz2qXwGZCSQsxRZu4jUUZTBVrSZQvKuL8EEtWSlaaM65 I7hbtKY+fJ4wE01GTyNNXKz/9hl41/KouCM+I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=HCP4wnsuGb4zvSoC3j/AOqlRCWlZY/kSvAIXKcUitiM5Q/7ydWdNX5/Oi33o7AeEez 9O+WlfSflbR6NrGqvJr8rZbzbZDjeyjq9tl+VWMixeZa0nRxVHcu7wIlhaDLgGiZJvUc KqY93XlVunH7cCSgPBdh3iMbQk87lNtPTMKMY= Received: by 10.213.105.80 with SMTP id s16mr9528063ebo.18.1296794282070; Thu, 03 Feb 2011 20:38:02 -0800 (PST) Received: from localhost.localdomain (p22.eregie.pub.ro [141.85.0.122]) by mx.google.com with ESMTPS id t50sm216814eeh.12.2011.02.03.20.37.59 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 03 Feb 2011 20:38:01 -0800 (PST) From: Lucian Adrian Grijincu To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, "Eric W. Biederman" , Eric Dumazet , "David S. Miller" , Octavian Purdila Cc: Lucian Adrian Grijincu Subject: [PATCH 2/5] sysctl: remove useless ctl_table->parent field Date: Fri, 4 Feb 2011 06:37:05 +0200 Message-Id: <9a1977a6526ca9e0b03ba1df767f842aea62b5f4.1296793770.git.lucian.grijincu@gmail.com> X-Mailer: git-send-email 1.7.4.rc1.7.g2cf08.dirty In-Reply-To: References: In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The 'parent' field was added for selinux in: commit d912b0cc1a617d7c590d57b7ea971d50c7f02503 [PATCH] sysctl: add a parent entry to ctl_table and set the parent entry and then was used for sysctl_check_table. Both of the users have found other implementations. CC: Eric W. Biederman Signed-off-by: Lucian Adrian Grijincu --- include/linux/sysctl.h | 1 - kernel/sysctl.c | 11 ----------- kernel/sysctl_check.c | 4 ++-- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 7bb5cb6..1f1da4b 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -1018,7 +1018,6 @@ struct ctl_table int maxlen; mode_t mode; struct ctl_table *child; - struct ctl_table *parent; /* Automatically set */ proc_handler *proc_handler; /* Callback for text formatting */ void *extra1; void *extra2; diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 56f6fc1..42025ec 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -1695,18 +1695,8 @@ int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op) return test_perm(mode, op); } -static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) -{ - for (; table->procname; table++) { - table->parent = parent; - if (table->child) - sysctl_set_parent(table, table->child); - } -} - static __init int sysctl_init(void) { - sysctl_set_parent(NULL, root_table); #ifdef CONFIG_SYSCTL_SYSCALL_CHECK sysctl_check_table(current->nsproxy, root_table); #endif @@ -1864,7 +1854,6 @@ struct ctl_table_header *__register_sysctl_paths( header->used = 0; header->unregistering = NULL; header->root = root; - sysctl_set_parent(NULL, header->ctl_table); header->count = 1; #ifdef CONFIG_SYSCTL_SYSCALL_CHECK if (sysctl_check_table(namespaces, header->ctl_table)) { diff --git a/kernel/sysctl_check.c b/kernel/sysctl_check.c index 9b4fecd..b7d9c66 100644 --- a/kernel/sysctl_check.c +++ b/kernel/sysctl_check.c @@ -95,8 +95,8 @@ static int __sysctl_check_table(struct nsproxy *namespaces, for (; table->procname; table++) { const char *fail = NULL; - if (table->parent) { - if (table->procname && !table->parent->procname) + if (depth != 0) { /* has parent */ + if (table->procname && !parents[depth - 1]->procname) SET_FAIL("Parent without procname"); } if (!table->procname)