Date: Tue, 9 Apr 2013 19:15:59 +0200 From: Oliver Pinter <oliver.pntr@gmail.com> To: Vijay Singh <vijju.singh@gmail.com> Cc: hackers@freebsd.org Subject: Re: copyinstr() Message-ID: <CAPjTQNG-jVyA2K8Oo1q%2BkQZNTU1zj10VPYDXkHVysA-29Ovmfw@mail.gmail.com> In-Reply-To: <CALCNsJTtf5UCwGXb5eO8kESQG9GFqyT8%2B6BXdTjfzJ%2BjLW=_CQ@mail.gmail.com> References: <CALCNsJTtf5UCwGXb5eO8kESQG9GFqyT8%2B6BXdTjfzJ%2BjLW=_CQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 4/9/13, Vijay Singh <vijju.singh@gmail.com> wrote: > Hi, I was looking for some help with copyinstr() on an amd64 platform. > > My from address happens to be in the kernel (stack). I am getting an > EFAULT, and I am wondering how to fix that. > > Would using memory from malloc() make a difference? The copyinstr check the address before do anything. amd64/support.S: /* * copyinstr(from, to, maxlen, int *lencopied) - MP SAFE * %rdi, %rsi, %rdx, %rcx * * copy a string from from to to, stop when a 0 character is reached. * return ENAMETOOLONG if string is longer than maxlen, and * EFAULT on protection violations. If lencopied is non-zero, * return the actual length in *lencopied. */ ENTRY(copyinstr) movq %rdx,%r8 /* %r8 = maxlen */ movq %rcx,%r9 /* %r9 = *len */ xchgq %rdi,%rsi /* %rdi = from, %rsi = to */ movq PCPU(CURPCB),%rcx movq $cpystrflt,PCB_ONFAULT(%rcx) movq $VM_MAXUSER_ADDRESS,%rax /* make sure 'from' is within bounds */ subq %rsi,%rax jbe cpystrfl [...] cpystrflt: movq $EFAULT,%rax [...] Try copyout() instead of copyinstr(), as there in amd64 are no copyoutstr(). > > -vijay > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPjTQNG-jVyA2K8Oo1q%2BkQZNTU1zj10VPYDXkHVysA-29Ovmfw>