All pastes #576954 Raw Edit

Unnamed

public c v1 · immutable
·published 2007-06-19 18:26 UTC
rendered paste body
falcon randint # cat randint.c /*-  {solar,pappy}(@)gentoo.org  Tue Jun 19 00:39:29*/#include <linux/init.h>  #include <linux/module.h>#include <linux/kernel.h>#include <linux/jiffies.h>#include <linux/random.h>static int randint_init(void) {  unsigned int seed[2];  unsigned int jiffiecatcher[2];  /* let's do the time warp */  jiffiecatcher[0] = jiffies;  jiffiecatcher[1] = jiffies;  printk(KERN_INFO "jiffies: 0x%0*x,0x%0*x\n", sizeof(int), jiffiecatcher[0], sizeof(int), jiffiecatcher[1]);  seed[0] = secure_tcp_sequence_number(0,(__force __be32)(current->pid + jiffiecatcher[0]),0,0);  seed[1] = secure_tcp_sequence_number(0,(__force __be32)(current->pid + jiffiecatcher[1]),0,0);  if (seed[0] == seed[1]) {    printk(KERN_ALERT "Possible Security Problem: Fast repeated calls to the function secure_tcp_sequence_number() is not cryptographically safe: 0x%0*x=0x%0*x\n",      sizeof(long), seed[0], sizeof(long), seed[1]);    return 1;  } else {    printk(KERN_INFO "Checking randomization: Fast repeated calls to the function secure_tcp_sequence_number(): 0x%0*x=0x%0*x\n",      sizeof(long), seed[0], sizeof(long), seed[1]);    return 0;  }}static void randint_exit(void) {  return;}module_init(randint_init);module_exit(randint_exit);MODULE_LICENSE("GPL");