From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/1246 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: openssh and sendmsg() problem Date: Tue, 26 Jun 2012 22:40:16 +0200 Message-ID: <20120626204016.GA17860@port70.net> References: <20120626190146.1c086ed2@sibserver.ru> <20120626120017.GZ17860@port70.net> <20120626160106.GJ544@brightrain.aerifal.cx> <20120627012441.2af9b154@sibserver.ru> <20120626173205.GK544@brightrain.aerifal.cx> <20120627021640.42af7e4f@sibserver.ru> <20120626190823.GL544@brightrain.aerifal.cx> <20120627033934.0a201cfb@sibserver.ru> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1340743231 27888 80.91.229.3 (26 Jun 2012 20:40:31 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 26 Jun 2012 20:40:31 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-1247-gllmg-musl=m.gmane.org@lists.openwall.com Tue Jun 26 22:40:30 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1SjcYo-0002QX-GG for gllmg-musl@plane.gmane.org; Tue, 26 Jun 2012 22:40:30 +0200 Original-Received: (qmail 32110 invoked by uid 550); 26 Jun 2012 20:40:28 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 32102 invoked from network); 26 Jun 2012 20:40:28 -0000 Content-Disposition: inline In-Reply-To: <20120627033934.0a201cfb@sibserver.ru> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:1246 Archived-At: * orc [2012-06-27 03:39:34 +0800]: > On Tue, 26 Jun 2012 15:08:23 -0400 > Rich Felker wrote: > > On Wed, Jun 27, 2012 at 02:16:40AM +0800, orc wrote: > > > > > On Tue, 26 Jun 2012 12:01:06 -0400 > > > > > Rich Felker wrote: > > > > > > > * orc [2012-06-26 19:01:46 +0800]: > > > > > > > > strace shows that sendmsg system call returns EINVAL: > > > > > > > > > > > > > > > > sendmsg(5, {msg_name(0)=NULL, msg_iov(1)=[{"\0", 1}], > > > > > > > > msg_controllen=24, {cmsg_len=20, cmsg_level=SOL_SOCKET, > > > > > > > > cmsg_ type=SCM_RIGHTS, {4, 385875968}}, msg_flags=0}, 0) > > > > > > > > = -1 EINVAL (Invalid argument) > > > > > > > > > > > > > > strace from glibc system on this syscall: > > > > > > sendmsg(5, {msg_name(0)=NULL, msg_iov(1)=[{"\0", 1}], > > > msg_controllen=24, {cmsg_len=20, cmsg_level=SOL_SOCKET, > > > cmsg_type=SCM_RIGHTS, {4}}, msg_flags=0}, 0) = 1 sendmsg(5, > > > {msg_name(0)=NULL, msg_iov(1)=[{"\0", 1}], msg_controllen=24, > > > {cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, {6}}, > > > msg_flags=0}, 0) = 1 > > > > I don't quite understand this from the strace, but it looks like > > there's an issue with the size of cmsg structures on 64-bit machines > > due to another buggy kernel socklen_t/size_t mismatch. I'm not sure > > how it can be worked around, but musl's failure to work around it is a > > flaw that needs to be fixed. glibc just violates POSIX and defines > > the wrong type. > > > > Rich > > And kernel too. > > Both they define incompatible msghdr and cmsghdr structs. > The problem sits in cmsghdr struct, changing it's first member type to > 'size_t' solves openssh issue. so the issue is that the kernel and glibc uses size_t for socklen_t in struct msghdr and struct cmsghdr as well musl fixes msghdr but not cmsghdr (by using int + padding) where is it specified in posix that socklen_t should be unsigned int? it seems using size_t would make things easier.. i only see a recommendation that "To forestall portability problems, it is recommended that applications not use values larger than 2^31 -1 for the socklen_t type."