Commit 5b2785a1 authored by Chris Wedgwood's avatar Chris Wedgwood Committed by Linus Torvalds

[PATCH] stat nlink resolution fix

Some filesystems can get overflows when their link-count exceeds
65534.  This patch increases the kernels internal resolution for this
and also has a check for the old-system call paths to return and error
(-EOVERFLOW) as required (as suggested by Al Viro).
Signed-off-by: default avatarChris Wedgwood <cw@f00f.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2f3600ce
......@@ -131,6 +131,8 @@ static int cp_old_stat(struct kstat *stat, struct __old_kernel_stat __user * sta
tmp.st_ino = stat->ino;
tmp.st_mode = stat->mode;
tmp.st_nlink = stat->nlink;
if (tmp.st_nlink != stat->nlink)
return -EOVERFLOW;
SET_UID(tmp.st_uid, stat->uid);
SET_GID(tmp.st_gid, stat->gid);
tmp.st_rdev = old_encode_dev(stat->rdev);
......@@ -199,6 +201,8 @@ static int cp_new_stat(struct kstat *stat, struct stat __user *statbuf)
tmp.st_ino = stat->ino;
tmp.st_mode = stat->mode;
tmp.st_nlink = stat->nlink;
if (tmp.st_nlink != stat->nlink)
return -EOVERFLOW;
SET_UID(tmp.st_uid, stat->uid);
SET_GID(tmp.st_gid, stat->gid);
#if BITS_PER_LONG == 32
......
......@@ -60,7 +60,7 @@ struct kstat {
unsigned long ino;
dev_t dev;
umode_t mode;
nlink_t nlink;
unsigned int nlink;
uid_t uid;
gid_t gid;
dev_t rdev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment