From nobody Tue Nov 14 17:34:47 2023 X-Original-To: dev-commits-src-all@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 4SVD2K4vdBz51cMp; Tue, 14 Nov 2023 17:34:49 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-oo1-xc34.google.com (mail-oo1-xc34.google.com [IPv6:2607:f8b0:4864:20::c34]) (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 4SVD2K30P5z3Vgx; Tue, 14 Nov 2023 17:34:49 +0000 (UTC) (envelope-from mjguzik@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-oo1-xc34.google.com with SMTP id 006d021491bc7-589d4033e84so3010103eaf.1; Tue, 14 Nov 2023 09:34:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699983288; x=1700588088; darn=freebsd.org; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=MY4B18eXxgcdW+CNXzUXbIWy6O7g6CzQbkkHpM86L0E=; b=CSJHA91FPRRnC3kiwe8uxSHfpE7e3C6vW8B/TbtY4v+KJCozMhG2YCJ7hn5VcwX17Z 4kgzCRQafJHfZNdGei3T8uDw283ipNWBJVHJ1BHR4+SnFXc6OLVzmYk+tYqr4CSr05XV AlXTB3a0RPgjqbUx7aQkN6H15timee8AhfqBO/i9Ib5QMtV4nawautKlJdDJNCRUoHCm vY9Fzgn0TGs+3rNjJHM7fQqE5O4onQdI8bDLShh20lPCR9ONU6jmCzH4IdCre9itYVF9 2i6r/OREDNMEv0QcmoukoBUEZvjkAjQ9rL7hBy6FKX1dDJaOlrArRSRYpUD1L8ePHzAw /FQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699983288; x=1700588088; h=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=MY4B18eXxgcdW+CNXzUXbIWy6O7g6CzQbkkHpM86L0E=; b=aD+R6d69G5E8D3HYAe8JOMm7nEyWeUs2N5x9LIiUC7W3TMxQ3V6Ykmopr/tXBgH/9+ Ym7xbgYXBDoaHSjSyqG2RggYSSUSHf3Mv5/wymrf551jOzvPBpo3agO9ySqQC+4boWL9 zUr5s3XMThRiYMuDBgFHY8+M7pco4AuWPbbVkvsiTJdeAMIkvFWiZ8h3aAkbj6kWt3Mq Y3hrCVqNe+m933S9fUbYgm7NvUjGGTr6ttisdg2xDVkthOQZe8VM887+DS8MQkp3gXAj DYpbMTxXniD0moGg9PbpIPpiylYOPA37hqS0umBI2qp37BGQVspHtezpHtmdgQ11HEOu f7uA== X-Gm-Message-State: AOJu0YwO4NnN7da0spOwxBlUvpKqatiY/pcwB/q+F+b/dQ8LpknHow9p d0J1ei/kaOyTHtTGz4ZHe2vTifLwBwsv//UirtLlKSTw X-Google-Smtp-Source: AGHT+IG2DwzheGi5SohUthV1CrgbAZKS7PJ2zOvRqpvhTaRayHtdcAcZ7yPhgV2LAsgPQH7TbDUOZaqeL7LgCTibHC4= X-Received: by 2002:a4a:ea28:0:b0:57b:7e41:9f11 with SMTP id y8-20020a4aea28000000b0057b7e419f11mr10185003ood.2.1699983288215; Tue, 14 Nov 2023 09:34:48 -0800 (PST) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Received: by 2002:ac9:57d4:0:b0:4f0:1250:dd51 with HTTP; Tue, 14 Nov 2023 09:34:47 -0800 (PST) In-Reply-To: <202311132228.3ADMS19n063754@gitrepo.freebsd.org> References: <202311132228.3ADMS19n063754@gitrepo.freebsd.org> From: Mateusz Guzik Date: Tue, 14 Nov 2023 18:34:47 +0100 Message-ID: Subject: Re: git: 89188bd6ba8d - main - vn_copy_file_range(): use local variables for invp/outvp vnodes v_mounts To: Konstantin Belousov Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] X-Rspamd-Queue-Id: 4SVD2K30P5z3Vgx On 11/13/23, Konstantin Belousov wrote: > The branch main has been updated by kib: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=89188bd6ba8d8332c65498f2b71c90e5ed4b9dae > > commit 89188bd6ba8d8332c65498f2b71c90e5ed4b9dae > Author: Konstantin Belousov > AuthorDate: 2023-11-12 18:29:14 +0000 > Commit: Konstantin Belousov > CommitDate: 2023-11-13 22:26:28 +0000 > > vn_copy_file_range(): use local variables for invp/outvp vnodes > v_mounts > > This avoids possible NULL dereference when checking mnt_vfc names. > > Reviewed by: jah, rmacklem, Olivier Certner > > Tested by: pho > Sponsored by: The FreeBSD Foundation > MFC after: 1 week > Differential revision: https://reviews.freebsd.org/D42554 > --- > sys/kern/vfs_vnops.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c > index 4e4161ef1a7f..e2227537dde1 100644 > --- a/sys/kern/vfs_vnops.c > +++ b/sys/kern/vfs_vnops.c > @@ -3046,6 +3046,7 @@ vn_copy_file_range(struct vnode *invp, off_t *inoffp, > struct vnode *outvp, > off_t *outoffp, size_t *lenp, unsigned int flags, struct ucred > *incred, > struct ucred *outcred, struct thread *fsize_td) > { > + struct mount *inmp, *outmp; > int error; > size_t len; > uint64_t uval; > @@ -3075,15 +3076,17 @@ vn_copy_file_range(struct vnode *invp, off_t > *inoffp, struct vnode *outvp, > if (len == 0) > goto out; > > + inmp = invp->v_mount; > + outmp = outvp->v_mount; > + > /* > * 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 = len; > - if (invp->v_mount == outvp->v_mount || > - strcmp(invp->v_mount->mnt_vfc->vfc_name, > - outvp->v_mount->mnt_vfc->vfc_name) == 0) > + if (inmp == outmp || strcmp(inmp->mnt_vfc->vfc_name, > + outmp->mnt_vfc->vfc_name) == 0) > error = VOP_COPY_FILE_RANGE(invp, inoffp, outvp, outoffp, > lenp, flags, incred, outcred, fsize_td); > else > > ->mnt_vfc is global per filesystem code, so this strcmp does not make any sense. mere comparison to mnt_vfc will do it. -- Mateusz Guzik