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

Limit KeyctlString() to DESCRIBE / GET_SECURITY #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Aug 19, 2022

  1. Limit KeyctlString() to DESCRIBE / GET_SECURITY

    KeyctlString() treats the query data buffer filled by the keyctl(2) syscall as C-Style string with a trailing NULL byte.
    
    This is only true for two cmds - KEYCTL_DESCRIBE and KEYCTL_GET_SECURITY.
    
    Both are guaranteed to return at least an empty (C) string (i.e. a one-byte-sized buffer containing only a NULL byte) if the requested attribute is not set at all.
    
    Other cmds that can be passed to the system call - KEYCTL_READ most prominently - return explicitly-sized binary data; NULL bytes have no special meaning for these queries and are _part_ of the returned data, irrespective of where in the buffer they occur. Returning nothing (zero-length) can also be permitted; example of this is a KEYCTL_READ on an empty keyring.
    
    If KeyctlString() is called with any of the keyctl(2) query commands other than the two that are guaranteed to return C-style strings, it will either:
    * panic (attempting to strip trailing null bytes from zero-sized buffers), or
    * truncate the returned data in error (for KEYCTL_READ of a key payload).
    
    Therefore, restrict the use.
    fhofmannCF committed Aug 19, 2022
    Configuration menu
    Copy the full SHA
    446fe46 View commit details
    Browse the repository at this point in the history