From nobody Thu May 16 13:01:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1690194848; cv=none; d=zohomail.com; s=zohoarc; b=gG/x3EgjmgmlSGFwJV5nPW5/CBacoJgG1jclUDex5NhOuxr/ykrPI/00EAbugbLZrnE+HvSVHyuJeaUrlqxH8sQ5cnd2CCcaLv4VjKFx5GWOB5HRaaGWZdJFn1SkEWBdlYJ3WzCBQZubqjvnWnNTvMoK3ENZcbNU/Ai2wo4ms98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690194848; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QztVVey2YoDwROHqqVV26V6sbdHLNr1pk8Dham/+sKc=; b=iHNSzVg7VQHTlu+VWdhxmQKMZKUHKT0UCc0GByp0qzY8fW9vCnhhNhaFYX82/GriopZuwU1WKIk6WAFDr5Q+a8WPuOAbH3MTTy2aOwivXNTaqkkTHBqjcUYftQhObm6IU7e3gAR2CesDVu4jvFFLu8Q1QQB0teZKpAa2+z4mC3g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690194848127744.1036058812666; Mon, 24 Jul 2023 03:34:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.568717.888524 (Exim 4.92) (envelope-from ) id 1qNssh-0003Ii-5j; Mon, 24 Jul 2023 10:33:35 +0000 Received: by outflank-mailman (output) from mailman id 568717.888524; Mon, 24 Jul 2023 10:33:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qNssh-0003IW-16; Mon, 24 Jul 2023 10:33:35 +0000 Received: by outflank-mailman (input) for mailman id 568717; Mon, 24 Jul 2023 10:33:34 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qNssf-00031Q-Sl for xen-devel@lists.xenproject.org; Mon, 24 Jul 2023 10:33:34 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 89b2cb80-2a0d-11ee-b23a-6b7b168915f2; Mon, 24 Jul 2023 12:33:32 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9934820665; Mon, 24 Jul 2023 10:33:32 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6A849138E8; Mon, 24 Jul 2023 10:33:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GMJQGHxTvmR0UAAAMHmgww (envelope-from ); Mon, 24 Jul 2023 10:33:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 89b2cb80-2a0d-11ee-b23a-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1690194812; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QztVVey2YoDwROHqqVV26V6sbdHLNr1pk8Dham/+sKc=; b=cLneK8POTES+WRVwOCQkrwj+rrLBR86cUux8d7OfyKkgvypopcr8qraUjAlhjJMh0dcfLH ReWg6z6NFjlOnUQqxuSogp3c0QsJ1lezCwIJgY/LBdR3Cx8JwwQttTYv6QBaRgdTO0DCnk ZJ3IzSbzZl0+z0nH/GBmX0Duy9Qgzlk= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD Subject: [PATCH v3 1/2] tools/xenstore: add const to the return type of canonicalize() Date: Mon, 24 Jul 2023 12:33:23 +0200 Message-Id: <20230724103324.4207-2-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230724103324.4207-1-jgross@suse.com> References: <20230724103324.4207-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1690194849089100001 Content-Type: text/plain; charset="utf-8" The return type of canonicalize() can be modified to const char *. This avoids the need to cast the const away from the input parameter. There need to be quite some other functions modified to take const parameters in order to avoid further casts. Signed-off-by: Juergen Gross Reviewed-by: Julien Grall --- V2: - new patch (Julien Grall) V3: - add get_strings() conversion to take const pointer (Julien Grall) --- tools/xenstore/xenstored_control.c | 33 ++++++++++++++-------------- tools/xenstore/xenstored_core.c | 26 ++++++++++++---------- tools/xenstore/xenstored_core.h | 5 +++-- tools/xenstore/xenstored_domain.c | 4 ++-- tools/xenstore/xenstored_lu.c | 2 +- tools/xenstore/xenstored_lu.h | 4 ++-- tools/xenstore/xenstored_lu_daemon.c | 2 +- tools/xenstore/xenstored_lu_minios.c | 2 +- tools/xenstore/xenstored_watch.c | 14 +++++++----- 9 files changed, 49 insertions(+), 43 deletions(-) diff --git a/tools/xenstore/xenstored_control.c b/tools/xenstore/xenstored_= control.c index 145a0e5aff..3bdf2edc34 100644 --- a/tools/xenstore/xenstored_control.c +++ b/tools/xenstore/xenstored_control.c @@ -34,7 +34,7 @@ =20 struct cmd_s { char *cmd; - int (*func)(const void *, struct connection *, char **, int); + int (*func)(const void *, struct connection *, const char **, int); char *pars; /* * max_pars can be used to limit the size of the parameter vector, @@ -47,7 +47,7 @@ struct cmd_s { }; =20 static int do_control_check(const void *ctx, struct connection *conn, - char **vec, int num) + const char **vec, int num) { if (num) return EINVAL; @@ -59,7 +59,7 @@ static int do_control_check(const void *ctx, struct conne= ction *conn, } =20 static int do_control_log(const void *ctx, struct connection *conn, - char **vec, int num) + const char **vec, int num) { int ret; =20 @@ -126,7 +126,7 @@ static int quota_show_current(const void *ctx, struct c= onnection *conn, } =20 static int quota_set(const void *ctx, struct connection *conn, - char **vec, int num, struct quota *quotas) + const char **vec, int num, struct quota *quotas) { unsigned int i; int val; @@ -150,7 +150,7 @@ static int quota_set(const void *ctx, struct connection= *conn, } =20 static int quota_get(const void *ctx, struct connection *conn, - char **vec, int num) + const char **vec, int num) { if (num !=3D 1) return EINVAL; @@ -159,7 +159,7 @@ static int quota_get(const void *ctx, struct connection= *conn, } =20 static int quota_max(const void *ctx, struct connection *conn, - char **vec, int num) + const char **vec, int num) { if (num > 1) return EINVAL; @@ -175,7 +175,7 @@ static int quota_max(const void *ctx, struct connection= *conn, } =20 static int do_control_quota(const void *ctx, struct connection *conn, - char **vec, int num) + const char **vec, int num) { if (num =3D=3D 0) return quota_show_current(ctx, conn, hard_quotas); @@ -190,7 +190,7 @@ static int do_control_quota(const void *ctx, struct con= nection *conn, } =20 static int do_control_quota_s(const void *ctx, struct connection *conn, - char **vec, int num) + const char **vec, int num) { if (num =3D=3D 0) return quota_show_current(ctx, conn, soft_quotas); @@ -203,7 +203,7 @@ static int do_control_quota_s(const void *ctx, struct c= onnection *conn, =20 #ifdef __MINIOS__ static int do_control_memreport(const void *ctx, struct connection *conn, - char **vec, int num) + const char **vec, int num) { if (num) return EINVAL; @@ -215,7 +215,7 @@ static int do_control_memreport(const void *ctx, struct= connection *conn, } #else static int do_control_logfile(const void *ctx, struct connection *conn, - char **vec, int num) + const char **vec, int num) { if (num !=3D 1) return EINVAL; @@ -230,7 +230,7 @@ static int do_control_logfile(const void *ctx, struct c= onnection *conn, } =20 static int do_control_memreport(const void *ctx, struct connection *conn, - char **vec, int num) + const char **vec, int num) { FILE *fp; int fd; @@ -270,7 +270,7 @@ static int do_control_memreport(const void *ctx, struct= connection *conn, #endif =20 static int do_control_print(const void *ctx, struct connection *conn, - char **vec, int num) + const char **vec, int num) { if (num !=3D 1) return EINVAL; @@ -281,7 +281,8 @@ static int do_control_print(const void *ctx, struct con= nection *conn, return 0; } =20 -static int do_control_help(const void *, struct connection *, char **, int= ); +static int do_control_help(const void *, struct connection *, const char *= *, + int); =20 static struct cmd_s cmds[] =3D { { "check", do_control_check, "" }, @@ -322,7 +323,7 @@ static struct cmd_s cmds[] =3D { }; =20 static int do_control_help(const void *ctx, struct connection *conn, - char **vec, int num) + const char **vec, int num) { int cmd; char *resp; @@ -348,7 +349,7 @@ int do_control(const void *ctx, struct connection *conn, struct buffered_data *in) { unsigned int cmd, num, off; - char **vec =3D NULL; + const char **vec =3D NULL; =20 if (domain_is_unprivileged(conn)) return EACCES; @@ -365,7 +366,7 @@ int do_control(const void *ctx, struct connection *conn, num =3D xenstore_count_strings(in->buffer, in->used); if (cmds[cmd].max_pars) num =3D min(num, cmds[cmd].max_pars); - vec =3D talloc_array(ctx, char *, num); + vec =3D (const char **)talloc_array(ctx, char *, num); if (!vec) return ENOMEM; if (get_strings(in, vec, num) < num) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_cor= e.c index a1d3047e48..6d27b2dd7f 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -994,7 +994,7 @@ unsigned int get_string(const struct buffered_data *dat= a, unsigned int offset) * ignore any data after the final nul. */ unsigned int get_strings(struct buffered_data *data, - char *vec[], unsigned int num) + const char *vec[], unsigned int num) { unsigned int off, i, len; =20 @@ -1216,25 +1216,26 @@ static char *perms_to_strings(const void *ctx, cons= t struct node_perms *perms, return strings; } =20 -char *canonicalize(struct connection *conn, const void *ctx, const char *n= ode) +const char *canonicalize(struct connection *conn, const void *ctx, + const char *node) { const char *prefix; =20 if (!node || (node[0] =3D=3D '/') || (node[0] =3D=3D '@')) - return (char *)node; + return node; prefix =3D get_implicit_path(conn); if (prefix) return talloc_asprintf(ctx, "%s/%s", prefix, node); - return (char *)node; + return node; } =20 static struct node *get_node_canonicalized(struct connection *conn, const void *ctx, const char *name, - char **canonical_name, + const char **canonical_name, unsigned int perm) { - char *tmp_name; + const char *tmp_name; =20 if (!canonical_name) canonical_name =3D &tmp_name; @@ -1249,7 +1250,7 @@ static struct node *get_node_canonicalized(struct con= nection *conn, } =20 static struct node *get_spec_node(struct connection *conn, const void *ctx, - const char *name, char **canonical_name, + const char *name, const char **canonical_name, unsigned int perm) { if (name[0] =3D=3D '@') @@ -1538,8 +1539,8 @@ static int do_write(const void *ctx, struct connectio= n *conn, { unsigned int offset, datalen; struct node *node; - char *vec[1] =3D { NULL }; /* gcc4 + -W + -Werror fucks code. */ - char *name; + const char *vec[1] =3D { NULL }; /* gcc4 + -W + -Werror fucks code. */ + const char *name; =20 /* Extra "strings" can be created by binary data. */ if (get_strings(in, vec, ARRAY_SIZE(vec)) < ARRAY_SIZE(vec)) @@ -1574,7 +1575,7 @@ static int do_mkdir(const void *ctx, struct connectio= n *conn, struct buffered_data *in) { struct node *node; - char *name; + const char *name; =20 node =3D get_node_canonicalized(conn, ctx, onearg(in), &name, XS_PERM_WRITE); @@ -1703,7 +1704,7 @@ static int do_rm(const void *ctx, struct connection *= conn, { struct node *node; int ret; - char *name; + const char *name; char *parentname; =20 node =3D get_node_canonicalized(conn, ctx, onearg(in), &name, @@ -1765,7 +1766,8 @@ static int do_set_perms(const void *ctx, struct conne= ction *conn, struct buffered_data *in) { struct node_perms perms, old_perms; - char *name, *permstr; + const char *name; + char *permstr; struct node *node; =20 perms.num =3D xenstore_count_strings(in->buffer, in->used); diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_cor= e.h index 84a611cbb5..005556de90 100644 --- a/tools/xenstore/xenstored_core.h +++ b/tools/xenstore/xenstored_core.h @@ -212,7 +212,7 @@ const char *onearg(struct buffered_data *in); =20 /* Break input into vectors, return the number, fill in up to num of them.= */ unsigned int get_strings(struct buffered_data *data, - char *vec[], unsigned int num); + const char *vec[], unsigned int num); unsigned int get_string(const struct buffered_data *data, unsigned int off= set); =20 void send_reply(struct connection *conn, enum xsd_sockmsg_type type, @@ -224,7 +224,8 @@ void send_event(struct buffered_data *req, struct conne= ction *conn, void send_ack(struct connection *conn, enum xsd_sockmsg_type type); =20 /* Canonicalize this path if possible. */ -char *canonicalize(struct connection *conn, const void *ctx, const char *n= ode); +const char *canonicalize(struct connection *conn, const void *ctx, + const char *node); =20 /* Get access permissions. */ unsigned int perm_for_conn(struct connection *conn, diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_d= omain.c index 632ddb5efc..cc67af5b98 100644 --- a/tools/xenstore/xenstored_domain.c +++ b/tools/xenstore/xenstored_domain.c @@ -1014,7 +1014,7 @@ int do_introduce(const void *ctx, struct connection *= conn, struct buffered_data *in) { struct domain *domain; - char *vec[3]; + const char *vec[3]; unsigned int domid; evtchn_port_t port; =20 @@ -1055,7 +1055,7 @@ static struct domain *find_connected_domain(unsigned = int domid) int do_set_target(const void *ctx, struct connection *conn, struct buffered_data *in) { - char *vec[2]; + const char *vec[2]; unsigned int domid, tdomid; struct domain *domain, *tdomain; if (get_strings(in, vec, ARRAY_SIZE(vec)) < ARRAY_SIZE(vec)) diff --git a/tools/xenstore/xenstored_lu.c b/tools/xenstore/xenstored_lu.c index b20d0d37ea..f7f76acbf9 100644 --- a/tools/xenstore/xenstored_lu.c +++ b/tools/xenstore/xenstored_lu.c @@ -360,7 +360,7 @@ static const char *lu_start(const void *ctx, struct con= nection *conn, return NULL; } =20 -int do_control_lu(const void *ctx, struct connection *conn, char **vec, +int do_control_lu(const void *ctx, struct connection *conn, const char **v= ec, int num) { const char *ret =3D NULL; diff --git a/tools/xenstore/xenstored_lu.h b/tools/xenstore/xenstored_lu.h index d633a765a3..ac3c572ca8 100644 --- a/tools/xenstore/xenstored_lu.h +++ b/tools/xenstore/xenstored_lu.h @@ -50,7 +50,7 @@ void lu_read_state(void); /* Write the "OK" response for the live-update command */ unsigned int lu_write_response(FILE *fp); =20 -int do_control_lu(const void *ctx, struct connection *conn, char **vec, +int do_control_lu(const void *ctx, struct connection *conn, const char **v= ec, int num); =20 /* Live update private interfaces. */ @@ -59,7 +59,7 @@ void lu_close_dump_state(struct lu_dump_state *state); FILE *lu_dump_open(const void *ctx); void lu_dump_close(FILE *fp); char *lu_exec(const void *ctx, int argc, char **argv); -const char *lu_arch(const void *ctx, struct connection *conn, char **vec, +const char *lu_arch(const void *ctx, struct connection *conn, const char *= *vec, int num); const char *lu_begin(struct connection *conn); void lu_destroy_arch(void *data); diff --git a/tools/xenstore/xenstored_lu_daemon.c b/tools/xenstore/xenstore= d_lu_daemon.c index 310fb8c2e6..8c7522b0e1 100644 --- a/tools/xenstore/xenstored_lu_daemon.c +++ b/tools/xenstore/xenstored_lu_daemon.c @@ -118,7 +118,7 @@ static const char *lu_binary(const void *ctx, struct co= nnection *conn, return NULL; } =20 -const char *lu_arch(const void *ctx, struct connection *conn, char **vec, +const char *lu_arch(const void *ctx, struct connection *conn, const char *= *vec, int num) { if (num =3D=3D 2 && !strcmp(vec[0], "-f")) diff --git a/tools/xenstore/xenstored_lu_minios.c b/tools/xenstore/xenstore= d_lu_minios.c index 88fb9e0f38..ae0483575e 100644 --- a/tools/xenstore/xenstored_lu_minios.c +++ b/tools/xenstore/xenstored_lu_minios.c @@ -104,7 +104,7 @@ static const char *lu_binary_save(const void *ctx, stru= ct connection *conn, return NULL; } =20 -const char *lu_arch(const void *ctx, struct connection *conn, char **vec, +const char *lu_arch(const void *ctx, struct connection *conn, const char *= *vec, int num) { if (num =3D=3D 2 && !strcmp(vec[0], "-b")) diff --git a/tools/xenstore/xenstored_watch.c b/tools/xenstore/xenstored_wa= tch.c index 4195c59e17..fefbf56ab2 100644 --- a/tools/xenstore/xenstored_watch.c +++ b/tools/xenstore/xenstored_watch.c @@ -161,7 +161,7 @@ static int destroy_watch(void *_watch) } =20 static int check_watch_path(struct connection *conn, const void *ctx, - char **path, bool *relative) + const char **path, bool *relative) { /* Check if valid event. */ if (strstarts(*path, "@")) { @@ -184,8 +184,9 @@ static int check_watch_path(struct connection *conn, co= nst void *ctx, return errno; } =20 -static struct watch *add_watch(struct connection *conn, char *path, char *= token, - bool relative, bool no_quota_check) +static struct watch *add_watch(struct connection *conn, const char *path, + const char *token, bool relative, + bool no_quota_check) { struct watch *watch; =20 @@ -217,7 +218,7 @@ static struct watch *add_watch(struct connection *conn,= char *path, char *token, int do_watch(const void *ctx, struct connection *conn, struct buffered_dat= a *in) { struct watch *watch; - char *vec[2]; + const char *vec[2]; bool relative; =20 if (get_strings(in, vec, ARRAY_SIZE(vec)) !=3D ARRAY_SIZE(vec)) @@ -258,7 +259,8 @@ int do_unwatch(const void *ctx, struct connection *conn, struct buffered_data *in) { struct watch *watch; - char *node, *vec[2]; + const char *node; + const char *vec[2]; =20 if (get_strings(in, vec, ARRAY_SIZE(vec)) !=3D ARRAY_SIZE(vec)) return EINVAL; @@ -336,7 +338,7 @@ void read_state_watch(const void *ctx, const void *stat= e) { const struct xs_state_watch *sw =3D state; struct connection *conn; - char *path, *token; + const char *path, *token; bool relative; =20 conn =3D get_connection_by_id(sw->conn_id); --=20 2.35.3 From nobody Thu May 16 13:01:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1690194837; cv=none; d=zohomail.com; s=zohoarc; b=RUXs6UpnDs7zvpGCMI4PMbMce/t8H83uvI4AM4ubKR5WCqTgVY+6uoNGMbb3rKRkn5MWCCfcyjWkyWn/W72oZCwn7BJ/XFoXn54sbN8lMiPg2itVikCJpi9i5kgxXi1/jAQjmBoTfJNp+I9TajOHteclI9MbuD7wD/QDQ7eTxAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690194837; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=joi8pFR+Pd5xgecdMs2fa+83mlaOI82o45Pbhsckn/E=; b=Y6u/vH25noxIUOrKriC5XXjJQA+MdoHJrY8GjpBDTYoVRDe404wpmgVXB3hfk1XFXn1vhSGsq6ytlTr9wUKM5b2BQwfqmQgXV8qHTrwZiy/UtdLX1+bgNvmVB8JCJq4IRwuO0xf8UAoBQQewqAy+u0XyjdeM4bctAfn32BzLj2Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 169019483765323.352990452580002; Mon, 24 Jul 2023 03:33:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.568718.888532 (Exim 4.92) (envelope-from ) id 1qNssn-0003dr-GM; Mon, 24 Jul 2023 10:33:41 +0000 Received: by outflank-mailman (output) from mailman id 568718.888532; Mon, 24 Jul 2023 10:33:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qNssn-0003dk-DW; Mon, 24 Jul 2023 10:33:41 +0000 Received: by outflank-mailman (input) for mailman id 568718; Mon, 24 Jul 2023 10:33:40 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qNssm-0003cS-9H for xen-devel@lists.xenproject.org; Mon, 24 Jul 2023 10:33:40 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8cf6a66b-2a0d-11ee-8612-37d641c3527e; Mon, 24 Jul 2023 12:33:38 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 399B520661; Mon, 24 Jul 2023 10:33:38 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0641F138E8; Mon, 24 Jul 2023 10:33:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id w60gAIJTvmSIUAAAMHmgww (envelope-from ); Mon, 24 Jul 2023 10:33:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 8cf6a66b-2a0d-11ee-8612-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1690194818; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=joi8pFR+Pd5xgecdMs2fa+83mlaOI82o45Pbhsckn/E=; b=K8MEtNjc3I4B4iavlfe0JoeBEbufnan4Mw7rSfaAkqgYrJy8rtwHdNXzgmY/ZC5Rg50HjH 8ccOMb+DPhv36nxgkpxQFAIOrnX4BoXmH05EpjVg18Sd6uX5X7XN2SjOoIwzjhDiUe6MB1 Ll/NRUQr6zqt2z81eegjmhrRQTypUhQ= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD , Julien Grall Subject: [PATCH v3 2/2] tools/xenstore: fix get_spec_node() Date: Mon, 24 Jul 2023 12:33:24 +0200 Message-Id: <20230724103324.4207-3-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230724103324.4207-1-jgross@suse.com> References: <20230724103324.4207-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1690194838504100001 Content-Type: text/plain; charset="utf-8" In case get_spec_node() is being called for a special node starting with '@' it won't set *canonical_name. This can result in a crash of xenstored due to dereferencing the uninitialized name in fire_watches(). This is no security issue as it requires either a privileged caller or ownership of the special node in question by an unprivileged caller (which is questionable, as this would make the owner privileged in some way). Fixes: d6bb63924fc2 ("tools/xenstore: introduce dummy nodes for special wat= ch paths") Signed-off-by: Juergen Gross Reviewed-by: Julien Grall --- V2: - avoid casting const away (Julien Grall) --- tools/xenstore/xenstored_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_cor= e.c index 6d27b2dd7f..9f1328a31f 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -1253,8 +1253,11 @@ static struct node *get_spec_node(struct connection = *conn, const void *ctx, const char *name, const char **canonical_name, unsigned int perm) { - if (name[0] =3D=3D '@') + if (name[0] =3D=3D '@') { + if (canonical_name) + *canonical_name =3D name; return get_node(conn, ctx, name, perm); + } =20 return get_node_canonicalized(conn, ctx, name, canonical_name, perm); } --=20 2.35.3