public/io: xs_wire: Allow Xenstore to report EPERM
v2 cover public/io: xs_wire: Allow Xenstore to report EPERM
From: Julien Grall <[email protected]>
Hi all,
This small patch series allows xenstore to report EPERM (see patch #2). Patch #1 was introduced to avoid someone else making the mistake to introduce a new error before EINVAL.
Cheers,
Julien Grall (2):
public/io: xs_wire: Document that EINVAL should always be first in
xsd_errors
public/io: xs_wire: Allow Xenstore to report EPERM
xen/include/public/io/xs_wire.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Signature · 1 line
2.32.0
PATCH v2 1/2 public/io: xs_wire: Document that EINVAL should always be first in xsd_errors
From: Julien Grall <[email protected]>
Some tools (e.g. xenstored) always expect EINVAL to be first in xsd_errors.
Document it so, one doesn't add a new entry before hand by mistake.
----
I have tried to add a BUILD_BUG_ON() but GCC complained that the value was not a constant. I couldn't figure out a way to make GCC happy.
Changes in v2:
- New patch
--- xen/include/public/io/xs_wire.h | 1 + 1 file changed, 1 insertion(+)
xen/include/public/io/xs_wire.h +1 -0
@@ -76,6 +76,7 @@ static struct xsd_errors xsd_errors[] __attribute__((unused)) #endif = { + /* /!\ Some users (e.g. xenstored) expect EINVAL to be the first entry. */ XSD_ERROR(EINVAL), XSD_ERROR(EACCES), XSD_ERROR(EEXIST),
Signature · 1 line
2.32.0
Re: [PATCH v2 1/2] public/io: xs_wire: Document that EINVAL should always be first in xsd_errors
Quoted 24 lines · Julien Grall
From: Julien Grall <[email protected]>
Some tools (e.g. xenstored) always expect EINVAL to be first in
xsd_errors.Document it so, one doesn't add a new entry before hand by mistake.
Signed-off-by Julien Grall <[email protected]>----
I have tried to add a
BUILD_BUG_ON()but GCC complained that the value was not a constant. I couldn't figure out a way to make GCC happy.Changes in v2:
- New patch--- xen/include/public/io/xs_wire.h | 1 + 1 file changed, 1 insertion(+)xen/include/public/io/xs_wire.h +0
-0
xen/include/public/io/xs_wire.h static struct xsd_errors xsd_errors[] · line 82
Quoted 7 lines
xen/include/public/io/xs_wire.h +1
-0@@ -76,6 +76,7 @@ static struct xsd_errors xsd_errors[] __attribute__((unused)) #endif = { + /* /!\ Some users (e.g. xenstored) expect EINVAL to be the first entry. */ XSD_ERROR(EINVAL), XSD_ERROR(EACCES), XSD_ERROR(EEXIST),
What about another approach, like:
tools/xenstore/xenstored_core.c +4 -3
@@ -746,16 +746,17 @@ unsigned int get_strings(struct buffered_data *data,static void send_error (struct connection *conn,int error) {unsigned int i; +char *err =NULL ;for (i =0 ; error != xsd_errors[i].errnum; i++) {if (i ==ARRAY_SIZE (xsd_errors) -1 ) {eprintf ("xenstored: error %i untranslatable" , error); - i =0 ;/* EINVAL */ + err ="EINVAL" ;break ; } } -send_reply (conn,XS_ERROR , xsd_errors[i].errstring, -strlen (xsd_errors[i].errstring) +1 ); + err = err ? : xsd_errors[i].errstring; +send_reply (conn,XS_ERROR , err,strlen (err) +1 ); } void send_reply(struct connection *conn, enum xsd_sockmsg_type type,
Re: [PATCH v2 1/2] public/io: xs_wire: Document that EINVAL should always be first in xsd_errors
Hi,
Quoted 20 lines · Juergen Gross
Quoted 19 lines · Julien Grall
From: Julien Grall <[email protected]>
Some tools (e.g. xenstored) always expect EINVAL to be first in
xsd_errors.Document it so, one doesn't add a new entry before hand by mistake.
Signed-off-by Julien Grall <[email protected]>----
I have tried to add a
BUILD_BUG_ON()but GCC complained that the value was not a constant. I couldn't figure out a way to make GCC happy.Changes in v2:
- New patch
---
xen/include/public/io/xs_wire.h| 1 +1 file changed, 1 insertion(+)
Quoted 15 lines
Quoted 9 lines
xen/include/public/io/xs_wire.h +1
-0@@ -76,6 +76,7 @@ static struct xsd_errors xsd_errors[] __attribute__((unused)) #endif = { + /* /!\ Some users (e.g. xenstored) expect EINVAL to be the firstQuoted 4 lines
entry. */
XSD_ERROR(EINVAL),
XSD_ERROR(EACCES),
XSD_ERROR(EEXIST),What about another approach, like:
In place of what? I still think we need the comment because this assumption is not part of the ABI (AFAICT xs_wire.h is meant to be stable).
At which point, I see limited reason to fix xenstored_core.c.
But I would have really prefer to use a BUILD_BUG_ON() (or similar) so we can catch any misue a build. Maybe I should write a small program that is executed at compile time?
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v2 1/2] public/io: xs_wire: Document that EINVAL should always be first in xsd_errors
Quoted 38 lines · Julien Grall
Hi,
Quoted 20 lines · Juergen Gross
Quoted 19 lines · Julien Grall
From: Julien Grall <[email protected]>
Some tools (e.g. xenstored) always expect EINVAL to be first in
xsd_errors.Document it so, one doesn't add a new entry before hand by mistake.
Signed-off-by Julien Grall <[email protected]>----
I have tried to add a
BUILD_BUG_ON()but GCC complained that the value was not a constant. I couldn't figure out a way to make GCC happy.Changes in v2:
- New patch
---
xen/include/public/io/xs_wire.h| 1 +1 file changed, 1 insertion(+)Quoted 14 lines
xen/include/public/io/xs_wire.h static struct xsd_errors xsd_errors[] · line 82
Quoted 12 lines
xen/include/public/io/xs_wire.h +1
-0@@ -76,6 +76,7 @@ static struct xsd_errors xsd_errors[] __attribute__((unused)) #endif = { + /* /!\ Some users (e.g. xenstored) expect EINVAL to be the first entry. */ XSD_ERROR(EINVAL), XSD_ERROR(EACCES), XSD_ERROR(EEXIST),What about another approach, like:
Quoted 5 lines
In place of what? I still think we need the comment because this assumption is not part of the ABI (AFAICT
xs_wire.his meant to be stable).At which point, I see limited reason to fix
xenstored_core.c.But I would have really prefer to use a
BUILD_BUG_ON()(or similar) so we can catch any misue a build. Maybe I should write a small program that is executed at compile time?
My suggestion removes the need for EINVAL being the first entry.
Juergen
Re: [PATCH v2 1/2] public/io: xs_wire: Document that EINVAL should always be first in xsd_errors
Hi Juergen,
Quoted 40 lines · Juergen Gross
Quoted 39 lines · Julien Grall
Hi,
Quoted 35 lines · Juergen Gross
Quoted 28 lines · Julien Grall
From: Julien Grall <[email protected]>
Some tools (e.g. xenstored) always expect EINVAL to be first in
xsd_errors.Document it so, one doesn't add a new entry before hand by mistake.
Signed-off-by Julien Grall <[email protected]>----
I have tried to add a
BUILD_BUG_ON()but GCC complained that the value was not a constant. I couldn't figure out a way to make GCC happy.Changes in v2:
- New patch
---
xen/include/public/io/xs_wire.h| 1 +1 file changed, 1 insertion(+)xen/include/public/io/xs_wire.h +1
-0@@ -76,6 +76,7 @@ static struct xsd_errors xsd_errors[] __attribute__((unused)) #endif = { + /* /!\ Some users (e.g. xenstored) expect EINVAL to be theQuoted 4 lines
first entry. */
XSD_ERROR(EINVAL),
XSD_ERROR(EACCES),
XSD_ERROR(EEXIST),What about another approach, like:
Quoted 7 lines
Quoted 5 lines
In place of what? I still think we need the comment because this assumption is not part of the ABI (AFAICT
xs_wire.his meant to be stable).At which point, I see limited reason to fix
xenstored_core.c.But I would have really prefer to use a
BUILD_BUG_ON()(or similar) so we can catch any misue a build. Maybe I should write a small program that is executed at compile time?My suggestion removes the need for EINVAL being the first entry
xsd_errors[] is part of the stable ABI. If Xenstored is already "misusing" it, then I wouldn't be surprised if other software rely on this as well.
Therefore, I don't really see how fixing Xenstored would allow us to remove this restriction.
The only reason this was spotted is by Jan reviewing C Xenstored. Without that, it would have problably took a long time to notice this change (I don't think there are many other errno used by Xenstored
and xsd_errors). So I think the risk is not worth the effort.
At least, this is not a patch I would be willing to have my name on (either as a signed-off-by or acked-by).
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v2 1/2] public/io: xs_wire: Document that EINVAL should always be first in xsd_errors
Quoted 45 lines · Julien Grall
Hi Juergen,
Quoted 42 lines · Juergen Gross
Quoted 41 lines · Julien Grall
Hi,
Quoted 20 lines · Juergen Gross
Quoted 19 lines · Julien Grall
From: Julien Grall <[email protected]>
Some tools (e.g. xenstored) always expect EINVAL to be first in
xsd_errors.Document it so, one doesn't add a new entry before hand by mistake.
Signed-off-by Julien Grall <[email protected]>----
I have tried to add a
BUILD_BUG_ON()but GCC complained that the value was not a constant. I couldn't figure out a way to make GCC happy.Changes in v2:
- New patch
---
xen/include/public/io/xs_wire.h| 1 +1 file changed, 1 insertion(+)Quoted 15 lines
Quoted 9 lines
xen/include/public/io/xs_wire.h +1
-0@@ -76,6 +76,7 @@ static struct xsd_errors xsd_errors[] __attribute__((unused)) #endif = { + /* /!\ Some users (e.g. xenstored) expect EINVAL to be the firstQuoted 4 lines
entry. */
XSD_ERROR(EINVAL),
XSD_ERROR(EACCES),
XSD_ERROR(EEXIST),What about another approach, like:
In place of what? I still think we need the comment because this assumption is not part of the ABI (AFAICT
xs_wire.his meant to be stable).
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
At which point, I see limited reason to fix
xenstored_core.c.But I would have really prefer to use a
BUILD_BUG_ON()(or similar) so we can catch any misue a build. Maybe I should write a small program that is executed at compile time?My suggestion removes the need for EINVAL being the first entry
xsd_errors[] is part of the stable ABI. If Xenstored is already "misusing" it, then I wouldn't be surprised if other software rely on this as well.
Xenstored is the only instance which needs a translation from value to string, while all other users should need only the opposite direction. The only other candidate would be oxenstored, but that seems not to use xsd_errors[].
And in fact libxenstore will just return a plain EINVAL in case it can't find a translation, while hvmloader will return EIO in that case.
With your reasoning and the hvmloader use case you could argue that the EIO entry needs to stay at the same position, too.
Quoted 5 lines
Therefore, I don't really see how fixing Xenstored would allow us to remove this restriction.
The only reason this was spotted is by Jan reviewing C Xenstored. Without that, it would have problably took a long time to notice this change (I don't think there are many other errno used by Xenstored
andxsd_errors). So I think the risk is not worth the effort.
I don't see a real risk here, but if there is consensus that the risk should not be taken, then I'd rather add a comment that new entries are only allowed to be added at the end of the array.
Quoted 1 line
At least, this is not a patch I would be willing to have my name on (either as a signed-off-by or acked-by).
Fair enough. :-)
Juergen
Re: [PATCH v2 1/2] public/io: xs_wire: Document that EINVAL should always be first in xsd_errors
Hi Juergen,
Quoted 50 lines · Juergen Gross
Quoted 49 lines · Julien Grall
Hi Juergen,
Quoted 46 lines · Juergen Gross
Quoted 44 lines · Julien Grall
Hi,
Quoted 20 lines · Juergen Gross
Quoted 19 lines · Julien Grall
From: Julien Grall <[email protected]>
Some tools (e.g. xenstored) always expect EINVAL to be first in
xsd_errors.Document it so, one doesn't add a new entry before hand by mistake.
Signed-off-by Julien Grall <[email protected]>----
I have tried to add a
BUILD_BUG_ON()but GCC complained that the value was not a constant. I couldn't figure out a way to make GCC happy.Changes in v2:
- New patch
---
xen/include/public/io/xs_wire.h| 1 +1 file changed, 1 insertion(+)Quoted 15 lines
Quoted 9 lines
xen/include/public/io/xs_wire.h +1
-0@@ -76,6 +76,7 @@ static struct xsd_errors xsd_errors[] __attribute__((unused)) #endif = { + /* /!\ Some users (e.g. xenstored) expect EINVAL to be theQuoted 4 lines
first entry. */
XSD_ERROR(EINVAL),
XSD_ERROR(EACCES),
XSD_ERROR(EEXIST),What about another approach, like:
In place of what? I still think we need the comment because this assumption is not part of the ABI (AFAICT
xs_wire.his meant to be stable).At which point, I see limited reason to fix
xenstored_core.c.But I would have really prefer to use a
BUILD_BUG_ON()(or similar) so we can catch any misue a build. Maybe I should write a small program that is executed at compile time?
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
My suggestion removes the need for EINVAL being the first entry
xsd_errors[] is part of the stable ABI. If Xenstored is already "misusing" it, then I wouldn't be surprised if other software rely on this as well.
Xenstored is the only instance which needs a translation from value to string, while all other users should need only the opposite direction. The only other candidate would be oxenstored, but that seems not to use xsd_errors[].
That's assuming this is the only two implementation of Xenstored existing ;).
Quoted 5 lines
And in fact libxenstore will just return a plain EINVAL in case it can't find a translation, while hvmloader will return EIO in that case. > With your reasoning and the hvmloader use case you could argue that the EIO entry needs to stay at the same position, too.
I have looked at the hmvloader code. It doesn't seem to expect EIO to be at a specific position.
However, I do agree that it is probably best to keep each error at the same position.
Quoted 10 lines
Quoted 6 lines
Therefore, I don't really see how fixing Xenstored would allow us to remove this restriction.
The only reason this was spotted is by Jan reviewing C Xenstored. Without that, it would have problably took a long time to notice this change (I don't think there are many other errno used by Xenstored
andxsd_errors). So I think the risk is not worth the effort.I don't see a real risk here, but if there is consensus that the risk should not be taken, then I'd rather add a comment that new entries are only allowed to be added at the end of the array.
I would be fine to mandate that new errors should be added at the end of the array.
Cheersm
Signature · 1 line
Julien Grall
PATCH v2 2/2 public/io: xs_wire: Allow Xenstore to report EPERM
In reply to Julien GrallFrom: Julien Grall <[email protected]>
C Xenstored is using EPERM when the client is not allowed to change the owner (see GET_PERMS). However, the xenstore protocol doesn't describe EPERM so EINVAL will be sent to the client.
When writing test, it would be useful to differentiate between EINVAL (e.g. parsing error) and EPERM (i.e. no permission). So extend xsd_errors[] to support return EPERM.
Looking at previous time xsd_errors was extended (8b2c441a1b), it was considered to be safe to add a new error because at least Linux driver and libxenstore treat an unknown error code as EINVAL.
This statement doesn't cover other possible OSes, however I am not aware of any breakage.
----
Changes in v2:
- Define EPERM at the end of xsd_errors
--- xen/include/public/io/xs_wire.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
xen/include/public/io/xs_wire.h +2 -1
@@ -91,7 +91,8 @@ __attribute__((unused))XSD_ERROR (EBUSY ),XSD_ERROR (EAGAIN ),XSD_ERROR (EISCONN ), -XSD_ERROR (E2BIG ) +XSD_ERROR (E2BIG ), + XSD_ERROR(EPERM), };#endif
Signature · 1 line
2.32.0
Quoted 10 lines · Julien Grall
From: Julien Grall <[email protected]>
C Xenstored is using EPERM when the client is not allowed to change the owner (see
GET_PERMS). However, the xenstore protocol doesn't describe EPERM so EINVAL will be sent to the client.When writing test, it would be useful to differentiate between EINVAL (e.g. parsing error) and EPERM (i.e. no permission). So extend xsd_errors[] to support return EPERM.
Quoted 8 lines
Looking at previous time
xsd_errorswas extended (8b2c441a1b), it was considered to be safe to add a new error because at least Linux driver and libxenstore treat an unknown error code as EINVAL.This statement doesn't cover other possible OSes, however I am not aware of any breakage.
Signed-off-by Julien Grall <[email protected]>
Juergen
Hi Juergen,
Quoted 15 lines · Juergen Gross
Quoted 14 lines · Julien Grall
From: Julien Grall <[email protected]>
C Xenstored is using EPERM when the client is not allowed to change the owner (see
GET_PERMS). However, the xenstore protocol doesn't describe EPERM so EINVAL will be sent to the client.When writing test, it would be useful to differentiate between EINVAL (e.g. parsing error) and EPERM (i.e. no permission). So extend xsd_errors[] to support return EPERM.
Looking at previous time
xsd_errorswas extended (8b2c441a1b), it was considered to be safe to add a new error because at least Linux driver and libxenstore treat an unknown error code as EINVAL.
Quoted 6 lines
Quoted 4 lines
This statement doesn't cover other possible OSes, however I am not aware of any breakage.
Signed-off-by Julien Grall <[email protected]>Reviewed-by Juergen Gross <[email protected]>
Thanks. I have committed this patch and respin the first one.
Cheers,
Signature · 1 line
Julien Grall