Anonymous (NULL-named) objects from user-space
PATCH 1/1 Anonymous (NULL-named) objects from user-space
Hi,
anonymous objects (name == NULL) from user-space get registered under unique names, - which is a string representation of the object's kernel-space address, - but remain not-exported via the /proc interface.
Not tested with the all objects yet (well, I have upgraded the system, a compiler in particular err..., so I cannot load the recently rebuilt xeno_* modules at the moment), but the changes are not intrusive so everything should work as expected.
---
Best regards,
Dmitry
types2.h renamed from types.h +6 -0
@@ -91,6 +91,12 @@ *dst ='\0' ; } +static inline int xnobject_create_name ( +char *dst,size_t n,void *obj) +{ +return snprintf (dst, n,"%p" , obj); +} +#define minval (a,b) ((a) < (b) ? (a) : (b))#define maxval (a,b) ((a) > (b) ? (a) : (b))
alarm.c +12 -2
@@ -208,9 +208,19 @@complete objects, so that the registry cannot return handles to half-baked objects... */ -if (name && *name) +if (name) { - err =rt_registry_enter (alarm->name,alarm,&alarm->handle,&__alarm_pnode); +RT_OBJECT_PROCNODE *pnode = &__alarm_pnode; + +if (!*name) + { +/* Since this is an anonymous object (NULL-named) from user-space, +it gets registratred under an unique name but remains not-exported via /proc */ +xnobject_create_name (alarm->name,sizeof (alarm->name),(void *)alarm); + pnode =NULL ; + } + + err =rt_registry_enter (alarm->name,alarm,&alarm->handle,pnode);if (err)rt_alarm_delete (alarm);
cond.c +12 -2
@@ -168,9 +168,19 @@complete objects, so that the registry cannot return handles to half-baked objects... */ -if (name && *name) +if (name) { - err =rt_registry_enter (cond->name,cond,&cond->handle,&__cond_pnode); +RT_OBJECT_PROCNODE *pnode = &__cond_pnode; + +if (!*name) + { +/* Since this is an anonymous object (NULL-named) from user-space, +it gets registratred under an unique name but remains not-exported via /proc */ +xnobject_create_name (cond->name,sizeof (cond->name),(void *)cond); + pnode =NULL ; + } + + err =rt_registry_enter (cond->name,cond,&cond->handle,pnode);if (err)rt_cond_delete (cond);
event.c +12 -2
@@ -190,9 +190,19 @@complete objects, so that the registry cannot return handles to half-baked objects... */ -if (name && *name) +if (name) { - err =rt_registry_enter (event->name,event,&event->handle,&__event_pnode); +RT_OBJECT_PROCNODE *pnode = &__event_pnode; + +if (!*name) + { +/* Since this is an anonymous object (NULL-named) from user-space, +it gets registratred under an unique name but remains not-exported via /proc */ +xnobject_create_name (event->name,sizeof (event->name),(void *)event); + pnode =NULL ; + } + + err =rt_registry_enter (event->name,event,&event->handle,pnode);if (err)rt_event_delete (event);
heap.c +12 -2
@@ -287,9 +287,19 @@complete objects, so that the registry cannot return handles to half-baked objects... */ -if (name && *name) +if (name) { - err =rt_registry_enter (heap->name,heap,&heap->handle,&__heap_pnode); +RT_OBJECT_PROCNODE *pnode = &__heap_pnode; + +if (!*name) + { +/* Since this is an anonymous object (NULL-named) from user-space, +it gets registratred under an unique name but remains not-exported via /proc */ +xnobject_create_name (heap->name,sizeof (heap->name),(void *)heap); + pnode =NULL ; + } + + err =rt_registry_enter (heap->name,heap,&heap->handle,pnode);if (err)rt_heap_delete (heap);
mutex.c +12 -2
@@ -181,9 +181,19 @@complete objects, so that the registry cannot return handles to half-baked objects... */ -if (name && *name) +if (name) { - err =rt_registry_enter (mutex->name,mutex,&mutex->handle,&__mutex_pnode); +RT_OBJECT_PROCNODE *pnode = &__mutex_pnode; + +if (!*name) + { +/* Since this is an anonymous object (NULL-named) from user-space, +it gets registratred under an unique name but remains not-exported via /proc */ +xnobject_create_name (mutex->name,sizeof (mutex->name),(void *)mutex); + pnode =NULL ; + } + + err =rt_registry_enter (mutex->name,mutex,&mutex->handle,pnode);if (err)rt_mutex_delete (mutex);
pipe.c +12 -2
@@ -257,9 +257,19 @@complete objects, so that the registry cannot return handles to half-baked objects... */ -if (name && *name) +if (name) { - err =rt_registry_enter (pipe->name,pipe,&pipe->handle,&__pipe_pnode); +RT_OBJECT_PROCNODE *pnode = &__pipe_pnode; + +if (!*name) + { +/* Since this is an anonymous object (NULL-named) from user-space, +it gets registratred under an unique name but remains not-exported via /proc */ +xnobject_create_name (pipe->name,sizeof (pipe->name),(void *)pipe); + pnode =NULL ; + } + + err =rt_registry_enter (pipe->name,pipe,&pipe->handle,pnode);if (err)rt_pipe_delete (pipe);
queue.c +12 -2
@@ -281,9 +281,19 @@complete objects, so that the registry cannot return handles to half-baked objects... */ -if (name && *name) +if (name) { - err =rt_registry_enter (q->name,q,&q->handle,&__queue_pnode); +RT_OBJECT_PROCNODE *pnode = &__queue_pnode; + +if (!*name) + { +/* Since this is an anonymous object (NULL-named) from user-space, +it gets registratred under an unique name but remains not-exported via /proc */ +xnobject_create_name (q->name,sizeof (q->name),(void *)q); + pnode =NULL ; + } + + err =rt_registry_enter (q->name,q,&q->handle,pnode);if (err)rt_queue_delete (q);
sem.c +12 -2
@@ -193,9 +193,19 @@complete objects, so that the registry cannot return handles to half-baked objects... */ -if (name && *name) +if (name) { - err =rt_registry_enter (sem->name,sem,&sem->handle,&__sem_pnode); +RT_OBJECT_PROCNODE *pnode = &__sem_pnode; + +if (!*name) + { +/* Since this is an anonymous object (NULL-named) from user-space, +it gets registratred under an unique name but remains not-exported via /proc */ +xnobject_create_name (sem->name,sizeof (sem->name),(void *)sem); + pnode =NULL ; + } + + err =rt_registry_enter (sem->name,sem,&sem->handle,pnode);if (err)rt_sem_delete (sem);
Quoted 4 lines · Dmitry Adamushko
Hi,
anonymous objects (name == NULL) from user-space get registered under unique names, - which is a string representation of the object's kernel-space address, - but remain not-exported via the /proc interface.
Applied (fixing the comment), thanks.
Quoted 2 lines
Not tested with the all objects yet (well, I have upgraded the system, a compiler in particular err..., so I cannot load the recently rebuilt xeno_* modules at the moment), but the changes are not intrusive so everything should work as expected.
Should be ok.
Quoted 227 lines
---
Best regards,
Dmitry------------------------------------------------------------------------
types2.h renamed from types.h +6
-1@@ -91,6 +91,12 @@ *dst ='\0' ; } +static inline int xnobject_create_name ( +char *dst,size_t n,void *obj) +{ +return snprintf (dst, n,"%p" , obj); +} +#define minval (a,b) ((a) < (b) ? (a) : (b))#define maxval (a,b) ((a) > (b) ? (a) : (b)) ------------------------------------------------------------------------diff -ur
native/alarm.cnative2/alarm.calarm.c +12
-2@@ -208,9 +208,19 @@complete objects, so that the registry cannot return handles to half-baked objects... */ -if (name && *name) +if (name) { - err =rt_registry_enter (alarm->name,alarm,&alarm->handle,&__alarm_pnode); +RT_OBJECT_PROCNODE *pnode = &__alarm_pnode; + +if (!*name) + { +/* Since this is an anonymous object (NULL-named) from user-space, +it gets registratred under an unique name but remains not-exported via /proc */ +xnobject_create_name (alarm->name,sizeof (alarm->name),(void *)alarm); + pnode =NULL ; + } + + err =rt_registry_enter (alarm->name,alarm,&alarm->handle,pnode);if (err)rt_alarm_delete (alarm);diff -ur
native/cond.cnative2/cond.ccond.c +12
-2@@ -168,9 +168,19 @@complete objects, so that the registry cannot return handles to half-baked objects... */ -if (name && *name) +if (name) { - err =rt_registry_enter (cond->name,cond,&cond->handle,&__cond_pnode); +RT_OBJECT_PROCNODE *pnode = &__cond_pnode; + +if (!*name) + { +/* Since this is an anonymous object (NULL-named) from user-space, +it gets registratred under an unique name but remains not-exported via /proc */ +xnobject_create_name (cond->name,sizeof (cond->name),(void *)cond); + pnode =NULL ; + } + + err =rt_registry_enter (cond->name,cond,&cond->handle,pnode);if (err)rt_cond_delete (cond);diff -ur
native/event.cnative2/event.cevent.c +12
-2@@ -190,9 +190,19 @@complete objects, so that the registry cannot return handles to half-baked objects... */ -if (name && *name) +if (name) { - err =rt_registry_enter (event->name,event,&event->handle,&__event_pnode); +RT_OBJECT_PROCNODE *pnode = &__event_pnode; + +if (!*name) + { +/* Since this is an anonymous object (NULL-named) from user-space, +it gets registratred under an unique name but remains not-exported via /proc */ +xnobject_create_name (event->name,sizeof (event->name),(void *)event); + pnode =NULL ; + } + + err =rt_registry_enter (event->name,event,&event->handle,pnode);if (err)rt_event_delete (event);diff -ur
native/heap.cnative2/heap.cheap.c +12
-2@@ -287,9 +287,19 @@complete objects, so that the registry cannot return handles to half-baked objects... */ -if (name && *name) +if (name) { - err =rt_registry_enter (heap->name,heap,&heap->handle,&__heap_pnode); +RT_OBJECT_PROCNODE *pnode = &__heap_pnode; + +if (!*name) + { +/* Since this is an anonymous object (NULL-named) from user-space, +it gets registratred under an unique name but remains not-exported via /proc */ +xnobject_create_name (heap->name,sizeof (heap->name),(void *)heap); + pnode =NULL ; + } + + err =rt_registry_enter (heap->name,heap,&heap->handle,pnode);if (err)rt_heap_delete (heap);diff -ur
native/mutex.cnative2/mutex.cmutex.c +12
-2@@ -181,9 +181,19 @@complete objects, so that the registry cannot return handles to half-baked objects... */ -if (name && *name) +if (name) { - err =rt_registry_enter (mutex->name,mutex,&mutex->handle,&__mutex_pnode); +RT_OBJECT_PROCNODE *pnode = &__mutex_pnode; + +if (!*name) + { +/* Since this is an anonymous object (NULL-named) from user-space, +it gets registratred under an unique name but remains not-exported via /proc */ +xnobject_create_name (mutex->name,sizeof (mutex->name),(void *)mutex); + pnode =NULL ; + } + + err =rt_registry_enter (mutex->name,mutex,&mutex->handle,pnode);if (err)rt_mutex_delete (mutex);diff -ur
native/pipe.cnative2/pipe.cpipe.c +12
-2@@ -257,9 +257,19 @@complete objects, so that the registry cannot return handles to half-baked objects... */ -if (name && *name) +if (name) { - err =rt_registry_enter (pipe->name,pipe,&pipe->handle,&__pipe_pnode); +RT_OBJECT_PROCNODE *pnode = &__pipe_pnode; + +if (!*name) + { +/* Since this is an anonymous object (NULL-named) from user-space, +it gets registratred under an unique name but remains not-exported via /proc */ +xnobject_create_name (pipe->name,sizeof (pipe->name),(void *)pipe); + pnode =NULL ; + } + + err =rt_registry_enter (pipe->name,pipe,&pipe->handle,pnode);if (err)rt_pipe_delete (pipe);diff -ur
native/queue.cnative2/queue.cqueue.c +12
-2@@ -281,9 +281,19 @@complete objects, so that the registry cannot return handles to half-baked objects... */ -if (name && *name) +if (name) { - err =rt_registry_enter (q->name,q,&q->handle,&__queue_pnode); +RT_OBJECT_PROCNODE *pnode = &__queue_pnode; + +if (!*name) + { +/* Since this is an anonymous object (NULL-named) from user-space, +it gets registratred under an unique name but remains not-exported via /proc */ +xnobject_create_name (q->name,sizeof (q->name),(void *)q); + pnode =NULL ; + } + + err =rt_registry_enter (q->name,q,&q->handle,pnode);if (err)rt_queue_delete (q);diff -ur
native/sem.cnative2/sem.csem.c +12
-2@@ -193,9 +193,19 @@complete objects, so that the registry cannot return handles to half-baked objects... */ -if (name && *name) +if (name) { - err =rt_registry_enter (sem->name,sem,&sem->handle,&__sem_pnode); +RT_OBJECT_PROCNODE *pnode = &__sem_pnode; + +if (!*name) + { +/* Since this is an anonymous object (NULL-named) from user-space, +it gets registratred under an unique name but remains not-exported via /proc */ +xnobject_create_name (sem->name,sizeof (sem->name),(void *)sem); + pnode =NULL ; + } + + err =rt_registry_enter (sem->name,sem,&sem->handle,pnode);if (err)rt_sem_delete (sem);
Signature · 1 line
Philippe.