From owner-freebsd-arm@FreeBSD.ORG Thu Jan 24 11:40:43 2008 Return-Path: Delivered-To: freebsd-arm@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6942016A418; Thu, 24 Jan 2008 11:40:43 +0000 (UTC) (envelope-from jhay@meraka.csir.co.za) Received: from zibbi.meraka.csir.co.za (zibbi.meraka.csir.co.za [IPv6:2001:4200:7000:2::1]) by mx1.freebsd.org (Postfix) with ESMTP id 4B6DC13C4DD; Thu, 24 Jan 2008 11:40:42 +0000 (UTC) (envelope-from jhay@meraka.csir.co.za) Received: by zibbi.meraka.csir.co.za (Postfix, from userid 3973) id 4740333C7D; Thu, 24 Jan 2008 13:40:40 +0200 (SAST) Date: Thu, 24 Jan 2008 13:40:40 +0200 From: John Hay To: "M. Warner Losh" Message-ID: <20080124114039.GF79134@zibbi.meraka.csir.co.za> References: <20080118185634.GA28843@zibbi.meraka.csir.co.za> <20080118.120152.-345488389.imp@bsdimp.com> <20080118191638.GA30155@zibbi.meraka.csir.co.za> <20080118.145436.-1540399028.imp@bsdimp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080118.145436.-1540399028.imp@bsdimp.com> User-Agent: Mutt/1.4.2.1i Cc: freebsd-arm@FreeBSD.ORG, des@FreeBSD.ORG Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2008 11:40:43 -0000 On Fri, Jan 18, 2008 at 02:54:36PM -0700, M. Warner Losh wrote: > In message: <20080118191638.GA30155@zibbi.meraka.csir.co.za> > John Hay writes: > : On Fri, Jan 18, 2008 at 12:01:52PM -0700, M. Warner Losh wrote: > : > In message: <20080118185634.GA28843@zibbi.meraka.csir.co.za> > : > John Hay writes: > : > : On Fri, Jan 18, 2008 at 10:17:47AM -0700, M. Warner Losh wrote: > : > : > In message: <4790D750.4060702@errno.com> > : > : > Sam Leffler writes: > : > : > : John Hay wrote: > : > : > : > On Thu, Jan 17, 2008 at 12:58:54PM +0200, John Hay wrote: > : > : > : > > : > : > : >> Hi Guys, > : > : > : >> > : > : > : >> I just did a new build using RELENG_7 for the arm (Avila boards) and then > : > : > : >> found that I cannot ssh into them. The sshd crash with a bus error just > : > : > : >> after you entered your username and password. My build of mid November > : > : > : >> did not do it. Anybody got ideas? > : > : > : >> > : > : > : >> The last part of "sshd -Dddd" on the arm board looks like this: > : > : > : >> > : > : > : >> debug1: server_input_channel_req: channel 0 request pty-req reply 0 > : > : > : >> debug1: session_by_channel: session 0 channel 0 > : > : > : >> debug1: session_input_channel_req: session 0 req pty-req > : > : > : >> debug1: Allocating pty. > : > : > : >> debug3: mm_request_send entering: type 25 > : > : > : >> debug3: monitor_read: checking request 25 > : > : > : >> debug3: mm_answer_pty entering > : > : > : >> debug1: session_new: init > : > : > : >> debug1: session_new: session 0 > : > : > : >> debug3: mm_pty_allocate: waiting for MONITOR_ANS_PTY > : > : > : >> debug3: mm_request_receive_expect entering: type 26 > : > : > : >> debug3: mm_request_receive entering > : > : > : >> debug3: mm_request_send entering: type 26 > : > : > : >> ssh_mm_receive_fd: recvmsg: expected received 1 got 0 > : > : > : >> debug1: do_cleanup > : > : > : >> debug1: PAM: cleanup > : > : > : >> Bus error (core dumped) > : > : > : >> debug3: PAM: sshpam_thread_cleanup entering > : > : > : >> > : > : > : > > : > : > : > Ok, I found the problem. It looks like something changed and now the > : > : > : > alignment for the char tmp[...] array in monitor_fdpass.c:mm_send_fd > : > : > : > and monitor_fdpass.c:mm_receive_fd is different and the arm processors > : > : > : > do not like it. Attached is my quick fix. > : > : > : > > : > : > : > One question that I have is if we should just fix all of these "problems" > : > : > : > or should something be changed so that these things are aligned again? In > : > : > : > the last month or two I have come across quite a few of these things that > : > : > : > used to work on the arm and now do not anymore because of alignment > : > : > : > changes. > : > : > : > > : > : > : > (I have cc'ed des@ because his name pitch up a lot in the openssh cvs logs. > : > : > : > :-) > : > : > : > > : > : > : > : > : > : This used to work fine so the problem is elsewhere. Sounds like a > : > : > : toolchain or header change is the root cause. > : > : > > : > : > Or some subtle change in the kernel that isn't using the macro (or is > : > : > now and didn't used to be). > : > : > : > : Hmmm Just to make sure that I'm on the right page. On FreeBSD ARM one > : > : is not supposed to be able to access unaligned memory? Ie. an int that > : > : does not start on an address that is a multiple of 4. > : > : > : > : In a C function if you have something like "char tmp[4]", can you assume > : > : that the compiler will align it on a 4 byte boundary or can it do it on > : > : a byte boundary? > : > : > : > : If one cannot access unaligned ints and char arrays are not int aligned, > : > : then we were just lucky that the code worked at some stage. > : > > : > You are correct. The fact that it seemed to work meant that we were > : > either getting lucky before, or there was some critical code on the > : > kernel side that has accidentally been removed... > : > : I don't think the kernel will make a difference. The bus error happened > : on line 64 of openssh/monitor_fdpass.c. That is before the kernel was > : called (sendmsg())... Except if the kernel aligned the stack differently. > > OK. Maybe the right fix is to add '__aligned(4)' to the declaration? > > : > : > John, I don't suppose you'd have time for a binary search? > : > : > : > : I'll see what I can do, but it will be slow going. > : > > : > Bad sshd with kernels going back in time should be sufficient... Ok, it turned out that the problem/change was not in the kernel. Old and new kernels work equally well/bad. On December 2, the default optimisation for the ARMs was changed from -O2 to -O. That is it. If I compile libsshd with -O2, it works and if I compile it with -O, it does not. Just adding __aligned(4) like Warner suggested also fix the problem. Index: crypto/openssh/monitor_fdpass.c =================================================================== RCS file: /home/ncvs/src/crypto/openssh/monitor_fdpass.c,v retrieving revision 1.1.1.7 diff -u -r1.1.1.7 monitor_fdpass.c --- crypto/openssh/monitor_fdpass.c 10 Nov 2006 16:38:34 -0000 1.1.1.7 +++ crypto/openssh/monitor_fdpass.c 24 Jan 2008 11:32:43 -0000 @@ -49,7 +49,7 @@ char ch = '\0'; ssize_t n; #ifndef HAVE_ACCRIGHTS_IN_MSGHDR - char tmp[CMSG_SPACE(sizeof(int))]; + char tmp[CMSG_SPACE(sizeof(int))] __aligned(4); struct cmsghdr *cmsg; #endif @@ -94,7 +94,7 @@ char ch; int fd; #ifndef HAVE_ACCRIGHTS_IN_MSGHDR - char tmp[CMSG_SPACE(sizeof(int))]; + char tmp[CMSG_SPACE(sizeof(int))] __aligned(4); struct cmsghdr *cmsg; #endif So what should we do? John -- John Hay -- John.Hay@meraka.csir.co.za / jhay@FreeBSD.org From owner-freebsd-arm@FreeBSD.ORG Thu Jan 24 12:32:10 2008 Return-Path: Delivered-To: freebsd-arm@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E262516A417; Thu, 24 Jan 2008 12:32:10 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from mail.digiware.nl (www.tegenbosch28.nl [217.21.251.97]) by mx1.freebsd.org (Postfix) with ESMTP id 37BE113C4CE; Thu, 24 Jan 2008 12:32:10 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from localhost (localhost.digiware.nl [127.0.0.1]) by mail.digiware.nl (Postfix) with ESMTP id 07CC917395; Thu, 24 Jan 2008 13:12:30 +0100 (CET) X-Virus-Scanned: amavisd-new at digiware.nl Received: from mail.digiware.nl ([127.0.0.1]) by localhost (rack1.digiware.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RETjnp8UIIW9; Thu, 24 Jan 2008 13:12:25 +0100 (CET) Received: from [212.61.27.67] (opteron.digiware.nl [212.61.27.67]) by mail.digiware.nl (Postfix) with ESMTP id B1A101738F; Thu, 24 Jan 2008 13:12:25 +0100 (CET) Message-ID: <479880A7.1030107@digiware.nl> Date: Thu, 24 Jan 2008 13:12:23 +0100 From: Willem Jan Withagen Organization: Digiware User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: John Hay References: <20080118185634.GA28843@zibbi.meraka.csir.co.za> <20080118.120152.-345488389.imp@bsdimp.com> <20080118191638.GA30155@zibbi.meraka.csir.co.za> <20080118.145436.-1540399028.imp@bsdimp.com> <20080124114039.GF79134@zibbi.meraka.csir.co.za> In-Reply-To: <20080124114039.GF79134@zibbi.meraka.csir.co.za> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-arm@FreeBSD.ORG, des@FreeBSD.ORG Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2008 12:32:11 -0000 John Hay and others wrote: >> : > : Hmmm Just to make sure that I'm on the right page. On FreeBSD ARM one >> : > : is not supposed to be able to access unaligned memory? Ie. an int that >> : > : does not start on an address that is a multiple of 4. >> : > : >> : > : In a C function if you have something like "char tmp[4]", can you assume >> : > : that the compiler will align it on a 4 byte boundary or can it do it on >> : > : a byte boundary? >> : > : >> : > : If one cannot access unaligned ints and char arrays are not int aligned, >> : > : then we were just lucky that the code worked at some stage. >> : > >> : > You are correct. The fact that it seemed to work meant that we were >> : > either getting lucky before, or there was some critical code on the >> : > kernel side that has accidentally been removed... I was actually reading up on the Arm hardware when the first messages came in. So in the continuance of reading I kept this question in the back of my mind. And as far as I've now red and understood the requirements of the ARM, they do not support unaligned memory accesses. I've also not seen any suggestions that they generate exceptions for these arrors... Which would have been the nice thing to do. That holds for both 4-bytes ints, as for 2 byte words. But it also hold for the code, "regular" code is 4 byte aligned and thumb code is 2 byte aligned. And looking at the eg. indexing instructions in the instructionset it is clear that the assumption above is used in building the instructions. So here the adresses are not aligned because the variables before occupie only 2 bytes in the first piece of code. And thus the suggested ints in char tmp[*] are word aligned. The second part of the fix however has the first previous variable be: int fd; Which would lead to 4-byte alignment and thus should not pose a problem unless the compiler also reshuffles the order of the variables on the stack. It gets even more funny that things work when the compiler is allowed to optimise. To be shure what is really going on, one would have to take a look at the generated assembly code. And yes, I'm very amazed that if the above is the problem that it did not raize it ugly head earlier.... > Ok, it turned out that the problem/change was not in the kernel. Old > and new kernels work equally well/bad. On December 2, the default > optimisation for the ARMs was changed from -O2 to -O. That is it. If > I compile libsshd with -O2, it works and if I compile it with -O, it > does not. > > Just adding __aligned(4) like Warner suggested also fix the problem. > > Index: crypto/openssh/monitor_fdpass.c > =================================================================== > RCS file: /home/ncvs/src/crypto/openssh/monitor_fdpass.c,v > retrieving revision 1.1.1.7 > diff -u -r1.1.1.7 monitor_fdpass.c > --- crypto/openssh/monitor_fdpass.c 10 Nov 2006 16:38:34 -0000 1.1.1.7 > +++ crypto/openssh/monitor_fdpass.c 24 Jan 2008 11:32:43 -0000 > @@ -49,7 +49,7 @@ > char ch = '\0'; > ssize_t n; > #ifndef HAVE_ACCRIGHTS_IN_MSGHDR > - char tmp[CMSG_SPACE(sizeof(int))]; > + char tmp[CMSG_SPACE(sizeof(int))] __aligned(4); > struct cmsghdr *cmsg; > #endif > > @@ -94,7 +94,7 @@ > char ch; > int fd; > #ifndef HAVE_ACCRIGHTS_IN_MSGHDR > - char tmp[CMSG_SPACE(sizeof(int))]; > + char tmp[CMSG_SPACE(sizeof(int))] __aligned(4); > struct cmsghdr *cmsg; > #endif > > > So what should we do? I would say that the correct fix would be to fix the compiler. Going through all the code and make sure that everything is correctly aligned would be a humongous task.... --WjW From owner-freebsd-arm@FreeBSD.ORG Thu Jan 24 12:43:57 2008 Return-Path: Delivered-To: freebsd-arm@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 007E816A469 for ; Thu, 24 Jan 2008 12:43:57 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (tim.des.no [194.63.250.121]) by mx1.freebsd.org (Postfix) with ESMTP id AC62213C4D9 for ; Thu, 24 Jan 2008 12:43:56 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (localhost [127.0.0.1]) by spam.des.no (Postfix) with ESMTP id CBDF2208A; Thu, 24 Jan 2008 13:25:11 +0100 (CET) X-Spam-Tests: AWL X-Spam-Learn: disabled X-Spam-Score: -0.2/3.0 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on tim.des.no Received: from ds4.des.no (des.no [80.203.243.180]) by smtp.des.no (Postfix) with ESMTP id 4EA6A2088; Thu, 24 Jan 2008 13:25:11 +0100 (CET) Received: by ds4.des.no (Postfix, from userid 1001) id 3EBBC844AF; Thu, 24 Jan 2008 13:25:11 +0100 (CET) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: John Hay References: <20080118185634.GA28843@zibbi.meraka.csir.co.za> <20080118.120152.-345488389.imp@bsdimp.com> <20080118191638.GA30155@zibbi.meraka.csir.co.za> <20080118.145436.-1540399028.imp@bsdimp.com> <20080124114039.GF79134@zibbi.meraka.csir.co.za> Date: Thu, 24 Jan 2008 13:25:11 +0100 In-Reply-To: <20080124114039.GF79134@zibbi.meraka.csir.co.za> (John Hay's message of "Thu\, 24 Jan 2008 13\:40\:40 +0200") Message-ID: <86y7afv2ag.fsf@ds4.des.no> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-arm@FreeBSD.ORG Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2008 12:43:57 -0000 John Hay writes: > [89 lines of irrelevant context snipped - learn to quote!] > > Ok, it turned out that the problem/change was not in the kernel. Old > and new kernels work equally well/bad. On December 2, the default > optimisation for the ARMs was changed from -O2 to -O. That is it. If > I compile libsshd with -O2, it works and if I compile it with -O, it > does not. > > Just adding __aligned(4) like Warner suggested also fix the problem. > [...] > So what should we do? >From a portability POV, the simplest fix is to place the buffer in a union with a dummy member that forces the alignment. In any case, this should be discussed on the OpenSSH mailing lists, not here. DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no From owner-freebsd-arm@FreeBSD.ORG Thu Jan 24 15:50:17 2008 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 80A4C16A417; Thu, 24 Jan 2008 15:50:17 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 3110F13C467; Thu, 24 Jan 2008 15:50:17 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.1/8.14.1) with ESMTP id m0OFicOA010827; Thu, 24 Jan 2008 08:44:39 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Thu, 24 Jan 2008 08:48:28 -0700 (MST) Message-Id: <20080124.084828.1608359032.imp@bsdimp.com> To: wjw@digiware.nl From: "M. Warner Losh" In-Reply-To: <479880A7.1030107@digiware.nl> References: <20080118.145436.-1540399028.imp@bsdimp.com> <20080124114039.GF79134@zibbi.meraka.csir.co.za> <479880A7.1030107@digiware.nl> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: freebsd-arm@freebsd.org, des@freebsd.org Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2008 15:50:17 -0000 In message: <479880A7.1030107@digiware.nl> Willem Jan Withagen writes: : John Hay and others wrote: : >> : > : Hmmm Just to make sure that I'm on the right page. On FreeBSD ARM one : >> : > : is not supposed to be able to access unaligned memory? Ie. an int that : >> : > : does not start on an address that is a multiple of 4. : >> : > : : >> : > : In a C function if you have something like "char tmp[4]", can you assume : >> : > : that the compiler will align it on a 4 byte boundary or can it do it on : >> : > : a byte boundary? : >> : > : : >> : > : If one cannot access unaligned ints and char arrays are not int aligned, : >> : > : then we were just lucky that the code worked at some stage. : >> : > : >> : > You are correct. The fact that it seemed to work meant that we were : >> : > either getting lucky before, or there was some critical code on the : >> : > kernel side that has accidentally been removed... : : I was actually reading up on the Arm hardware when the first messages : came in. So in the continuance of reading I kept this question in the : back of my mind. And as far as I've now red and understood the : requirements of the ARM, they do not support unaligned memory accesses. : : I've also not seen any suggestions that they generate exceptions for : these arrors... Which would have been the nice thing to do. : : That holds for both 4-bytes ints, as for 2 byte words. : But it also hold for the code, "regular" code is 4 byte aligned and : thumb code is 2 byte aligned. And looking at the eg. indexing : instructions in the instructionset it is clear that the assumption above : is used in building the instructions. : : So here the adresses are not aligned because the variables before : occupie only 2 bytes in the first piece of code. And thus the suggested : ints in char tmp[*] are word aligned. : : The second part of the fix however has the first previous variable be: : int fd; Which would lead to 4-byte alignment and thus should not pose a : problem unless the compiler also reshuffles the order of the variables : on the stack. : : It gets even more funny that things work when the compiler is allowed to : optimise. : To be shure what is really going on, one would have to take a look at : the generated assembly code. : : And yes, I'm very amazed that if the above is the problem that it did : not raize it ugly head earlier.... : : > Ok, it turned out that the problem/change was not in the kernel. Old : > and new kernels work equally well/bad. On December 2, the default : > optimisation for the ARMs was changed from -O2 to -O. That is it. If : > I compile libsshd with -O2, it works and if I compile it with -O, it : > does not. : > : > Just adding __aligned(4) like Warner suggested also fix the problem. : > : > Index: crypto/openssh/monitor_fdpass.c : > =================================================================== : > RCS file: /home/ncvs/src/crypto/openssh/monitor_fdpass.c,v : > retrieving revision 1.1.1.7 : > diff -u -r1.1.1.7 monitor_fdpass.c : > --- crypto/openssh/monitor_fdpass.c 10 Nov 2006 16:38:34 -0000 1.1.1.7 : > +++ crypto/openssh/monitor_fdpass.c 24 Jan 2008 11:32:43 -0000 : > @@ -49,7 +49,7 @@ : > char ch = '\0'; : > ssize_t n; : > #ifndef HAVE_ACCRIGHTS_IN_MSGHDR : > - char tmp[CMSG_SPACE(sizeof(int))]; : > + char tmp[CMSG_SPACE(sizeof(int))] __aligned(4); : > struct cmsghdr *cmsg; : > #endif : > : > @@ -94,7 +94,7 @@ : > char ch; : > int fd; : > #ifndef HAVE_ACCRIGHTS_IN_MSGHDR : > - char tmp[CMSG_SPACE(sizeof(int))]; : > + char tmp[CMSG_SPACE(sizeof(int))] __aligned(4); : > struct cmsghdr *cmsg; : > #endif : > : > : > So what should we do? : : I would say that the correct fix would be to fix the compiler. : Going through all the code and make sure that everything is correctly : aligned would be a humongous task.... Actually, the above fix *IS* the correct fix for arm given the ABI that we're using... Warner From owner-freebsd-arm@FreeBSD.ORG Thu Jan 24 16:17:05 2008 Return-Path: Delivered-To: freebsd-arm@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AFB1416A41B; Thu, 24 Jan 2008 16:17:05 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from mail.digiware.nl (www.tegenbosch28.nl [217.21.251.97]) by mx1.freebsd.org (Postfix) with ESMTP id 6192F13C4D5; Thu, 24 Jan 2008 16:17:05 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from localhost (localhost.digiware.nl [127.0.0.1]) by mail.digiware.nl (Postfix) with ESMTP id 15E7217340; Thu, 24 Jan 2008 17:17:04 +0100 (CET) X-Virus-Scanned: amavisd-new at digiware.nl Received: from mail.digiware.nl ([127.0.0.1]) by localhost (rack1.digiware.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NxciYwxFjaYi; Thu, 24 Jan 2008 17:17:00 +0100 (CET) Received: from [212.61.27.67] (opteron.digiware.nl [212.61.27.67]) by mail.digiware.nl (Postfix) with ESMTP id E2FCB17343; Thu, 24 Jan 2008 17:17:00 +0100 (CET) Message-ID: <4798B9FA.9070501@digiware.nl> Date: Thu, 24 Jan 2008 17:16:58 +0100 From: Willem Jan Withagen Organization: Digiware User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: "M. Warner Losh" References: <20080118.145436.-1540399028.imp@bsdimp.com> <20080124114039.GF79134@zibbi.meraka.csir.co.za> <479880A7.1030107@digiware.nl> <20080124.084828.1608359032.imp@bsdimp.com> In-Reply-To: <20080124.084828.1608359032.imp@bsdimp.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-arm@FreeBSD.ORG, des@FreeBSD.ORG Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2008 16:17:05 -0000 M. Warner Losh wrote: > In message: <479880A7.1030107@digiware.nl> > Willem Jan Withagen writes: > : John Hay and others wrote: > : > Just adding __aligned(4) like Warner suggested also fix the problem. > : > + char tmp[CMSG_SPACE(sizeof(int))] __aligned(4); > : > So what should we do? > : > : I would say that the correct fix would be to fix the compiler. > : Going through all the code and make sure that everything is correctly > : aligned would be a humongous task.... > > Actually, the above fix *IS* the correct fix for arm given the ABI > that we're using... Well usually this is the punishment one get when jumping right in, without lurking for a longer time..... I only subscribed to this specific freebsd-arm recently, 'cause my job requires me to start doing ARM. So other than a few years of FreeBSD and my general knowledge on systems and Compilers I have not followed the discussion on the way things are coded. Given that tricks like accessing char-arrays with int pointers is a bit of a stretch, but not a very uncommon one, the following question pops in my mind: Does this then require programmers to real carefully look at what they are whiping up on code, to make shure that they don't by accident run into un-aligned access? And how about all that is already lying about?? Even still if this is mostly an embedded platform... Other than on the newer ARMs where unalinged access IS possible. Something that was not in my book, but I was told that is in the new v6 architecture. crawling back into his corner to do some more list searching. --WjW From owner-freebsd-arm@FreeBSD.ORG Thu Jan 24 17:40:14 2008 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 03B8D16A496 for ; Thu, 24 Jan 2008 17:40:14 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (tim.des.no [194.63.250.121]) by mx1.freebsd.org (Postfix) with ESMTP id B84CC13C448 for ; Thu, 24 Jan 2008 17:40:13 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (localhost [127.0.0.1]) by spam.des.no (Postfix) with ESMTP id 079D22088; Thu, 24 Jan 2008 18:40:05 +0100 (CET) X-Spam-Tests: AWL X-Spam-Learn: disabled X-Spam-Score: -0.2/3.0 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on tim.des.no Received: from ds4.des.no (des.no [80.203.243.180]) by smtp.des.no (Postfix) with ESMTP id E8C092087; Thu, 24 Jan 2008 18:40:04 +0100 (CET) Received: by ds4.des.no (Postfix, from userid 1001) id C0ABB844AF; Thu, 24 Jan 2008 18:40:04 +0100 (CET) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: "M. Warner Losh" References: <20080118.145436.-1540399028.imp@bsdimp.com> <20080124114039.GF79134@zibbi.meraka.csir.co.za> <479880A7.1030107@digiware.nl> <20080124.084828.1608359032.imp@bsdimp.com> Date: Thu, 24 Jan 2008 18:40:04 +0100 In-Reply-To: <20080124.084828.1608359032.imp@bsdimp.com> (M. Warner Losh's message of "Thu\, 24 Jan 2008 08\:48\:28 -0700 \(MST\)") Message-ID: <864pd386mj.fsf@ds4.des.no> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-arm@freebsd.org Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2008 17:40:14 -0000 "M. Warner Losh" writes: > Actually, the above fix *IS* the correct fix for arm given the ABI > that we're using... No. The correct fix is one that will be acceptable to the upstream vendor, who has a different perspective on things than we do. And guys, please learn to trim your quotes. DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no From owner-freebsd-arm@FreeBSD.ORG Thu Jan 24 18:03:24 2008 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 537D916A46C for ; Thu, 24 Jan 2008 18:03:24 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from mail.digiware.nl (www.tegenbosch28.nl [217.21.251.97]) by mx1.freebsd.org (Postfix) with ESMTP id 0B4E113C461 for ; Thu, 24 Jan 2008 18:03:23 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from localhost (localhost.digiware.nl [127.0.0.1]) by mail.digiware.nl (Postfix) with ESMTP id ADFC41736D; Thu, 24 Jan 2008 19:03:22 +0100 (CET) X-Virus-Scanned: amavisd-new at digiware.nl Received: from mail.digiware.nl ([127.0.0.1]) by localhost (rack1.digiware.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UAXxw-BiLk-4; Thu, 24 Jan 2008 19:03:17 +0100 (CET) Received: from [212.61.27.67] (opteron.digiware.nl [212.61.27.67]) by mail.digiware.nl (Postfix) with ESMTP id 52F3417331; Thu, 24 Jan 2008 19:03:17 +0100 (CET) Message-ID: <4798D2E2.4000809@digiware.nl> Date: Thu, 24 Jan 2008 19:03:14 +0100 From: Willem Jan Withagen Organization: Digiware User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: =?UTF-8?B?RGFnLUVybGluZyBTbcO4cmdyYXY=?= References: <20080118.145436.-1540399028.imp@bsdimp.com> <20080124114039.GF79134@zibbi.meraka.csir.co.za> <479880A7.1030107@digiware.nl> <20080124.084828.1608359032.imp@bsdimp.com> <864pd386mj.fsf@ds4.des.no> In-Reply-To: <864pd386mj.fsf@ds4.des.no> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Cc: freebsd-arm@freebsd.org Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2008 18:03:24 -0000 Dag-Erling Smørgrav wrote: > "M. Warner Losh" writes: >> Actually, the above fix *IS* the correct fix for arm given the ABI >> that we're using... > > No. The correct fix is one that will be acceptable to the upstream > vendor, who has a different perspective on things than we do. Well that was more what I would expect and both answers are hard. Because it requires either: - the openSSH people to add something that is awkward to say the least. - get the compiler guys to do "the right thing", so now you have to convince them that they need to do a better analysis. --WjW From owner-freebsd-arm@FreeBSD.ORG Thu Jan 24 18:11:21 2008 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AA13F16A419 for ; Thu, 24 Jan 2008 18:11:21 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 5296813C468 for ; Thu, 24 Jan 2008 18:11:21 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.1/8.14.1) with ESMTP id m0OI63BV016264; Thu, 24 Jan 2008 11:06:03 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Thu, 24 Jan 2008 11:09:54 -0700 (MST) Message-Id: <20080124.110954.179240992.imp@bsdimp.com> To: des@des.no From: "M. Warner Losh" In-Reply-To: <864pd386mj.fsf@ds4.des.no> References: <479880A7.1030107@digiware.nl> <20080124.084828.1608359032.imp@bsdimp.com> <864pd386mj.fsf@ds4.des.no> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-arm@freebsd.org Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2008 18:11:21 -0000 In message: <864pd386mj.fsf@ds4.des.no> Dag-Erling_Sm=F8rgrav writes: : "M. Warner Losh" writes: : > Actually, the above fix *IS* the correct fix for arm given the ABI : > that we're using... : = : No. The correct fix is one that will be acceptable to the upstream : vendor, who has a different perspective on things than we do. The problem is that the char array isn't guaranteed to be aligned in any way. The fix posted is correct. There may be other fixes too, such as using a union to force alignment. Warner From owner-freebsd-arm@FreeBSD.ORG Thu Jan 24 20:50:23 2008 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3B97F16A417 for ; Thu, 24 Jan 2008 20:50:23 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (tim.des.no [194.63.250.121]) by mx1.freebsd.org (Postfix) with ESMTP id EC46813C478 for ; Thu, 24 Jan 2008 20:50:22 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (localhost [127.0.0.1]) by spam.des.no (Postfix) with ESMTP id AA11F208A; Thu, 24 Jan 2008 21:50:14 +0100 (CET) X-Spam-Tests: AWL X-Spam-Learn: disabled X-Spam-Score: -0.2/3.0 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on tim.des.no Received: from ds4.des.no (des.no [80.203.243.180]) by smtp.des.no (Postfix) with ESMTP id 8B83B2088; Thu, 24 Jan 2008 21:50:14 +0100 (CET) Received: by ds4.des.no (Postfix, from userid 1001) id 5DF51844AF; Thu, 24 Jan 2008 21:50:14 +0100 (CET) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: "M. Warner Losh" References: <479880A7.1030107@digiware.nl> <20080124.084828.1608359032.imp@bsdimp.com> <864pd386mj.fsf@ds4.des.no> <20080124.110954.179240992.imp@bsdimp.com> Date: Thu, 24 Jan 2008 21:50:14 +0100 In-Reply-To: <20080124.110954.179240992.imp@bsdimp.com> (M. Warner Losh's message of "Thu\, 24 Jan 2008 11\:09\:54 -0700 \(MST\)") Message-ID: <86hch36j95.fsf@ds4.des.no> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-arm@freebsd.org Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2008 20:50:23 -0000 "M. Warner Losh" writes: > Dag-Erling_Sm=C3=B8rgrav writes: > > No. The correct fix is one that will be acceptable to the upstream > > vendor, who has a different perspective on things than we do. > The problem is that the char array isn't guaranteed to be aligned in > any way. The fix posted is correct. The fix posted works for one specific case. That does not make it correct. Sorry to split hairs like this, but I would much prefer a fix that does not depend on a particular OS and toolchain, and that will be acceptable to the upstream vendor. The union trick meets the former requirement, but I'm not sure about the latter. There is only one way to find out: as mentioned previously in this thread, the issue should be discussed directly with the OpenSSH developers instead of here. For bonus points, start by verifying that the bug is present in the latest -portable version from ports. I haven't updated the base system's OpenSSH in a while (because I haven't seen any changes worth the hassle) and the OpenSSH developers aren't going to be happy about a bug report against 4.5p1 when the latest version is 4.7p1. DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no From owner-freebsd-arm@FreeBSD.ORG Thu Jan 24 23:23:59 2008 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4EB2916A418 for ; Thu, 24 Jan 2008 23:23:59 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from mail.digiware.nl (www.tegenbosch28.nl [217.21.251.97]) by mx1.freebsd.org (Postfix) with ESMTP id EA91D13C4E5 for ; Thu, 24 Jan 2008 23:23:58 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from localhost (localhost.digiware.nl [127.0.0.1]) by mail.digiware.nl (Postfix) with ESMTP id 390DC1735A; Fri, 25 Jan 2008 00:23:54 +0100 (CET) X-Virus-Scanned: amavisd-new at digiware.nl Received: from mail.digiware.nl ([127.0.0.1]) by localhost (rack1.digiware.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tBBiE0FocZ0Y; Fri, 25 Jan 2008 00:23:51 +0100 (CET) Received: from [192.168.2.10] (unknown [192.168.2.10]) by mail.digiware.nl (Postfix) with ESMTP id CA42C17331; Fri, 25 Jan 2008 00:23:51 +0100 (CET) Message-ID: <47991E08.6070609@digiware.nl> Date: Fri, 25 Jan 2008 00:23:52 +0100 From: Willem Jan Withagen Organization: Digiware User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: "M. Warner Losh" References: <479880A7.1030107@digiware.nl> <20080124.084828.1608359032.imp@bsdimp.com> <864pd386mj.fsf@ds4.des.no> <20080124.110954.179240992.imp@bsdimp.com> In-Reply-To: <20080124.110954.179240992.imp@bsdimp.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Cc: des@des.no, freebsd-arm@freebsd.org Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2008 23:23:59 -0000 M. Warner Losh wrote: > In message: <864pd386mj.fsf@ds4.des.no> > Dag-Erling_Smørgrav writes: > : "M. Warner Losh" writes: > : > Actually, the above fix *IS* the correct fix for arm given the ABI > : > that we're using... > : > : No. The correct fix is one that will be acceptable to the upstream > : vendor, who has a different perspective on things than we do. > > The problem is that the char array isn't guaranteed to be aligned in > any way. The fix posted is correct. > > There may be other fixes too, such as using a union to force > alignment. Well I'm sort of puzzled right now since after preprocessing the variable allocation part boils down to: ===== struct msghdr msg; struct iovec vec; char ch = '\0'; ssize_t n; char tmp[((((unsigned)(sizeof(struct cmsghdr)) + (sizeof(int) - 1)) & ~(sizeof(int) - 1)) + (((unsigned)(sizeof(int)) + (sizeof(int ) - 1)) & ~(sizeof(int) - 1)))]; struct cmsghdr *cmsg; ===== So as far as I can see is char tmp[] included between 2 4-byte items and allocation should be "automagically" 4-byte aligned. Now adding simple code like tmp[0] = 50, the first part of the assembly is: (Comments are mine for as far as I can grasp them) ==== mm_send_fd: @ args = 0, pretend = 0, frame = 72 @ frame_needed = 1, current_function_anonymous_args = 0 // entry code mov ip, sp stmfd sp!, {fp, ip, lr, pc} sub fp, ip, #4 // allocate stack space sub sp, sp, #72 str r0, [fp, #-16] str r1, [fp, #-20] // ch = '\0' mov r3, #0 mov r2, r3 strb r2, [fp, #-57] // tmp[0] = 50 mov r3, #50 mov r2, r3 strb r2, [fp, #-80] // msg = &tmp sub r3, fp, #80 str r3, [fp, #-32] // ==== So it seems that with this compiler tmp is correctly aligned. What I used for this is the arm-elf-gcc-295 from ports, not doing any optimisation. Optimisation eliminates just about everything in my simple test. Trying it on the full code, I still don't see an unaligned reference to &tmp But then that might vary with the compiler. But I cannot follow the suggestions at the freebsd/arm pages. I do not have a -CURRENT system, and trying it on 7.0 starts to complain right away on the first file to compile. Su suggestions there are welcome. --WjW From owner-freebsd-arm@FreeBSD.ORG Fri Jan 25 04:15:45 2008 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0247E16A418 for ; Fri, 25 Jan 2008 04:15:45 +0000 (UTC) (envelope-from jhay@meraka.csir.co.za) Received: from zibbi.meraka.csir.co.za (zibbi.meraka.csir.co.za [IPv6:2001:4200:7000:2::1]) by mx1.freebsd.org (Postfix) with ESMTP id 0ECD613C44B for ; Fri, 25 Jan 2008 04:15:44 +0000 (UTC) (envelope-from jhay@meraka.csir.co.za) Received: by zibbi.meraka.csir.co.za (Postfix, from userid 3973) id D094833CBC; Fri, 25 Jan 2008 06:15:40 +0200 (SAST) Date: Fri, 25 Jan 2008 06:15:40 +0200 From: John Hay To: Willem Jan Withagen Message-ID: <20080125041540.GA30262@zibbi.meraka.csir.co.za> References: <479880A7.1030107@digiware.nl> <20080124.084828.1608359032.imp@bsdimp.com> <864pd386mj.fsf@ds4.des.no> <20080124.110954.179240992.imp@bsdimp.com> <47991E08.6070609@digiware.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <47991E08.6070609@digiware.nl> User-Agent: Mutt/1.4.2.1i Cc: des@des.no, freebsd-arm@freebsd.org Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jan 2008 04:15:45 -0000 > > > >The problem is that the char array isn't guaranteed to be aligned in > >any way. The fix posted is correct. > > > >There may be other fixes too, such as using a union to force > >alignment. > > Well I'm sort of puzzled right now since after preprocessing the > variable allocation part boils down to: > ===== > struct msghdr msg; > struct iovec vec; > char ch = '\0'; > ssize_t n; > > char tmp[((((unsigned)(sizeof(struct cmsghdr)) + (sizeof(int) - 1)) & > ~(sizeof(int) - 1)) + (((unsigned)(sizeof(int)) + (sizeof(int > ) - 1)) & ~(sizeof(int) - 1)))]; > struct cmsghdr *cmsg; > ===== > So as far as I can see is char tmp[] included between 2 4-byte items and > allocation should be "automagically" 4-byte aligned. > > Now adding simple code like tmp[0] = 50, the first part of the assembly > is: (Comments are mine for as far as I can grasp them) Just doing tmp[0] = 50 will cause a byte access which should not be a problem. The original code does something like this (simplified): char tmp[CMSG_SPACE(sizeof(int))]; int *ti; ti = tmp; *ti = 50; Now the 50 is an int and not a byte and then the alignment does matter. John -- John Hay -- John.Hay@meraka.csir.co.za / jhay@FreeBSD.org From owner-freebsd-arm@FreeBSD.ORG Fri Jan 25 08:50:05 2008 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0E45C16A418 for ; Fri, 25 Jan 2008 08:50:05 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from mail.digiware.nl (www.tegenbosch28.nl [217.21.251.97]) by mx1.freebsd.org (Postfix) with ESMTP id B46CE13C469 for ; Fri, 25 Jan 2008 08:50:04 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from localhost (localhost.digiware.nl [127.0.0.1]) by mail.digiware.nl (Postfix) with ESMTP id 68AE6171C6; Fri, 25 Jan 2008 09:50:03 +0100 (CET) X-Virus-Scanned: amavisd-new at digiware.nl Received: from mail.digiware.nl ([127.0.0.1]) by localhost (rack1.digiware.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EgNeBj+xni7o; Fri, 25 Jan 2008 09:49:57 +0100 (CET) Received: from [212.61.27.67] (opteron.digiware.nl [212.61.27.67]) by mail.digiware.nl (Postfix) with ESMTP id A56F117219; Fri, 25 Jan 2008 09:49:57 +0100 (CET) Message-ID: <4799A2B3.4060003@digiware.nl> Date: Fri, 25 Jan 2008 09:49:55 +0100 From: Willem Jan Withagen Organization: Digiware User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: John Hay References: <479880A7.1030107@digiware.nl> <20080124.084828.1608359032.imp@bsdimp.com> <864pd386mj.fsf@ds4.des.no> <20080124.110954.179240992.imp@bsdimp.com> <47991E08.6070609@digiware.nl> <20080125041540.GA30262@zibbi.meraka.csir.co.za> In-Reply-To: <20080125041540.GA30262@zibbi.meraka.csir.co.za> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: des@des.no, freebsd-arm@freebsd.org Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jan 2008 08:50:05 -0000 John Hay wrote: >>> The problem is that the char array isn't guaranteed to be aligned in >>> any way. The fix posted is correct. >>> >>> There may be other fixes too, such as using a union to force >>> alignment. >> Well I'm sort of puzzled right now since after preprocessing the >> variable allocation part boils down to: >> ===== >> struct msghdr msg; >> struct iovec vec; >> char ch = '\0'; >> ssize_t n; >> >> char tmp[((((unsigned)(sizeof(struct cmsghdr)) + (sizeof(int) - 1)) & >> ~(sizeof(int) - 1)) + (((unsigned)(sizeof(int)) + (sizeof(int >> ) - 1)) & ~(sizeof(int) - 1)))]; >> struct cmsghdr *cmsg; >> ===== >> So as far as I can see is char tmp[] included between 2 4-byte items and >> allocation should be "automagically" 4-byte aligned. >> >> Now adding simple code like tmp[0] = 50, the first part of the assembly >> is: (Comments are mine for as far as I can grasp them) > > Just doing tmp[0] = 50 will cause a byte access which should not be a > problem. The original code does something like this (simplified): > > char tmp[CMSG_SPACE(sizeof(int))]; > int *ti; > > ti = tmp; > *ti = 50; > > Now the 50 is an int and not a byte and then the alignment does matter. I know, But to figure out where the array temp is allocated on the stack the easiest to do that is to assign a value to its first element. In assembly you will then find that the starting address that the compiler has calculated for this array. And as far as I can tell [ fp, #-80 ] is going to be quad-aligned assuming that the framepointer is also quad-aligned. Now the not optimised version is that 50 is first loaded into r3, then moved into r2. And only then r2 is moved into memory. Whereas is would be allowed to skip the 'mov r2, r3' step, and do it directly from r3. You'd have to dump you erroneous code into asm, an have a look at what it generated. the gcc switch for that is -S and it leaves a .s file. Also do this for the case that works, and see the differences. Which is not going to be easy. Because by the time -O2 optimizing gets going, the code becomes rather obfuscated. I'm still trying to find an option that puts the source code and/or linenumbers in the asm code. I seem to remember that there used to be such a beast. But the gcc man-pages never stops.... --WjW From owner-freebsd-arm@FreeBSD.ORG Fri Jan 25 11:23:18 2008 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3348516A41A for ; Fri, 25 Jan 2008 11:23:18 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (tim.des.no [194.63.250.121]) by mx1.freebsd.org (Postfix) with ESMTP id E937513C459 for ; Fri, 25 Jan 2008 11:23:17 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (localhost [127.0.0.1]) by spam.des.no (Postfix) with ESMTP id 95CD42084; Fri, 25 Jan 2008 12:23:09 +0100 (CET) X-Spam-Tests: AWL X-Spam-Learn: disabled X-Spam-Score: -0.2/3.0 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on tim.des.no Received: from ds4.des.no (des.no [80.203.243.180]) by smtp.des.no (Postfix) with ESMTP id 813072082; Fri, 25 Jan 2008 12:23:09 +0100 (CET) Received: by ds4.des.no (Postfix, from userid 1001) id 5D483844B6; Fri, 25 Jan 2008 12:23:09 +0100 (CET) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Willem Jan Withagen References: <479880A7.1030107@digiware.nl> <20080124.084828.1608359032.imp@bsdimp.com> <864pd386mj.fsf@ds4.des.no> <20080124.110954.179240992.imp@bsdimp.com> <47991E08.6070609@digiware.nl> <20080125041540.GA30262@zibbi.meraka.csir.co.za> <4799A2B3.4060003@digiware.nl> Date: Fri, 25 Jan 2008 12:23:09 +0100 In-Reply-To: <4799A2B3.4060003@digiware.nl> (Willem Jan Withagen's message of "Fri\, 25 Jan 2008 09\:49\:55 +0100") Message-ID: <86prvq5eua.fsf@ds4.des.no> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-arm@freebsd.org Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jan 2008 11:23:18 -0000 Willem Jan Withagen writes: > John Hay wrote: >>>> The problem is that the char array isn't guaranteed to be aligned in >>>> any way. The fix posted is correct. >>>> >>>> There may be other fixes too, such as using a union to force >>>> alignment. >>> Well I'm sort of puzzled right now since after preprocessing the >>> variable allocation part boils down to: >>> =3D=3D=3D=3D=3D >>> struct msghdr msg; >>> struct iovec vec; >>> char ch =3D '\0'; >>> ssize_t n; >>> >>> char tmp[((((unsigned)(sizeof(struct cmsghdr)) + (sizeof(int) - >>> 1)) & ~(sizeof(int) - 1)) + (((unsigned)(sizeof(int)) + (sizeof(int >>> ) - 1)) & ~(sizeof(int) - 1)))]; >>> struct cmsghdr *cmsg; >>> =3D=3D=3D=3D=3D >>> So as far as I can see is char tmp[] included between 2 4-byte >>> items and allocation should be "automagically" 4-byte aligned. >>> >>> Now adding simple code like tmp[0] =3D 50, the first part of the >>> assembly is: (Comments are mine for as far as I can grasp them) >> >> Just doing tmp[0] =3D 50 will cause a byte access which should not be a >> problem. The original code does something like this (simplified): >> >> char tmp[CMSG_SPACE(sizeof(int))]; >> int *ti; >> >> ti =3D tmp; >> *ti =3D 50; >> >> Now the 50 is an int and not a byte and then the alignment does matter. > > I know, But to figure out where the array temp is allocated on the > stack the easiest to do that is to assign a value to its first > element. In assembly you will then find that the starting address that > the compiler has calculated for this array. > [...] None of this matters. What John pointed out means that the code is wrong and the compiler is right. The code is not allowed to assume that an object is correctly aligned unless it is of a type that requires the correct alignment. The easiest way to do this is with a union, e.g. union { char space[CMSG_SPACE(sizeof(int)); int value; } tmp; tmp.value =3D 50; A trickier way to do it is with a struct: struct { int value; char pad[CMSG_SPACE(sizeof(int)) - sizeof(int)]; } tmp; tmp.value =3D 50; in both cases, you are guaranteed that 1) tmp is be large enough (though possibly larger than required) 2) tmp is correctly aligned and 3) (void *)&tmp =3D=3D (void *)&tmp.value. DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no From owner-freebsd-arm@FreeBSD.ORG Fri Jan 25 11:39:18 2008 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1173E16A417 for ; Fri, 25 Jan 2008 11:39:18 +0000 (UTC) (envelope-from nick@flirble.org) Received: from plum.flirble.org (plum.flirble.org [194.70.3.20]) by mx1.freebsd.org (Postfix) with ESMTP id D58F313C448 for ; Fri, 25 Jan 2008 11:39:17 +0000 (UTC) (envelope-from nick@flirble.org) Received: from nick by plum.flirble.org with local (Exim 4.66 (FreeBSD)) (envelope-from ) id 1JIMtw-000Pfb-EB; Fri, 25 Jan 2008 11:39:16 +0000 Date: Fri, 25 Jan 2008 11:39:16 +0000 From: Nicholas Clark To: Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= Message-ID: <20080125113916.GP81396@plum.flirble.org> Mail-Followup-To: Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= , Willem Jan Withagen , freebsd-arm@freebsd.org References: <479880A7.1030107@digiware.nl> <20080124.084828.1608359032.imp@bsdimp.com> <864pd386mj.fsf@ds4.des.no> <20080124.110954.179240992.imp@bsdimp.com> <47991E08.6070609@digiware.nl> <20080125041540.GA30262@zibbi.meraka.csir.co.za> <4799A2B3.4060003@digiware.nl> <86prvq5eua.fsf@ds4.des.no> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <86prvq5eua.fsf@ds4.des.no> User-Agent: Mutt/1.4.2.1i X-Organisation: Tetrachloromethane Sender: Nicholas Clark Cc: freebsd-arm@freebsd.org Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jan 2008 11:39:18 -0000 On Fri, Jan 25, 2008 at 12:23:09PM +0100, Dag-Erling Smrgrav wrote: > None of this matters. What John pointed out means that the code is > wrong and the compiler is right. The code is not allowed to assume that > an object is correctly aligned unless it is of a type that requires the > correct alignment. The easiest way to do this is with a union, e.g. Whilst that is correct, why is the compiler changing the alignment of the struct for different optimiser settings but all other flags identical? [Have I got that right?] Surely that's a compiler bug too? (In that it is in breach of an ABI, even if ANSI permits different padding for any different compiler flags, making no special reference to "optimisation") Nicholas Clark From owner-freebsd-arm@FreeBSD.ORG Fri Jan 25 12:54:49 2008 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C723316A417 for ; Fri, 25 Jan 2008 12:54:49 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (tim.des.no [194.63.250.121]) by mx1.freebsd.org (Postfix) with ESMTP id 8FBE313C45A for ; Fri, 25 Jan 2008 12:54:49 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (localhost [127.0.0.1]) by spam.des.no (Postfix) with ESMTP id 8DAEB207F; Fri, 25 Jan 2008 13:54:40 +0100 (CET) X-Spam-Tests: AWL X-Spam-Learn: disabled X-Spam-Score: -0.2/3.0 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on tim.des.no Received: from ds4.des.no (des.no [80.203.243.180]) by smtp.des.no (Postfix) with ESMTP id 06F73207E; Fri, 25 Jan 2008 13:54:40 +0100 (CET) Received: by ds4.des.no (Postfix, from userid 1001) id D1EAE844B6; Fri, 25 Jan 2008 13:54:39 +0100 (CET) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Willem Jan Withagen References: <479880A7.1030107@digiware.nl> <20080124.084828.1608359032.imp@bsdimp.com> <864pd386mj.fsf@ds4.des.no> <20080124.110954.179240992.imp@bsdimp.com> <47991E08.6070609@digiware.nl> <20080125041540.GA30262@zibbi.meraka.csir.co.za> <4799A2B3.4060003@digiware.nl> <86prvq5eua.fsf@ds4.des.no> <20080125113916.GP81396@plum.flirble.org> Date: Fri, 25 Jan 2008 13:54:39 +0100 In-Reply-To: <20080125113916.GP81396@plum.flirble.org> (Nicholas Clark's message of "Fri\, 25 Jan 2008 11\:39\:16 +0000") Message-ID: <86hch25als.fsf@ds4.des.no> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-arm@freebsd.org Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jan 2008 12:54:49 -0000 Nicholas Clark writes: > On Fri, Jan 25, 2008 at 12:23:09PM +0100, Dag-Erling Smrgrav wrote: > > None of this matters. What John pointed out means that the code is > > wrong and the compiler is right. The code is not allowed to assume > > that an object is correctly aligned unless it is of a type that > > requires the correct alignment. The easiest way to do this is with > > a union, e.g. > Whilst that is correct, why is the compiler changing the alignment of the > struct for different optimiser settings but all other flags identical? Because *it is not a struct*. It is an array of char, and char has no special alignment requirement. The bug is in the code, which uses pointer aliasing in a way that is strictly speaking legal but which places responsibility for alignment issues squarely in the code and not the compiler. IIRC, this is precisely the same issue that we had in libalias when the checksum recalculation broke because it was doing unaligned 16-bit accesses (many years ago now, see twowords() in alias.c) DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no From owner-freebsd-arm@FreeBSD.ORG Fri Jan 25 13:02:15 2008 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 777B416A417 for ; Fri, 25 Jan 2008 13:02:15 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from mail.digiware.nl (www.tegenbosch28.nl [217.21.251.97]) by mx1.freebsd.org (Postfix) with ESMTP id 3803E13C458 for ; Fri, 25 Jan 2008 13:02:14 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from localhost (localhost.digiware.nl [127.0.0.1]) by mail.digiware.nl (Postfix) with ESMTP id AA0BA17219; Fri, 25 Jan 2008 14:02:13 +0100 (CET) X-Virus-Scanned: amavisd-new at digiware.nl Received: from mail.digiware.nl ([127.0.0.1]) by localhost (rack1.digiware.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zeY4bCmWc32J; Fri, 25 Jan 2008 14:02:11 +0100 (CET) Received: from [212.61.27.67] (opteron.digiware.nl [212.61.27.67]) by mail.digiware.nl (Postfix) with ESMTP id 6910A171A1; Fri, 25 Jan 2008 14:02:11 +0100 (CET) Message-ID: <4799DDD1.9050201@digiware.nl> Date: Fri, 25 Jan 2008 14:02:09 +0100 From: Willem Jan Withagen Organization: Digiware User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: =?UTF-8?B?RGFnLUVybGluZyBTbcO4cmdyYXY=?= References: <479880A7.1030107@digiware.nl> <20080124.084828.1608359032.imp@bsdimp.com> <864pd386mj.fsf@ds4.des.no> <20080124.110954.179240992.imp@bsdimp.com> <47991E08.6070609@digiware.nl> <20080125041540.GA30262@zibbi.meraka.csir.co.za> <4799A2B3.4060003@digiware.nl> <86prvq5eua.fsf@ds4.des.no> <20080125113916.GP81396@plum.flirble.org> <86hch25als.fsf@ds4.des.no> In-Reply-To: <86hch25als.fsf@ds4.des.no> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Cc: freebsd-arm@freebsd.org Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jan 2008 13:02:15 -0000 Dag-Erling Smørgrav wrote: > It is an array of char, and char has no special alignment requirement. > > The bug is in the code, which uses pointer aliasing in a way that is > strictly speaking legal but which places responsibility for alignment > issues squarely in the code and not the compiler. This is exactly what I ment by 'obfuscated code' and a liberal language like 'C'. --WjW From owner-freebsd-arm@FreeBSD.ORG Fri Jan 25 13:05:35 2008 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1846016A41B for ; Fri, 25 Jan 2008 13:05:35 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from mail.digiware.nl (www.tegenbosch28.nl [217.21.251.97]) by mx1.freebsd.org (Postfix) with ESMTP id C102D13C458 for ; Fri, 25 Jan 2008 13:05:34 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from localhost (localhost.digiware.nl [127.0.0.1]) by mail.digiware.nl (Postfix) with ESMTP id DBB1B1715B for ; Fri, 25 Jan 2008 14:05:33 +0100 (CET) X-Virus-Scanned: amavisd-new at digiware.nl Received: from mail.digiware.nl ([127.0.0.1]) by localhost (rack1.digiware.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RMltolhovHhp for ; Fri, 25 Jan 2008 14:05:31 +0100 (CET) Received: from [212.61.27.67] (opteron.digiware.nl [212.61.27.67]) by mail.digiware.nl (Postfix) with ESMTP id 3309E1712B for ; Fri, 25 Jan 2008 14:05:31 +0100 (CET) Message-ID: <4799DE99.8010207@digiware.nl> Date: Fri, 25 Jan 2008 14:05:29 +0100 From: Willem Jan Withagen Organization: Digiware User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: freebsd-arm@freebsd.org References: <479880A7.1030107@digiware.nl> <20080124.084828.1608359032.imp@bsdimp.com> <864pd386mj.fsf@ds4.des.no> <20080124.110954.179240992.imp@bsdimp.com> <47991E08.6070609@digiware.nl> <20080125041540.GA30262@zibbi.meraka.csir.co.za> <4799A2B3.4060003@digiware.nl> <86prvq5eua.fsf@ds4.des.no> <20080125113916.GP81396@plum.flirble.org> In-Reply-To: <20080125113916.GP81396@plum.flirble.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jan 2008 13:05:35 -0000 Nicholas Clark wrote: > On Fri, Jan 25, 2008 at 12:23:09PM +0100, Dag-Erling Smrgrav wrote: > >> None of this matters. What John pointed out means that the code is >> wrong and the compiler is right. The code is not allowed to assume that >> an object is correctly aligned unless it is of a type that requires the >> correct alignment. The easiest way to do this is with a union, e.g. > > Whilst that is correct, why is the compiler changing the alignment of the > struct for different optimiser settings but all other flags identical? > [Have I got that right?] Surely that's a compiler bug too? > > (In that it is in breach of an ABI, even if ANSI permits different padding > for any different compiler flags, making no special reference to > "optimisation") In the assembly output I looked at things were correctly aligned. But then that was still an horribly old version of GCC. I'm in the process of getting 4.2.1 to work. But for the moment I have the feeling that cc1 thinks it is compiling for C++: cc1: warning: command line option "-Wnested-externs" is valid for C/ObjC but not for C++ cc1: warning: command line option "-Wstrict-prototypes" is valid for C/ObjC but not for C++ cc1: warning: command line option "-Wmissing-prototypes" is valid for C/ObjC but not for C++ cc1: warning: command line option "-Wno-pointer-sign" is valid for C/ObjC but not for C++ cc1: warning: command line option "-std=c99" is valid for C/ObjC but not for C++ cc1: warning: command line option "-ffreestanding" is valid for C/ObjC but not for C++ So please bare with me, I'll get there in the end. ;) --WjW From owner-freebsd-arm@FreeBSD.ORG Fri Jan 25 13:43:10 2008 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ECF7F16A41A for ; Fri, 25 Jan 2008 13:43:10 +0000 (UTC) (envelope-from nick@flirble.org) Received: from plum.flirble.org (plum.flirble.org [194.70.3.20]) by mx1.freebsd.org (Postfix) with ESMTP id 395FE13C474 for ; Fri, 25 Jan 2008 13:43:10 +0000 (UTC) (envelope-from nick@flirble.org) Received: from nick by plum.flirble.org with local (Exim 4.66 (FreeBSD)) (envelope-from ) id 1JIOpp-000CJb-03; Fri, 25 Jan 2008 13:43:09 +0000 Date: Fri, 25 Jan 2008 13:43:08 +0000 From: Nicholas Clark To: Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= Message-ID: <20080125134308.GR81396@plum.flirble.org> Mail-Followup-To: Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= , Willem Jan Withagen , freebsd-arm@freebsd.org References: <479880A7.1030107@digiware.nl> <20080124.084828.1608359032.imp@bsdimp.com> <864pd386mj.fsf@ds4.des.no> <20080124.110954.179240992.imp@bsdimp.com> <47991E08.6070609@digiware.nl> <20080125041540.GA30262@zibbi.meraka.csir.co.za> <4799A2B3.4060003@digiware.nl> <86prvq5eua.fsf@ds4.des.no> <20080125113916.GP81396@plum.flirble.org> <86hch25als.fsf@ds4.des.no> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <86hch25als.fsf@ds4.des.no> User-Agent: Mutt/1.4.2.1i X-Organisation: Tetrachloromethane Sender: Nicholas Clark Cc: freebsd-arm@freebsd.org Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jan 2008 13:43:11 -0000 On Fri, Jan 25, 2008 at 01:54:39PM +0100, Dag-Erling Smrgrav wrote: > Nicholas Clark writes: > > On Fri, Jan 25, 2008 at 12:23:09PM +0100, Dag-Erling Smrgrav wrote: > > > None of this matters. What John pointed out means that the code is > > > wrong and the compiler is right. The code is not allowed to assume > > > that an object is correctly aligned unless it is of a type that > > > requires the correct alignment. The easiest way to do this is with > > > a union, e.g. > > Whilst that is correct, why is the compiler changing the alignment of the > > struct for different optimiser settings but all other flags identical? > > Because *it is not a struct*. Aha. That was what I missed. > It is an array of char, and char has no special alignment requirement. > > The bug is in the code, which uses pointer aliasing in a way that is > strictly speaking legal but which places responsibility for alignment > issues squarely in the code and not the compiler. Yes, I agree. In which case I agree with whoever said previously that the fix needs to be taken upstream, but in turn that they may have already fixed it as (IIRC) FreeBSD is using a non-current version of openssh. Nicholas Clark From owner-freebsd-arm@FreeBSD.ORG Fri Jan 25 14:28:11 2008 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 97EEF16A496 for ; Fri, 25 Jan 2008 14:28:11 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (tim.des.no [194.63.250.121]) by mx1.freebsd.org (Postfix) with ESMTP id 607FA13C465 for ; Fri, 25 Jan 2008 14:28:10 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (localhost [127.0.0.1]) by spam.des.no (Postfix) with ESMTP id 5C6A72083; Fri, 25 Jan 2008 15:27:59 +0100 (CET) X-Spam-Tests: AWL X-Spam-Learn: disabled X-Spam-Score: -0.2/3.0 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on tim.des.no Received: from ds4.des.no (des.no [80.203.243.180]) by smtp.des.no (Postfix) with ESMTP id 4E50E2082; Fri, 25 Jan 2008 15:27:59 +0100 (CET) Received: by ds4.des.no (Postfix, from userid 1001) id 2B479844B6; Fri, 25 Jan 2008 15:27:59 +0100 (CET) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Willem Jan Withagen References: <479880A7.1030107@digiware.nl> <20080124.084828.1608359032.imp@bsdimp.com> <864pd386mj.fsf@ds4.des.no> <20080124.110954.179240992.imp@bsdimp.com> <47991E08.6070609@digiware.nl> <20080125041540.GA30262@zibbi.meraka.csir.co.za> <4799A2B3.4060003@digiware.nl> <86prvq5eua.fsf@ds4.des.no> <20080125113916.GP81396@plum.flirble.org> <86hch25als.fsf@ds4.des.no> <20080125134308.GR81396@plum.flirble.org> Date: Fri, 25 Jan 2008 15:27:59 +0100 In-Reply-To: <20080125134308.GR81396@plum.flirble.org> (Nicholas Clark's message of "Fri\, 25 Jan 2008 13\:43\:08 +0000") Message-ID: <86sl0m3rps.fsf@ds4.des.no> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-arm@freebsd.org Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jan 2008 14:28:11 -0000 Nicholas Clark writes: > Dag-Erling Smrgrav writes: > > The bug is in the code, which uses pointer aliasing in a way that is > > strictly speaking legal but which places responsibility for > > alignment issues squarely in the code and not the compiler. > Yes, I agree. In which case I agree with whoever said previously that > the fix needs to be taken upstream, but in turn that they may have > already fixed it as (IIRC) FreeBSD is using a non-current version of > openssh. That was me :) DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no