lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 3 May 2009 20:55:37 +0200
From:	Oleg Nesterov <oleg@...hat.com>
To:	Andrew Morton <akpm@...ux-foundation.org>,
	Roland McGrath <roland@...hat.com>
Cc:	Jeff Dike <jdike@...toit.com>, utrace-devel@...hat.com,
	linux-kernel@...r.kernel.org
Subject: [RFC, PATCH 0/2] utrace/ptrace: simplify/cleanup ptrace attach

Shouldn't be applied without Roland's ack.

I just don't know how to merge the second patch properly. I think it would be
really nice to cleanup ptrace attach before "ptracee data structures cleanup",
but this depends on utrace-core.patch which adds exclude_ptrace().

With the first patch, the second one (and hopefully the further cleanups) does
not depend on utrace.

Or, we can start with something like the patch below. Or, instead we can move
the "already traced" check into exclude_ptrace, this way only this helper will
depend on utrace changes. But personally I'd prefer to remove exclude_ptrace()
for now and add the correct checks later.

Roland, what do you think?

Oleg.

--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -190,6 +190,9 @@ int ptrace_attach(struct task_struct *ta
 
 	audit_ptrace(task);
 
+	if (exclude_ptrace(task))
+		return -EBUSY;
+
 	retval = -EPERM;
 	if (same_thread_group(task, current))
 		goto out;
@@ -221,11 +224,6 @@ repeat:
 		goto repeat;
 	}
 
-	if (exclude_ptrace(task)) {
-		retval = -EBUSY;
-		goto bad;
-	}
-
 	if (!task->mm)
 		goto bad;
 	/* the same process cannot be attached many times */
@@ -597,14 +595,14 @@ int ptrace_traceme(void)
 {
 	int ret = -EPERM;
 
+	if (exclude_ptrace(current))
+		return -EBUSY;
 	/*
 	 * Are we already being traced?
 	 */
 repeat:
 	task_lock(current);
-	if (exclude_ptrace(current)) {
-		ret = -EBUSY;
-	} else if (!(current->ptrace & PT_PTRACED)) {
+	if (!(current->ptrace & PT_PTRACED)) {
 		/*
 		 * See ptrace_attach() comments about the locking here.
 		 */

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ