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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 26 Jun 2011 22:04:42 +0200
From:	Oleg Nesterov <oleg@...hat.com>
To:	Denys Vlasenko <vda.linux@...glemail.com>
Cc:	Tejun Heo <tj@...nel.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ptrace: make former thread ID available via
	PTRACE_GETEVENTMSG after PTRACE_EVENT_EXEC stop (v.2)

On 06/26, Denys Vlasenko wrote:
>
> @@ -1366,13 +1366,22 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
>  	for (try=0; try<2; try++) {
>  		read_lock(&binfmt_lock);
>  		list_for_each_entry(fmt, &formats, lh) {
> -			int (*fn)(struct linux_binprm *, struct pt_regs *) = fmt->load_binary;
> -			if (!fn)
> +			int (*load_binary)(struct linux_binprm *, struct pt_regs *);
> +			pid_t old_pid = old_pid; /* for compiler */

we have uninitialized_var() for this,

	pid_t uninitialized_var(old_pid);

> +
> +			load_binary = fmt->load_binary;
> +			if (!load_binary)
>  				continue;
>  			if (!try_module_get(fmt->module))
>  				continue;
>  			read_unlock(&binfmt_lock);
> -			retval = fn(bprm, regs);
> +			if (task_ptrace(current) & PT_PTRACED) {

May be PT_TRACE_EXEC makes more sense. Note that ptrace_event_enabled() was
recently added.

> +				/* Need to fetch pid before load_binary changes it */
> +				rcu_read_lock();
> +				old_pid = task_pid_nr_ns(current, task_active_pid_ns(current->parent));

OK, this looks correct. But imho this code looks strange inside the
for (;;) loop. Perhaps it would be more clean to record the old pid
before.

Also, this line is too long. Personally I do not care, but I told you
we have the coding style police. Please use ./scripts/checkpatch.pl

> @@ -1381,7 +1390,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
>  			bprm->recursion_depth = depth;
>  			if (retval >= 0) {
>  				if (depth == 0)
> -					tracehook_report_exec(fmt, bprm, regs);
> +					tracehook_report_exec(fmt, bprm, regs, old_pid);

Heh, you are out of luck ;) This hook was already killed. Please redo
against git://git.kernel.org/pub/scm/linux/kernel/git/oleg/misc.git ptrace


Also, please update the changelog. It should clearly explain why do we
need this feature and what this patch does. The output from a test
program doesn't make too much sense unless you show the source code.

Oleg.

--
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