All of lore.kernel.org
 help / color / mirror / Atom feed
* [nfs-utils PATCH] fsidd: replace assertions with explicit malformed-input handling
@ 2026-09-03 17:48 Scott Mayhew
  2026-09-16 14:14 ` Steve Dickson
  0 siblings, 1 reply; 2+ messages in thread
From: Scott Mayhew @ 2026-09-03 17:48 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

fsidd relies on assert() to ensure that an argument is present after the
command prefix while parsing commands received over the local socket.
Malformed input can cause fsidd to abort.  Replace the assertions with
explicit malformed-input handling and return an error to the client.

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
 support/reexport/fsidd.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/support/reexport/fsidd.c b/support/reexport/fsidd.c
index 51750ea3..f5c397aa 100644
--- a/support/reexport/fsidd.c
+++ b/support/reexport/fsidd.c
@@ -48,7 +48,11 @@ static void client_cb(evutil_socket_t cl, short ev, void *d)
 		char *answer = NULL;
 		bool found;
 
-		assert(req_path < buf + n );
+		if (req_path >= buf + n) {
+			char answer[] = "- Command failed: Bad input";
+			(void)send(cl, answer, strlen(answer), 0);
+			return;
+		}
 
 		printf("client asks for %s\n", req_path);
 
@@ -70,8 +74,11 @@ static void client_cb(evutil_socket_t cl, short ev, void *d)
 		char *answer = NULL;
 		bool found;
 
-		assert(req_path < buf + n );
-
+		if (req_path >= buf + n) {
+			char answer[] = "- Command failed: Bad input";
+			(void)send(cl, answer, strlen(answer), 0);
+			return;
+		}
 
 		if (dbbackend->fsidnum_by_path(req_path, &fsidnum, true, &found)) {
 			if (found) {
@@ -94,7 +101,11 @@ static void client_cb(evutil_socket_t cl, short ev, void *d)
 		uint32_t fsidnum;
 		bool found;
 
-		assert(req_fsidnum < buf + n );
+		if (req_fsidnum >= buf + n) {
+			char answer[] = "- Command failed: Bad input";
+			(void)send(cl, answer, strlen(answer), 0);
+			return;
+		}
 
 		errno = 0;
 		fsidnum = strtoul(req_fsidnum, &endp, 10);
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [nfs-utils PATCH] fsidd: replace assertions with explicit malformed-input handling
  2026-09-03 17:48 [nfs-utils PATCH] fsidd: replace assertions with explicit malformed-input handling Scott Mayhew
@ 2026-09-16 14:14 ` Steve Dickson
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Dickson @ 2026-09-16 14:14 UTC (permalink / raw)
  To: Scott Mayhew; +Cc: linux-nfs



On 9/3/26 1:48 PM, Scott Mayhew wrote:
> fsidd relies on assert() to ensure that an argument is present after the
> command prefix while parsing commands received over the local socket.
> Malformed input can cause fsidd to abort.  Replace the assertions with
> explicit malformed-input handling and return an error to the client.
> 
> Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Committed... (tag: nfs-utils-2-9-3-rc4)

steved.
> ---
>   support/reexport/fsidd.c | 19 +++++++++++++++----
>   1 file changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/support/reexport/fsidd.c b/support/reexport/fsidd.c
> index 51750ea3..f5c397aa 100644
> --- a/support/reexport/fsidd.c
> +++ b/support/reexport/fsidd.c
> @@ -48,7 +48,11 @@ static void client_cb(evutil_socket_t cl, short ev, void *d)
>   		char *answer = NULL;
>   		bool found;
>   
> -		assert(req_path < buf + n );
> +		if (req_path >= buf + n) {
> +			char answer[] = "- Command failed: Bad input";
> +			(void)send(cl, answer, strlen(answer), 0);
> +			return;
> +		}
>   
>   		printf("client asks for %s\n", req_path);
>   
> @@ -70,8 +74,11 @@ static void client_cb(evutil_socket_t cl, short ev, void *d)
>   		char *answer = NULL;
>   		bool found;
>   
> -		assert(req_path < buf + n );
> -
> +		if (req_path >= buf + n) {
> +			char answer[] = "- Command failed: Bad input";
> +			(void)send(cl, answer, strlen(answer), 0);
> +			return;
> +		}
>   
>   		if (dbbackend->fsidnum_by_path(req_path, &fsidnum, true, &found)) {
>   			if (found) {
> @@ -94,7 +101,11 @@ static void client_cb(evutil_socket_t cl, short ev, void *d)
>   		uint32_t fsidnum;
>   		bool found;
>   
> -		assert(req_fsidnum < buf + n );
> +		if (req_fsidnum >= buf + n) {
> +			char answer[] = "- Command failed: Bad input";
> +			(void)send(cl, answer, strlen(answer), 0);
> +			return;
> +		}
>   
>   		errno = 0;
>   		fsidnum = strtoul(req_fsidnum, &endp, 10);


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-16 14:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-03 17:48 [nfs-utils PATCH] fsidd: replace assertions with explicit malformed-input handling Scott Mayhew
2026-09-16 14:14 ` Steve Dickson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.