Skip to content

Commit

Permalink
MFC: fix for predictable TCP sequence numbers, requires MFC of arc4ra…
Browse files Browse the repository at this point in the history
…ndom.
  • Loading branch information
splbio committed Oct 6, 2000
1 parent bf483ab commit d8e34cd
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions sys/i386/conf/files.i386
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ libkern/strncmp.c standard
libkern/strncpy.c standard
libkern/udivdi3.c standard
libkern/umoddi3.c standard
libkern/arc4random.c standard
gnu/i386/fpemul/div_small.s optional gpl_math_emulate
gnu/i386/fpemul/errors.c optional gpl_math_emulate
gnu/i386/fpemul/fpu_arith.c optional gpl_math_emulate
Expand Down
1 change: 0 additions & 1 deletion sys/libkern/arc4random.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*/

#include <sys/types.h>
#include <sys/random.h>
#include <sys/libkern.h>

#define ARC4_MAXRUNS 64
Expand Down
2 changes: 1 addition & 1 deletion sys/netinet/tcp_seq.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ extern tcp_cc tcp_ccgen; /* global connection count */
* number in the range [0-0x3ffff] that is hard to predict.
*/
#ifndef tcp_random18
#define tcp_random18() ((random() >> 14) & 0x3ffff)
#define tcp_random18() (arc4random() & 0x3ffff)
#endif
#define TCP_ISSINCR (122*1024 + tcp_random18())

Expand Down
2 changes: 1 addition & 1 deletion sys/netinet/tcp_subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void
tcp_init()
{

tcp_iss = random(); /* wrong, but better than a constant */
tcp_iss = arc4random(); /* wrong, but better than a constant */
tcp_ccgen = 1;
tcp_cleartaocache();
LIST_INIT(&tcb);
Expand Down
1 change: 1 addition & 0 deletions sys/sys/libkern.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ static __inline u_long ulmax(u_long a, u_long b) { return (a > b ? a : b); }
static __inline u_long ulmin(u_long a, u_long b) { return (a < b ? a : b); }

/* Prototypes for non-quad routines. */
u_int32_t arc4random __P((void));
int bcmp __P((const void *, const void *, size_t));
#ifndef HAVE_INLINE_FFS
int ffs __P((int));
Expand Down

0 comments on commit d8e34cd

Please sign in to comment.