From dce98d50da62d652120a593f47b760992b77f4f4 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Sun, 3 May 2020 17:49:52 +0200 Subject: [PATCH] [#316] endpoint.Receiver.ListFilesystems: early-exit if root_fs is not imported - discovered during investigation of #316 - this is not the fix for #316, as a malicious receiver who doesn't implement the behavior added by this patch could still cause leakage of step holds on the sender refs #316 --- endpoint/endpoint.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index 97c7075..35279c9 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -623,6 +623,13 @@ func (f subroot) MapToLocal(fs string) (*zfs.DatasetPath, error) { func (s *Receiver) ListFilesystems(ctx context.Context, req *pdu.ListFilesystemReq) (*pdu.ListFilesystemRes, error) { defer trace.WithSpanFromStackUpdateCtx(&ctx)() + // first make sure that root_fs is imported + if rphs, err := zfs.ZFSGetFilesystemPlaceholderState(ctx, s.conf.RootWithoutClientComponent); err != nil { + return nil, errors.Wrap(err, "cannot determine whether root_fs exists") + } else if !rphs.FSExists { + return nil, errors.New("root_fs does not exist") + } + root := s.clientRootFromCtx(ctx) filtered, err := zfs.ZFSListMapping(ctx, subroot{root}) if err != nil {