Commit 234041df authored by Kees Cook's avatar Kees Cook

sgi-xp: Use designated initializers

Prepare to mark sensitive kernel structures for randomization by making
sure they're using designated initializers. In this case, no initializers
are needed (they can be NULL initialized and callers adjusted to check
for NULL, which is more efficient than an indirect call).

Cc: Robin Holt <robinmholt@gmail.com>
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Reviewed-by: default avatarChristoph Hellwig <hch@infradead.org>
parent 7585d12f
...@@ -309,6 +309,9 @@ static inline enum xp_retval ...@@ -309,6 +309,9 @@ static inline enum xp_retval
xpc_send(short partid, int ch_number, u32 flags, void *payload, xpc_send(short partid, int ch_number, u32 flags, void *payload,
u16 payload_size) u16 payload_size)
{ {
if (!xpc_interface.send)
return xpNotLoaded;
return xpc_interface.send(partid, ch_number, flags, payload, return xpc_interface.send(partid, ch_number, flags, payload,
payload_size); payload_size);
} }
...@@ -317,6 +320,9 @@ static inline enum xp_retval ...@@ -317,6 +320,9 @@ static inline enum xp_retval
xpc_send_notify(short partid, int ch_number, u32 flags, void *payload, xpc_send_notify(short partid, int ch_number, u32 flags, void *payload,
u16 payload_size, xpc_notify_func func, void *key) u16 payload_size, xpc_notify_func func, void *key)
{ {
if (!xpc_interface.send_notify)
return xpNotLoaded;
return xpc_interface.send_notify(partid, ch_number, flags, payload, return xpc_interface.send_notify(partid, ch_number, flags, payload,
payload_size, func, key); payload_size, func, key);
} }
...@@ -324,12 +330,16 @@ xpc_send_notify(short partid, int ch_number, u32 flags, void *payload, ...@@ -324,12 +330,16 @@ xpc_send_notify(short partid, int ch_number, u32 flags, void *payload,
static inline void static inline void
xpc_received(short partid, int ch_number, void *payload) xpc_received(short partid, int ch_number, void *payload)
{ {
return xpc_interface.received(partid, ch_number, payload); if (xpc_interface.received)
xpc_interface.received(partid, ch_number, payload);
} }
static inline enum xp_retval static inline enum xp_retval
xpc_partid_to_nasids(short partid, void *nasids) xpc_partid_to_nasids(short partid, void *nasids)
{ {
if (!xpc_interface.partid_to_nasids)
return xpNotLoaded;
return xpc_interface.partid_to_nasids(partid, nasids); return xpc_interface.partid_to_nasids(partid, nasids);
} }
......
...@@ -69,23 +69,9 @@ struct xpc_registration xpc_registrations[XPC_MAX_NCHANNELS]; ...@@ -69,23 +69,9 @@ struct xpc_registration xpc_registrations[XPC_MAX_NCHANNELS];
EXPORT_SYMBOL_GPL(xpc_registrations); EXPORT_SYMBOL_GPL(xpc_registrations);
/* /*
* Initialize the XPC interface to indicate that XPC isn't loaded. * Initialize the XPC interface to NULL to indicate that XPC isn't loaded.
*/ */
static enum xp_retval struct xpc_interface xpc_interface = { };
xpc_notloaded(void)
{
return xpNotLoaded;
}
struct xpc_interface xpc_interface = {
(void (*)(int))xpc_notloaded,
(void (*)(int))xpc_notloaded,
(enum xp_retval(*)(short, int, u32, void *, u16))xpc_notloaded,
(enum xp_retval(*)(short, int, u32, void *, u16, xpc_notify_func,
void *))xpc_notloaded,
(void (*)(short, int, void *))xpc_notloaded,
(enum xp_retval(*)(short, void *))xpc_notloaded
};
EXPORT_SYMBOL_GPL(xpc_interface); EXPORT_SYMBOL_GPL(xpc_interface);
/* /*
...@@ -115,17 +101,7 @@ EXPORT_SYMBOL_GPL(xpc_set_interface); ...@@ -115,17 +101,7 @@ EXPORT_SYMBOL_GPL(xpc_set_interface);
void void
xpc_clear_interface(void) xpc_clear_interface(void)
{ {
xpc_interface.connect = (void (*)(int))xpc_notloaded; memset(&xpc_interface, 0, sizeof(xpc_interface));
xpc_interface.disconnect = (void (*)(int))xpc_notloaded;
xpc_interface.send = (enum xp_retval(*)(short, int, u32, void *, u16))
xpc_notloaded;
xpc_interface.send_notify = (enum xp_retval(*)(short, int, u32, void *,
u16, xpc_notify_func,
void *))xpc_notloaded;
xpc_interface.received = (void (*)(short, int, void *))
xpc_notloaded;
xpc_interface.partid_to_nasids = (enum xp_retval(*)(short, void *))
xpc_notloaded;
} }
EXPORT_SYMBOL_GPL(xpc_clear_interface); EXPORT_SYMBOL_GPL(xpc_clear_interface);
...@@ -188,7 +164,8 @@ xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size, ...@@ -188,7 +164,8 @@ xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size,
mutex_unlock(&registration->mutex); mutex_unlock(&registration->mutex);
xpc_interface.connect(ch_number); if (xpc_interface.connect)
xpc_interface.connect(ch_number);
return xpSuccess; return xpSuccess;
} }
...@@ -237,7 +214,8 @@ xpc_disconnect(int ch_number) ...@@ -237,7 +214,8 @@ xpc_disconnect(int ch_number)
registration->assigned_limit = 0; registration->assigned_limit = 0;
registration->idle_limit = 0; registration->idle_limit = 0;
xpc_interface.disconnect(ch_number); if (xpc_interface.disconnect)
xpc_interface.disconnect(ch_number);
mutex_unlock(&registration->mutex); mutex_unlock(&registration->mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment