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] [day] [month] [year] [list]
Message-ID: <20090615110240.GA16735@infradead.org>
Date:	Mon, 15 Jun 2009 07:02:40 -0400
From:	Christoph Hellwig <hch@...radead.org>
To:	liqin.chen@...plusct.com
Cc:	linux-arch@...r.kernel.org, linux-kernel@...r.kernel.org,
	Arnd Bergmann <arnd@...db.de>,
	Andrew Morton <akpm@...ux-foundation.org>,
	torvalds@...ux-foundation.org
Subject: Re: [PATCH 21/27] score: create kernel files ptrace.c setup.c

On Tue, Jun 09, 2009 at 02:35:45PM +0800, liqin.chen@...plusct.com wrote:
> +long
> +arch_ptrace(struct task_struct *child, long request, long addr, long 
> data)
> +{
> +       int ret;
> +
> +       if (request == PTRACE_TRACEME) {
> +               /* are we already being traced? */
> +               if (current->ptrace & PT_PTRACED)
> +                       return -EPERM;
> +
> +               /* set the ptrace bit in the process flags. */
> +               current->ptrace |= PT_PTRACED;
> +               return 0;
> +       }
> +
> +       ret = -ESRCH;
> +       if (!child)
> +               return ret;
> +
> +       ret = -EPERM;
> +
> +       if (request == PTRACE_ATTACH) {
> +               ret = ptrace_attach(child);
> +               return ret;
> +       }
> +
> +       ret = ptrace_check_attach(child, request == PTRACE_KILL);
> +       if (ret < 0)
> +               return ret;
> +

All this stuff has been done by generic ptrace code for a long time
and is not needed at all.

> +       switch (request) {
> +       case PTRACE_PEEKTEXT: /* read word at location addr. */
> +       case PTRACE_PEEKDATA: {
> +               unsigned long tmp;
> +               int copied;
> +
> +               copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 
> 0);
> +               ret = -EIO;
> +               if (copied != sizeof(tmp))
> +                       break;
> +
> +               ret = put_user(tmp, (unsigned long *) data);
> +               return ret;
> +       }
> +

This also has a generic implementation.  Please take a look at a modern
ptrace implementation like sh, powerpc or x86 to model yours after.

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