linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Aloni <dan@kernelim.com>
To: Olga Kornievskaia <olga.kornievskaia@gmail.com>
Cc: Trond Myklebust <trond.myklebust@hammerspace.com>,
	Anna Schumaker <anna.schumaker@netapp.com>,
	linux-nfs <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH v7 10/12] sunrpc: add dst_attr attributes to the sysfs xprt directory
Date: Mon, 17 May 2021 20:16:13 +0300	[thread overview]
Message-ID: <20210517171613.toxgdygnzw76ibgd@gmail.com> (raw)
In-Reply-To: <CAN-5tyGGnrGPMq4kakCZhNdJj9i-Arc-FXn=uxWRW9nuAVpE7A@mail.gmail.com>

On Mon, May 17, 2021 at 09:53:30AM -0400, Olga Kornievskaia wrote:
> On Sat, May 15, 2021 at 8:42 AM Dan Aloni <dan@kernelim.com> wrote:
> >
> > On Fri, May 14, 2021 at 10:13:21AM -0400, Olga Kornievskaia wrote:
> > > From: Olga Kornievskaia <kolga@netapp.com>
> > >
> > > Allow to query and set the destination's address of a transport.
> > > Setting of the destination address is allowed only for TCP or RDMA
> > > based connections.
> > >
> > > Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
> > ..
> > > +     saddr = (struct sockaddr *)&xprt->addr;
> > > +     port = rpc_get_port(saddr);
> > > +
> > > +     dst_addr = kstrndup(buf, count - 1, GFP_KERNEL);
> > > +     if (!dst_addr)
> > > +             goto out_err;
> > > +     saved_addr = kzalloc(sizeof(*saved_addr), GFP_KERNEL);
> > > +     if (!saved_addr)
> > > +             goto out_err_free;
> > > +     saved_addr->addr =
> > > +             rcu_dereference_raw(xprt->address_strings[RPC_DISPLAY_ADDR]);
> > > +     rcu_assign_pointer(xprt->address_strings[RPC_DISPLAY_ADDR], dst_addr);
> > > +     call_rcu(&saved_addr->rcu, free_xprt_addr);
> > > +     xprt->addrlen = rpc_pton(xprt->xprt_net, buf, count - 1, saddr,
> > > +                              sizeof(*saddr));
> >
> > Hi Olga,
> >
> > How does this behave if rpc_pton fails? Perhaps this conversion being
> > also a validation check on input given from user-space should be done
> > before the xprt is being modified?
> 
> It's assumed that an administrator is providing a valid (and correct)
> address value. Transport would continue to be disconnected until a
> proper value is supplied. We can't validate for instance that the
> supplied value is a "correct" value for the v4.1 server (which would
> require sending an EXCHANGE_ID and checking that it's the same server
> as before).

I'm not sure it would work that way - looks like `rpc_pton` zeroes
`saddr` before trying to fill it (or leaves it as it in other cases such
as the INET_ADDRSTRLEN bound check). I think `0.0.0.0` routes to
localhost by default? That might cause unexpected behavior from admin PoV.

More to consider is that `xprt->address_strings[RPC_DISPLAY_ADDR]`
should be consistent with the value of `saddr` in the error cases,
otherwise debugging xprt state may be give confusing output.

-- 
Dan Aloni

  reply	other threads:[~2021-05-17 17:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-14 14:13 [PATCH v7 00/12] create sysfs files for changing IP address Olga Kornievskaia
2021-05-14 14:13 ` [PATCH v7 01/12] sunrpc: Create a sunrpc directory under /sys/kernel/ Olga Kornievskaia
2021-05-14 14:13 ` [PATCH v7 02/12] sunrpc: Create a client/ subdirectory in the sunrpc sysfs Olga Kornievskaia
2021-05-14 14:13 ` [PATCH v7 03/12] sunrpc: Create per-rpc_clnt sysfs kobjects Olga Kornievskaia
2021-05-14 14:13 ` [PATCH v7 04/12] sunrpc: add xprt id Olga Kornievskaia
2021-05-14 14:13 ` [PATCH v7 05/12] sunrpc: add IDs to multipath Olga Kornievskaia
2021-05-14 14:13 ` [PATCH v7 06/12] sunrpc: keep track of the xprt_class in rpc_xprt structure Olga Kornievskaia
2021-05-14 14:13 ` [PATCH v7 07/12] sunrpc: add xprt_switch direcotry to sunrpc's sysfs Olga Kornievskaia
2021-05-14 14:13 ` [PATCH v7 08/12] sunrpc: add a symlink from rpc-client directory to the xprt_switch Olga Kornievskaia
2021-05-14 14:13 ` [PATCH v7 09/12] sunrpc: add add sysfs directory per xprt under each xprt_switch Olga Kornievskaia
2021-05-14 14:13 ` [PATCH v7 10/12] sunrpc: add dst_attr attributes to the sysfs xprt directory Olga Kornievskaia
2021-05-15 12:42   ` Dan Aloni
2021-05-17 13:53     ` Olga Kornievskaia
2021-05-17 17:16       ` Dan Aloni [this message]
2021-05-17 18:14         ` Olga Kornievskaia
2021-05-14 14:13 ` [PATCH v7 11/12] sunrpc: provide transport info in the sysfs directory Olga Kornievskaia
2021-05-14 14:13 ` [PATCH v7 12/12] sunrpc: provide multipath " Olga Kornievskaia

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=20210517171613.toxgdygnzw76ibgd@gmail.com \
    --to=dan@kernelim.com \
    --cc=anna.schumaker@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=olga.kornievskaia@gmail.com \
    --cc=trond.myklebust@hammerspace.com \
    /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;
as well as URLs for NNTP newsgroup(s).