• Nathan Lynch's avatar
    powerpc/rtas: Move token validation from block_rtas_call() to sys_rtas() · e7582edb
    Nathan Lynch authored
    The rtas system call handler sys_rtas() delegates certain input
    validation steps to a helper function: block_rtas_call(). One of these
    steps ensures that the user-supplied token value maps to a known RTAS
    function. This is done by performing a "reverse" token-to-function
    lookup via rtas_token_to_function_untrusted() to obtain an
    rtas_function object.
    
    In changes to come, sys_rtas() itself will need the function
    descriptor for the token. To prepare:
    
    * Move the lookup and validation up into sys_rtas() and pass the
      resulting rtas_function pointer to block_rtas_call(), which is
      otherwise unconcerned with the token value.
    
    * Change block_rtas_call() to report the RTAS function name instead of
      the token value on validation failures, since it can now rely on
      having a valid function descriptor.
    
    One behavior change is that sys_rtas() now silently errors out when
    passed a bad token, before calling block_rtas_call(). So we will no
    longer log "RTAS call blocked - exploit attempt?" on invalid
    tokens. This is consistent with how sys_rtas() currently handles other
    "metadata" (nargs and nret), while block_rtas_call() is primarily
    concerned with validating the arguments to be passed to specific RTAS
    functions.
    Signed-off-by: default avatarNathan Lynch <nathanl@linux.ibm.com>
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    Link: https://msgid.link/20231212-papr-sys_rtas-vs-lockdown-v6-5-e9eafd0c8c6c@linux.ibm.com
    e7582edb
rtas.c 54.8 KB