xensore: fixing two bugs
cover xensore: fixing two bugs
Two small patches to fix bugs: one error path correction (setting correct error code for caller) and add some missing checks for allocation failures.
Juergen Gross (2):
xenstore: set correct error code when violating quota
xenstore: add missing checks for allocation failure
tools/xenstore/xenstored_core.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
Signature · 7 lines
2.10.2 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 1/2 xenstore: set correct error code when violating quota
When the number of permitted xenstore entries for a domain is being exceeded the operation trying to create a new entry is denied. Unfortunately errno isn't being set in this case so the error code returned to the client is undefined.
Set errno to ENOSPC in this case.
---
This is a backport candidate.
--- tools/xenstore/xenstored_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/xenstore/xenstored_core.c +3 -1
@@ -937,8 +937,10 @@ static struct node *construct_node(struct connection *conn, const void *ctx,if (!parent)return NULL ; -if (domain_entry (conn) >= quota_nb_entry_per_domain) +if (domain_entry (conn) >= quota_nb_entry_per_domain) { + errno =ENOSPC ;return NULL ; + }/* Add child to parent. */ base =basename (name);
Signature · 7 lines
2.10.2 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 2/2 xenstore: add missing checks for allocation failure
In reply to Juergen GrossAdd a missing allocation failure checks.
--- tools/xenstore/xenstored_core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
tools/xenstore/xenstored_core.c +12 -0
@@ -946,6 +946,8 @@ static struct node *construct_node(struct connection *conn, const void *ctx, base =basename (name); baselen =strlen (base) +1 ; children =talloc_array (ctx, char, parent->childlen + baselen); +if (!children) + goto nomem;memcpy (children, parent->children, parent->childlen);memcpy (children + parent->childlen, base, baselen); parent->children = children;
@@ -953,13 +955,19 @@ static struct node *construct_node(struct connection *conn, const void *ctx,/* Allocate node */ node = talloc(ctx, struct node); +if (!node) + goto nomem; node->tdb =tdb_context (conn); node->name =talloc_strdup (node, name); +if (!node->name) + goto nomem;/* Inherit permissions, except unprivileged domains own what they create */ node->num_perms = parent->num_perms; node->perms =talloc_memdup (node, parent->perms, node->num_perms *sizeof (node->perms[0 ])); +if (!node->perms) + goto nomem;if (domain_is_unprivileged (conn)) node->perms[0 ].id = conn->id;
@@ -969,6 +977,10 @@ static struct node *construct_node(struct connection *conn, const void *ctx, node->parent = parent;domain_entry_inc (conn, node);return node; + +nomem: + errno =ENOMEM ; +return NULL ; }static int destroy_node (void *_node)
Signature · 7 lines
2.10.2 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 1/2] xenstore: set correct error code when violating quota
In reply to Juergen GrossQuoted 8 lines · Juergen Gross
When the number of permitted xenstore entries for a domain is being exceeded the operation trying to create a new entry is denied. Unfortunately errno isn't being set in this case so the error code returned to the client is undefined.
Set errno to ENOSPC in this case.
Signed-off-by Juergen Gross <[email protected]>
But ...
tools/xenstore/xenstored_core.c static struct node *construct_node(struct connection *conn, const void *ctx, · line 938
Quoted 13 lines
---
This is a backport candidate.--- tools/xenstore/xenstored_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)tools/xenstore/xenstored_core.c +0
-0@@ -937,8 +937,10 @@ static struct node *construct_node(struct connection *conn, const void *ctx,if (!parent)return NULL ;
What about this and other places?
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 1/2] xenstore: set correct error code when violating quota
Quoted 20 lines · Wei Liu
Quoted 8 lines · Juergen Gross
When the number of permitted xenstore entries for a domain is being exceeded the operation trying to create a new entry is denied. Unfortunately errno isn't being set in this case so the error code returned to the client is undefined.
Set errno to ENOSPC in this case.
Signed-off-by Juergen Gross <[email protected]>Acked-by Wei Liu <[email protected]>But ...
Quoted 6 lines
---
This is a backport candidate.--- tools/xenstore/xenstored_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 9 lines
tools/xenstore/xenstored_core.c static struct node *construct_node(struct connection *conn, const void *ctx, · line 938
Quoted 7 lines
tools/xenstore/xenstored_core.c +0
-0@@ -937,8 +937,10 @@ static struct node *construct_node(struct connection *conn, const void *ctx,if (!parent)return NULL ;What about this and other places?
Oh, this relies on errno being set in some other place(s).
This is really poor error handling style... :-/
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/2] xenstore: add missing checks for allocation failure
In reply to Juergen GrossQuoted 1 line · Juergen Gross
Add a missing allocation failure checks.
s/a//
Quoted 2 lines
Signed-off-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 1/2] xenstore: set correct error code when violating quota
In reply to Wei LiuQuoted 31 lines · Wei Liu
Quoted 20 lines · Wei Liu
Quoted 8 lines · Juergen Gross
When the number of permitted xenstore entries for a domain is being exceeded the operation trying to create a new entry is denied. Unfortunately errno isn't being set in this case so the error code returned to the client is undefined.
Set errno to ENOSPC in this case.
Signed-off-by Juergen Gross <[email protected]>Acked-by Wei Liu <[email protected]>But ...
Quoted 6 lines
---
This is a backport candidate.--- tools/xenstore/xenstored_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)Quoted 9 lines
tools/xenstore/xenstored_core.c static struct node *construct_node(struct connection *conn, const void *ctx, · line 938
Quoted 7 lines
tools/xenstore/xenstored_core.c +0
-0@@ -937,8 +937,10 @@ static struct node *construct_node(struct connection *conn, const void *ctx,if (!parent)return NULL ;What about this and other places?
Quoted 3 lines
Oh, this relies on errno being set in some other place(s).
This is really poor error handling style... :-/
I can fix this up in another patch, but I don't think this should be done in this patch (and possibly not in 4.9).
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 1/2] xenstore: set correct error code when violating quota
Quoted 32 lines · Juergen Gross
Quoted 31 lines · Wei Liu
Quoted 29 lines · Wei Liu
Quoted 8 lines · Juergen Gross
When the number of permitted xenstore entries for a domain is being exceeded the operation trying to create a new entry is denied. Unfortunately errno isn't being set in this case so the error code returned to the client is undefined.
Set errno to ENOSPC in this case.
Signed-off-by Juergen Gross <[email protected]>Acked-by Wei Liu <[email protected]>But ...
tools/xenstore/xenstored_core.c static struct node *construct_node(struct connection *conn, const void *ctx, · line 938
Quoted 13 lines
---
This is a backport candidate.--- tools/xenstore/xenstored_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)tools/xenstore/xenstored_core.c +0
-0@@ -937,8 +937,10 @@ static struct node *construct_node(struct connection *conn, const void *ctx,if (!parent)return NULL ;What about this and other places?
Quoted 7 lines
Quoted 3 lines
Oh, this relies on errno being set in some other place(s).
This is really poor error handling style... :-/
I can fix this up in another patch, but I don't think this should be done in this patch (and possibly not in 4.9).
Of course. I didn't mean to ask you fix them in one patch.
Quoted 3 lines
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
cover xensore: fixing two bugs
In reply to Juergen GrossJuergen Gross writes ("[PATCH 0/2] xensore: fixing two bugs"):
Quoted 7 lines
Two small patches to fix bugs: one error path correction (setting correct error code for caller) and add some missing checks for allocation failures.
Juergen Gross (2):
xenstore: set correct error code when violating quota
xenstore: add missing checks for allocation failure
Both,
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel