From nobody Tue Nov 14 21:15:34 2023 X-Original-To: current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SVJx45yRWz50sVC for ; Tue, 14 Nov 2023 21:15:36 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-oo1-xc30.google.com (mail-oo1-xc30.google.com [IPv6:2607:f8b0:4864:20::c30]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SVJx41fXyz3D1D; Tue, 14 Nov 2023 21:15:36 +0000 (UTC) (envelope-from mjguzik@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20230601 header.b=K8Y1xnO9; spf=pass (mx1.freebsd.org: domain of mjguzik@gmail.com designates 2607:f8b0:4864:20::c30 as permitted sender) smtp.mailfrom=mjguzik@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-5844bc378feso3453898eaf.0; Tue, 14 Nov 2023 13:15:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699996535; x=1700601335; darn=freebsd.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=wSLD480hnKCj21lK15I1ejbrxRBXYmYErW+mqpuWpd0=; b=K8Y1xnO9hi1AGfMS59JoopAv92c+y1wizkLs3IHlHiIxdKVy5TWxAJuiSe/yta9Qd9 7nFZFN9k7pAkDI6Vw9JvWafHQQWtv1MK3xNAMQ/IYt76SkeCCk/skarvM81fcfG9yAol EX/X6KGeXEp6SqQ6AkCPMGwL0rH/X6MzVa9OqWPKFyIzcxgpcV7GpYRafzfWkYRgDvyq 75bqG0pXCZUwFwLETZ71m+9mgs8faTcmcVxvxpP17HSdWsNhIxTcWwshDTK2VN2GDRVv HxJd3enVqsAdmhS/jrIE7Bel/x1yrBC2ADTV7lTHfnWYd7GBEkX8cdUW+LJ37JytXtgQ sFQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699996535; x=1700601335; h=content-transfer-encoding:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wSLD480hnKCj21lK15I1ejbrxRBXYmYErW+mqpuWpd0=; b=wgAf0Rja+hMIJsR1DgLDtB0J7cLMCqYRP/tIo2rawu1RHgGgX2hl/h9rR/rrREw4fP tgVrudQHw3n25ytpOsVIpSyBRsIGEi5XqwjmWt+b7uesT1q5NXHHuGaJbP6NtAhWrr4K NfbEONRYPqCV1IaBFPlIOVpzeWzGUmsOe17eLj4MJKSh7Z3SR25R58DcMys88b93J/7N VasNwpNXMXAgtRiJ8sHCC86664MOo0GklA308oG11FzTwHd+0Y7o+7GcDxlTZr9M4J2z ZTGGS4JfCISSyT44x0InmVnHCKTfi+iIY2Pey/Z70vm988glbLDfa8TbegN0V6Kxz8bi RpKw== X-Gm-Message-State: AOJu0Yy9CSpMFdjLfTFthK98RD6JmKluyyLdqs6wLSeLxmhaAWp1BX/D mZASkzuZ9GdNX4jcDp0S/ykgauhkgEJmfV/WTvs= X-Google-Smtp-Source: AGHT+IEE2yS+CedPbNYOyigdKbZbeV0ldVtFG56832RWAgyjWsMo9An7PAs22SXzpxYNHec6kRfb83QaVZw0NaYfc/8= X-Received: by 2002:a4a:9c51:0:b0:586:8c18:ddd9 with SMTP id c17-20020a4a9c51000000b005868c18ddd9mr10790774ook.9.1699996534744; Tue, 14 Nov 2023 13:15:34 -0800 (PST) List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org MIME-Version: 1.0 Received: by 2002:ac9:7510:0:b0:4f0:1250:dd51 with HTTP; Tue, 14 Nov 2023 13:15:34 -0800 (PST) In-Reply-To: References: <349700057.3452.1699611152405@localhost> <1900239445.5968.1699966796547@localhost> From: Mateusz Guzik Date: Tue, 14 Nov 2023 22:15:34 +0100 Message-ID: Subject: Re: crash zfs_clone_range() To: Rick Macklem Cc: Alexander Motin , Ronald Klop , Konstantin Belousov , current@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.49 / 15.00]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.99)[-0.994]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36:c]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20230601]; MIME_GOOD(-0.10)[text/plain]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::c30:from]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TAGGED_RCPT(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MLMMJ_DEST(0.00)[current@freebsd.org]; ARC_NA(0.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FREEMAIL_CC(0.00)[freebsd.org,klop.ws,gmail.com]; MID_RHS_MATCH_FROMTLD(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_FIVE(0.00)[5]; FREEMAIL_FROM(0.00)[gmail.com]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_TLS_LAST(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[] X-Rspamd-Queue-Id: 4SVJx41fXyz3D1D X-Spamd-Bar: -- On 11/14/23, Rick Macklem wrote: > On Tue, Nov 14, 2023 at 10:46=E2=80=AFAM Alexander Motin wrote: >> >> On 14.11.2023 12:44, Alexander Motin wrote: >> > On 14.11.2023 12:39, Mateusz Guzik wrote: >> >> One of the vnodes is probably not zfs, I suspect this will do it >> >> (untested): >> >> >> >> diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c >> >> b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c >> >> index 107cd69c756c..e799a7091b8e 100644 >> >> --- a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c >> >> +++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c >> >> @@ -6270,6 +6270,11 @@ zfs_freebsd_copy_file_range(struct >> >> vop_copy_file_range_args *ap) >> >> goto bad_write_fallback; >> >> } >> >> } >> >> + >> >> + if (invp->v_mount->mnt_vfc !=3D outvp->v_mount->mnt_vfc) { >> >> + goto bad_write_fallback; >> >> + } >> >> + >> >> if (invp =3D=3D outvp) { >> >> if (vn_lock(outvp, LK_EXCLUSIVE) !=3D 0) { >> >> goto bad_write_fallback; >> >> >> > >> > vn_copy_file_range() verifies for that: >> > >> > /* >> > * If the two vnodes are for the same file system type, call >> > * VOP_COPY_FILE_RANGE(), otherwise call >> > vn_generic_copy_file_range() >> > * which can handle copies across multiple file system types. >> > */ >> > *lenp =3D len; >> > if (inmp =3D=3D outmp || strcmp(inmp->mnt_vfc->vfc_name, >> > outmp->mnt_vfc->vfc_name) =3D=3D 0) >> > error =3D VOP_COPY_FILE_RANGE(invp, inoffp, outvp, >> > outoffp, >> > lenp, flags, incred, outcred, fsize_td); >> > else >> > error =3D vn_generic_copy_file_range(invp, inoffp, >> > outvp, >> > outoffp, lenp, flags, incred, outcred, fsize_td); >> >> Thinking again, what happen if there are two nullfs mounts on top of two >> different file systems, one of which is indeed not ZFS? Do we need to >> add those checks to all ZFS, NFS and FUSE, implementing >> VOP_COPY_FILE_RANGE, or it is responsibility of nullfs or VFS? > Although it would be nice to do the check before the VOP call, I don't > see an easy way to do that. > > It looks like the simple solution is to add a check in each of the > VOP_COPY_FILE_RANGE() calls, such as mjg@ has proposed > for ZFS. At this point there is only the three and I can easily do the > NFS one. > All filesystems except for zfs are already covered because they check for mismatched mount. --=20 Mateusz Guzik