From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boris Ostrovsky Subject: Re: [PATCH v12 for-xen-4.5 01/20] common/symbols: Export hypervisor symbols to privileged guest Date: Fri, 26 Sep 2014 18:12:37 -0400 Message-ID: <5425E4D5.60001@oracle.com> References: <1411673336-32736-1-git-send-email-boris.ostrovsky@oracle.com> <1411673336-32736-2-git-send-email-boris.ostrovsky@oracle.com> <5425DE01.80506@tycho.nsa.gov> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5425DE01.80506@tycho.nsa.gov> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Daniel De Graaf , jbeulich@suse.com, kevin.tian@intel.com, suravee.suthikulpanit@amd.com, Aravind.Gopalakrishnan@amd.com, dietmar.hahn@ts.fujitsu.com Cc: andrew.cooper3@citrix.com, xen-devel@lists.xen.org, keir@xen.org, jun.nakajima@intel.com, tim@xen.org List-Id: xen-devel@lists.xenproject.org On 09/26/2014 05:43 PM, Daniel De Graaf wrote: > >> @@ -601,6 +602,38 @@ ret_t >> do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op) >> } >> break; >> >> + case XENPF_get_symbol: >> + { >> + static char name[KSYM_NAME_LEN + 1]; /* protected by >> xenpf_lock */ >> + XEN_GUEST_HANDLE(char) nameh; >> + uint32_t namelen, copylen; >> + >> + guest_from_compat_handle(nameh, op->u.symdata.name); >> + >> + ret = xensyms_read(&op->u.symdata.symnum, &op->u.symdata.type, >> + &op->u.symdata.address, name); >> + >> + namelen = strlen(name) + 1; >> + >> + if ( namelen > op->u.symdata.namelen ) >> + { >> + /* Caller's buffer is too small for the whole string */ >> + if ( op->u.symdata.namelen ) >> + name[op->u.symdata.namelen] = '\0'; > > I don't think this assignment is needed at all: name[copylen] is never > copied to the guest and the buffer is not reused internally. True, this is not needed. Thanks. -boris > >> + copylen = op->u.symdata.namelen; >> + } >> + else >> + copylen = namelen; >> + >> + op->u.symdata.namelen = namelen; >> + >> + if ( !ret && copy_to_guest(nameh, name, copylen) ) >> + ret = -EFAULT; >> + if ( !ret && __copy_field_to_guest(u_xenpf_op, op, u.symdata) ) >> + ret = -EFAULT; >> + } >> + break; >> + >> default: >> ret = -ENOSYS; >> break; > [...] >