Skip to content

Commit 76bdaa1

Browse files
Dan Carpentergregkh
authored andcommitted
staging: lustre: libcfs: double copy bug
The problem is that we copy hdr.ioc_len, we verify it, then we copy it again without checking to see if it has changed in between the two copies. This could result in an information leak. Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent dcdf43a commit 76bdaa1

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

drivers/staging/lustre/lnet/libcfs/linux/linux-module.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
122122
const struct libcfs_ioctl_hdr __user *uhdr)
123123
{
124124
struct libcfs_ioctl_hdr hdr;
125-
int err = 0;
125+
int err;
126126

127127
if (copy_from_user(&hdr, uhdr, sizeof(hdr)))
128128
return -EFAULT;
@@ -150,9 +150,20 @@ int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
150150
return -ENOMEM;
151151

152152
if (copy_from_user(*hdr_pp, uhdr, hdr.ioc_len)) {
153-
LIBCFS_FREE(*hdr_pp, hdr.ioc_len);
154153
err = -EFAULT;
154+
goto free;
155155
}
156+
157+
if ((*hdr_pp)->ioc_version != hdr.ioc_version ||
158+
(*hdr_pp)->ioc_len != hdr.ioc_len) {
159+
err = -EINVAL;
160+
goto free;
161+
}
162+
163+
return 0;
164+
165+
free:
166+
LIBCFS_FREE(*hdr_pp, hdr.ioc_len);
156167
return err;
157168
}
158169

0 commit comments

Comments
 (0)