From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 18509 invoked from network); 16 Sep 1998 07:11:03 -0000 Received: from mail.redhat.com (199.183.24.239) by mail2.redhat.com with SMTP; 16 Sep 1998 07:11:03 -0000 Received: from earth.terran.org (bryan@earth.terran.org [208.152.24.33]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id DAA17980 for ; Wed, 16 Sep 1998 03:11:39 -0400 Received: from localhost (bryan@localhost) by earth.terran.org (8.8.7/8.8.9) with SMTP id AAA27921; Wed, 16 Sep 1998 00:14:28 -0700 Date: Wed, 16 Sep 1998 00:14:28 -0700 (PDT) From: "B. James Phillippe" Reply-To: "B. James Phillippe" To: Linux GNU libc list cc: RedHat AXP list Subject: Mistakes in glibc-2.0.7 includes Message-ID: Organization: Terran.ORG/LinuxWorld.NET X-Subliminal-Message: Use Linux MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Hello, I posted this information quite a while back but never got any response. I'd like to know what other folks think about this, if anyone can please comment. The problem is that some files in the glibc includes specify fixed-size variables (u_int32_t, u_int16_t, etc) in places where natural-size variables are required. In particular, specifies struct ip_fw as such: struct ip_fw { ... u_int16_t fw_nsp, fw_ndp; /* N'of src ports and # of dst ports */ ... u_int32_t fw_pcnt, fw_bcnt; /* Packet and byte counters */ ... }; fw_nsp and fw_ndp show a proper usage of fixed-size variables, afterall, a port number is specified to be 16 bits. However, the variables fw_pcnt and fw_bcnt are an explicit 32 bits. The problem is subtle.. These same values in the Linux kernel are specified as "unsigned long". On x86, u_int32_t and unsigned long coincidentally happen to be the same size, and the bug is masked. However, on Alpha (and presumably UltraSparc) unsigned long is 64 bits. Now the bug is apparent, because when networking tools use the include from the glibc headers, the struct ip_fw has the wrong size. This can cause syscalls such as setsockopt() to fail -EINVAL. The suggestion is to make variables which do not clearly require an explicit size to use a natural size. In the case I point out here, there is no logical reason I can see to force a counter variable to a specific number of bits. Why limit architectures that are capable of better? FWIW, this little bugger is the cause of the "ifpwadm does not work" on RedHat-5.1 and several unaligned accesses in various other networking tools (several in net-tools). I suspect a similar problem with tcpdump also, but have not yet investigated further. thanks, -bp -- B. James Phillippe Linux Software Engineer, WGTI. http://earth.terran.org/~bryan