From nobody Fri Jun 23 18:49:42 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 4QnmWH4cRYz4gX9v; Fri, 23 Jun 2023 18:49:47 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) (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 4QnmWG3t3Mz44D1; Fri, 23 Jun 2023 18:49:46 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6687096c6ddso615191b3a.0; Fri, 23 Jun 2023 11:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687546184; x=1690138184; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=/g4d/Ebmthdu8EYYhFsdNKR80HRLGYjmpAJCUqEbiEk=; b=DLBNwbzD1S3MRsa4doLy6FMKNO5AGT7w1tybL2+R+1aSTteE47Gd1Llxst0KygwDKV Mp8j7cIo/VB1F0D6X2MIihOI1SgSuCGsQhA1UqDD3Cw4c1azE8uBC87PTAxTveLH7iPS +jXqOmbsIlaTjqdVtuyw2i+PWOIhyY377amAAOnDgKUoxcqjuK8bhpoApqGcA+RfOP+5 8GL8A/EMthUeMqZ+h0QG7fhqO1wuzTYh9rnZ7BlRmSLkczzXLDASgyJwmIKnt9WVAJu5 t9FnVchYVaT0F5zz+OazsaYTT/T+iVBiGjU0ylffCcC9RrCOlwU1UFGy0a3OD39aYPWG zf0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687546184; x=1690138184; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/g4d/Ebmthdu8EYYhFsdNKR80HRLGYjmpAJCUqEbiEk=; b=LtJ7sKbgwajSAAibAKQIl2NN2bCzQzy6t58dl6mYNKkpaYiGefEVUwog/sjPOwct4d CDYRxxtxDPdjl9Vmxn7wQt3aBzG+TNEFx0Rr2XDtB+TR7qonrq4DV50pFBOSUWKO/bGo s3/Z8scYaAclJ6u1fix1pKwBWQoncTAFWJto7g/Kc6WFf8Peg7tjM4BouCozobfYkJVH AW/Tie45IFwqpCq+Zln7pD31e0VsRvOY1NmX6B1iK0PsCcrgz218EPSmXxFMHyPqDlWO ajsiHkIlLydzV3sQXyoVc/EcuCXgXBPEKKlfaYthpTTPwhMa3EIAsZGnlJ35nhyfWLgg RPYQ== X-Gm-Message-State: AC+VfDy3X+WOB+4dNXkAaRGEx1akDkM9mklgzFuE9mSA7JXZLEQuFbkW UfK2/l5oI86rkrZWWvF606zcp64JE7s= X-Google-Smtp-Source: ACHHUZ6HlAof8g5zMcRkK7ysimvKVGF1TLPxvhgb8IwxeUrt5wntknJ9JBAqrmiBdJBe82KCGcR59Q== X-Received: by 2002:a05:6a20:2590:b0:119:87f9:3b04 with SMTP id k16-20020a056a20259000b0011987f93b04mr19419523pzd.6.1687546184212; Fri, 23 Jun 2023 11:49:44 -0700 (PDT) Received: from smtpclient.apple (c-73-19-52-228.hsd1.wa.comcast.net. [73.19.52.228]) by smtp.gmail.com with ESMTPSA id s1-20020a170902a50100b001b3fb2f0296sm6931262plq.120.2023.06.23.11.49.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jun 2023 11:49:43 -0700 (PDT) From: Enji Cooper Message-Id: Content-Type: multipart/signed; boundary="Apple-Mail=_F9A75F62-F1BB-43C2-8C19-EBC79BAE7801"; protocol="application/pgp-signature"; micalg=pgp-sha256 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 (Mac OS X Mail 16.0 \(3696.120.41.1.3\)) Subject: Re: git: fc915f1be145 - main - pseudofs: Fix a potential out-of-bounds access in pfs_lookup() Date: Fri, 23 Jun 2023 11:49:42 -0700 In-Reply-To: Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org To: Mark Johnston References: <202306231509.35NF9sAk037726@gitrepo.freebsd.org> <0BAC85B7-6A67-4F6E-87B8-97ABD2FF7075@gmail.com> X-Mailer: Apple Mail (2.3696.120.41.1.3) X-Rspamd-Queue-Id: 4QnmWG3t3Mz44D1 X-Spamd-Bar: ---- 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-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N --Apple-Mail=_F9A75F62-F1BB-43C2-8C19-EBC79BAE7801 Content-Type: multipart/alternative; boundary="Apple-Mail=_D51E7714-1DA8-491A-844D-DF0846B5FC1D" --Apple-Mail=_D51E7714-1DA8-491A-844D-DF0846B5FC1D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jun 23, 2023, at 8:56 AM, Mark Johnston wrote: =E2=80=A6 >> Naive question: should this be an && conditional or an || = conditional? >=20 > It should be &&. Using || here would reintroduce the original bug. > If strncmp(pname, pn->pn_name, namelen) =3D=3D 0, then > strlen(pn->pn_name) >=3D namelen, and pn->pn_name is nul-terminated, = so it > is safe to check pn->pn_name[namelen] =3D=3D '\0'. >=20 >> If the former, could this be simplified by using a direct NUL char = equality check instead of using strncmp? >=20 > I'm not sure what you mean by this. This code is simply checking > whether pname and pn->pn_name are the same string, without assuming = that > pname is nul-terminated. I completely misread the conditional when I sent out my email. = After you pointed out the obvious part dealing with namelen, it = doesn=E2=80=99t make sense for the conditionals to exist by themselves. Thanks for the explanation :)! -Enji --Apple-Mail=_D51E7714-1DA8-491A-844D-DF0846B5FC1D Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
On = Jun 23, 2023, at 8:56 AM, Mark Johnston <markj@FreeBSD.org> = wrote:

=E2=80=A6
Naive = question: should this be an && conditional or an || = conditional?

It should be &&.  Using || here would = reintroduce the original bug.
If strncmp(pname, pn->pn_name, namelen) =3D=3D 0, = then
strlen(pn->pn_name) >=3D namelen, and pn->pn_name is = nul-terminated, so it
is safe to check pn->pn_name[namelen] =3D=3D = '\0'.

If = the former, could this be simplified by using a direct NUL char equality = check instead of using strncmp?

I'm not sure what you mean by = this.  This code is simply checking
whether pname and pn->pn_name are the same string, without = assuming that
pname is = nul-terminated.

= I completely misread the conditional when I sent out my email. = After you pointed out the obvious part dealing with namelen, it = doesn=E2=80=99t make sense for the conditionals to exist by = themselves.
Thanks for the explanation = :)!
-Enji
= --Apple-Mail=_D51E7714-1DA8-491A-844D-DF0846B5FC1D-- --Apple-Mail=_F9A75F62-F1BB-43C2-8C19-EBC79BAE7801 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEtvtxN6kOllEF3nmX5JFNMZeDGN4FAmSV6UYACgkQ5JFNMZeD GN50Bg/+PM8qBKLJFGqnq9CpweSVddfEAjDYZ7R9ETaxddyytqqEkW11GR3aUDNy N8lmy5ux59y6l2pMeCutJ0I6vCRX+taXqZEwOPohlEMtX2bYw/om1vQBc92JVmdu XcVyng8l09ZnYZy/dJsiAG9/tMW5qn7DLkX0aYQcvKTzn/3z32tpyWUBxe7wVZ8X gWKkztSp/wvNGyoqLn9EIiMLBPweZzpKq6PIhmfKFsvxBPuPFhNUcpQ3LKAxmEIO 248lG7GNqDmy/e0uD7IY0B1jEdIkFdv3k9CcjZkSRyfLa+8+hHvy1ZdWOEnAoV5W LIJPsdWgZq5A0cCsgRmTFGzOmubgnXOI8yRikpJpSI/hUHIHysAat4dGwCJml28M 7/B1CHZ0IzS9HNWslA5pe8d3xpAT+5n+EF4wFIfYb/wpH/7dnW34xWaaiP8J9s1I CiWg2V99pUzhVBBjzqmj3EM9K7RQAyf6OUdMDvy+RLLASeOmvMNlcdLdt7IWcW7l 6FTBN5vPlhyvXfiDvX//5Rnhd0j1ZKuGZmX8OD80IbDRK6R5tky/bfx9ZD0U087V QBaFNSAyWK9kl8xRo7f1ilCmBDeMM4e/r4Dlq7HBOWhnJR+USfXRpv6WsBec46he bjzxGWmBnryDFL9xU+3pELy5rklwTQY7BsoB0/bpV17vB59Nbr0= =aJ/Z -----END PGP SIGNATURE----- --Apple-Mail=_F9A75F62-F1BB-43C2-8C19-EBC79BAE7801--