Skip to contentSkip to conversation

tools/oxenstored: Fix | vs & error in fd event handling

PATCH Applied Andrew Cooper 5 participants 10 messages Nov 26, 2014 – Nov 28, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/oxenstored: Fix | vs & error in fd event handling

This makes fields 0 and 1 true more often than they should be, resulting problems when handling events.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Dave Scott <[email protected]>
CC Zheng Li <[email protected]>
CC Konrad Rzeszutek Wilk <[email protected]>

---

This was discovered with XenServers internal Coverity instance. I have yet to work out why the issue is not identified by the upstream coverity scanning.

Konrad: This is a bug in the default event handling used by oxenstored in 4.5, as the default switched from select() to poll() in the 4.5 timeframe. It would appear that the negative side effects are limited to just logspam about certain clients attempting invalid actions, but I can't rule out anything more problematic.

---
 tools/ocaml/xenstored/select_stubs.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/ocaml/xenstored/select_stubs.c +2 -2
index 4a8edb5..af72b84 100644
@@ -56,8 +56,8 @@ CAMLprim value stub_select_on_poll(value fd_events, value timeo) {
 			events = Field(Field(fd_events, i), 1);
 
 			if (c_fds[i].revents & POLLNVAL) unix_error(EBADF, "select", Nothing);
-			Field(events, 0) = Val_bool(c_fds[i].events | POLLIN  && c_fds[i].revents & (POLLIN |POLLHUP|POLLERR));
-			Field(events, 1) = Val_bool(c_fds[i].events | POLLOUT && c_fds[i].revents & (POLLOUT|POLLHUP|POLLERR));
+			Field(events, 0) = Val_bool(c_fds[i].events & POLLIN  && c_fds[i].revents & (POLLIN |POLLHUP|POLLERR));
+			Field(events, 1) = Val_bool(c_fds[i].events & POLLOUT && c_fds[i].revents & (POLLOUT|POLLHUP|POLLERR));
 			Field(events, 2) = Val_bool(c_fds[i].revents & POLLPRI);
 
 		}
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw
Quoted 2 lines · Andrew Cooper

This makes fields 0 and 1 true more often than they should be, resulting problems when handling events.

Indeed, looks like a mistake I made when rewriting the logic terms lately. The result is POLLUP or POLLERR events being returned in more categories than we'd interest. Thanks for fixing this!

Cheers,
Zheng

Quoted 30 lines

---

This was discovered with XenServers internal Coverity instance. I have yet to work out why the issue is not identified by the upstream coverity scanning.

Konrad: This is a bug in the default event handling used by oxenstored in 4.5, as the default switched from select() to poll() in the 4.5 timeframe. It would appear that the negative side effects are limited to just logspam about certain clients attempting invalid actions, but I can't rule out anything more problematic.

---
  tools/ocaml/xenstored/select_stubs.c |    4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
tools/ocaml/xenstored/select_stubs.c +2 -2
index 4a8edb5..af72b84 100644
@@ -56,8 +56,8 @@ CAMLprim value stub_select_on_poll(value fd_events, value timeo) {
  			events = Field(Field(fd_events, i), 1);
 
  			if (c_fds[i].revents & POLLNVAL) unix_error(EBADF, "select", Nothing);
-			Field(events, 0) = Val_bool(c_fds[i].events | POLLIN  && c_fds[i].revents & (POLLIN |POLLHUP|POLLERR));
-			Field(events, 1) = Val_bool(c_fds[i].events | POLLOUT && c_fds[i].revents & (POLLOUT|POLLHUP|POLLERR));
+			Field(events, 0) = Val_bool(c_fds[i].events & POLLIN  && c_fds[i].revents & (POLLIN |POLLHUP|POLLERR));
+			Field(events, 1) = Val_bool(c_fds[i].events & POLLOUT && c_fds[i].revents & (POLLOUT|POLLHUP|POLLERR));
  			Field(events, 2) = Val_bool(c_fds[i].revents & POLLPRI);
 
  		}
Acked-by
#2 lore raw
Quoted 10 lines · Zheng Li
Quoted 2 lines · Andrew Cooper

This makes fields 0 and 1 true more often than they should be, resulting problems when handling events.

Indeed, looks like a mistake I made when rewriting the logic terms lately. The result is POLLUP or POLLERR events being returned in more categories than we'd interest. Thanks for fixing this!

This also looks fine to me

Cheers,
Dave

Quoted 36 lines

Cheers,
Zheng

Quoted 30 lines

---

This was discovered with XenServers internal Coverity instance. I have yet to work out why the issue is not identified by the upstream coverity scanning.

Konrad: This is a bug in the default event handling used by oxenstored in 4.5, as the default switched from select() to poll() in the 4.5 timeframe. It would appear that the negative side effects are limited to just logspam about certain clients attempting invalid actions, but I can't rule out anything more problematic.

---
 tools/ocaml/xenstored/select_stubs.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/ocaml/xenstored/select_stubs.c +2 -2
index 4a8edb5..af72b84 100644
@@ -56,8 +56,8 @@ CAMLprim value stub_select_on_poll(value fd_events, value timeo) {
 			events = Field(Field(fd_events, i), 1);
 
 			if (c_fds[i].revents & POLLNVAL) unix_error(EBADF, "select", Nothing);
-			Field(events, 0) = Val_bool(c_fds[i].events | POLLIN  && c_fds[i].revents & (POLLIN |POLLHUP|POLLERR));
-			Field(events, 1) = Val_bool(c_fds[i].events | POLLOUT && c_fds[i].revents & (POLLOUT|POLLHUP|POLLERR));
+			Field(events, 0) = Val_bool(c_fds[i].events & POLLIN  && c_fds[i].revents & (POLLIN |POLLHUP|POLLERR));
+			Field(events, 1) = Val_bool(c_fds[i].events & POLLOUT && c_fds[i].revents & (POLLOUT|POLLHUP|POLLERR));
 			Field(events, 2) = Val_bool(c_fds[i].revents & POLLPRI);
 
 		}
#3 lore raw
Quoted 7 lines · Dave Scott
Quoted 7 lines · Zheng Li
Quoted 2 lines · Andrew Cooper

This makes fields 0 and 1 true more often than they should be, resulting problems when handling events.

Quoted 7 lines
Quoted 3 lines

Indeed, looks like a mistake I made when rewriting the logic terms lately. The result is POLLUP or POLLERR events being returned in more categories than we'd interest. Thanks for fixing this!

This also looks fine to me

Would it be possible to get an Reviewed-by please?

Thank you.

Quoted 41 lines

Cheers,
Dave

Quoted 36 lines

Cheers,
Zheng

Quoted 30 lines

---

This was discovered with XenServers internal Coverity instance. I have yet to work out why the issue is not identified by the upstream coverity scanning.

Konrad: This is a bug in the default event handling used by oxenstored in 4.5, as the default switched from select() to poll() in the 4.5 timeframe. It would appear that the negative side effects are limited to just logspam about certain clients attempting invalid actions, but I can't rule out anything more problematic.

---
 tools/ocaml/xenstored/select_stubs.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/ocaml/xenstored/select_stubs.c +2 -2
index 4a8edb5..af72b84 100644
@@ -56,8 +56,8 @@ CAMLprim value stub_select_on_poll(value fd_events, value timeo) {
 			events = Field(Field(fd_events, i), 1);
 
 			if (c_fds[i].revents & POLLNVAL) unix_error(EBADF, "select", Nothing);
-			Field(events, 0) = Val_bool(c_fds[i].events | POLLIN  && c_fds[i].revents & (POLLIN |POLLHUP|POLLERR));
-			Field(events, 1) = Val_bool(c_fds[i].events | POLLOUT && c_fds[i].revents & (POLLOUT|POLLHUP|POLLERR));
+			Field(events, 0) = Val_bool(c_fds[i].events & POLLIN  && c_fds[i].revents & (POLLIN |POLLHUP|POLLERR));
+			Field(events, 1) = Val_bool(c_fds[i].events & POLLOUT && c_fds[i].revents & (POLLOUT|POLLHUP|POLLERR));
 			Field(events, 2) = Val_bool(c_fds[i].revents & POLLPRI);
 
 		}
#4 lore raw
Quoted 6 lines · Konrad Rzeszutek Wilk
Quoted 5 lines · Dave Scott
Quoted 5 lines · Zheng Li
Quoted 2 lines · Andrew Cooper

This makes fields 0 and 1 true more often than they should be, resulting problems when handling events.

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

Indeed, looks like a mistake I made when rewriting the logic terms lately. The result is POLLUP or POLLERR events being returned in more categories than we'd interest. Thanks for fixing this!

This also looks fine to me

Would it be possible to get an Reviewed-by please?

Strictly speaking Zheng, not being a maintainer, can't ack the patch, given what I believe to be Xens current rules for these things. However, as the author of the code and comment in this thread, his ack can reasonably be considered equivalent to a Reviewed-by: I guess this is just a matter of semantics.

Furthermore, as we all share an office, I have already been through this process informally, and have confirmed the fix under my Xen-4.5 based XenServer branch. There appear to be 100% less "error -EINVAL" messages in the logs.

~Andrew

Reviewed-by
#5 lore raw
Quoted 11 lines · Andrew Cooper

Strictly speaking Zheng, not being a maintainer, can't ack the patch, given what I believe to be Xens current rules for these things. However, as the author of the code and comment in this thread, his ack can reasonably be considered equivalent to a Reviewed-by: I guess this is just a matter of semantics.

Furthermore, as we all share an office, I have already been through this process informally, and have confirmed the fix under my Xen-4.5 based XenServer branch. There appear to be 100% less "error -EINVAL" messages in the logs.

Agreed. I was a bit confused by the "XXX-by" semantics. As Andy mentioned, he already went through the patch with me offline, so here is the line if more appropriate:

Thanks,
Zheng

#6 lore raw
In reply to Andrew Cooper
Quoted 12 lines · Andrew Cooper
Quoted 11 lines · Konrad Rzeszutek Wilk
Quoted 10 lines · Dave Scott
Quoted 8 lines · Zheng Li
Quoted 2 lines · Andrew Cooper

This makes fields 0 and 1 true more often than they should be, resulting problems when handling events.

Indeed, looks like a mistake I made when rewriting the logic terms lately. The result is POLLUP or POLLERR events being returned in more categories than we'd interest. Thanks for fixing this!

This also looks fine to me

Quoted 8 lines
Quoted 2 lines
Quoted 1 line

Would it be possible to get an Reviewed-by please?

Strictly speaking Zheng, not being a maintainer, can't ack the patch, given what I believe to be Xens current rules for these things. However, as the author of the code and comment in this thread, his ack can reasonably be considered equivalent to a Reviewed-by: I guess this is just a matter of semantics.

In theory/According to
https://www.kernel.org/doc/Documentation/SubmittingPatches Reviewed-by "indicates that the patch has been reviewed and found acceptable according to the Reviewer's Statement:

Reviewer's statement of oversight

By offering my Reviewed-by: tag, I state that:

(a) I have carried out a technical review of this patch to evaluate its appropriateness and readiness for inclusion into the mainline kernel.

(b) Any problems, concerns, or questions relating to the patch have been communicated back to the submitter. I am satisfied with the submitter's response to my comments.

(c) While there may be things that could be improved with this submission, I believe that it is, at this time, (1) a worthwhile modification to the kernel, and (2) free of known issues which would argue against its inclusion.

(d) While I have reviewed the patch and believe it to be sound, I do not (unless explicitly stated elsewhere) make any warranties or guarantees that it will achieve its stated purpose or function properly in any given situation.

Whereas Acked-by is just an indication of no-objections or fine-by-me from the maintainer or possibly a previous reviewer indicating that their previous concerns have been removed.

That said when they come from someone relevant to the code at hand (as e.g. Zheng is here) personally I mostly treat them the same (and I pretty much always say Acked-by not Reviewed-by because my fingers just do that by default). I think there are others in the project who do treat them as distinct.

All in all I think it's safe to say that the XenProject neither implements any distinction in a very strict way in practice nor has a very consistent view on the differences between them. Personally I don't think the distinction really matters a great deal and we have more than enough rules and process as it is without getting too worked up about Acked vs Reviewed by.

Ian.

Reviewed-by
#7 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 13 lines · Konrad Rzeszutek Wilk
Quoted 9 lines · Dave Scott
Quoted 9 lines · Zheng Li
Quoted 2 lines · Andrew Cooper

This makes fields 0 and 1 true more often than they should be, resulting problems when handling events.

Indeed, looks like a mistake I made when rewriting the logic terms lately. The result is POLLUP or POLLERR events being returned in more categories than we'd interest. Thanks for fixing this!

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

This also looks fine to me

Would it be possible to get an Reviewed-by please?

I’ll certainly offer

Cheers,
Dave

Quoted 40 lines

Thank you.

Quoted 38 lines

Cheers,
Dave

Quoted 34 lines

Cheers,
Zheng

Quoted 28 lines

---

This was discovered with XenServers internal Coverity instance. I have yet to work out why the issue is not identified by the upstream coverity scanning.

Konrad: This is a bug in the default event handling used by oxenstored in 4.5, as the default switched from select() to poll() in the 4.5 timeframe. It would appear that the negative side effects are limited to just logspam about certain clients attempting invalid actions, but I can't rule out anything more problematic.
---
tools/ocaml/xenstored/select_stubs.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
tools/ocaml/xenstored/select_stubs.c +2 -2
index 4a8edb5..af72b84 100644
@@ -56,8 +56,8 @@ CAMLprim value stub_select_on_poll(value fd_events, value timeo) {
 			events = Field(Field(fd_events, i), 1);
 
 			if (c_fds[i].revents & POLLNVAL) unix_error(EBADF, "select", Nothing);
-			Field(events, 0) = Val_bool(c_fds[i].events | POLLIN  && c_fds[i].revents & (POLLIN |POLLHUP|POLLERR));
-			Field(events, 1) = Val_bool(c_fds[i].events | POLLOUT && c_fds[i].revents & (POLLOUT|POLLHUP|POLLERR));
+			Field(events, 0) = Val_bool(c_fds[i].events & POLLIN  && c_fds[i].revents & (POLLIN |POLLHUP|POLLERR));
+			Field(events, 1) = Val_bool(c_fds[i].events & POLLOUT && c_fds[i].revents & (POLLOUT|POLLHUP|POLLERR));
 			Field(events, 2) = Val_bool(c_fds[i].revents & POLLPRI);
 
Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

tools/ocaml/xenstored/select_stubs.c CAMLprim value stub_select_on_poll(value fd_events, value timeo) { · line 63

Quoted 2 lines
tools/ocaml/xenstored/select_stubs.c +0 -0
 		}

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#8 lore raw
Quoted 17 lines · Dave Scott
Quoted 17 lines · Konrad Rzeszutek Wilk
Quoted 13 lines · Dave Scott
Quoted 10 lines · Zheng Li
Quoted 2 lines · Andrew Cooper

This makes fields 0 and 1 true more often than they should be, resulting problems when handling events.

Indeed, looks like a mistake I made when rewriting the logic terms lately. The result is POLLUP or POLLERR events being returned in more categories than we'd interest. Thanks for fixing this!

This also looks fine to me

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Would it be possible to get an Reviewed-by please?

I’ll certainly offer

OK, Release-Acked-by: Konrad Rzeszutek Wilk <[email protected]>

Thank you.

Quoted 53 lines

Cheers,
Dave

Quoted 48 lines

Thank you.

Quoted 38 lines

Cheers,
Dave

Quoted 34 lines

Cheers,
Zheng

Quoted 28 lines

---

This was discovered with XenServers internal Coverity instance. I have yet to work out why the issue is not identified by the upstream coverity scanning.

Konrad: This is a bug in the default event handling used by oxenstored in 4.5, as the default switched from select() to poll() in the 4.5 timeframe. It would appear that the negative side effects are limited to just logspam about certain clients attempting invalid actions, but I can't rule out anything more problematic.
---
tools/ocaml/xenstored/select_stubs.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
tools/ocaml/xenstored/select_stubs.c +2 -2
index 4a8edb5..af72b84 100644
@@ -56,8 +56,8 @@ CAMLprim value stub_select_on_poll(value fd_events, value timeo) {
 			events = Field(Field(fd_events, i), 1);
 
 			if (c_fds[i].revents & POLLNVAL) unix_error(EBADF, "select", Nothing);
-			Field(events, 0) = Val_bool(c_fds[i].events | POLLIN  && c_fds[i].revents & (POLLIN |POLLHUP|POLLERR));
-			Field(events, 1) = Val_bool(c_fds[i].events | POLLOUT && c_fds[i].revents & (POLLOUT|POLLHUP|POLLERR));
+			Field(events, 0) = Val_bool(c_fds[i].events & POLLIN  && c_fds[i].revents & (POLLIN |POLLHUP|POLLERR));
+			Field(events, 1) = Val_bool(c_fds[i].events & POLLOUT && c_fds[i].revents & (POLLOUT|POLLHUP|POLLERR));
 			Field(events, 2) = Val_bool(c_fds[i].revents & POLLPRI);
 
Quoted 3 lines
Quoted 2 lines

tools/ocaml/xenstored/select_stubs.c CAMLprim value stub_select_on_poll(value fd_events, value timeo) { · line 63

Quoted 2 lines
tools/ocaml/xenstored/select_stubs.c +0 -0
 		}

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Applied
#9 lore raw
Quoted 20 lines · Konrad Rzeszutek Wilk
Quoted 19 lines · Dave Scott
Quoted 19 lines · Konrad Rzeszutek Wilk
Quoted 14 lines · Dave Scott
Quoted 10 lines · Zheng Li
Quoted 2 lines · Andrew Cooper

This makes fields 0 and 1 true more often than they should be, resulting problems when handling events.

Indeed, looks like a mistake I made when rewriting the logic terms lately. The result is POLLUP or POLLERR events being returned in more categories than we'd interest. Thanks for fixing this!

This also looks fine to me

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Would it be possible to get an Reviewed-by please?

I’ll certainly offer

OK, Release-Acked-by: Konrad Rzeszutek Wilk <[email protected]>

Applied, thanks.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel