diff options
author | mckusick <mckusick@FreeBSD.org> | 2003-02-14 21:31:58 +0000 |
---|---|---|
committer | mckusick <mckusick@FreeBSD.org> | 2003-02-14 21:31:58 +0000 |
commit | d9ebbec084d4cd0e0a21fb74427a996f22d248d9 (patch) | |
tree | 63dc48c454d25fb06dee4802e18680e0ebce6eb9 /sys/ufs | |
parent | e6a38537d0f62bfb7a171d986541d180b8a9071d (diff) | |
download | FreeBSD-src-d9ebbec084d4cd0e0a21fb74427a996f22d248d9.zip FreeBSD-src-d9ebbec084d4cd0e0a21fb74427a996f22d248d9.tar.gz |
Replace use of random() with arc4random() to provide less guessable
values for the initial inode generation numbers in newfs and for
newly allocated inode generation numbers in the kernel.
Submitted by: Theo de Raadt <deraadt@cvs.openbsd.org>
Sponsored by: DARPA & NAI Labs.
Diffstat (limited to 'sys/ufs')
-rw-r--r-- | sys/ufs/ffs/ffs_alloc.c | 4 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 622ca59b..745050c 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -879,7 +879,7 @@ ffs_valloc(pvp, mode, cred, vpp) * Set up a new generation number for this inode. */ if (ip->i_gen == 0 || ++ip->i_gen == 0) - ip->i_gen = random() / 2 + 1; + ip->i_gen = arc4random() / 2 + 1; DIP(ip, i_gen) = ip->i_gen; if (fs->fs_magic == FS_UFS2_MAGIC) { vfs_timestamp(&ts); @@ -1630,7 +1630,7 @@ gotit: bzero(ibp->b_data, (int)fs->fs_bsize); dp2 = (struct ufs2_dinode *)(ibp->b_data); for (i = 0; i < INOPB(fs); i++) { - dp2->di_gen = random() / 2 + 1; + dp2->di_gen = arc4random() / 2 + 1; dp2++; } bawrite(ibp); diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 203ad03..de01977 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1345,7 +1345,7 @@ ffs_vget(mp, ino, flags, vpp) * already have one. This should only happen on old filesystems. */ if (ip->i_gen == 0) { - ip->i_gen = random() / 2 + 1; + ip->i_gen = arc4random() / 2 + 1; if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0) { ip->i_flag |= IN_MODIFIED; DIP(ip, i_gen) = ip->i_gen; |