Re: 2^64 - 39 ...
Hereâs a function that computes unsigned long square roots using Newtonâs method. I believe that I have tested it quite carefully and am quite confident that it works correctly. It returns the unsigned long exact square root value if there is one. Otherwise, it returns the closest unsigned long int which is less than the exact real square root value. For example, it would return 0 as the square root of 0 1 as the square root of 1, 2 and 3 2 as the square root of 4, 5, 6, 7 and 8 3 as the square root of 9, 10 ⦠15 4 as the square root of 16 ⦠24 etc. I believe that it properly handles all unsigned long values of n from 0L to ((unsigned long)~0L) == 2^64 - 1. There are probably ways of making it faster. I am not including my test software because I would be much more confident that the code works if it was independently tested. -Danny #define DELTA(a,b) ( (a) > (b) ? (a) - (b) : (b) - (a) ) unsigned long ulong_sqrt( unsigned long n ) { if ( n == 0 || n == 1 ) { return n; } unsigned long guess = n >> 1; unsigned long quotient = n / guess; while ( 1 ) { unsigned long gap = DELTA( guess, quotient ); if ( gap < 2 ) { break; } guess = ( quotient + guess ) >> 1; quotient = n / guess; } guess = guess > quotient ? quotient : guess; return guess; } > On Sep 8, 2015, at 00:03 , Otto Moerbeek wrote: > > On Mon, Sep 07, 2015 at 06:20:02PM -0400, Raul Miller wrote: > >> On Mon, Sep 7, 2015 at 6:03 PM, Ted Unangst wrote: >>> Michael Warmuth-Uhl wrote: On 2015-09-07, Otto Moerbeek wrote: It seems to fix the issues on amd64, but I'm not sure if the accuracy of long double and sqrtl is guaranteed to be enough in general. >>> >>> using floating point seems suspect. i think what's needed is an integer sqrt >>> function. >> >> Floating point works fine for integers as long as your integers fit >> within the mantissa component of the floating point representation. >> >> Assuming the usual IEEE-754 implementation: >> >> For double, this means integers cannot exceed 2^53 (9007199254740992) >> without losing least significant bits (2^53-1 can be represented, 2^53 >> can be represented but has lost the least significant bit so typically >> that means it's assumed to be zero - which is fine, but that means >> that 1+2^53 cannot be represented). >> >> For long double, this means integers cannot exceed 2^113 >> (10384593717069655257060992658440192) without losing least significant >> bits. >> >> That said, you can implement integer square root using binary search. > > My bet would be Newton iteration, which should converge faster than > binary search. ping(8) has an implementation of integer sqrt. > > BTW, long double won't fix the problem on al platforms since it is not > guaranteed to be longer than double. > > -Otto
Re: OpenBSD machine was hacked
There is all sorts of information that you could provide: - why do you believe that your machine was hacked? You seem to think that someone at your ISP did whatever was done. Why do you believe that to be true? Why would someone at your ISP want to do this? Why would someone at you ISP be better able to do this than some random bad person out on the Internet? - you say that whatever happened was done by your ISP even though you had no Internet connection. Why do you believe that this is even possible? Why do you believe that you had no Internet connection? If you had no Internet connection, how is it that someone at your ISP would have been able to access the machine? Where is the machine actually located? - you say that your pf rules were flushed. Why do you believe that they were ever loaded in the first place? Can you demonstrate that the rules were in place at one point in time and that they are no longer in place later? Have you tried rebooting the machine and then immediately checking to see if the rules are there or not? - you say that you suspect that your ISP used some sort of “Layer 2 by using mac spoofing/mac target” technique. Please say more about “some sort of” - what sort of? Why do you believe that this technique, whatever it is, might work? Can you even provide a basic explanation of how this technique, whatever it is, might have been used to hack your machine or is this just a theory with no evidence to support it. There are lots of other questions you could answer. For example, what messages appear in your log files that support your theory? Even a list of the evidence that you see that supports your theory might help. It almost sounds like you are saying that you cannot figure out how whatever happened occurred so it must have been someone at your ISP. That is a pretty big leap to make without some evidence that actually points at your ISP. -Danny > On Jul 28, 2015, at 18:00 , Wong Peter wrote: > > What information you all require? > > On Tue, Jul 28, 2015 at 10:28 PM, Giancarlo Razzolini > wrote: > >> Em 28-07-2015 06:17, Wong Peter escreveu: >>> Dear All, >>> >>> Recently, I'm realized that my openbsd firewall router was not usable >>> anymore due to pf rules had changed by using carp and pfsync mechanism. >>> >>> Here is my prove. >>> >>> I'm tried to reinstall the whole machine and plugged in the modem LAN >> cable >>> to NIC card. All my written pf rules was flush and changed. This happen >>> even without internet connection(No IP address assign). >>> >>> I'm suspected this is did by my ISP. I'm believed my openbsd machine was >>> located same subnet with their machine. >>> >>> I'm even tried to disable carp protocol but my pf rules still get flushed >>> out. >>> How this can happen? >>> How to prevent it? >>> How my ISP can synchronize its pf rules to my machine without IP assign? >>> I'm suspect they achieved at Layer 2 by using mac spoofing/mac target to >> my >>> machine. >>> net.inet.carp.allow=0 >>> >>> Please help. Very urgent. >>> >>> >>> >>> >>> >>> >> You use a very controversial subject in order to draw attention in the >> hope that someone will help you. And not only you can't manage to give a >> shred of evidence to support your claim, as you can't even manage to >> provide enough information for some good soul on this list to help you. >> Come back when you sorted this out. >> >> Cheers, >> Giancarlo Razzolini >> > > > > -- > Linux