2018-09-01 10:18:12

by Frank Sorenson

[permalink] [raw]
Subject: [nfs-utils PATCH] statd: fix use-after-free in monitor list if insertion fails

If nsm_insert_monitored_host() fails while saving the record to
stable storage, we can't just assume the entry was new. Existing
records must be removed from the list before being freed.

Signed-off-by: Frank Sorenson <[email protected]>

diff --git a/utils/statd/monitor.c b/utils/statd/monitor.c
index 45c4346..9400048 100644
--- a/utils/statd/monitor.c
+++ b/utils/statd/monitor.c
@@ -197,7 +197,7 @@ sm_mon_1_svc(struct mon *argp, struct svc_req *rqstp)

if (!nsm_insert_monitored_host(dnsname,
(struct sockaddr *)(char *)&my_addr, argp)) {
- nlist_free(NULL, clnt);
+ nlist_free(existing ? &rtnl : NULL, clnt);
goto failure;
}



2018-09-05 18:40:37

by Chuck Lever III

[permalink] [raw]
Subject: Re: [nfs-utils PATCH] statd: fix use-after-free in monitor list if insertion fails



> On Sep 1, 2018, at 2:07 AM, Frank Sorenson <[email protected]> wrote:
>
> If nsm_insert_monitored_host() fails while saving the record to
> stable storage, we can't just assume the entry was new. Existing
> records must be removed from the list before being freed.
>
> Signed-off-by: Frank Sorenson <[email protected]>

Reviewed-by: Chuck Lever <[email protected]>


> diff --git a/utils/statd/monitor.c b/utils/statd/monitor.c
> index 45c4346..9400048 100644
> --- a/utils/statd/monitor.c
> +++ b/utils/statd/monitor.c
> @@ -197,7 +197,7 @@ sm_mon_1_svc(struct mon *argp, struct svc_req *rqstp)
>
> if (!nsm_insert_monitored_host(dnsname,
> (struct sockaddr *)(char *)&my_addr, argp)) {
> - nlist_free(NULL, clnt);
> + nlist_free(existing ? &rtnl : NULL, clnt);
> goto failure;
> }
>

--
Chuck Lever

2018-09-06 19:00:05

by Steve Dickson

[permalink] [raw]
Subject: Re: [nfs-utils PATCH] statd: fix use-after-free in monitor list if insertion fails



On 09/01/2018 02:07 AM, Frank Sorenson wrote:
> If nsm_insert_monitored_host() fails while saving the record to
> stable storage, we can't just assume the entry was new. Existing
> records must be removed from the list before being freed.
>
> Signed-off-by: Frank Sorenson <[email protected]>
Committed....

steved.
>
> diff --git a/utils/statd/monitor.c b/utils/statd/monitor.c
> index 45c4346..9400048 100644
> --- a/utils/statd/monitor.c
> +++ b/utils/statd/monitor.c
> @@ -197,7 +197,7 @@ sm_mon_1_svc(struct mon *argp, struct svc_req *rqstp)
>
> if (!nsm_insert_monitored_host(dnsname,
> (struct sockaddr *)(char *)&my_addr, argp)) {
> - nlist_free(NULL, clnt);
> + nlist_free(existing ? &rtnl : NULL, clnt);
> goto failure;
> }
>
>