docs/misc/xenstore.txt minor fixes
PATCH 1/1 docs/misc/xenstore.txt minor fixes
Steven Smith has pointed out a few minor errors and provided some more information about the behaviour of old xenstoreds. I've documented the relevant facts, as I understand them, in the attached documentation patch.
I'm going to follow this up with another patch about size limits for xenstore messages.
Ian.
docs/misc/xenstore.txt +13 -7
@@ -174,6 +174,17 @@ WATCH <wpath>|<token>|? away, with <path> equal to <wpath>. Watches may be triggered spuriously. The tx_id in a WATCH request is ignored. + Watches are supposed to be restricted by the permissions + system but in practice the implementation is imperfect. + Applications should not rely on being sent a notification for + paths that they cannot read; however, an application may rely + on being sent a watch when a path which it _is_ able to read + is deleted even if that leaves only a nonexistent unreadable + parent. A notification may omitted if a node's permissions + are changed so as to make it unreadable, in which case future + notifications may be suppressed (and if the node is later made + readable, some notifications may have been lost). + WATCH_EVENT <epath>|<token>| Unsolicited `reply' generated for matching modfication events as described above. req_id and tx_id are both 0.
@@ -182,7 +193,7 @@ WATCH_EVENT <epath>|<token>| modifed; however if the event was the recursive removal of an parent of <wpath>, <epath> is just <wpath> (rather than the actual path which was removed). So - <epath> is a child of <epath>, regardless. + <epath> is a child of <wpath>, regardless. Iff <wpath> for the watch was specified as a relative pathname, the <epath> path will also be relative (with the same base,
@@ -192,7 +203,7 @@ UNWATCH <wpath>|<token>|? ---------- Transactions ---------- -TRANSACTION_START ?? <transid>| +TRANSACTION_START | <transid>| <transid> is an opaque uint32_t allocated by xenstored represented as unsigned decimal. After this, transaction may be referenced by using <transid> (as 32-bit binary) in the
@@ -202,11 +213,6 @@ TRANSACTION_START ?? <transid>| Currently xenstored has the bug that after 2^32 transactions it will allocate the transid 0 for an actual transaction. - Clients using the provided xs.c bindings will send a single - nul byte for the argument payload. We recommend that future - clients continue to do the same; any future extension will not - use that syntax. - TRANSACTION_END T| TRANSACTION_END F| tx_id must refer to existing transaction. After this
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
PATCH 1/1 xenstore size limits
I wrote ("[PATCH] docs/misc/xenstore.txt minor fixes"):
Quoted 2 lines
I'm going to follow this up with another patch about size limits for xenstore messages.
The patch below:
* Documents the existing 4kby size limit on xenstore message payloads
* Causes xs.c in libxenstore to fail locally rather than violating said limit (which is good because xenstored kills the client connection if it's exceeded).
* Introduces some limits on path lengths in xenstored. I trust no-one is using path lengths >2kby. This is good because currently a domain client can create a 4kby relative path that the dom0 tools cannot access since they'd have to specify the somewhat longer absolute path.
* Removes uses of the host's PATH_MAX (!)
docs/misc/xenstore.txt +17 -1
@@ -38,7 +38,9 @@ the four punctuation characters -/_@ (hy the four punctuation characters -/_@ (hyphen slash underscore atsign). @ should be avoided except to specify special watches (see below). Doubled slashes and trailing slashes (except to specify the root) are -forbidden. The empty path is also forbidden. +forbidden. The empty path is also forbidden. Paths longer than 3072 +bytes are forbidden; clients specifying relative paths should keep +them to within 2048 bytes. (See XENSTORE_*_PATH_MAX in xs_wire.h.) Communication with xenstore is via either sockets, or event channel
@@ -55,6 +57,20 @@ order and must use req_id (and tx_id, if order and must use req_id (and tx_id, if applicable) to match up replies to requests. (The current implementation always replies to requests in the order received but this should not be relied on.) + +The payload length (len field of the header) is limited to 4096 +(XENSTORE_PAYLOAD_MAX) in both directions. If a client exceeds the +limit, its xenstored connection will be immediately killed by +xenstored, which is usually catastrophic from the client's point of +view. Clients (particularly domains, which cannot just reconnect) +should avoid this. + +Existing clients do not always contain defences against overly long +payloads. Increasing xenstored's limit is therefore difficult; it +would require negotiation with the client, and obviously would make +parts of xenstore inaccessible to some clients. In any case passing +bulk data through xenstore is not recommended as the performance +properties are poor. ---------- Xenstore protocol details - introduction ----------
tools/xenstore/xenstored_core.c +4 -1
@@ -672,6 +672,9 @@ bool is_valid_nodename(const char *node)if (strstr (node,"//" ))return false; +if (strlen (node) >XENSTORE_ABS_PATH_MAX ) +return false; +return valid_chars (node); }
@@ -1281,7 +1284,7 @@ static void handle_input(struct connectiif (in->used !=sizeof (in->hdr))return ; -if (in->hdr.msg.len >PATH_MAX ) { +if (in->hdr.msg.len >XENSTORE_PAYLOAD_MAX ) {syslog (LOG_ERR ,"Client tried to feed us %i" , in->hdr.msg.len); goto bad_client;
tools/xenstore/xenstored_watch.c +4 -0
@@ -125,6 +125,10 @@ void do_watch(struct connection *conn, sif (strstarts (vec[0 ],"@" )) { relative = false; +if (strlen (vec[0 ]) >XENSTORE_REL_PATH_MAX ) { +send_error (conn,EINVAL ); +return ; + }/* check if valid event */ }else { relative = !strstarts (vec[0 ],"/" );
tools/xenstore/xs.c +5 -0
@@ -319,6 +319,11 @@ static void *xs_talkv(struct xs_handle *for (i =0 ; i < num_vecs; i++) msg.len += iovec[i].iov_len; +if (msg.len >XENSTORE_PAYLOAD_MAX ) { + errno =E2BIG ; +return 0 ; + } + ignorepipe.sa_handler =SIG_IGN ;sigemptyset (&ignorepipe.sa_mask); ignorepipe.sa_flags =0 ;
tools/xenstore/xsls.c +1 -1
@@ -8,7 +8,7 @@#include <sys/ioctl.h> #include <termios.h> -#define STRING_MAX PATH_MAX +#define STRING_MAX XENSTORE_ABS_PATH_MAX+1024static int max_width =80 ;static int desired_width =60 ;static int show_whole_path =0 ;
xen/include/public/io/xs_wire.h +7 -0
@@ -108,6 +108,13 @@ struct xenstore_domain_interface { XENSTORE_RING_IDX rsp_cons, rsp_prod; }; +#define XENSTORE_PAYLOAD_MAX 4096 +/* Violating this is very bad. See docs/misc/xenstore.txt. */ + +#define XENSTORE_ABS_PATH_MAX 3072 +#define XENSTORE_REL_PATH_MAX 2048 +/* Violating these just gets you an error back */ +#endif /* _XS_WIRE_H */ /*
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel