linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: linux-arch@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, rth@twiddle.net,
	ink@jurassic.park.msu.ru, mattst88@gmail.com,
	vgupta@synopsys.com, linux@arm.linux.org.uk,
	catalin.marinas@arm.com, will.deacon@arm.com,
	hskinnemoen@gmail.com, egtvedt@samfundet.no, realmz6@gmail.com,
	msalter@redhat.com, a-jacquiot@ti.com, starvik@axis.com,
	jesper.nilsson@axis.com, dhowells@redhat.com,
	rkuo@codeaurora.org, tony.luck@intel.com, fenghua.yu@intel.com,
	geert@linux-m68k.org, james.hogan@imgtec.com, monstr@monstr.eu,
	ralf@linux-mips.org, yasutake.koichi@jp.panasonic.com,
	lftan@altera.com, jonas@southpole.se, jejb@parisc-linux.org,
	deller@gmx.de, benh@kernel.crashing.org, paulus@samba.org,
	mpe@ellerman.id.au, schwidefsky@de.ibm.com,
	heiko.carstens@de.ibm.com, liqin.linux@gmail.com,
	lennox.wu@gmail.com, davem@davemloft.net, cmetcalf@ezchip.com,
	jdike@addtoit.com, akpm@linux-foundation.org, oleg@redhat.com,
	hch@inf
Subject: [PATCH 03/24] Remove execution domain support
Date: Sat, 11 Apr 2015 22:47:42 +0200	[thread overview]
Message-ID: <1428785283-20501-4-git-send-email-richard@nod.at> (raw)
In-Reply-To: <1428785283-20501-1-git-send-email-richard@nod.at>

All users of exec_domain are gone, now we can get rid
of that abandoned feature.
To not break existing userspace we keep a dummy
/proc/execdomains file which will always contain
"0-0     Linux                   [kernel]".

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 kernel/exec_domain.c | 100 +--------------------------------------------------
 kernel/exit.c        |   2 --
 kernel/fork.c        |   4 ---
 3 files changed, 1 insertion(+), 105 deletions(-)

diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c
index 83d4382..b2fb57d 100644
--- a/kernel/exec_domain.c
+++ b/kernel/exec_domain.c
@@ -20,13 +20,7 @@
 #include <linux/types.h>
 #include <linux/fs_struct.h>
 
-
 static void default_handler(int, struct pt_regs *);
-
-static struct exec_domain *exec_domains = &default_exec_domain;
-static DEFINE_RWLOCK(exec_domains_lock);
-
-
 static unsigned long ident_map[32] = {
 	0,	1,	2,	3,	4,	5,	6,	7,
 	8,	9,	10,	11,	12,	13,	14,	15,
@@ -55,94 +49,9 @@ default_handler(int segment, struct pt_regs *regp)
 		send_sig(SIGSEGV, current, 1);
 }
 
-static struct exec_domain *
-lookup_exec_domain(unsigned int personality)
-{
-	unsigned int pers = personality(personality);
-	struct exec_domain *ep;
-
-	read_lock(&exec_domains_lock);
-	for (ep = exec_domains; ep; ep = ep->next) {
-		if (pers >= ep->pers_low && pers <= ep->pers_high)
-			if (try_module_get(ep->module))
-				goto out;
-	}
-
-#ifdef CONFIG_MODULES
-	read_unlock(&exec_domains_lock);
-	request_module("personality-%d", pers);
-	read_lock(&exec_domains_lock);
-
-	for (ep = exec_domains; ep; ep = ep->next) {
-		if (pers >= ep->pers_low && pers <= ep->pers_high)
-			if (try_module_get(ep->module))
-				goto out;
-	}
-#endif
-
-	ep = &default_exec_domain;
-out:
-	read_unlock(&exec_domains_lock);
-	return ep;
-}
-
-int
-register_exec_domain(struct exec_domain *ep)
-{
-	struct exec_domain	*tmp;
-	int			err = -EBUSY;
-
-	if (ep == NULL)
-		return -EINVAL;
-
-	if (ep->next != NULL)
-		return -EBUSY;
-
-	write_lock(&exec_domains_lock);
-	for (tmp = exec_domains; tmp; tmp = tmp->next) {
-		if (tmp == ep)
-			goto out;
-	}
-
-	ep->next = exec_domains;
-	exec_domains = ep;
-	err = 0;
-
-out:
-	write_unlock(&exec_domains_lock);
-	return err;
-}
-EXPORT_SYMBOL(register_exec_domain);
-
-int
-unregister_exec_domain(struct exec_domain *ep)
-{
-	struct exec_domain	**epp;
-
-	epp = &exec_domains;
-	write_lock(&exec_domains_lock);
-	for (epp = &exec_domains; *epp; epp = &(*epp)->next) {
-		if (ep == *epp)
-			goto unregister;
-	}
-	write_unlock(&exec_domains_lock);
-	return -EINVAL;
-
-unregister:
-	*epp = ep->next;
-	ep->next = NULL;
-	write_unlock(&exec_domains_lock);
-	return 0;
-}
-EXPORT_SYMBOL(unregister_exec_domain);
-
 int __set_personality(unsigned int personality)
 {
-	struct exec_domain *oep = current_thread_info()->exec_domain;
-
-	current_thread_info()->exec_domain = lookup_exec_domain(personality);
 	current->personality = personality;
-	module_put(oep->module);
 
 	return 0;
 }
@@ -151,14 +60,7 @@ EXPORT_SYMBOL(__set_personality);
 #ifdef CONFIG_PROC_FS
 static int execdomains_proc_show(struct seq_file *m, void *v)
 {
-	struct exec_domain	*ep;
-
-	read_lock(&exec_domains_lock);
-	for (ep = exec_domains; ep; ep = ep->next)
-		seq_printf(m, "%d-%d\t%-16s\t[%s]\n",
-			       ep->pers_low, ep->pers_high, ep->name,
-			       module_name(ep->module));
-	read_unlock(&exec_domains_lock);
+	seq_puts(m, "0-0\tLinux           \t[kernel]\n");
 	return 0;
 }
 
diff --git a/kernel/exit.c b/kernel/exit.c
index feff10b..22fcc05 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -756,8 +756,6 @@ void do_exit(long code)
 
 	cgroup_exit(tsk);
 
-	module_put(task_thread_info(tsk)->exec_domain->module);
-
 	/*
 	 * FIXME: do that only when needed, using sched_exit tracepoint
 	 */
diff --git a/kernel/fork.c b/kernel/fork.c
index cf65139..f2c1e73 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1279,9 +1279,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
 	if (nr_threads >= max_threads)
 		goto bad_fork_cleanup_count;
 
-	if (!try_module_get(task_thread_info(p)->exec_domain->module))
-		goto bad_fork_cleanup_count;
-
 	delayacct_tsk_init(p);	/* Must remain after dup_task_struct() */
 	p->flags &= ~(PF_SUPERPRIV | PF_WQ_WORKER);
 	p->flags |= PF_FORKNOEXEC;
@@ -1590,7 +1587,6 @@ bad_fork_cleanup_threadgroup_lock:
 	if (clone_flags & CLONE_THREAD)
 		threadgroup_change_end(current);
 	delayacct_tsk_free(p);
-	module_put(task_thread_info(p)->exec_domain->module);
 bad_fork_cleanup_count:
 	atomic_dec(&p->cred->user->processes);
 	exit_creds(p);
-- 
1.8.4.5

WARNING: multiple messages have this Message-ID (diff)
From: Richard Weinberger <richard@nod.at>
To: linux-arch@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, rth@twiddle.net,
	ink@jurassic.park.msu.ru, mattst88@gmail.com,
	vgupta@synopsys.com, linux@arm.linux.org.uk,
	catalin.marinas@arm.com, will.deacon@arm.com,
	hskinnemoen@gmail.com, egtvedt@samfundet.no, realmz6@gmail.com,
	msalter@redhat.com, a-jacquiot@ti.com, starvik@axis.com,
	jesper.nilsson@axis.com, dhowells@redhat.com,
	rkuo@codeaurora.org, tony.luck@intel.com, fenghua.yu@intel.com,
	geert@linux-m68k.org, james.hogan@imgtec.com, monstr@monstr.eu,
	ralf@linux-mips.org, yasutake.koichi@jp.panasonic.com,
	lftan@altera.com, jonas@southpole.se, jejb@parisc-linux.org,
	deller@gmx.de, benh@kernel.crashing.org, paulus@samba.org,
	mpe@ellerman.id.au, schwidefsky@de.ibm.com,
	heiko.carstens@de.ibm.com, liqin.linux@gmail.com,
	lennox.wu@gmail.com, davem@davemloft.net, cmetcalf@ezchip.com,
	jdike@addtoit.com, akpm@linux-foundation.org, oleg@redhat.com,
	hch@infradead.org, viro@zeniv.linux.org.uk,
	torvalds@linux-foundation.org,
	Richard Weinberger <richard@nod.at>
Subject: [PATCH 03/24] Remove execution domain support
Date: Sat, 11 Apr 2015 22:47:42 +0200	[thread overview]
Message-ID: <1428785283-20501-4-git-send-email-richard@nod.at> (raw)
Message-ID: <20150411204742.MaVwAkqxtenkSkQ9fZzxJVru_SeIVrm3Vzj39qQ2iHo@z> (raw)
In-Reply-To: <1428785283-20501-1-git-send-email-richard@nod.at>

All users of exec_domain are gone, now we can get rid
of that abandoned feature.
To not break existing userspace we keep a dummy
/proc/execdomains file which will always contain
"0-0     Linux                   [kernel]".

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 kernel/exec_domain.c | 100 +--------------------------------------------------
 kernel/exit.c        |   2 --
 kernel/fork.c        |   4 ---
 3 files changed, 1 insertion(+), 105 deletions(-)

diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c
index 83d4382..b2fb57d 100644
--- a/kernel/exec_domain.c
+++ b/kernel/exec_domain.c
@@ -20,13 +20,7 @@
 #include <linux/types.h>
 #include <linux/fs_struct.h>
 
-
 static void default_handler(int, struct pt_regs *);
-
-static struct exec_domain *exec_domains = &default_exec_domain;
-static DEFINE_RWLOCK(exec_domains_lock);
-
-
 static unsigned long ident_map[32] = {
 	0,	1,	2,	3,	4,	5,	6,	7,
 	8,	9,	10,	11,	12,	13,	14,	15,
@@ -55,94 +49,9 @@ default_handler(int segment, struct pt_regs *regp)
 		send_sig(SIGSEGV, current, 1);
 }
 
-static struct exec_domain *
-lookup_exec_domain(unsigned int personality)
-{
-	unsigned int pers = personality(personality);
-	struct exec_domain *ep;
-
-	read_lock(&exec_domains_lock);
-	for (ep = exec_domains; ep; ep = ep->next) {
-		if (pers >= ep->pers_low && pers <= ep->pers_high)
-			if (try_module_get(ep->module))
-				goto out;
-	}
-
-#ifdef CONFIG_MODULES
-	read_unlock(&exec_domains_lock);
-	request_module("personality-%d", pers);
-	read_lock(&exec_domains_lock);
-
-	for (ep = exec_domains; ep; ep = ep->next) {
-		if (pers >= ep->pers_low && pers <= ep->pers_high)
-			if (try_module_get(ep->module))
-				goto out;
-	}
-#endif
-
-	ep = &default_exec_domain;
-out:
-	read_unlock(&exec_domains_lock);
-	return ep;
-}
-
-int
-register_exec_domain(struct exec_domain *ep)
-{
-	struct exec_domain	*tmp;
-	int			err = -EBUSY;
-
-	if (ep == NULL)
-		return -EINVAL;
-
-	if (ep->next != NULL)
-		return -EBUSY;
-
-	write_lock(&exec_domains_lock);
-	for (tmp = exec_domains; tmp; tmp = tmp->next) {
-		if (tmp == ep)
-			goto out;
-	}
-
-	ep->next = exec_domains;
-	exec_domains = ep;
-	err = 0;
-
-out:
-	write_unlock(&exec_domains_lock);
-	return err;
-}
-EXPORT_SYMBOL(register_exec_domain);
-
-int
-unregister_exec_domain(struct exec_domain *ep)
-{
-	struct exec_domain	**epp;
-
-	epp = &exec_domains;
-	write_lock(&exec_domains_lock);
-	for (epp = &exec_domains; *epp; epp = &(*epp)->next) {
-		if (ep == *epp)
-			goto unregister;
-	}
-	write_unlock(&exec_domains_lock);
-	return -EINVAL;
-
-unregister:
-	*epp = ep->next;
-	ep->next = NULL;
-	write_unlock(&exec_domains_lock);
-	return 0;
-}
-EXPORT_SYMBOL(unregister_exec_domain);
-
 int __set_personality(unsigned int personality)
 {
-	struct exec_domain *oep = current_thread_info()->exec_domain;
-
-	current_thread_info()->exec_domain = lookup_exec_domain(personality);
 	current->personality = personality;
-	module_put(oep->module);
 
 	return 0;
 }
@@ -151,14 +60,7 @@ EXPORT_SYMBOL(__set_personality);
 #ifdef CONFIG_PROC_FS
 static int execdomains_proc_show(struct seq_file *m, void *v)
 {
-	struct exec_domain	*ep;
-
-	read_lock(&exec_domains_lock);
-	for (ep = exec_domains; ep; ep = ep->next)
-		seq_printf(m, "%d-%d\t%-16s\t[%s]\n",
-			       ep->pers_low, ep->pers_high, ep->name,
-			       module_name(ep->module));
-	read_unlock(&exec_domains_lock);
+	seq_puts(m, "0-0\tLinux           \t[kernel]\n");
 	return 0;
 }
 
diff --git a/kernel/exit.c b/kernel/exit.c
index feff10b..22fcc05 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -756,8 +756,6 @@ void do_exit(long code)
 
 	cgroup_exit(tsk);
 
-	module_put(task_thread_info(tsk)->exec_domain->module);
-
 	/*
 	 * FIXME: do that only when needed, using sched_exit tracepoint
 	 */
diff --git a/kernel/fork.c b/kernel/fork.c
index cf65139..f2c1e73 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1279,9 +1279,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
 	if (nr_threads >= max_threads)
 		goto bad_fork_cleanup_count;
 
-	if (!try_module_get(task_thread_info(p)->exec_domain->module))
-		goto bad_fork_cleanup_count;
-
 	delayacct_tsk_init(p);	/* Must remain after dup_task_struct() */
 	p->flags &= ~(PF_SUPERPRIV | PF_WQ_WORKER);
 	p->flags |= PF_FORKNOEXEC;
@@ -1590,7 +1587,6 @@ bad_fork_cleanup_threadgroup_lock:
 	if (clone_flags & CLONE_THREAD)
 		threadgroup_change_end(current);
 	delayacct_tsk_free(p);
-	module_put(task_thread_info(p)->exec_domain->module);
 bad_fork_cleanup_count:
 	atomic_dec(&p->cred->user->processes);
 	exit_creds(p);
-- 
1.8.4.5


  parent reply	other threads:[~2015-04-11 20:47 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-11 20:47 Remove execution domain support Richard Weinberger
2015-04-11 20:47 ` Richard Weinberger
2015-04-11 20:47 ` [PATCH 01/24] arm: Remove RISC OS personality Richard Weinberger
2015-04-11 20:47   ` Richard Weinberger
2015-04-11 20:47 ` [PATCH 02/24] ia64: Remove Linux/x86 exec domain support Richard Weinberger
2015-04-11 20:47   ` Richard Weinberger
2015-04-11 20:47 ` Richard Weinberger [this message]
2015-04-11 20:47   ` [PATCH 03/24] Remove execution " Richard Weinberger
2015-04-11 20:47 ` [PATCH 04/24] arm: Remove signal translation and exec_domain Richard Weinberger
2015-04-11 20:47   ` Richard Weinberger
2015-04-11 20:47 ` [PATCH 05/24] arm64: " Richard Weinberger
2015-04-11 20:47   ` Richard Weinberger
2015-04-13 13:52   ` Thierry Reding
2015-04-13 13:52     ` Thierry Reding
2015-04-11 20:47 ` [PATCH 06/24] blackfin: Autogenerate offsets in struct thread_info Richard Weinberger
2015-04-11 20:47   ` Richard Weinberger
2015-04-11 20:47 ` [PATCH 07/24] blackfin: Remove exec_domain usage Richard Weinberger
2015-04-11 20:47   ` Richard Weinberger
2015-04-11 20:47 ` [PATCH 08/24] frv: Remove signal translation and exec_domain Richard Weinberger
2015-04-11 20:47   ` Richard Weinberger
2015-04-11 20:47 ` [PATCH 09/24] m32r: Autogenerate offsets in struct thread_info Richard Weinberger
2015-04-11 20:47   ` Richard Weinberger
2015-04-11 20:47 ` [PATCH 10/24] m32r: Remove signal translation and exec_domain Richard Weinberger
2015-04-11 20:47   ` Richard Weinberger
2015-04-11 20:47 ` [PATCH 11/24] m68k: " Richard Weinberger
2015-04-11 20:47   ` Richard Weinberger
2015-04-14  7:48   ` Geert Uytterhoeven
2015-04-14  7:48     ` Geert Uytterhoeven
2015-04-11 20:47 ` [PATCH 12/24] microblaze: " Richard Weinberger
2015-04-11 20:47   ` Richard Weinberger
2015-04-11 20:47 ` [PATCH 13/24] mn10300: " Richard Weinberger
2015-04-11 20:47   ` Richard Weinberger
2015-04-11 20:47 ` [PATCH 14/24] s390: " Richard Weinberger
2015-04-11 20:47   ` Richard Weinberger
2015-04-11 20:47 ` [PATCH 15/24] sh: " Richard Weinberger
2015-04-11 20:47   ` Richard Weinberger
2015-04-11 20:47 ` [PATCH 16/24] sparc: " Richard Weinberger
2015-04-11 20:47   ` Richard Weinberger
2015-04-11 20:47 ` [PATCH 17/24] tile: " Richard Weinberger
2015-04-11 20:47   ` Richard Weinberger
2015-04-11 20:47 ` [PATCH 18/24] um: " Richard Weinberger
2015-04-11 20:47   ` Richard Weinberger
2015-04-11 20:47 ` [PATCH 19/24] unicore32: " Richard Weinberger
2015-04-11 20:47   ` Richard Weinberger
2015-04-11 20:47 ` [PATCH 20/24] x86: " Richard Weinberger
2015-04-11 20:47   ` Richard Weinberger
2015-04-11 20:48 ` [PATCH 21/24] xtensa: " Richard Weinberger
2015-04-11 20:48   ` Richard Weinberger
2015-04-11 20:48 ` [PATCH 22/24] arc: " Richard Weinberger
2015-04-11 20:48   ` Richard Weinberger
2015-04-11 20:48 ` [PATCH 23/24] arch: Remove exec_domain from remaining archs Richard Weinberger
2015-04-11 20:48   ` Richard Weinberger
2015-04-13  8:19   ` Jesper Nilsson
2015-04-13  8:19     ` Jesper Nilsson
2015-04-13 16:57   ` Hans-Christian Egtvedt
2015-04-13 16:57     ` Hans-Christian Egtvedt
2015-04-11 20:48 ` [PATCH 24/24] Remove rest of exec domains Richard Weinberger
2015-04-11 20:48   ` Richard Weinberger
2015-04-11 20:52 ` Remove execution domain support Linus Torvalds
2015-04-11 20:52   ` Linus Torvalds
2015-04-11 21:04   ` Al Viro
2015-04-11 21:04     ` Al Viro
2015-04-11 21:08     ` Richard Weinberger
2015-04-11 21:08       ` Richard Weinberger
2015-04-11 21:12   ` Richard Weinberger
2015-04-11 21:12     ` Richard Weinberger
2015-04-11 22:31     ` David Miller
2015-04-11 22:31       ` David Miller
2015-04-11 23:25     ` Benjamin Herrenschmidt
2015-04-11 23:25       ` Benjamin Herrenschmidt
2015-04-11 23:30   ` Stephen Rothwell
2015-04-11 23:30     ` Stephen Rothwell
2015-04-12  0:06     ` Stephen Rothwell
2015-04-12  0:06       ` Stephen Rothwell
2015-04-12  2:03 ` Guenter Roeck
2015-04-12 20:57 ` Remove execution domain support v2 Richard Weinberger
2015-04-12 20:57   ` Richard Weinberger
2015-04-12 21:13   ` Stephen Rothwell
2015-04-12 21:13     ` Stephen Rothwell
2015-04-12 21:17     ` Richard Weinberger
2015-04-12 21:17       ` Richard Weinberger
2015-04-12 21:56       ` Linus Torvalds
2015-04-12 21:56         ` Linus Torvalds
2015-04-12 22:06         ` Richard Weinberger
2015-04-12 22:06           ` Richard Weinberger
2015-04-12 22:57   ` Guenter Roeck
2015-04-12 22:57     ` Guenter Roeck
2015-04-14  1:21 ` Remove execution domain support Andy Lutomirski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1428785283-20501-4-git-send-email-richard@nod.at \
    --to=richard@nod.at \
    --cc=a-jacquiot@ti.com \
    --cc=akpm@linux-foundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=catalin.marinas@arm.com \
    --cc=cmetcalf@ezchip.com \
    --cc=davem@davemloft.net \
    --cc=deller@gmx.de \
    --cc=dhowells@redhat.com \
    --cc=egtvedt@samfundet.no \
    --cc=fenghua.yu@intel.com \
    --cc=geert@linux-m68k.org \
    --cc=hch@inf \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hskinnemoen@gmail.com \
    --cc=ink@jurassic.park.msu.ru \
    --cc=james.hogan@imgtec.com \
    --cc=jdike@addtoit.com \
    --cc=jejb@parisc-linux.org \
    --cc=jesper.nilsson@axis.com \
    --cc=jonas@southpole.se \
    --cc=lennox.wu@gmail.com \
    --cc=lftan@altera.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=liqin.linux@gmail.com \
    --cc=mattst88@gmail.com \
    --cc=monstr@monstr.eu \
    --cc=mpe@ellerman.id.au \
    --cc=msalter@redhat.com \
    --cc=oleg@redhat.com \
    --cc=paulus@samba.org \
    --cc=ralf@linux-mips.org \
    --cc=realmz6@gmail.com \
    --cc=rkuo@codeaurora.org \
    --cc=rth@twiddle.net \
    --cc=schwidefsky@de.ibm.com \
    --cc=starvik@axis.com \
    --cc=tony.luck@intel.com \
    --cc=vgupta@synopsys.com \
    --cc=will.deacon@arm.com \
    --cc=yasutake.koichi@jp.panasonic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).