* [PATCH] svc_fd_create: skip getsockname on a non-network socket
@ 2024-10-14 8:55 Chen Hanxiao
2024-10-16 14:53 ` Steve Dickson
0 siblings, 1 reply; 2+ messages in thread
From: Chen Hanxiao @ 2024-10-14 8:55 UTC (permalink / raw)
To: libtirpc-devel; +Cc: linux-nfs
As svcfd_create(3) said, it can:
Create a service on top of any open file descriptor.
But getsockname and getpeername in svc_fd_create assume that
fd should be a connected socket.
This patch will leave xp_raddr and xp_laddr uninitialized
if fd is not a connected socket.
Signed-off-by: Chen Hanxiao <chenhx.fnst@fujitsu.com>
---
src/svc_vc.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/svc_vc.c b/src/svc_vc.c
index 3dc8a75..438cbc5 100644
--- a/src/svc_vc.c
+++ b/src/svc_vc.c
@@ -59,6 +59,7 @@
#include <rpc/rpc.h>
#include "rpc_com.h"
+#include "debug.h"
#include <getpeereid.h>
@@ -232,6 +233,12 @@ svc_fd_create(fd, sendsize, recvsize)
slen = sizeof (struct sockaddr_storage);
if (getsockname(fd, (struct sockaddr *)(void *)&ss, &slen) < 0) {
+ if (errno == ENOTSOCK) {
+ if (libtirpc_debug_level > 3) {
+ LIBTIRPC_DEBUG(4, ("svc_fd_create: ENOTSOCK, return directly"));
+ }
+ return ret;
+ }
warnx("svc_fd_create: could not retrieve local addr");
goto freedata;
}
--
2.43.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] svc_fd_create: skip getsockname on a non-network socket
2024-10-14 8:55 [PATCH] svc_fd_create: skip getsockname on a non-network socket Chen Hanxiao
@ 2024-10-16 14:53 ` Steve Dickson
0 siblings, 0 replies; 2+ messages in thread
From: Steve Dickson @ 2024-10-16 14:53 UTC (permalink / raw)
To: Chen Hanxiao, libtirpc-devel; +Cc: linux-nfs
On 10/14/24 4:55 AM, Chen Hanxiao wrote:
> As svcfd_create(3) said, it can:
> Create a service on top of any open file descriptor.
>
> But getsockname and getpeername in svc_fd_create assume that
> fd should be a connected socket.
>
> This patch will leave xp_raddr and xp_laddr uninitialized
> if fd is not a connected socket.
>
> Signed-off-by: Chen Hanxiao <chenhx.fnst@fujitsu.com>
Committed... (tag: libtirpc-1-3-6-rc3)
steved.
> ---
> src/svc_vc.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/src/svc_vc.c b/src/svc_vc.c
> index 3dc8a75..438cbc5 100644
> --- a/src/svc_vc.c
> +++ b/src/svc_vc.c
> @@ -59,6 +59,7 @@
> #include <rpc/rpc.h>
>
> #include "rpc_com.h"
> +#include "debug.h"
>
> #include <getpeereid.h>
>
> @@ -232,6 +233,12 @@ svc_fd_create(fd, sendsize, recvsize)
>
> slen = sizeof (struct sockaddr_storage);
> if (getsockname(fd, (struct sockaddr *)(void *)&ss, &slen) < 0) {
> + if (errno == ENOTSOCK) {
> + if (libtirpc_debug_level > 3) {
> + LIBTIRPC_DEBUG(4, ("svc_fd_create: ENOTSOCK, return directly"));
> + }
> + return ret;
> + }
> warnx("svc_fd_create: could not retrieve local addr");
> goto freedata;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-16 14:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-14 8:55 [PATCH] svc_fd_create: skip getsockname on a non-network socket Chen Hanxiao
2024-10-16 14:53 ` Steve Dickson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox