From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17626 invoked by alias); 3 Oct 2007 07:49:11 -0000 Received: (qmail 17592 invoked by uid 22791); 3 Oct 2007 07:49:09 -0000 X-Spam-Check-By: sourceware.org Received: from sunsite.ms.mff.cuni.cz (HELO sunsite.mff.cuni.cz) (195.113.15.26) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 03 Oct 2007 07:49:06 +0000 Received: from sunsite.mff.cuni.cz (localhost.localdomain [127.0.0.1]) by sunsite.mff.cuni.cz (8.13.8/8.13.8) with ESMTP id l937pVo2030074; Wed, 3 Oct 2007 09:51:31 +0200 Received: (from jj@localhost) by sunsite.mff.cuni.cz (8.13.8/8.13.8/Submit) id l937pUZK030021; Wed, 3 Oct 2007 09:51:31 +0200 Date: Wed, 03 Oct 2007 07:49:00 -0000 From: Jakub Jelinek To: Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] Fix BZ#5070 Message-ID: <20071003075130.GB2896@sunsite.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2007-10/txt/msg00000.txt.bz2 Hi! This patch should IMHO cure the weirdo struct layout problem on arm while not pessimizing code on sane architectures (on x86_64-linux the routine with this patch has minor differences in insn scheduling, but it is the same size and same instructions, just reordered and it is unclear what is more efficient if not equivalent). On arm at least with cross compiler distilled testcase also passes compile time assertion made from the assert and the memset looks good as well. 2007-10-03 Jakub Jelinek [BZ #5070] * sysdeps/unix/sysv/linux/check_pf.c (make_request): Remove pad array from req, instead use offsetof and sizeof to clear padding. --- libc/sysdeps/unix/sysv/linux/check_pf.c.jj 2007-09-02 19:09:33.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/check_pf.c 2007-10-03 09:26:18.000000000 +0200 @@ -54,10 +54,6 @@ make_request (int fd, pid_t pid, bool *s { struct nlmsghdr nlh; struct rtgenmsg g; - /* struct rtgenmsg consists of a single byte. This means there - are three bytes of padding included in the REQ definition. - We make them explicit here. */ - char pad[3]; } req; struct sockaddr_nl nladdr; @@ -68,8 +64,11 @@ make_request (int fd, pid_t pid, bool *s req.nlh.nlmsg_seq = time (NULL); req.g.rtgen_family = AF_UNSPEC; - assert (sizeof (req) - offsetof (struct req, pad) == 3); - memset (req.pad, '\0', sizeof (req.pad)); + assert (sizeof (req) - offsetof (struct req, g) + - sizeof (req.g.rtgen_family) == 3); + memset (&req.g.rtgen_family + 1, '\0', + sizeof (req) - offsetof (struct req, g) + - sizeof (req.g.rtgen_family)); memset (&nladdr, '\0', sizeof (nladdr)); nladdr.nl_family = AF_NETLINK; Jakub