From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10965 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Re: Need to zero pads in msghdr Date: Wed, 25 Jan 2017 14:59:01 -0500 Message-ID: <20170125195901.GD1533@brightrain.aerifal.cx> References: <20170125194023.GQ17692@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1485374369 14957 195.159.176.226 (25 Jan 2017 19:59:29 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 25 Jan 2017 19:59:29 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-10980-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jan 25 20:59:19 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1cWTit-0002rB-4X for gllmg-musl@m.gmane.org; Wed, 25 Jan 2017 20:59:15 +0100 Original-Received: (qmail 27993 invoked by uid 550); 25 Jan 2017 19:59:15 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 27963 invoked from network); 25 Jan 2017 19:59:14 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:10965 Archived-At: On Wed, Jan 25, 2017 at 11:46:44AM -0800, Andrei Vagin wrote: > On Wed, Jan 25, 2017 at 11:40 AM, Szabolcs Nagy wrote: > > * Andrei Vagin [2017-01-25 10:56:22 -0800]: > >> On Wed, Jan 25, 2017 at 8:42 AM, Andrei Vagin wrote: > >> > In this patch > >> > http://git.musl-libc.org/cgit/musl/commit/arch/x86_64/bits/socket.h?id=7168790763cdeb794df52be6e3b39fbb021c5a64 > >> > you suppose that the kernel ignores the upper 32 bits of msg_iovlen, > >> > but it doesn't, so pads in msghdr structures have to be zeroed before > >> > calling sendmsg and recvmsg syscalls. > >> > >> Actually the problem is a bit different. In CRIU we use the msghdr > >> structure from musl-libc, but in some cases we have to call raw system > >> calls. We don't expect to have pads in structures and so we don't zero > >> them. > > > > why do you need a raw syscall? > > We inject our code into processes which are going to be dumped: > https://criu.org/Parasite_code > > And on restore we have to unmap old libc to restore process mappings. > > > > > (i think if you do raw syscalls you should use > > your own linux syscall wrappers including typedefs > > and macro defines, not libc ones, because the libc > > can and does do all sorts of remapping of things to > > workaround various mismatches between the posix > > library api it provides and the linux syscall abi) > > We know about this risk, but before this day we executed out test for > glibc and it worked for everyone. Now we need think how to resolve the > problem. While you may hit problems elsewhere, I think there's a clean solution here, just pre-zeroing the structure so that any possible padding is zero. It's unfortunate that this is needed but it comes from the kernel getting the structure definition wrong. Rich