[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] gsync: Avoid NULL pointer dereference
From: |
Brent Baccala |
Subject: |
[PATCH] gsync: Avoid NULL pointer dereference |
Date: |
Wed, 9 Nov 2016 20:51:05 -1000 |
Hi -
Here's another gsync patch, to avoid kernel panics if the task port
passed in isn't actually a task port, in which case TASK_NULL is
passed as the task argument.
agape
brent
-- >8 --
Subject: [PATCH] gsync: Avoid NULL pointer dereference
* kern/gsync.c (gsync_wait, gsync_wake, gsync_requeue):
Return immediately if task argument is TASK_NULL
---
kern/gsync.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/kern/gsync.c b/kern/gsync.c
index adb6e6e..e70e119 100644
--- a/kern/gsync.c
+++ b/kern/gsync.c
@@ -185,12 +185,13 @@ gsync_find_key (const struct list *entries,
kern_return_t gsync_wait (task_t task, vm_offset_t addr,
unsigned int lo, unsigned int hi, natural_t msec, int flags)
{
- struct gsync_waiter w;
- int bucket = gsync_fill_key (task, addr, flags, &w.key);
-
if (unlikely (task != current_task()))
/* Not implemented yet. */
return (KERN_FAILURE);
+
+ struct gsync_waiter w;
+ int bucket = gsync_fill_key (task, addr, flags, &w.key);
+
if (unlikely (bucket < 0))
return (KERN_INVALID_ADDRESS);
@@ -280,12 +281,13 @@ dequeue_waiter (struct list *nodep)
kern_return_t gsync_wake (task_t task,
vm_offset_t addr, unsigned int val, int flags)
{
- struct gsync_key key;
- int bucket = gsync_fill_key (task, addr, flags, &key);
-
if (unlikely (task != current_task()))
/* Not implemented yet. */
return (KERN_FAILURE);
+
+ struct gsync_key key;
+ int bucket = gsync_fill_key (task, addr, flags, &key);
+
if (unlikely (bucket < 0))
return (KERN_INVALID_ADDRESS);
@@ -330,13 +332,14 @@ kern_return_t gsync_wake (task_t task,
kern_return_t gsync_requeue (task_t task, vm_offset_t src,
vm_offset_t dst, boolean_t wake_one, int flags)
{
+ if (unlikely (task != current_task()))
+ /* Not implemented yet. */
+ return (KERN_FAILURE);
+
struct gsync_key src_k, dst_k;
int src_bkt = gsync_fill_key (task, src, flags, &src_k);
int dst_bkt = gsync_fill_key (task, dst, flags, &dst_k);
- if (unlikely (task != current_task()))
- /* Not implemented yet. */
- return (KERN_FAILURE);
if ((src_bkt | dst_bkt) < 0)
return (KERN_INVALID_ADDRESS);
--
2.7.4
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] gsync: Avoid NULL pointer dereference,
Brent Baccala <=