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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080628045908.GG25492@linux-sh.org>
Date:	Sat, 28 Jun 2008 13:59:08 +0900
From:	Paul Mundt <lethal@...ux-sh.org>
To:	monstr@...nam.cz
Cc:	linux-kernel@...r.kernel.org, arnd@...db.de,
	linux-arch@...r.kernel.org, stephen.neuendorffer@...inx.com,
	John.Linn@...inx.com, john.williams@...alogix.com, matthew@....cx,
	will.newton@...il.com, drepper@...hat.com,
	microblaze-uclinux@...e.uq.edu.au, grant.likely@...retlab.ca,
	linuxppc-dev@...abs.org, vapier.adi@...il.com,
	alan@...rguk.ukuu.org.uk, hpa@...or.com,
	Michal Simek <monstr@...str.eu>
Subject: Re: [PATCH 28/60] microblaze_v4: ptrace support

On Thu, Jun 26, 2008 at 02:29:57PM +0200, monstr@...nam.cz wrote:
> +long arch_ptrace(struct task_struct *child, long request, long addr, long data)
> +{
> +	int rval;
> +
> +	switch (request) {
> +		unsigned long val, copied;
> +
> +	case PTRACE_PEEKTEXT: /* read word at location addr. */
> +	case PTRACE_PEEKDATA:
> +		pr_debug("PEEKTEXT/PEEKDATA at %08lX\n", addr);
> +		copied = access_process_vm(child, addr, &val, sizeof(val), 0);
> +		rval = -EIO;
> +		if (copied != sizeof(val))
> +			break;
> +		rval = put_user(val, (unsigned long *)data);
> +		goto out;
> +
> +	case PTRACE_POKETEXT: /* write the word at location addr. */
> +	case PTRACE_POKEDATA:
> +		pr_debug("POKETEXT/POKEDATA to %08lX\n", addr);
> +		rval = 0;
> +		if (access_process_vm(child, addr, &data, sizeof(data), 1)
> +			== sizeof(data))
> +			break;
> +		rval = -EIO;
> +		goto out;
> +
You can use generic_ptrace_peekdata()/generic_ptrace_pokedata() for
these. Or kill them off and let ptrace_request() handle it.

> +	/* Continue and stop at next (return from) syscall */
> +	case PTRACE_SYSCALL:
> +		pr_debug("PTRACE_SYSCALL\n");
> +	case PTRACE_SINGLESTEP:
> +		pr_debug("PTRACE_SINGLESTEP\n");
> +	/* Restart after a signal. */
> +	case PTRACE_CONT:
> +		pr_debug("PTRACE_CONT\n");
> +		rval = -EIO;
> +		if (!valid_signal(data))
> +			break;
> +
> +		if (request == PTRACE_SYSCALL)
> +			set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
> +		else
> +			clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
> +
> +		child->exit_code = data;
> +		pr_debug("wakeup_process\n");
> +		wake_up_process(child);
> +		rval = 0;
> +		break;
> +
This is a reimplementation of ptrace_resume(), you can kill all of these
off as well, as they are also handled generically these days.

> +	/*
> +	 * make the child exit. Best I can do is send it a sigkill.
> +	 * perhaps it should be put in the status that it wants to
> +	 * exit.
> +	 */
> +	case PTRACE_KILL:
> +		pr_debug("PTRACE_KILL\n");
> +		rval = 0;
> +		if (child->exit_state == EXIT_ZOMBIE)	/* already dead */
> +			break;
> +		child->exit_code = SIGKILL;
> +		wake_up_process(child);
> +		break;
> +
> +	case PTRACE_DETACH: /* detach a process that was attached. */
> +		pr_debug("PTRACE_DETACH\n");
> +		rval = ptrace_detach(child, data);
> +		break;
> +
> +	default:
> +		rval = -EIO;
> +		goto out;
> +	}
> + out:
> +	return rval;
> +}
> +
Or rather, they would be, if you defaulted to ptrace_request() for the
unhandled cases.
--
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