From owner-freebsd-hackers@FreeBSD.ORG Sat Nov 5 18:59:35 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AB7B8106564A; Sat, 5 Nov 2011 18:59:35 +0000 (UTC) (envelope-from to.my.trociny@gmail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 0E50F8FC0A; Sat, 5 Nov 2011 18:59:34 +0000 (UTC) Received: by faar19 with SMTP id r19so5540892faa.13 for ; Sat, 05 Nov 2011 11:59:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:references:x-comment-to:sender:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=HmPFLkhEzOJzUFsnImczOtRd8TJya36QfUs3AC4y56o=; b=FWEVp5MooQedWuY2vEP6qW86+clNtRLa9f5wr4HpMqV9OAuVrYGg0RS0ccfOweyLpl ZgNjNRwFovQy2XWoVWaonkpMBmC+WOJMsUp3mFRj2K0mz1T15IMAthcJLQA0GZTuK6kL Qi6KJ9z/3fIyvKYJ8IjCMFd5NOmlSCDdOZ918= Received: by 10.223.75.129 with SMTP id y1mr17705759faj.34.1320519574092; Sat, 05 Nov 2011 11:59:34 -0700 (PDT) Received: from localhost ([95.69.173.122]) by mx.google.com with ESMTPS id k13sm11159513fah.0.2011.11.05.11.59.23 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 05 Nov 2011 11:59:30 -0700 (PDT) From: Mikolaj Golub To: Kostik Belousov References: <86y5wkeuw9.fsf@kopusha.home.net> <20111016171005.GB50300@deviant.kiev.zoral.com.ua> <86aa8qozyx.fsf@kopusha.home.net> <20111025082451.GO50300@deviant.kiev.zoral.com.ua> <86aa8k2im0.fsf@kopusha.home.net> <20111031094948.GB50300@deviant.kiev.zoral.com.ua> <86vcr21agm.fsf@kopusha.home.net> <20111105135801.GT50300@deviant.kiev.zoral.com.ua> <86ehxmpogp.fsf@kopusha.home.net> <20111105154443.GB50300@deviant.kiev.zoral.com.ua> X-Comment-To: Kostik Belousov Sender: Mikolaj Golub Date: Sat, 05 Nov 2011 20:59:21 +0200 In-Reply-To: <20111105154443.GB50300@deviant.kiev.zoral.com.ua> (Kostik Belousov's message of "Sat, 5 Nov 2011 17:44:43 +0200") Message-ID: <86ehxmjsza.fsf@kopusha.home.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: freebsd-hackers@freebsd.org, Robert Watson Subject: Re: "ps -e" without procfs(5) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Nov 2011 18:59:35 -0000 On Sat, 5 Nov 2011 17:44:43 +0200 Kostik Belousov wrote: >> KB> I think that the aux vector must be naturally aligned. You can return >> KB> ENOEXEC early if vptr is not aligned. >> >> Not sure I see what you mean. vptr for auxv is calculated just couple lines >> above, and I check the result here, in the part common for all vector types. KB> You do not check for the alignment. Am I wrong ? I see now. If natural alignment means "addr % sizeof(aux) == 0" then the aux vectors are not naturally aligned. After adding this check: if (vptr % sizeof(aux) != 0) return (ENOEXEC); I started to observe many ENOEXEC errors. Adding printf showed that the vectors are half size aligned. On i386: get_proc_vector(pid = getty[3442], type = 2): vptr (2143284876) % sizeof(aux) (8) = 4) On amd64: get_proc_vector(pid = getty[2425], type = 2): vptr (140737488346568) % sizeof(aux) (16) = 8) Looking at exec_copyout_strings() from kern_exec.c, how destp is calculated, I think they are sizeof(char *) aligned. Do you think it is worth adding the check for sizeof(char *) alignment? if (vptr % (sizeof(char *) != 0) return (ENOEXEC); -- Mikolaj Golub