From owner-freebsd-hackers@FreeBSD.ORG Tue Apr 9 17:15:59 2013 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id BF1AACF2 for ; Tue, 9 Apr 2013 17:15:59 +0000 (UTC) (envelope-from oliver.pntr@gmail.com) Received: from mail-ob0-x22f.google.com (mail-ob0-x22f.google.com [IPv6:2607:f8b0:4003:c01::22f]) by mx1.freebsd.org (Postfix) with ESMTP id 91C7FA6C for ; Tue, 9 Apr 2013 17:15:59 +0000 (UTC) Received: by mail-ob0-f175.google.com with SMTP id va7so7101202obc.6 for ; Tue, 09 Apr 2013 10:15:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=u4le+lY+D2TY/A1vx5OmjSyfQJ1RWVOpzuuYIwQaSoE=; b=dOLU7PzMxdw1iV9W0COFWXa/szSMimaE1sK3/+L/mPnw6/YKDV4r5CuwbFJriEuJcN D45f0qwxSQlGiKyNiAseAA28VMRuxCyS8fkOBIc223ntDUY8FDfaAs7hT1vfsJXN7/45 mOlmx8K0RFN9VAKDdQCuead5mHcovn0YEP9jgBfoBK+Vl+Ylx/l8ylPnre2lCD0dAO3d eXLSjQQ6wycFBpwG+OYj3zpohVDVJovqLgeDO73OQYo1EWcQ2k3ijEqc0MdIaTqpHRV7 d+Aq/YauiLIsEj2zvvSWEVPGfpYUixm26O4ZzIftNbjB8/zcEG3/tbwevI0RchE4i+d3 Gp7Q== MIME-Version: 1.0 X-Received: by 10.60.132.237 with SMTP id ox13mr1280151oeb.33.1365527759166; Tue, 09 Apr 2013 10:15:59 -0700 (PDT) Received: by 10.182.161.100 with HTTP; Tue, 9 Apr 2013 10:15:59 -0700 (PDT) In-Reply-To: References: Date: Tue, 9 Apr 2013 19:15:59 +0200 Message-ID: Subject: Re: copyinstr() From: Oliver Pinter To: Vijay Singh Content-Type: text/plain; charset=ISO-8859-1 Cc: hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Apr 2013 17:15:59 -0000 On 4/9/13, Vijay Singh 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" >