All pastes #575496 Raw Edit

Untitled

public text v1 · immutable
·published 2007-06-19 02:09 UTC
rendered paste body
falcon randint # cat Kbuild ; cat Makefile ; cat randint.c 
obj-m := randtest.o
randtest-objs := randint.o
# sha1.o random.o


default:

        make -C /lib/modules/$(shell uname -r)/build/ SUBDIRS=$(PWD) modules

clean:

        rm -f Module.symvers *.o *~ .\#* .*.cmd *.mod.c *.ko
        rm -rf .tmp_versions

/*-
  {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");


Possible Security Problem: Fast repeated calls to the function secure_tcp_sequence_number() is not cryptographically safe: 0xd58e41b7=0xd58e41b7
Possible Security Problem: Fast repeated calls to the function secure_tcp_sequence_number() is not cryptographically safe: 0xd718afe3=0xd718afe3
Checking randomization: Fast repeated calls to the function secure_tcp_sequence_number(): 0xda1db174=0xda1db175
Possible Security Problem: Fast repeated calls to the function secure_tcp_sequence_number() is not cryptographically safe: 0xda77abf0=0xda77abf0


jiffies: 0x144244=0x144244
jiffies: 0x145dc4=0x145dc4
jiffies: 0x14856f,0x14856f
jiffies: 0x148bf6,0x148bf6