tools/xenstore: fix get_spec_node()
PATCH 1/1 tools/xenstore: fix get_spec_node()
In case get_spec_node() is being called for a special node starting with '@' it won't set *canonical_name. This can result in a crash of xenstored due to dereferencing the uninitialized name in fire_watches().
This is no security issue as it requires either a privileged caller or ownership of the special node in question by an unprivileged caller (which is questionable, as this would make the owner privileged in some way).
--- tools/xenstore/xenstored_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/xenstore/xenstored_core.c +4 -1
@@ -1252,8 +1252,11 @@ static struct node *get_spec_node(struct connection *conn, const void *ctx, const char *name, char **canonical_name, unsigned int perm) { - if (name[0] == '@') + if (name[0] == '@') { + if (canonical_name) + *canonical_name = (char *)name;return get_node (conn, ctx, name, perm); + }return get_node_canonicalized (conn, ctx, name, canonical_name, perm); }
Signature · 1 line
2.35.3
Hi Juergen,
Quoted 21 lines · Juergen Gross
In case
get_spec_node()is being called for a special node starting with '@' it won't set*canonical_name. This can result in a crash of xenstored due to dereferencing the uninitialized name infire_watches().This is no security issue as it requires either a privileged caller or ownership of the special node in question by an unprivileged caller (which is questionable, as this would make the owner privileged in some way).
Fixes d6bb63924fc2 ("tools/xenstore: introduce dummy nodes for special watch paths")Signed-off-by Juergen Gross <[email protected]>--- tools/xenstore/xenstored_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)tools/xenstore/xenstored_core.c +0
-0
tools/xenstore/xenstored_core.c static struct node *get_spec_node(struct connection *conn, const void *ctx, · line 1257
Quoted 7 lines
tools/xenstore/xenstored_core.c +3
-1@@ -1252,8 +1252,11 @@ static struct node *get_spec_node(struct connection *conn, const void *ctx, const char *name, char **canonical_name, unsigned int perm) { - if (name[0] == '@') + if (name[0] == '@') { + if (canonical_name) + *canonical_name = (char *)name;
eww. Let's not continue the bad practice in Xenstored to cast away the const. I will have a look to remove the const and you can rebase your patch on top.
Cheers,
Signature · 1 line
Julien Grall
Quoted 19 lines · Julien Grall
Hi Juergen,
Quoted 16 lines · Juergen Gross
In case
get_spec_node()is being called for a special node starting with '@' it won't set*canonical_name. This can result in a crash of xenstored due to dereferencing the uninitialized name infire_watches().This is no security issue as it requires either a privileged caller or ownership of the special node in question by an unprivileged caller (which is questionable, as this would make the owner privileged in some way).
Fixes d6bb63924fc2 ("tools/xenstore: introduce dummy nodes for special watch paths")Signed-off-by Juergen Gross <[email protected]>---
tools/xenstore/xenstored_core.c| 5 ++++-1 file changed, 4 insertions(+), 1 deletion(-)
Quoted 15 lines
tools/xenstore/xenstored_core.c static struct node *get_spec_node(struct connection · line 1258
Quoted 13 lines
tools/xenstore/xenstored_core.c +3
-1@@ -1252,8 +1252,11 @@ static struct node *get_spec_node(struct connection *conn, const void *ctx, const char *name, char **canonical_name, unsigned int perm) { - if (name[0] == '@') + if (name[0] == '@') { + if (canonical_name) + *canonical_name = (char *)name;eww. Let's not continue the bad practice in Xenstored to cast away the const. I will have a look to remove the const and you can rebase your patch on top.
I think it should be possible to make canonical_name const. I'll look into that.
Juergen