home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / linux / 21232 < prev    next >
Encoding:
Text File  |  1992-12-21  |  2.1 KB  |  66 lines

  1. Newsgroups: comp.os.linux
  2. Path: sparky!uunet!spool.mu.edu!sgiblab!munnari.oz.au!metro!extro.ucc.su.OZ.AU!shanea
  3. From: shanea@extro.ucc.su.OZ.AU (Shane Alderton)
  4. Subject: patch for chmod "bug"
  5. Message-ID: <shanea.724916757@extro.ucc.su.OZ.AU>
  6. Summary: fix for security problem with chmod
  7. Keywords: patch chmod bug security
  8. Sender: news@ucc.su.OZ.AU
  9. Nntp-Posting-Host: extro.ucc.su.oz.au
  10. Organization: Sydney University Computing Service, Sydney, NSW, Australia
  11. Date: Mon, 21 Dec 1992 05:45:57 GMT
  12. Lines: 52
  13.  
  14.  
  15. Linux' chmod currently allows you to set the sgid bit on a file
  16. if you own that file, regardless of whether the file's group is
  17. one of your primary or secondary groups.  This can cause security
  18. problems - for example with mail, where you may own your mail
  19. file but it is group owned by mail.
  20.  
  21. The following patch can be applied relative to 098p6 (and probably
  22. 099 - I haven't actually attempted it, but it looked similar enough)
  23. to prevent this occuring.
  24.  
  25. Please let me know if there is a problem with the way I have done
  26. this - I make no guarantee that it will work for you, but it certainly
  27. solved my problem.
  28.  
  29. Regards,
  30. Shane Alderton
  31. shanea@extro.ucc.su.oz.au
  32.  
  33. ----- snip snip --------------------------------------------------------
  34. --- newlinux/linux/fs/open.c    Sun Nov 29 22:59:47 1992
  35. +++ linux/fs/open.c    Mon Dec 21 15:16:15 1992
  36. @@ -234,4 +234,5 @@
  37.      struct inode * inode;
  38.      struct file * file;
  39. +    int        mask = 07777;
  40.  
  41.      if (fd >= NR_OPEN || !(file = current->filp[fd]))
  42. @@ -243,5 +244,7 @@
  43.      if (IS_RDONLY(inode))
  44.          return -EROFS;
  45. -    inode->i_mode = (mode & 07777) | (inode->i_mode & ~07777);
  46. +    if (!in_group_p(inode->i_gid) && !suser())
  47. +        mask = 05777;
  48. +    inode->i_mode = (mode & mask) | (inode->i_mode & ~mask);
  49.      inode->i_dirt = 1;
  50.      return notify_change(inode);
  51. @@ -252,4 +255,5 @@
  52.      struct inode * inode;
  53.      int error;
  54. +    int        mask = 07777;
  55.  
  56.      error = namei(filename,&inode);
  57. @@ -264,5 +268,7 @@
  58.          return -EROFS;
  59.      }
  60. -    inode->i_mode = (mode & 07777) | (inode->i_mode & ~07777);
  61. +    if (!in_group_p(inode->i_gid) && !suser())
  62. +        mask = 05777;
  63. +    inode->i_mode = (mode & mask) | (inode->i_mode & ~mask);
  64.      inode->i_dirt = 1;
  65.      error = notify_change(inode);
  66.