From: Eric-Terminal <ericterminal@gmail.com>
To: Dominique Martinet <asmadeus@codewreck.org>,
Eric Van Hensbergen <ericvh@kernel.org>,
Latchesar Ionkov <lucho@ionkov.net>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>
Cc: v9fs@lists.linux.dev, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Nikolay Aleksandrov <razor@blackwall.org>,
bridge@lists.linux.dev, Anna Schumaker <anna@kernel.org>,
Chuck Lever <chuck.lever@oracle.com>,
linux-nfs@vger.kernel.org, Yufan Chen <ericterminal@gmail.com>
Subject: [PATCH v2 2/4] 9p/trans_xen: replace simple_strto* with kstrtouint
Date: Wed, 25 Feb 2026 11:38:38 +0800 [thread overview]
Message-ID: <20260225033840.33000-3-ericterminal@gmail.com> (raw)
In-Reply-To: <20260225033840.33000-1-ericterminal@gmail.com>
From: Yufan Chen <ericterminal@gmail.com>
In xen_9pfs_front_init(), parse the backend version list as comma-separated
tokens with kstrtouint(). This improves error reporting and ensures strict
token validation while explicitly requiring protocol version 1.
Signed-off-by: Yufan Chen <ericterminal@gmail.com>
---
net/9p/trans_xen.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c
index 85b9ebfaa..f9fb2db7a 100644
--- a/net/9p/trans_xen.c
+++ b/net/9p/trans_xen.c
@@ -413,23 +413,29 @@ static int xen_9pfs_front_init(struct xenbus_device *dev)
int ret, i;
struct xenbus_transaction xbt;
struct xen_9pfs_front_priv *priv;
- char *versions, *v;
- unsigned int max_rings, max_ring_order, len = 0;
+ char *versions, *v, *token;
+ bool version_1 = false;
+ unsigned int max_rings, max_ring_order, len = 0, version;
versions = xenbus_read(XBT_NIL, dev->otherend, "versions", &len);
if (IS_ERR(versions))
return PTR_ERR(versions);
- for (v = versions; *v; v++) {
- if (simple_strtoul(v, &v, 10) == 1) {
- v = NULL;
- break;
+ for (v = versions; (token = strsep(&v, ",")); ) {
+ if (!*token)
+ continue;
+
+ ret = kstrtouint(token, 10, &version);
+ if (ret) {
+ kfree(versions);
+ return ret;
}
- }
- if (v) {
- kfree(versions);
- return -EINVAL;
+ if (version == 1)
+ version_1 = true;
}
kfree(versions);
+ if (!version_1)
+ return -EINVAL;
+
max_rings = xenbus_read_unsigned(dev->otherend, "max-rings", 0);
if (max_rings < XEN_9PFS_NUM_RINGS)
return -EINVAL;
--
2.47.3
next prev parent reply other threads:[~2026-02-25 3:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260225010853.15916-1-ericterminal@gmail.com>
2026-02-25 3:38 ` [PATCH v2 0/4] net: replace deprecated simple_strto* parsers with kstrto* Eric-Terminal
2026-02-25 3:38 ` [PATCH v2 1/4] 9p/trans_xen: make cleanup idempotent after dataring alloc errors Eric-Terminal
2026-02-25 3:38 ` Eric-Terminal [this message]
2026-02-25 3:38 ` [PATCH v2 3/4] net: bridge: replace deprecated simple_strtoul with kstrtoul Eric-Terminal
2026-02-25 3:38 ` [PATCH v2 4/4] sunrpc: sysctl: replace simple_strtol with kstrtouint Eric-Terminal
2026-03-01 15:29 ` [PATCH v2 0/4] net: replace deprecated simple_strto* parsers with kstrto* Simon Horman
2026-03-04 15:28 ` Eric_Terminal
2026-03-24 4:27 ` Eric_Terminal
2026-03-24 4:50 ` Dominique Martinet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260225033840.33000-3-ericterminal@gmail.com \
--to=ericterminal@gmail.com \
--cc=anna@kernel.org \
--cc=asmadeus@codewreck.org \
--cc=bridge@lists.linux.dev \
--cc=chuck.lever@oracle.com \
--cc=davem@davemloft.net \
--cc=ericvh@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=lucho@ionkov.net \
--cc=netdev@vger.kernel.org \
--cc=razor@blackwall.org \
--cc=v9fs@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox