userspace: move _k_object_validate() definition
This API only gets used inside system call handlers and a specific test case dedicated to it. Move definition to the private kernel header along with the rest of the defines for system call handlers. A non-userspace inline variant of this function is unnecessary and has been deleted. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
2b6abf6f89
commit
cee72411e4
3 changed files with 23 additions and 31 deletions
|
@ -178,28 +178,6 @@ struct _k_object {
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
#define K_OBJ_FLAG_INITIALIZED BIT(0)
|
#define K_OBJ_FLAG_INITIALIZED BIT(0)
|
||||||
/**
|
|
||||||
* Ensure a system object is a valid object of the expected type
|
|
||||||
*
|
|
||||||
* Searches for the object and ensures that it is indeed an object
|
|
||||||
* of the expected type, that the caller has the right permissions on it,
|
|
||||||
* and that the object has been initialized.
|
|
||||||
*
|
|
||||||
* This function is intended to be called on the kernel-side system
|
|
||||||
* call handlers to validate kernel object pointers passed in from
|
|
||||||
* userspace.
|
|
||||||
*
|
|
||||||
* @param obj Address of the kernel object
|
|
||||||
* @param otype Expected type of the kernel object
|
|
||||||
* @param init If true, this is for an init function and we will not error
|
|
||||||
* out if the object is not initialized
|
|
||||||
* @return 0 If the object is valid
|
|
||||||
* -EBADF if not a valid object of the specified type
|
|
||||||
* -EPERM If the caller does not have permissions
|
|
||||||
* -EINVAL Object is not initialized
|
|
||||||
*/
|
|
||||||
int _k_object_validate(void *obj, enum k_objects otype, int init);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lookup a kernel object and init its metadata if it exists
|
* Lookup a kernel object and init its metadata if it exists
|
||||||
|
@ -212,15 +190,6 @@ int _k_object_validate(void *obj, enum k_objects otype, int init);
|
||||||
*/
|
*/
|
||||||
void _k_object_init(void *obj);
|
void _k_object_init(void *obj);
|
||||||
#else
|
#else
|
||||||
static inline int _k_object_validate(void *obj, enum k_objects otype, int init)
|
|
||||||
{
|
|
||||||
ARG_UNUSED(obj);
|
|
||||||
ARG_UNUSED(otype);
|
|
||||||
ARG_UNUSED(init);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void _k_object_init(void *obj)
|
static inline void _k_object_init(void *obj)
|
||||||
{
|
{
|
||||||
ARG_UNUSED(obj);
|
ARG_UNUSED(obj);
|
||||||
|
|
|
@ -17,6 +17,28 @@
|
||||||
|
|
||||||
extern const _k_syscall_handler_t _k_syscall_table[K_SYSCALL_LIMIT];
|
extern const _k_syscall_handler_t _k_syscall_table[K_SYSCALL_LIMIT];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure a system object is a valid object of the expected type
|
||||||
|
*
|
||||||
|
* Searches for the object and ensures that it is indeed an object
|
||||||
|
* of the expected type, that the caller has the right permissions on it,
|
||||||
|
* and that the object has been initialized.
|
||||||
|
*
|
||||||
|
* This function is intended to be called on the kernel-side system
|
||||||
|
* call handlers to validate kernel object pointers passed in from
|
||||||
|
* userspace.
|
||||||
|
*
|
||||||
|
* @param obj Address of the kernel object
|
||||||
|
* @param otype Expected type of the kernel object
|
||||||
|
* @param init If true, this is for an init function and we will not error
|
||||||
|
* out if the object is not initialized
|
||||||
|
* @return 0 If the object is valid
|
||||||
|
* -EBADF if not a valid object of the specified type
|
||||||
|
* -EPERM If the caller does not have permissions
|
||||||
|
* -EINVAL Object is not initialized
|
||||||
|
*/
|
||||||
|
int _k_object_validate(void *obj, enum k_objects otype, int init);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Runtime expression check for system call arguments
|
* @brief Runtime expression check for system call arguments
|
||||||
*
|
*
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <tc_util.h>
|
#include <tc_util.h>
|
||||||
#include <kernel_structs.h>
|
#include <kernel_structs.h>
|
||||||
#include <irq_offload.h>
|
#include <irq_offload.h>
|
||||||
|
#include <syscall_handler.h>
|
||||||
|
|
||||||
#define SEM_ARRAY_SIZE 16
|
#define SEM_ARRAY_SIZE 16
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue