Re: [PATCH v2] net/9p/fd: support ipv6 for trans=tcp

Daniel Verkamp
2025-01-17T22:51:17Z

On Fri, Jan 17, 2025 at 1:52 PM Joshua Murphy <joshuamurphy@posteo.net> wrote:
>
> Allows specifying an IPv6 address when mounting a remote 9p file system.
>
> Signed-off-by: Joshua Murphy <joshuamurphy@posteo.net>
> ---
[...]
> - cl.sin_family = AF_INET;
> - cl.sin_addr.s_addr = htonl(INADDR_ANY);
> + stor.ss_family = sock->ops->family;
> + inet_addr_is_any((struct sockaddr *) &stor);

It looks like inet_addr_is_any() checks the current sin_addr/sin6_addr
of a sockaddr, but does not change it, so this doesn't seem quite
right (its only effect is to return a bool, which is discarded here).

[...]
> - if (addr == NULL || valid_ipaddr4(addr) < 0)
> - return -EINVAL;
> + sprintf(port_str, "%u", opts.port);
> + err = inet_pton_with_scope(current->nsproxy->net_ns, AF_UNSPEC, addr,
> + port_str, &stor);
> + if (addr == NULL || err < 0) {

inet_pton_with_scope() appears to unconditionally dereference its
`src` parameter (`addr` in the call above), so the `addr == NULL`
check is too late.