home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / KERNEL-S / V1.0 / PATCH3.GZ / patch3
Encoding:
Text File  |  1994-03-21  |  25.5 KB  |  827 lines

  1. diff -u --recursive --new-file v1.0.2/linux/CREDITS linux/CREDITS
  2. --- v1.0.2/linux/CREDITS    Fri Mar 18 10:21:32 1994
  3. +++ linux/CREDITS    Sat Mar 19 20:01:34 1994
  4. @@ -403,6 +403,15 @@
  5.  S: FIN-00330 Helsingfors
  6.  S: Finland
  7.  
  8. +N: Kai Petzke
  9. +E: wpp@marie.physik.tu-berlin.de
  10. +D: Driver for Laser Magnetic Storage CD-ROM
  11. +D: Some kernel bug fixes, new swapping routine
  12. +D: Port of the database Postgres
  13. +S: Stresemannstr. 62
  14. +S: 10963 Berlin
  15. +S: Germany
  16. +
  17.  N: Stefan Probst
  18.  E: snprobst@immd4.informatik.uni-erlangen.de
  19.  D: The Linux Support Team Erlangen
  20. diff -u --recursive --new-file v1.0.2/linux/Makefile linux/Makefile
  21. --- v1.0.2/linux/Makefile    Mon Mar 21 16:36:20 1994
  22. +++ linux/Makefile    Mon Mar 21 17:05:21 1994
  23. @@ -1,6 +1,6 @@
  24.  VERSION = 1
  25.  PATCHLEVEL = 0
  26. -SUBLEVEL = 2
  27. +SUBLEVEL = 3
  28.  
  29.  all:    Version zImage
  30.  
  31. diff -u --recursive --new-file v1.0.2/linux/drivers/char/lp.c linux/drivers/char/lp.c
  32. --- v1.0.2/linux/drivers/char/lp.c    Fri Mar 18 10:21:33 1994
  33. +++ linux/drivers/char/lp.c    Mon Mar 21 16:26:07 1994
  34. @@ -445,10 +445,10 @@
  35.          for (testvalue = 0 ; testvalue < LP_DELAY ; testvalue++)
  36.              ;
  37.          testvalue = inb_p(LP_B(offset));
  38. -        if (testvalue != 255) {
  39. +        if (testvalue == LP_DUMMY) {
  40.              LP_F(offset) |= LP_EXIST;
  41.              lp_reset(offset);
  42. -            printk("lp_init: lp%d exists (%d), ", offset, testvalue);
  43. +            printk("lp_init: lp%d exists, ", offset);
  44.              if (LP_IRQ(offset))
  45.                  printk("using IRQ%d\n", LP_IRQ(offset));
  46.              else
  47. diff -u --recursive --new-file v1.0.2/linux/drivers/net/slip.c linux/drivers/net/slip.c
  48. --- v1.0.2/linux/drivers/net/slip.c    Mon Mar 14 11:30:53 1994
  49. +++ linux/drivers/net/slip.c    Mon Mar 21 16:16:10 1994
  50. @@ -1102,9 +1102,9 @@
  51.    DPRINTF((DBG_SLIP, "SLIP: ioctl(%d, 0x%X, 0x%X)\n", tty->line, cmd, arg));
  52.    switch(cmd) {
  53.      case SIOCGIFNAME:
  54. -        err=verify_area(VERIFY_WRITE, arg, 16);
  55. +        err=verify_area(VERIFY_WRITE, arg, strlen(sl->dev->name) + 1);
  56.          if(err)
  57. -            return -err;
  58. +            return err;
  59.          memcpy_tofs(arg, sl->dev->name, strlen(sl->dev->name) + 1);
  60.          return(0);
  61.      case SIOCGIFENCAP:
  62. diff -u --recursive --new-file v1.0.2/linux/drivers/scsi/sg.c linux/drivers/scsi/sg.c
  63. --- v1.0.2/linux/drivers/scsi/sg.c    Mon Mar 21 16:36:21 1994
  64. +++ linux/drivers/scsi/sg.c    Sat Mar 19 19:29:14 1994
  65. @@ -56,7 +56,7 @@
  66.   {
  67.    int dev = MINOR(inode->i_rdev);
  68.    if ((dev<0) || (dev>=NR_SG))
  69. -   return -ENXIO
  70. +   return -ENXIO;
  71.    switch(cmd_in)
  72.     {
  73.      case SG_SET_TIMEOUT:
  74. diff -u --recursive --new-file v1.0.2/linux/drivers/scsi/sr_ioctl.c linux/drivers/scsi/sr_ioctl.c
  75. --- v1.0.2/linux/drivers/scsi/sr_ioctl.c    Mon Mar 21 16:36:21 1994
  76. +++ linux/drivers/scsi/sr_ioctl.c    Mon Mar 21 16:13:13 1994
  77. @@ -95,7 +95,7 @@
  78.          u_char     sr_cmd[10];
  79.  
  80.      int dev = inode->i_rdev;
  81. -    int result, target;
  82. +    int result, target, err;
  83.  
  84.      target = MINOR(dev);
  85.      if (target >= NR_SR) return -ENXIO;
  86. @@ -192,7 +192,9 @@
  87.  
  88.              scsi_free(buffer, 512);
  89.  
  90. -            verify_area (VERIFY_WRITE, (void *) arg, sizeof (struct cdrom_tochdr));
  91. +            err = verify_area (VERIFY_WRITE, (void *) arg, sizeof (struct cdrom_tochdr));
  92. +            if (err)
  93. +                return err;
  94.              memcpy_tofs ((void *) arg, &tochdr, sizeof (struct cdrom_tochdr));
  95.              
  96.              return result;
  97. @@ -230,7 +232,9 @@
  98.  
  99.              scsi_free(buffer, 512);
  100.  
  101. -            verify_area (VERIFY_WRITE, (void *) arg, sizeof (struct cdrom_tocentry));
  102. +            err = verify_area (VERIFY_WRITE, (void *) arg, sizeof (struct cdrom_tocentry));
  103. +            if (err)
  104. +                return err;
  105.              memcpy_tofs ((void *) arg, &tocentry, sizeof (struct cdrom_tocentry));
  106.  
  107.              return result;
  108. @@ -369,7 +373,9 @@
  109.  
  110.                scsi_free(buffer, 512);
  111.  
  112. -              verify_area (VERIFY_WRITE, (void *) arg, sizeof (struct cdrom_subchnl));
  113. +              err = verify_area (VERIFY_WRITE, (void *) arg, sizeof (struct cdrom_subchnl));
  114. +              if (err)
  115. +                  return err;
  116.                memcpy_tofs ((void *) arg, &subchnl, sizeof (struct cdrom_subchnl));
  117.                return result;
  118.              }
  119. diff -u --recursive --new-file v1.0.2/linux/fs/ext2/ioctl.c linux/fs/ext2/ioctl.c
  120. --- v1.0.2/linux/fs/ext2/ioctl.c    Fri Dec 31 11:59:49 1993
  121. +++ linux/fs/ext2/ioctl.c    Mon Mar 21 16:13:13 1994
  122. @@ -17,11 +17,14 @@
  123.  int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
  124.          unsigned long arg)
  125.  {
  126. +    int err;
  127.  
  128.      ext2_debug ("cmd = %u, arg = %lu\n", cmd, arg);
  129.  
  130.      switch (cmd) {
  131.      case EXT2_IOC_GETFLAGS:
  132. +        if ((err = verify_area (VERIFY_WRITE, (long *) arg, sizeof(long))))
  133. +            return err;
  134.          put_fs_long (inode->u.ext2_i.i_flags, (long *) arg);
  135.          return 0;
  136.      case EXT2_IOC_SETFLAGS:
  137. @@ -34,6 +37,8 @@
  138.          inode->i_dirt = 1;
  139.          return 0;
  140.      case EXT2_IOC_GETVERSION:
  141. +        if ((err = verify_area (VERIFY_WRITE, (long *) arg, sizeof(long))))
  142. +            return err;
  143.          put_fs_long (inode->u.ext2_i.i_version, (long *) arg);
  144.          return 0;
  145.      case EXT2_IOC_SETVERSION:
  146. diff -u --recursive --new-file v1.0.2/linux/include/linux/mm.h linux/include/linux/mm.h
  147. --- v1.0.2/linux/include/linux/mm.h    Mon Feb 14 21:27:12 1994
  148. +++ linux/include/linux/mm.h    Sun Mar 20 22:13:06 1994
  149. @@ -73,6 +73,25 @@
  150.  #define BAD_PAGE __bad_page()
  151.  #define ZERO_PAGE __zero_page()
  152.  
  153. +/* planning stage.. */
  154. +#define P_DIRTY        0x0001
  155. +#define P_LOCKED    0x0002
  156. +#define P_UPTODATE    0x0004
  157. +#define P_RESERVED    0x8000
  158. +
  159. +struct page_info {
  160. +    unsigned short flags;
  161. +    unsigned short count;
  162. +    struct inode * inode;
  163. +    unsigned long offset;
  164. +    struct page_info * next_same_inode;
  165. +    struct page_info * prev_same_inode;
  166. +    struct page_info * next_hash;
  167. +    struct page_info * prev_hash;
  168. +    struct wait_queue *wait;
  169. +};
  170. +/* end of planning stage */
  171. +
  172.  extern volatile short free_page_ptr; /* used by malloc and tcp/ip. */
  173.  
  174.  extern int nr_swap_pages;
  175. @@ -189,7 +208,7 @@
  176.  
  177.  
  178.  /* vm_ops not present page codes */
  179. -#define SHM_SWP_TYPE 0x41        
  180. +#define SHM_SWP_TYPE 0x41
  181.  extern void shm_no_page (ulong *);
  182.  
  183.  #endif
  184. diff -u --recursive --new-file v1.0.2/linux/ipc/sem.c linux/ipc/sem.c
  185. --- v1.0.2/linux/ipc/sem.c    Mon Dec 27 16:22:39 1993
  186. +++ linux/ipc/sem.c    Mon Mar 21 16:16:11 1994
  187. @@ -235,7 +235,7 @@
  188.          case GETALL:
  189.              if (!arg || ! (array = (ushort *) get_fs_long((int *) arg)))
  190.                  return -EFAULT;
  191. -            i = verify_area (VERIFY_WRITE, array, nsems* sizeof(short));
  192. +            i = verify_area (VERIFY_WRITE, array, nsems*sizeof(short));
  193.              if (i)
  194.                  return i;
  195.          }
  196. @@ -266,7 +266,7 @@
  197.      case IPC_STAT:
  198.          if (!arg || !(buf = (struct semid_ds *) get_fs_long((int *) arg))) 
  199.              return -EFAULT;
  200. -        if ((i = verify_area (VERIFY_WRITE, arg, sizeof tbuf)))
  201. +        if ((i = verify_area (VERIFY_WRITE, buf, sizeof(*sma))))
  202.              return i;
  203.          break;
  204.      case IPC_SET:
  205. diff -u --recursive --new-file v1.0.2/linux/kernel/sched.c linux/kernel/sched.c
  206. --- v1.0.2/linux/kernel/sched.c    Mon Mar 21 16:36:22 1994
  207. +++ linux/kernel/sched.c    Fri Mar 18 11:18:45 1994
  208. @@ -772,7 +772,7 @@
  209.  
  210.  static void show_task(int nr,struct task_struct * p)
  211.  {
  212. -    int free;
  213. +    unsigned long free;
  214.      static char * stat_nam[] = { "R", "S", "D", "Z", "T", "W" };
  215.  
  216.      printk("%-8s %3d ", p->comm, (p == current) ? -nr : nr);
  217. diff -u --recursive --new-file v1.0.2/linux/kernel/sys.c linux/kernel/sys.c
  218. --- v1.0.2/linux/kernel/sys.c    Fri Mar  4 17:10:58 1994
  219. +++ linux/kernel/sys.c    Mon Mar 21 16:13:14 1994
  220. @@ -166,9 +166,14 @@
  221.  {
  222.      struct vm86_struct info;
  223.      struct pt_regs * pt_regs = (struct pt_regs *) &v86;
  224. +    int error;
  225.  
  226.      if (current->saved_kernel_stack)
  227.          return -EPERM;
  228. +    /* v86 must be readable (now) and writable (for save_v86_state) */
  229. +    error = verify_area(VERIFY_WRITE,v86,sizeof(*v86));
  230. +    if (error)
  231. +        return error;
  232.      memcpy_fromfs(&info,v86,sizeof(info));
  233.  /*
  234.   * make sure the vm86() system call doesn't try to do anything silly
  235. diff -u --recursive --new-file v1.0.2/linux/lib/malloc.c linux/lib/malloc.c
  236. --- v1.0.2/linux/lib/malloc.c    Wed Dec  1 14:44:15 1993
  237. +++ linux/lib/malloc.c
  238. @@ -1,540 +0,0 @@
  239. -/*
  240. - * malloc.c --- a general purpose kernel memory allocator for Linux.
  241. - *
  242. - * Written by Theodore Ts'o (tytso@mit.edu), 11/29/91
  243. - *
  244. - * This routine is written to be as fast as possible, so that it
  245. - * can be called from the interrupt level.
  246. - *
  247. - * Limitations: maximum size of memory we can allocate using this routine
  248. - *    is 4k, the size of a page in Linux.
  249. - *
  250. - * The general game plan is that each page (called a bucket) will only hold
  251. - * objects of a given size.  When all of the object on a page are released,
  252. - * the page can be returned to the general free pool.  When kmalloc() is
  253. - * called, it looks for the smallest bucket size which will fulfill its
  254. - * request, and allocate a piece of memory from that bucket pool.
  255. - *
  256. - * Each bucket has as its control block a bucket descriptor which keeps
  257. - * track of how many objects are in use on that page, and the free list
  258. - * for that page.  Like the buckets themselves, bucket descriptors are
  259. - * stored on pages requested from get_free_page().  However, unlike buckets,
  260. - * pages devoted to bucket descriptor pages are never released back to the
  261. - * system.  Fortunately, a system should probably only need 1 or 2 bucket
  262. - * descriptor pages, since a page can hold 256 bucket descriptors (which
  263. - * corresponds to 1 megabyte worth of bucket pages.)  If the kernel is using
  264. - * that much allocated memory, it's probably doing something wrong.  :-)
  265. - *
  266. - * Note: kmalloc() and kfree() both call get_free_page() and free_page()
  267. - *    in sections of code where interrupts are turned off, to allow
  268. - *    kmalloc() and kfree() to be safely called from an interrupt routine.
  269. - *    (We will probably need this functionality when networking code,
  270. - *    particularily things like NFS, is added to Linux.)  However, this
  271. - *    presumes that get_free_page() and free_page() are interrupt-level
  272. - *    safe, which they may not be once paging is added.  If this is the
  273. - *    case, we will need to modify kmalloc() to keep a few unused pages
  274. - *    "pre-allocated" so that it can safely draw upon those pages if
  275. - *     it is called from an interrupt routine.
  276. - *
  277. - *     Another concern is that get_free_page() should not sleep; if it
  278. - *    does, the code is carefully ordered so as to avoid any race
  279. - *    conditions.  The catch is that if kmalloc() is called re-entrantly,
  280. - *    there is a chance that unecessary pages will be grabbed from the
  281. - *    system.  Except for the pages for the bucket descriptor page, the
  282. - *    extra pages will eventually get released back to the system, though,
  283. - *    so it isn't all that bad.
  284. - */
  285. -
  286. -/* I'm going to modify it to keep some free pages around.  Get free page
  287. -   can sleep, and tcp/ip needs to call kmalloc at interrupt time  (Or keep
  288. -   big buffers around for itself.)  I guess I'll have return from
  289. -   syscall fill up the free page descriptors. -RAB */
  290. -
  291. -/* since the advent of GFP_ATOMIC, I've changed the kmalloc code to
  292. -   use it and return NULL if it can't get a page. -RAB  */
  293. -/* (mostly just undid the previous changes -RAB) */
  294. -
  295. -/* I've added the priority argument to kmalloc so routines can
  296. -   sleep on memory if they want. - RAB */
  297. -
  298. -/* I've also got to make sure that kmalloc is reentrant now. */
  299. -
  300. -/* Debugging support: add file/line info, add beginning+end markers. -M.U- */
  301. -
  302. -#include <linux/kernel.h>
  303. -#include <linux/mm.h>
  304. -#include <linux/string.h>
  305. -#include <linux/malloc.h>
  306. -
  307. -#include <asm/system.h>
  308. -
  309. -struct bucket_desc {    /* 16 bytes */
  310. -    void            *page;
  311. -    struct bucket_desc    *next;
  312. -    void            *freeptr;
  313. -    unsigned short        refcnt;
  314. -    unsigned short        bucket_size;
  315. -};
  316. -
  317. -struct _bucket_dir {    /* 8 bytes */
  318. -    unsigned int        size;
  319. -    struct bucket_desc    *chain;
  320. -};
  321. -
  322. -#ifdef CONFIG_DEBUG_MALLOC
  323. -
  324. -struct hdr_start {
  325. -    const char *file;
  326. -    const char *ok_file;
  327. -    unsigned short line;
  328. -    unsigned short ok_line;
  329. -    unsigned short size;
  330. -    int magic;
  331. -};
  332. -struct hdr_end {
  333. -    int magic;
  334. -};
  335. -
  336. -#define DEB_MAGIC_FREE  0x13579BDF /* free block */
  337. -#define DEB_MAGIC_ALLOC 0x2468ACE0 /* allocated block */
  338. -#define DEB_MAGIC_USED  0x147AD036 /* allocated but bad */
  339. -#define DEB_MAGIC_FREED 0x258BE169 /* free but abused */
  340. -
  341. -#define DEB_MAGIC_END   0x369CF258 /* end marker */
  342. -
  343. -#endif
  344. -/*
  345. - * The following is the where we store a pointer to the first bucket
  346. - * descriptor for a given size.
  347. - *
  348. - * If it turns out that the Linux kernel allocates a lot of objects of a
  349. - * specific size, then we may want to add that specific size to this list,
  350. - * since that will allow the memory to be allocated more efficiently.
  351. - * However, since an entire page must be dedicated to each specific size
  352. - * on this list, some amount of temperance must be exercised here.
  353. - *
  354. - * Note that this list *must* be kept in order.
  355. - */
  356. -struct _bucket_dir bucket_dir[] = {
  357. -#ifndef CONFIG_DEBUG_MALLOC /* Debug headers have too much overhead */
  358. -    { 16,    (struct bucket_desc *) 0},
  359. -#endif
  360. -    { 32,    (struct bucket_desc *) 0},
  361. -    { 64,    (struct bucket_desc *) 0},
  362. -    { 128,    (struct bucket_desc *) 0},
  363. -    { 256,    (struct bucket_desc *) 0},
  364. -    { 512,    (struct bucket_desc *) 0},
  365. -    { 1024,    (struct bucket_desc *) 0},
  366. -    { 2048, (struct bucket_desc *) 0},
  367. -    { 4096, (struct bucket_desc *) 0},
  368. -    { 0,    (struct bucket_desc *) 0}};   /* End of list marker */
  369. -
  370. -/*
  371. - * This contains a linked list of free bucket descriptor blocks
  372. - */
  373. -static struct bucket_desc *free_bucket_desc = (struct bucket_desc *) 0;
  374. -
  375. -/*
  376. - * This routine initializes a bucket description page.
  377. - */
  378. -
  379. -/* It assumes it is called with interrupts on. and will
  380. -   return that way.  It also can sleep if priority != GFP_ATOMIC. */
  381. -static inline void init_bucket_desc(unsigned long page)
  382. -{
  383. -    struct bucket_desc *bdesc;
  384. -    int i;
  385. -
  386. -    bdesc = (struct bucket_desc *) page;
  387. -    for (i = PAGE_SIZE/sizeof(struct bucket_desc); --i > 0; bdesc++ )
  388. -        bdesc->next = bdesc+1;
  389. -    /*
  390. -     * This is done last, to avoid race conditions in case
  391. -     * get_free_page() sleeps and this routine gets called again....
  392. -     */
  393. -    cli();
  394. -    bdesc->next = free_bucket_desc;
  395. -    free_bucket_desc = (struct bucket_desc *) page;
  396. -}
  397. -
  398. -/*
  399. - * Re-organized some code to give cleaner assembly output for easier
  400. - * verification.. LBT
  401. - */
  402. -#ifdef CONFIG_DEBUG_MALLOC
  403. -void *
  404. -deb_kmalloc(const char *deb_file, unsigned short deb_line,
  405. -    unsigned int len, int priority)
  406. -#else
  407. -void *
  408. -kmalloc(unsigned int len, int priority)
  409. -#endif
  410. -{
  411. -    int i;
  412. -    unsigned long        flags;
  413. -    unsigned long        page;
  414. -    struct _bucket_dir    *bdir;
  415. -    struct bucket_desc    *bdesc;
  416. -    void            *retval;
  417. -
  418. -#ifdef CONFIG_DEBUG_MALLOC
  419. -    len += sizeof(struct hdr_start)+sizeof(struct hdr_end);
  420. -#endif
  421. -    /*
  422. -     * First we search the bucket_dir to find the right bucket change
  423. -     * for this request.
  424. -     */
  425. -
  426. -    /* The sizes are static so there is no reentry problem here. */
  427. -    bdir = bucket_dir;
  428. -    for (bdir = bucket_dir ; bdir->size < len ; bdir++) {
  429. -        if (!bdir->size)
  430. -            goto too_large;
  431. -    }
  432. -
  433. -    /*
  434. -     * Now we search for a bucket descriptor which has free space
  435. -     */
  436. -    save_flags(flags);
  437. -    cli();            /* Avoid race conditions */
  438. -    for (bdesc = bdir->chain; bdesc != NULL; bdesc = bdesc->next)
  439. -        if (bdesc->freeptr)
  440. -            goto found_bdesc;
  441. -    /*
  442. -     * If we didn't find a bucket with free space, then we'll
  443. -     * allocate a new one.
  444. -     */
  445. -    
  446. -    /*
  447. -     * Note that init_bucket_descriptor() does its
  448. -     * own cli() before returning, and guarantees that
  449. -     * there is a bucket desc in the page.
  450. -     */
  451. -    if (!free_bucket_desc) {
  452. -        restore_flags(flags);
  453. -        if(!(page=__get_free_page(priority)))
  454. -            return NULL;
  455. -        init_bucket_desc(page);
  456. -    }
  457. -    
  458. -    bdesc = free_bucket_desc;
  459. -    free_bucket_desc = bdesc->next;
  460. -    restore_flags(flags);
  461. -
  462. -    if(!(page=__get_free_page(priority))) {
  463. -    /*
  464. -     * Out of memory? Put the bucket descriptor back on the free list
  465. -     */
  466. -        cli();
  467. -        bdesc->next = free_bucket_desc;
  468. -        free_bucket_desc = bdesc;
  469. -        restore_flags(flags);
  470. -        return NULL;
  471. -    }
  472. -        
  473. -    bdesc->refcnt = 0;
  474. -    bdesc->bucket_size = bdir->size;
  475. -    bdesc->page = bdesc->freeptr = (void *) page;
  476. -    
  477. -    /* Set up the chain of free objects */
  478. -    for (i=PAGE_SIZE/bdir->size; i > 0 ; i--) {
  479. -#ifdef CONFIG_DEBUG_MALLOC
  480. -        struct hdr_start *hd;
  481. -        struct hdr_end *he;
  482. -        hd = (struct hdr_start *) page;
  483. -        he = (struct hdr_end *)(page+(bdir->size-sizeof(struct hdr_end)));
  484. -        hd->magic = DEB_MAGIC_FREE;
  485. -        hd->file = hd->ok_file = "(expand)"; 
  486. -        hd->line = hd->ok_line = 0;
  487. -        hd->size = bdir->size-sizeof(struct hdr_start)-sizeof(struct hdr_end);
  488. -        he->magic = DEB_MAGIC_END;
  489. -
  490. -        memset(hd+1,0xF8,hd->size);
  491. -
  492. -        *((void **) (hd+1)) = (i==1) ? NULL : (void *)(page + bdir->size);
  493. -#else
  494. -        *((void **) page) = (i==1) ? NULL : (void *)(page + bdir->size);
  495. -#endif
  496. -        page += bdir->size;
  497. -    }
  498. -    
  499. -    /* turn interrupts back off for putting the
  500. -       thing onto the chain. */
  501. -    cli();
  502. -    /* remember bdir is not changed. */
  503. -    bdesc->next = bdir->chain; /* OK, link it in! */
  504. -    bdir->chain = bdesc;
  505. -
  506. -found_bdesc:
  507. -    retval = (void *) bdesc->freeptr;
  508. -#ifdef CONFIG_DEBUG_MALLOC
  509. -    bdesc->freeptr = *((void **) (((char *)retval)+sizeof(struct hdr_start)));
  510. -#else
  511. -    bdesc->freeptr = *((void **) retval);
  512. -#endif
  513. -    bdesc->refcnt++;
  514. -    restore_flags(flags);    /* OK, we're safe again */
  515. -#ifdef CONFIG_DEBUG_MALLOC
  516. -    {
  517. -        struct hdr_start *hd;
  518. -        struct hdr_end *he;
  519. -
  520. -        hd = (struct hdr_start *) retval;
  521. -        retval = hd+1;
  522. -        len -= sizeof(struct hdr_start)+sizeof(struct hdr_end);
  523. -        if(hd->magic != DEB_MAGIC_FREE && hd->magic != DEB_MAGIC_FREED) {
  524. -            printk("DEB_MALLOC allocating %s block 0x%x (head 0x%x) from %s:%d, magic %x\n",
  525. -                (hd->magic == DEB_MAGIC_ALLOC) ? "nonfree" : "trashed", 
  526. -                retval,hd,deb_file,deb_line,hd->magic);
  527. -            return NULL;
  528. -        }
  529. -        if(len > hd->size || len > bdir->size-sizeof(struct hdr_start)-sizeof(struct hdr_end)) {
  530. -            printk("DEB_MALLOC got %x:%x-byte block, wanted %x, from %s:%d, last %s:%d\n",
  531. -                hd->size,bdir->size,len,hd->file,hd->line,deb_file,deb_line);
  532. -            return NULL;
  533. -        }
  534. -        {
  535. -            unsigned char *x = (unsigned char *) retval;
  536. -            unsigned short pos = 4;
  537. -            x += pos;
  538. -            while(pos < hd->size) {
  539. -                if(*x++ != 0xF8) {
  540. -                    printk("DEB_MALLOC used 0x%x:%x(%x) while free, from %s:%d\n",
  541. -                        retval,pos,hd->size,hd->file,hd->line);
  542. -                    return NULL;
  543. -                }
  544. -                pos++;
  545. -            }
  546. -        }
  547. -        he = (struct hdr_end *)(((char *)retval)+hd->size);
  548. -        if(he->magic != DEB_MAGIC_END) {
  549. -            printk("DEB_MALLOC overran 0x%x:%d while free, from %s:%d\n",retval,hd->size,hd->file,hd->line);
  550. -        }
  551. -        memset(retval, 0xf0, len);
  552. -        he = (struct hdr_end *)(((char *)retval)+len);
  553. -        hd->file = hd->ok_file = deb_file;
  554. -        hd->line = hd->ok_line = deb_line;
  555. -        hd->size = len;
  556. -        hd->magic = DEB_MAGIC_ALLOC;
  557. -        he->magic = DEB_MAGIC_END;
  558. -    }
  559. -#endif
  560. -    return retval;
  561. -
  562. -too_large:
  563. -       /* This should be changed for sizes > 1 page. */
  564. -    printk("kmalloc called with impossibly large argument (%d)\n", len);
  565. -    return NULL;
  566. -}
  567. -
  568. -#ifdef CONFIG_DEBUG_MALLOC
  569. -void deb_kcheck_s(const char *deb_file, unsigned short deb_line,
  570. -    void *obj, int size)
  571. -{
  572. -    struct hdr_start *hd;
  573. -    struct hdr_end *he;
  574. -
  575. -    if (!obj)
  576. -        return;
  577. -    hd = (struct hdr_start *) obj;
  578. -    hd--;
  579. -
  580. -    if(hd->magic != DEB_MAGIC_ALLOC) {
  581. -        if(hd->magic == DEB_MAGIC_FREE) {
  582. -            printk("DEB_MALLOC Using free block of 0x%x at %s:%d, by %s:%d, wasOK %s:%d\n",
  583. -                obj,deb_file,deb_line,hd->file,hd->line,hd->ok_file,hd->ok_line);
  584. -            /* For any other condition it is either superfluous or dangerous to print something. */
  585. -            hd->magic = DEB_MAGIC_FREED;
  586. -        }
  587. -        return;
  588. -    }
  589. -    if(hd->size != size) {
  590. -        if(size != 0) {
  591. -            printk("DEB_MALLOC size for 0x%x given as %d, stored %d, at %s:%d, wasOK %s:%d\n",
  592. -                obj,size,hd->size,deb_file,deb_line,hd->ok_file,hd->ok_line);
  593. -        }
  594. -        size = hd->size;
  595. -    }
  596. -    he = (struct hdr_end *)(((char *)obj)+size);
  597. -    if(he->magic != DEB_MAGIC_END) {
  598. -        printk("DEB_MALLOC overran block 0x%x:%d, at %s:%d, wasOK %s:%d\n",
  599. -            obj,hd->size,deb_file,deb_line,hd->ok_file,hd->ok_line);
  600. -        hd->magic = DEB_MAGIC_USED;
  601. -        return;
  602. -    }
  603. -    hd->ok_file = deb_file;
  604. -    hd->ok_line = deb_line;
  605. -}
  606. -#endif
  607. -
  608. -/*
  609. - * Here is the kfree routine.  If you know the size of the object that you
  610. - * are freeing, then kfree_s() will use that information to speed up the
  611. - * search for the bucket descriptor.
  612. - *
  613. - * We will #define a macro so that "kfree(x)" is becomes "kfree_s(x, 0)"
  614. - */
  615. -#ifdef CONFIG_DEBUG_MALLOC
  616. -void deb_kfree_s(const char *deb_file, unsigned short deb_line,
  617. -    void *obj, int size)
  618. -#else
  619. -void kfree_s(void *obj, int size)
  620. -#endif
  621. -{
  622. -    unsigned long        flags;
  623. -    void            *page;
  624. -    struct _bucket_dir    *bdir;
  625. -    struct bucket_desc    *bdesc, *prev;
  626. -
  627. -    if (!obj)
  628. -        return;
  629. -#ifdef CONFIG_DEBUG_MALLOC
  630. -    {
  631. -        struct hdr_start *hd;
  632. -        struct hdr_end *he;
  633. -        hd = (struct hdr_start *) obj;
  634. -        hd--;
  635. -
  636. -        if(hd->magic == DEB_MAGIC_FREE) {
  637. -            printk("DEB_MALLOC dup free of 0x%x at %s:%d by %s:%d, wasOK %s:%d\n",
  638. -                    obj,deb_file,deb_line,hd->file,hd->line,hd->ok_file,hd->ok_line);
  639. -            return;
  640. -        }
  641. -        if(hd->size != size) {
  642. -            if(size != 0) {
  643. -                if(hd->magic != DEB_MAGIC_USED)
  644. -                    printk("DEB_MALLOC size for 0x%x given as %d, stored %d, at %s:%d, wasOK %s:%d\n",
  645. -                        obj,size,hd->size,deb_file,deb_line,hd->ok_file,hd->ok_line);
  646. -            }
  647. -            size = hd->size;
  648. -        }
  649. -        he = (struct hdr_end *)(((char *)obj)+size);
  650. -        if(he->magic != DEB_MAGIC_END) {
  651. -            if(hd->magic != DEB_MAGIC_USED)
  652. -                printk("DEB_MALLOC overran block 0x%x:%d, at %s:%d, from %s:%d, wasOK %s:%d\n",
  653. -                    obj,hd->size,deb_file,deb_line,hd->file,hd->line,hd->ok_file,hd->ok_line);
  654. -        }
  655. -        size += sizeof(struct hdr_start)+sizeof(struct hdr_end);
  656. -    }
  657. -#endif
  658. -    save_flags(flags);
  659. -    /* Calculate what page this object lives in */
  660. -    page = (void *)  ((unsigned long) obj & PAGE_MASK);
  661. -
  662. -    /* Now search the buckets looking for that page */
  663. -    for (bdir = bucket_dir; bdir->size; bdir++) {
  664. -        prev = 0;
  665. -        /* If size is zero then this conditional is always true */
  666. -        if (bdir->size >= size) {
  667. -        /* We have to turn off interrupts here because
  668. -           we are descending the chain.  If something
  669. -           changes it in the middle we could suddenly
  670. -           find ourselves descending the free list.
  671. -           I think this would only cause a memory
  672. -           leak, but better safe than sorry. */
  673. -        cli(); /* To avoid race conditions */
  674. -        for (bdesc = bdir->chain; bdesc; bdesc = bdesc->next) {
  675. -            if (bdesc->page == page)
  676. -            goto found;
  677. -            prev = bdesc;
  678. -        }
  679. -        }
  680. -    }
  681. -
  682. -    restore_flags(flags);
  683. -    printk("Bad address passed to kernel kfree_s(%p, %d)\n",obj, size);
  684. -#ifdef CONFIG_DEBUG_MALLOC
  685. -    printk("Offending code: %s:%d\n",deb_file,deb_line);
  686. -#else
  687. -    printk("Offending eip: %08x\n",((unsigned long *) &obj)[-1]);
  688. -#endif
  689. -    return;
  690. -
  691. -found:
  692. -    /* interrupts are off here. */
  693. -#ifdef CONFIG_DEBUG_MALLOC
  694. -
  695. -    {
  696. -        struct hdr_start *hd;
  697. -        struct hdr_end *he;
  698. -        hd = (struct hdr_start *) obj;
  699. -        hd--;
  700. -        
  701. -        hd->file = deb_file;
  702. -        hd->line = deb_line;
  703. -        hd->magic = DEB_MAGIC_FREE;
  704. -        hd->size = bdir->size-sizeof(struct hdr_start)-sizeof(struct hdr_end);
  705. -        he = (struct hdr_end *)(((char *)obj)+hd->size);
  706. -        memset(obj, 0xf8, hd->size);
  707. -        he->magic = DEB_MAGIC_END;
  708. -        *((void **)obj) = bdesc->freeptr;
  709. -        obj = hd;
  710. -    }
  711. -#else
  712. -    *((void **)obj) = bdesc->freeptr;
  713. -#endif
  714. -
  715. -    bdesc->freeptr = obj;
  716. -    bdesc->refcnt--;
  717. -    if (bdesc->refcnt == 0) {
  718. -        /*
  719. -         * We need to make sure that prev is still accurate.  It
  720. -         * may not be, if someone rudely interrupted us....
  721. -         */
  722. -        if ((prev && (prev->next != bdesc)) ||
  723. -            (!prev && (bdir->chain != bdesc)))
  724. -            for (prev = bdir->chain; prev; prev = prev->next)
  725. -                if (prev->next == bdesc)
  726. -                    break;
  727. -        if (prev)
  728. -            prev->next = bdesc->next;
  729. -        else {
  730. -            if (bdir->chain != bdesc)
  731. -                panic("kmalloc bucket chains corrupted");
  732. -            bdir->chain = bdesc->next;
  733. -        }
  734. -        bdesc->next = free_bucket_desc;
  735. -        free_bucket_desc = bdesc;
  736. -        free_page((unsigned long) bdesc->page);
  737. -    }
  738. -    restore_flags(flags);
  739. -    return;
  740. -}
  741. -
  742. -#ifdef CONFIG_DEBUG_MALLOC
  743. -int get_malloc(char *buffer)
  744. -{
  745. -    int len = 0;
  746. -    int i;
  747. -    unsigned long        flags;
  748. -    void            *page;
  749. -    struct _bucket_dir    *bdir;
  750. -    struct bucket_desc    *bdesc;
  751. -
  752. -    save_flags(flags);
  753. -    cli(); /* To avoid race conditions */
  754. -    for (bdir = bucket_dir; bdir->size; bdir++) {
  755. -        for (bdesc = bdir->chain; bdesc; bdesc = bdesc->next) {
  756. -            page = bdesc->page;
  757. -            for (i=PAGE_SIZE/bdir->size; i > 0 ; i--) {
  758. -                struct hdr_start *hd;
  759. -                hd = (struct hdr_start *)page;
  760. -                if(hd->magic == DEB_MAGIC_ALLOC) {
  761. -                    if(len > PAGE_SIZE-80) {
  762. -                        restore_flags(flags);
  763. -                        len += sprintf(buffer+len,"...\n");
  764. -                        return len;
  765. -                    }
  766. -                    len += sprintf(buffer+len,"%08x:%03x %s:%d %s:%d\n",
  767. -                        (long)(page+sizeof(struct hdr_start)),hd->size,hd->file,hd->line,hd->ok_file,hd->ok_line);
  768. -                }
  769. -                page += bdir->size;
  770. -            }
  771. -        }
  772. -    }
  773. -
  774. -    restore_flags(flags);
  775. -    return len;
  776. -}
  777. -#endif
  778. diff -u --recursive --new-file v1.0.2/linux/net/inet/dev.c linux/net/inet/dev.c
  779. --- v1.0.2/linux/net/inet/dev.c    Fri Mar 18 10:21:34 1994
  780. +++ linux/net/inet/dev.c    Mon Mar 21 16:13:14 1994
  781. @@ -745,6 +745,9 @@
  782.    memcpy_fromfs(&ifc, arg, sizeof(struct ifconf));
  783.    len = ifc.ifc_len;
  784.    pos = ifc.ifc_buf;
  785. +  err=verify_area(VERIFY_WRITE, pos, len);
  786. +  if(err)
  787. +    return err;
  788.  
  789.    /* Loop over the interfaces, and write an info block for each. */
  790.    for (dev = dev_base; dev != NULL; dev = dev->next) {
  791. diff -u --recursive --new-file v1.0.2/linux/net/inet/ip.c linux/net/inet/ip.c
  792. --- v1.0.2/linux/net/inet/ip.c    Fri Mar 18 10:21:34 1994
  793. +++ linux/net/inet/ip.c    Mon Mar 21 14:50:37 1994
  794. @@ -1000,7 +1000,9 @@
  795.         DPRINTF((DBG_IP, "    DEV=%s, MTU=%d, LEN=%d SRC=%s",
  796.           dev->name, dev->mtu, left, in_ntoa(iph->saddr)));
  797.         DPRINTF((DBG_IP, " DST=%s\n", in_ntoa(iph->daddr)));
  798. +
  799. +    if (mtu < 8)
  800. +        return;
  801.         /* Check for any "DF" flag. */
  802.         if (ntohs(iph->frag_off) & IP_DF) 
  803.         {
  804. diff -u --recursive --new-file v1.0.2/linux/net/inet/sock.c linux/net/inet/sock.c
  805. --- v1.0.2/linux/net/inet/sock.c    Mon Mar 21 16:36:23 1994
  806. +++ linux/net/inet/sock.c    Mon Mar 21 14:56:03 1994
  807. @@ -428,7 +428,7 @@
  808.     * structure, otherwise we need to keep it around until
  809.     * everything is gone.
  810.     */
  811. -      if (sk->rmem_alloc == 0 && sk->wmem_alloc == 0) 
  812. +      if (sk->dead && sk->rmem_alloc == 0 && sk->wmem_alloc == 0) 
  813.        {
  814.          kfree_s((void *)sk,sizeof(*sk));
  815.        } 
  816. @@ -1197,7 +1197,7 @@
  817.    if (newsock->data) {
  818.        struct sock * sk = (struct sock *) newsock->data;
  819.        newsock->data = NULL;
  820. -      kfree_s(sk, sizeof(struct sock));
  821. +      destroy_sock(sk);
  822.    }
  823.  
  824.    if (sk1->prot->accept == NULL) return(-EOPNOTSUPP);
  825.