From: Steve Dickson <SteveD@redhat.com>
To: "Carlos O'Donell" <carlos@redhat.com>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH] rpc.statd: Avoid passing unregistered socket to svc_getreqset.
Date: Thu, 26 Feb 2015 14:36:45 -0500 [thread overview]
Message-ID: <54EF75CD.2030805@RedHat.com> (raw)
In-Reply-To: <54E60C41.3060001@redhat.com>
On 02/19/2015 11:16 AM, Carlos O'Donell wrote:
> rpc.statd may crash if it receives both a notification reply and a client
> connection at the same time. It crashes because it adds sockfd to SVC_FDSET
> and that violates the API contract. The SVC_FDSET is to be considered read-only
> and must not be modified by user code. The daemon modifies it for expediency
> to avoid having to maintain two distinct fd lists and select on each one.
> It is a practical choice that makes sense.
>
> Thus, if a notification reply arrives by itself everything works, or if a
> client connection arrives by itself everything works. Both must arrive at
> the same time for sockfd to be set in SVC_FDSET and to be processed by
> svc_getreqset because more than one of readfds is ready.
>
> It is the processing by svc_getreqset that will crash when it finds an
> unregistered fd in the list that doesn't correlate to any of the internal
> book keeping done by the library. At present the glibc SunRPC library will
> crash, but TIRPC does not (it is robust against invalid API usage in this
> case). However, future RPC libraries may be implemented differently, and
> the questionable API usage should be fixed.
>
> The simplest fix is for process_reply to *clear* sockfd from the
> ready-to-read fds, since it was never registered with xprt_register.
> This works because the code always calls process_reply before handing the
> fd set to the RPC layer for processing.
>
> Compile-tested on x86_64 against master.
>
> Signed-off-by: Carlos O'Donell <carlos@redhat.com>
Committed!
steved.
> ---
> rmtcall.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/utils/statd/rmtcall.c b/utils/statd/rmtcall.c
> index fd576d9..66a6eeb 100644
> --- a/utils/statd/rmtcall.c
> +++ b/utils/statd/rmtcall.c
> @@ -221,6 +221,9 @@ process_reply(FD_SET_TYPE *rfds)
> if (sockfd == -1 || !FD_ISSET(sockfd, rfds))
> return 0;
>
> + /* Should not be processed again. */
> + FD_CLR (sockfd, rfds);
> +
> if (!(lp = recv_rply(&port)))
> return 1;
>
>
prev parent reply other threads:[~2015-02-26 19:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-19 16:16 [PATCH] rpc.statd: Avoid passing unregistered socket to svc_getreqset Carlos O'Donell
2015-02-26 19:36 ` Steve Dickson [this message]
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=54EF75CD.2030805@RedHat.com \
--to=steved@redhat.com \
--cc=carlos@redhat.com \
--cc=linux-nfs@vger.kernel.org \
/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).