Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardcoded buffer size in sgx_ioctl() #65

Open
mkow opened this issue Jun 21, 2018 · 0 comments
Open

Hardcoded buffer size in sgx_ioctl() #65

mkow opened this issue Jun 21, 2018 · 0 comments

Comments

@mkow
Copy link

mkow commented Jun 21, 2018

When reading the sgx_ioctl function code I noticed that the size of the receiving buffer is hardcoded:

char data[256];

And the input data is copied to the buffer in the following way:
if (copy_from_user(data, (void __user *)arg, _IOC_SIZE(cmd)))

_IOC_SIZE can return up to _IOC_SIZEMASK bytes (== 8191) and is user-controlled (but currently the switch right before will filter it).

This seems like a ticking bomb to me, it's very easy to accidentally turn it into a buffer overflow when changing this code (e.g. by adding more fields to the input structs or changing the switch statement). Such an overflow would be detected in newest kernels by the hardened copy_from_user, but I think it's still better to change the code and stay on the safe side.

If you think it's worth fixing I can create a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant