xen: fail gnttab_grow_table() in case of missing allocations
PATCH 1/1 xen: fail gnttab_grow_table() in case of missing allocations
In case gnttab_grow_table() is being called without grant_table_init() having been called for the domain, e.g. in case of a toolstack error, fail the function instead of crashing the system.
--- xen/common/grant_table.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
xen/common/grant_table.c +5 -1
@@ -1669,7 +1669,11 @@ gnttab_grow_table(struct domain *d, unsigned int req_nr_frames)struct grant_table *gt = d->grant_table;unsigned int i, j; -ASSERT (gt->active); +if (unlikely (!gt->active) ) + { +gdprintk (XENLOG_WARNING ,"grant_table_set_limits() call missing.\n" ); +return 0 ; + }if ( req_nr_frames <INITIAL_NR_GRANT_FRAMES ) req_nr_frames =INITIAL_NR_GRANT_FRAMES ;
Signature · 7 lines
2.12.3 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 14 lines · Juergen Gross
In case
gnttab_grow_table()is being called withoutgrant_table_init()having been called for the domain, e.g. in case of a toolstack error, fail the function instead of crashing the system.Signed-off-by Juergen Gross <[email protected]>--- xen/common/grant_table.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)xen/common/grant_table.c +0
-0
xen/common/grant_table.c gnttab_grow_table(struct domain *d, unsigned int req_nr_frames) · line 1674
Quoted 7 lines
xen/common/grant_table.c +3
-1@@ -1669,7 +1669,11 @@ gnttab_grow_table(struct domain *d, unsigned int req_nr_frames)struct grant_table *gt = d->grant_table;unsigned int i, j; -ASSERT (gt->active); +if (unlikely (!gt->active) ) + { +gdprintk (XENLOG_WARNING ,"grant_table_set_limits() call missing.\n" );
In the commit message you mention 'grant_table_init', yet the error message here says grant_table_set_limits. Shouldn't both mention the same precursor function?
Also I think this might be better as gprintk instead of gdprintk.
xen/common/grant_table.c gnttab_grow_table(struct domain *d, unsigned int req_nr_frames) · line 1675
Quoted 1 line
xen/common/grant_table.c +1
-0+return 0 ;
This return 0 has confused me, I was going to ask to return ENODEV, but then I saw this is actually treated like a boolean. Might be good to make gnttab_grow_table return bool, or either make it return proper error codes.
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 18 lines · Roger Pau Monné
Quoted 17 lines · Juergen Gross
In case
gnttab_grow_table()is being called withoutgrant_table_init()having been called for the domain, e.g. in case of a toolstack error, fail the function instead of crashing the system.Signed-off-by Juergen Gross <[email protected]>--- xen/common/grant_table.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)xen/common/grant_table.c +0
-0@@ -1669,7 +1669,11 @@ gnttab_grow_table(struct domain *d, unsigned int req_nr_frames)struct grant_table *gt = d->grant_table;unsigned int i, j;
Quoted 8 lines
xen/common/grant_table.c gnttab_grow_table(struct domain *d, unsigned int req_nr_frames) · line 1674
Quoted 4 lines
xen/common/grant_table.c +3
-1-ASSERT (gt->active); +if (unlikely (!gt->active) ) + { +gdprintk (XENLOG_WARNING ,"grant_table_set_limits() call missing.\n" );In the commit message you mention '
grant_table_init', yet the error message here saysgrant_table_set_limits. Shouldn't both mention the same precursor function?
Aah, sorry. Will update the commit message.
Quoted 1 line
Also I think this might be better as gprintk instead of gdprintk.
Okay.
Quoted 6 lines
xen/common/grant_table.c gnttab_grow_table(struct domain *d, unsigned int req_nr_frames) · line 1675
Quoted 1 line
xen/common/grant_table.c +1
-0+return 0 ;This return 0 has confused me, I was going to ask to return ENODEV, but then I saw this is actually treated like a boolean. Might be good to make
gnttab_grow_tablereturn bool, or either make it return proper error codes.
I wanted to keep the patch small.
I can either send a cleanup patch after 4.10 or do it in this patch (in which case I'd like to know whether this patch or the last one of my grant series will be applied first).
Thoughts?
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 9 lines · Juergen Gross
Quoted 7 lines · Roger Pau Monné
Quoted 1 line · Juergen Gross
+ return 0;
This return 0 has confused me, I was going to ask to return ENODEV, but then I saw this is actually treated like a boolean. Might be good to make
gnttab_grow_tablereturn bool, or either make it return proper error codes.
Quoted 7 lines
I wanted to keep the patch small.
I can either send a cleanup patch after 4.10 or do it in this patch (in which case I'd like to know whether this patch or the last one of my grant series will be applied first).
Thoughts?
Oh sorry. It was a rant rather than a request. No need for you to change this.
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 36 lines · Juergen Gross
Quoted 18 lines · Roger Pau Monné
Quoted 17 lines · Juergen Gross
In case
gnttab_grow_table()is being called withoutgrant_table_init()having been called for the domain, e.g. in case of a toolstack error, fail the function instead of crashing the system.Signed-off-by Juergen Gross <[email protected]>--- xen/common/grant_table.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)xen/common/grant_table.c +0
-0@@ -1669,7 +1669,11 @@ gnttab_grow_table(struct domain *d, unsigned int req_nr_frames)struct grant_table *gt = d->grant_table;unsigned int i, j;Quoted 7 lines
xen/common/grant_table.c gnttab_grow_table(struct domain *d, unsigned int req_nr_frames) · line 1674
Quoted 4 lines
xen/common/grant_table.c +3
-1-ASSERT (gt->active); +if (unlikely (!gt->active) ) + { +gdprintk (XENLOG_WARNING ,"grant_table_set_limits() call missing.\n" );In the commit message you mention '
grant_table_init', yet the error message here saysgrant_table_set_limits. Shouldn't both mention the same precursor function?Aah, sorry. Will update the commit message.
Quoted 1 line
Also I think this might be better as gprintk instead of gdprintk.
Okay.
Quoted 5 lines
xen/common/grant_table.c gnttab_grow_table(struct domain *d, unsigned int req_nr_frames) · line 1675
Quoted 1 line
xen/common/grant_table.c +1
-0+return 0 ;This return 0 has confused me, I was going to ask to return ENODEV, but then I saw this is actually treated like a boolean. Might be good to make
gnttab_grow_tablereturn bool, or either make it return proper error codes.
Quoted 7 lines
I wanted to keep the patch small.
I can either send a cleanup patch after 4.10 or do it in this patch (in which case I'd like to know whether this patch or the last one of my grant series will be applied first).
Thoughts?
This function is new in 4.10. I'm not concerned about absolute size of the patch, but I would prefer not to introduce new (mis)uses of int functions which actually have boolean properties. (Wei and I have spent a large quantity of time removing functions like this.)
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 39 lines · Andrew Cooper
Quoted 38 lines · Juergen Gross
Quoted 18 lines · Roger Pau Monné
Quoted 17 lines · Juergen Gross
In case
gnttab_grow_table()is being called withoutgrant_table_init()having been called for the domain, e.g. in case of a toolstack error, fail the function instead of crashing the system.Signed-off-by Juergen Gross <[email protected]>--- xen/common/grant_table.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)xen/common/grant_table.c +0
-0@@ -1669,7 +1669,11 @@ gnttab_grow_table(struct domain *d, unsigned int req_nr_frames)struct grant_table *gt = d->grant_table;unsigned int i, j;Quoted 7 lines
xen/common/grant_table.c gnttab_grow_table(struct domain *d, unsigned int req_nr_frames) · line 1674
Quoted 4 lines
xen/common/grant_table.c +3
-1-ASSERT (gt->active); +if (unlikely (!gt->active) ) + { +gdprintk (XENLOG_WARNING ,"grant_table_set_limits() call missing.\n" );In the commit message you mention '
grant_table_init', yet the error message here saysgrant_table_set_limits. Shouldn't both mention the same precursor function?Aah, sorry. Will update the commit message.
Quoted 1 line
Also I think this might be better as gprintk instead of gdprintk.
Okay.
Quoted 5 lines
xen/common/grant_table.c gnttab_grow_table(struct domain *d, unsigned int req_nr_frames) · line 1675
Quoted 1 line
xen/common/grant_table.c +1
-0+return 0 ;This return 0 has confused me, I was going to ask to return ENODEV, but then I saw this is actually treated like a boolean. Might be good to make
gnttab_grow_tablereturn bool, or either make it return proper error codes.I wanted to keep the patch small.
Quoted 7 lines
Quoted 5 lines
I can either send a cleanup patch after 4.10 or do it in this patch (in which case I'd like to know whether this patch or the last one of my grant series will be applied first).
Thoughts?
This function is new in 4.10.
Umm, not really. Its rather old.
Quoted 4 lines
I'm not concerned about absolute size of
the patch, but I would prefer not to introduce new (mis)uses of int functions which actually have boolean properties. (Wei and I have spent a large quantity of time removing functions like this.)
I'd rather return a proper error code.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 40 lines · Juergen Gross
Quoted 39 lines · Andrew Cooper
Quoted 38 lines · Juergen Gross
Quoted 18 lines · Roger Pau Monné
Quoted 17 lines · Juergen Gross
In case
gnttab_grow_table()is being called withoutgrant_table_init()having been called for the domain, e.g. in case of a toolstack error, fail the function instead of crashing the system.Signed-off-by Juergen Gross <[email protected]>--- xen/common/grant_table.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)xen/common/grant_table.c +0
-0@@ -1669,7 +1669,11 @@ gnttab_grow_table(struct domain *d, unsigned int req_nr_frames)struct grant_table *gt = d->grant_table;unsigned int i, j;Quoted 7 lines
xen/common/grant_table.c gnttab_grow_table(struct domain *d, unsigned int req_nr_frames) · line 1674
Quoted 4 lines
xen/common/grant_table.c +3
-1-ASSERT (gt->active); +if (unlikely (!gt->active) ) + { +gdprintk (XENLOG_WARNING ,"grant_table_set_limits() call missing.\n" );In the commit message you mention '
grant_table_init', yet the error message here saysgrant_table_set_limits. Shouldn't both mention the same precursor function?Aah, sorry. Will update the commit message.
Quoted 1 line
Also I think this might be better as gprintk instead of gdprintk.
Okay.
Quoted 5 lines
xen/common/grant_table.c gnttab_grow_table(struct domain *d, unsigned int req_nr_frames) · line 1675
Quoted 1 line
xen/common/grant_table.c +1
-0+return 0 ;This return 0 has confused me, I was going to ask to return ENODEV, but then I saw this is actually treated like a boolean. Might be good to make
gnttab_grow_tablereturn bool, or either make it return proper error codes.I wanted to keep the patch small.
Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
I can either send a cleanup patch after 4.10 or do it in this patch (in which case I'd like to know whether this patch or the last one of my grant series will be applied first).
Thoughts?
This function is new in 4.10.
Umm, not really. Its rather old.
Oh - so it is.
Quoted 6 lines
Quoted 5 lines
I'm not concerned about absolute size of
the patch, but I would prefer not to introduce new (mis)uses of int functions which actually have boolean properties. (Wei and I have spent a large quantity of time removing functions like this.)I'd rather return a proper error code.
Fine by me.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel