Skip to contentSkip to conversation

tools/xenstored: liveupdate: Increase the maximum number of parameters

PATCH In review Julien Grall 3 participants 11 messages Mar 5, 2021 – Mar 6, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/xenstored: liveupdate: Increase the maximum number of parameters

From: Julien Grall <[email protected]>

The longest possible command line for LiveUpdate is:

liveupdate -s -t <timeout> -F

This is 5 parameters. However, the maximum is currently specified to 4. This means the some of the parameters will get ignored.

Update the field max_pars to 5 so and admin can specify the timeout and force at the same time.

---

This is a candidate for Xen 4.15. Without it, it would not be possible to pass -F and -t together.

The change is only modifying behavior for XenStored LiveUpdate.

---
 tools/xenstore/xenstored_control.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/xenstore/xenstored_control.c +1 -1
index a1652219b247..8e470f2b2056 100644
@@ -768,7 +768,7 @@ static struct cmd_s cmds[] = {
 	 */
 	{ "live-update", do_control_lu,
 		"[-c <cmdline>] [-F] [-t <timeout>] <file>\n"
-		"    Default timeout is 60 seconds.", 4 },
+		"    Default timeout is 60 seconds.", 5 },
 #endif
 #ifdef __MINIOS__
 	{ "memreport", do_control_memreport, "" },
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Julien Grall

From: Julien Grall <[email protected]>

The longest possible command line for LiveUpdate is:

liveupdate -s -t <timeout> -F

Quoted 7 lines

This is 5 parameters. However, the maximum is currently specified to 4. This means the some of the parameters will get ignored.

Update the field max_pars to 5 so and admin can specify the timeout and force at the same time.

Juergen

#2 lore raw
In reply to Julien Grall

Julien Grall writes ("[PATCH for-4.15] tools/xenstored: liveupdate: Increase the maximum number of parameters"):

Quoted 8 lines

From: Julien Grall <[email protected]>

The longest possible command line for LiveUpdate is:

liveupdate -s -t <timeout> -F

This is 5 parameters. However, the maximum is currently specified to 4. This means the some of the parameters will get ignored.

Why are the extra parameters ignored rather than treated as errors ? This seems like an invitation to making code with bad behaviour (perhaps bad security-relevant behaviour).

CC Juergen who seems to have written the code...

Quoted 2 lines

Update the field max_pars to 5 so and admin can specify the timeout and force at the same time.

Anyway, for this patch,

#3 lore raw
Quoted 7 lines · Ian Jackson

Julien Grall writes ("[PATCH for-4.15] tools/xenstored: liveupdate: Increase the maximum number of parameters"):

Quoted 6 lines

From: Julien Grall <[email protected]>

The longest possible command line for LiveUpdate is:

liveupdate -s -t <timeout> -F

Quoted 8 lines
Quoted 2 lines

This is 5 parameters. However, the maximum is currently specified to 4. This means the some of the parameters will get ignored.

Why are the extra parameters ignored rather than treated as errors ? This seems like an invitation to making code with bad behaviour (perhaps bad security-relevant behaviour).

CC Juergen who seems to have written the code...

This is the max number of 0 delimited string parameters. Especially the stubdom case needs a binary blob (with length, of course) as parameter, and the number of 0 bytes in this data is just limited by the allowed payload length.

See the comment in line 111 of xenstored_control.c.

Juergen

#4 lore raw

Jürgen Groß writes ("Re: [PATCH for-4.15] tools/xenstored: liveupdate: Increase the maximum number of parameters"):

Quoted 6 lines

This is the max number of 0 delimited string parameters. Especially the stubdom case needs a binary blob (with length, of course) as parameter, and the number of 0 bytes in this data is just limited by the allowed payload length.

See the comment in line 111 of xenstored_control.c.

AFAICT this "live-update" command is variadic. So why is this parameter set here it all then ?

Ian.

#5 lore raw
Quoted 10 lines · Ian Jackson

Jürgen Groß writes ("Re: [PATCH for-4.15] tools/xenstored: liveupdate: Increase the maximum number of parameters"):

Quoted 6 lines

This is the max number of 0 delimited string parameters. Especially the stubdom case needs a binary blob (with length, of course) as parameter, and the number of 0 bytes in this data is just limited by the allowed payload length.

See the comment in line 111 of xenstored_control.c.

AFAICT this "live-update" command is variadic. So why is this parameter set here it all then ?

In order to avoid allocating an array for 4000 arguments when there are only 5 which need to be treated as strings.

Juergen

#6 lore raw

Jürgen Groß writes ("Re: [PATCH for-4.15] tools/xenstored: liveupdate: Increase the maximum number of parameters"):

Quoted 7 lines · Ian Jackson
Quoted 6 lines

Jürgen Groß writes ("Re: [PATCH for-4.15] tools/xenstored: liveupdate: Increase the maximum number of parameters"):

Quoted 5 lines

This is the max number of 0 delimited string parameters. Especially the stubdom case needs a binary blob (with length, of course) as parameter, and the number of 0 bytes in this data is just limited by the allowed payload length.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

See the comment in line 111 of xenstored_control.c.

AFAICT this "live-update" command is variadic. So why is this parameter set here it all then ?

In order to avoid allocating an array for 4000 arguments when there are only 5 which need to be treated as strings.

So this parameter is doing two jobs: 1. enabling non-variadic commands to take binary input; 2. preventing variadic commands from allocating unbounded memory.

The problem with this is that in case 1 exceeding the value is normal and the final argument is binary data; whereas in case 2 glomming together the arguments together with zeroes is wrong and potentially hazrdous.

I suggest we solve problem 2 by imposing a higher fixed (for all commands, variadic or not) limit (20 or something) which causes errors when exceeded, rather than silent argument misinterpretation.

Ian.

#7 lore raw

Ian Jackson writes ("Re: [PATCH for-4.15] tools/xenstored: liveupdate: Increase the maximum number of parameters"):

Quoted 20 lines

Jürgen Groß writes ("Re: [PATCH for-4.15] tools/xenstored: liveupdate: Increase the maximum number of parameters"):

Quoted 7 lines · Ian Jackson
Quoted 6 lines

Jürgen Groß writes ("Re: [PATCH for-4.15] tools/xenstored: liveupdate: Increase the maximum number of parameters"):

Quoted 5 lines

This is the max number of 0 delimited string parameters. Especially the stubdom case needs a binary blob (with length, of course) as parameter, and the number of 0 bytes in this data is just limited by the allowed payload length.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

See the comment in line 111 of xenstored_control.c.

AFAICT this "live-update" command is variadic. So why is this parameter set here it all then ?

In order to avoid allocating an array for 4000 arguments when there are only 5 which need to be treated as strings.

So this parameter is doing two jobs: 1. enabling non-variadic commands to take binary input; 2. preventing variadic commands from allocating unbounded memory.

Quoted 8 lines

The problem with this is that in case 1 exceeding the value is normal and the final argument is binary data; whereas in case 2 glomming together the arguments together with zeroes is wrong and potentially hazrdous.

I suggest we solve problem 2 by imposing a higher fixed (for all commands, variadic or not) limit (20 or something) which causes errors when exceeded, rather than silent argument misinterpretation.

Also, this use of max_pars to do job 2 seems very inconsistent. It is applied only to "live-update".

If it is necessary for "live-update", which is it not necessary for "check" or whatever ?

Ian.

#8 lore raw
Quoted 30 lines · Ian Jackson

Ian Jackson writes ("Re: [PATCH for-4.15] tools/xenstored: liveupdate: Increase the maximum number of parameters"):

Quoted 20 lines

Jürgen Groß writes ("Re: [PATCH for-4.15] tools/xenstored: liveupdate: Increase the maximum number of parameters"):

Quoted 7 lines · Ian Jackson
Quoted 6 lines

Jürgen Groß writes ("Re: [PATCH for-4.15] tools/xenstored: liveupdate: Increase the maximum number of parameters"):

Quoted 5 lines

This is the max number of 0 delimited string parameters. Especially the stubdom case needs a binary blob (with length, of course) as parameter, and the number of 0 bytes in this data is just limited by the allowed payload length.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

See the comment in line 111 of xenstored_control.c.

AFAICT this "live-update" command is variadic. So why is this parameter set here it all then ?

In order to avoid allocating an array for 4000 arguments when there are only 5 which need to be treated as strings.

So this parameter is doing two jobs: 1. enabling non-variadic commands to take binary input; 2. preventing variadic commands from allocating unbounded memory.

Quoted 8 lines

The problem with this is that in case 1 exceeding the value is normal and the final argument is binary data; whereas in case 2 glomming together the arguments together with zeroes is wrong and potentially hazrdous.

I suggest we solve problem 2 by imposing a higher fixed (for all commands, variadic or not) limit (20 or something) which causes errors when exceeded, rather than silent argument misinterpretation.

Quoted 5 lines

Also, this use of max_pars to do job 2 seems very inconsistent. It is applied only to "live-update".

If it is necessary for "live-update", which is it not necessary for "check" or whatever ?

live-update is the only command with binary data. The other commands are checking all parameters to be valid, similar to normal parameter parsing in a main() function of a user program.

Juergen

#9 lore raw
In reply to Ian Jackson
Quoted 20 lines · Ian Jackson

Jürgen Groß writes ("Re: [PATCH for-4.15] tools/xenstored: liveupdate: Increase the maximum number of parameters"):

Quoted 7 lines · Ian Jackson
Quoted 6 lines

Jürgen Groß writes ("Re: [PATCH for-4.15] tools/xenstored: liveupdate: Increase the maximum number of parameters"):

Quoted 5 lines

This is the max number of 0 delimited string parameters. Especially the stubdom case needs a binary blob (with length, of course) as parameter, and the number of 0 bytes in this data is just limited by the allowed payload length.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

See the comment in line 111 of xenstored_control.c.

AFAICT this "live-update" command is variadic. So why is this parameter set here it all then ?

In order to avoid allocating an array for 4000 arguments when there are only 5 which need to be treated as strings.

So this parameter is doing two jobs: 1. enabling non-variadic commands to take binary input; 2. preventing variadic commands from allocating unbounded memory.

Quoted 8 lines

The problem with this is that in case 1 exceeding the value is normal and the final argument is binary data; whereas in case 2 glomming together the arguments together with zeroes is wrong and potentially hazrdous.

I suggest we solve problem 2 by imposing a higher fixed (for all commands, variadic or not) limit (20 or something) which causes errors when exceeded, rather than silent argument misinterpretation.

Patches welcome.

Juergen