Date: Mon, 29 May 2000 11:00:04 -0700 (PDT) From: Anatoly Vorobey <mellon@pobox.com> To: freebsd-bugs@FreeBSD.org Subject: Re: kern/18874: 32bit NFS servers export wrong negative values to 64bit clients Message-ID: <200005291800.LAA61110@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/18874; it has been noted by GNATS. From: Anatoly Vorobey <mellon@pobox.com> To: Alexander Langer <alex@big.endian.de>, FreeBSD-gnats-submit@FreeBSD.ORG Cc: Subject: Re: kern/18874: 32bit NFS servers export wrong negative values to 64bit clients Date: Mon, 29 May 2000 13:53:16 -0400 You, Anatoly Vorobey, were spotted writing this on Mon, May 29, 2000 at 01:34:46PM -0400: > Hmm. I haven't thought of that. A simple test I made on i386 showed > that (long)(u_quad_t)(long)(-100) == -100, so I guess the conversion > works fine, even though long is 32bit, and I can't really explain why > at the moment :) Can't I? I can ;) If the negative value is small enough to fit into 32bit, then it'll get converted via u_quad_t just fine, because the high quadword will only contain 1's. The conversion from u_quad_t to long will just chop off the high word: Scenario A. Source long is 32-bit, destination long is 32-bit: (src long)-10 is 0xfffffff6 (u_quad_t)(src long)-10 is 0x00000000fffffff6 (dst long)(u_quad_t)(src long)-10 is 0xfffffff6 == -10 Senario B. Source long is 64-bit, destination long is 32-bit: (src long)-10 is 0xfffffffffffffff6 (u_quad_t)(dst long)-10 is 0xfffffffffffffff6 (dst long)(u_quad_t)(src long)-10 is 0xfffffff6 == -10 Scenario C. Source long is 32-bit, destination long is 64-bit: (src long)-10 is 0xfffffff6 (u_quad_t)(src long)-10 is 0x00000000fffffff6 (dst long)(u_quad_t)(src long)-10 is 0x00000000fffffff6 == 4294967286 Scenario D. Source long is 64-bit, destination long is 64-bit, left to the reader ;) Bummer, scenario C shouldn't work at all -- can you check? But this isn't your case, your case is scenario B IIRC -- and the conversion should work fine, my patch corrects the problem which might happen because the value gets divided before the third stage, when the compiler still thinks it's unsigned 64bit. -- Anatoly Vorobey, mellon@pobox.com http://pobox.com/~mellon/ "Angels can fly because they take themselves lightly" - G.K.Chesterton To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200005291800.LAA61110>
