Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Jul 2025 10:06:56 -0600
From:      Alan Somers <asomers@freebsd.org>
To:        Konstantin Belousov <kib@freebsd.org>
Cc:        src-committers@freebsd.org, dev-commits-src-all@freebsd.org,  dev-commits-src-main@freebsd.org
Subject:   Re: git: 29af6d2e2ec9 - main - msdosfs: replace '/' in direntries with '?'
Message-ID:  <CAOtMX2hdWCAzhieDJkzWZf-5bdw-%2Bycq0m_t0fdrqag11hPW0A@mail.gmail.com>
In-Reply-To: <202507172154.56HLsGLL095197@gitrepo.freebsd.org>
References:  <202507172154.56HLsGLL095197@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
--00000000000076cc48063a36510e
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Should we move this logic up into kern_getdirentries?  msdosfs is not the
only file system vulnerable to this problem.

On Thu, Jul 17, 2025 at 3:54=E2=80=AFPM Konstantin Belousov <kib@freebsd.or=
g> wrote:

> The branch main has been updated by kib:
>
> URL:
> https://cgit.FreeBSD.org/src/commit/?id=3D29af6d2e2ec9fe8df7cf1e1a0bf3597=
028831b18
>
> commit 29af6d2e2ec9fe8df7cf1e1a0bf3597028831b18
> Author:     Konstantin Belousov <kib@FreeBSD.org>
> AuthorDate: 2025-07-17 01:12:05 +0000
> Commit:     Konstantin Belousov <kib@FreeBSD.org>
> CommitDate: 2025-07-17 21:53:54 +0000
>
>     msdosfs: replace '/' in direntries with '?'
>
>     PR:     288266
>     Reported by:    Robert Morris <rtm@lcs.mit.edu>
>     Reviewed by:    markj
>     Sponsored by:   The FreeBSD Foundation
>     MFC after:      1 week
>     Differential revision:  https://reviews.freebsd.org/D51365
> ---
>  sys/fs/msdosfs/msdosfs_conv.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/sys/fs/msdosfs/msdosfs_conv.c b/sys/fs/msdosfs/msdosfs_conv.=
c
> index da4848169173..208b64930e61 100644
> --- a/sys/fs/msdosfs/msdosfs_conv.c
> +++ b/sys/fs/msdosfs/msdosfs_conv.c
> @@ -797,19 +797,24 @@ mbsadjpos(const char **instr, size_t inlen, size_t
> outlen, int weight, int flag,
>  static u_char *
>  dos2unixchr(u_char *outbuf, const u_char **instr, size_t *ilen, int
> lower, struct msdosfsmount *pmp)
>  {
> -       u_char c, *outp;
> -       size_t len, olen;
> +       u_char c, *outp, *outp1;
> +       size_t i, len, olen;
>
>         outp =3D outbuf;
>         if (pmp->pm_flags & MSDOSFSMNT_KICONV && msdosfs_iconv) {
>                 olen =3D len =3D 4;
>
> +               outp1 =3D outp;
>                 if (lower & (LCASE_BASE | LCASE_EXT))
>                         msdosfs_iconv->convchr_case(pmp->pm_d2u, (const
> char **)instr,
>                                                   ilen, (char **)&outp,
> &olen, KICONV_LOWER);
>                 else
>                         msdosfs_iconv->convchr(pmp->pm_d2u, (const char
> **)instr,
>                                              ilen, (char **)&outp, &olen)=
;
> +               for (i =3D 0; i < outp - outp1; i++) {
> +                       if (outp1[i] =3D=3D '/')
> +                               outp1[i] =3D '?';
> +               }
>                 len -=3D olen;
>
>                 /*
> @@ -826,6 +831,8 @@ dos2unixchr(u_char *outbuf, const u_char **instr,
> size_t *ilen, int lower, struc
>                 c =3D dos2unix[c];
>                 if (lower & (LCASE_BASE | LCASE_EXT))
>                         c =3D u2l[c];
> +               if (c =3D=3D '/')
> +                       c =3D '?';
>                 *outp++ =3D c;
>                 outbuf[1] =3D '\0';
>         }
>

--00000000000076cc48063a36510e
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Should we move this logic up into kern_getdirentries?=
=C2=A0 msdosfs is not the only file system vulnerable to this problem.</div=
><br><div class=3D"gmail_quote gmail_quote_container"><div dir=3D"ltr" clas=
s=3D"gmail_attr">On Thu, Jul 17, 2025 at 3:54=E2=80=AFPM Konstantin Belouso=
v &lt;<a href=3D"mailto:kib@freebsd.org">kib@freebsd.org</a>&gt; wrote:<br>=
</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;b=
order-left:1px solid rgb(204,204,204);padding-left:1ex">The branch main has=
 been updated by kib:<br>
<br>
URL: <a href=3D"https://cgit.FreeBSD.org/src/commit/?id=3D29af6d2e2ec9fe8df=
7cf1e1a0bf3597028831b18" rel=3D"noreferrer" target=3D"_blank">https://cgit.=
FreeBSD.org/src/commit/?id=3D29af6d2e2ec9fe8df7cf1e1a0bf3597028831b18</a><b=
r>
<br>
commit 29af6d2e2ec9fe8df7cf1e1a0bf3597028831b18<br>
Author:=C2=A0 =C2=A0 =C2=A0Konstantin Belousov &lt;kib@FreeBSD.org&gt;<br>
AuthorDate: 2025-07-17 01:12:05 +0000<br>
Commit:=C2=A0 =C2=A0 =C2=A0Konstantin Belousov &lt;kib@FreeBSD.org&gt;<br>
CommitDate: 2025-07-17 21:53:54 +0000<br>
<br>
=C2=A0 =C2=A0 msdosfs: replace &#39;/&#39; in direntries with &#39;?&#39;<b=
r>
<br>
=C2=A0 =C2=A0 PR:=C2=A0 =C2=A0 =C2=A0288266<br>
=C2=A0 =C2=A0 Reported by:=C2=A0 =C2=A0 Robert Morris &lt;<a href=3D"mailto=
:rtm@lcs.mit.edu" target=3D"_blank">rtm@lcs.mit.edu</a>&gt;<br>
=C2=A0 =C2=A0 Reviewed by:=C2=A0 =C2=A0 markj<br>
=C2=A0 =C2=A0 Sponsored by:=C2=A0 =C2=A0The FreeBSD Foundation<br>
=C2=A0 =C2=A0 MFC after:=C2=A0 =C2=A0 =C2=A0 1 week<br>
=C2=A0 =C2=A0 Differential revision:=C2=A0 <a href=3D"https://reviews.freeb=
sd.org/D51365" rel=3D"noreferrer" target=3D"_blank">https://reviews.freebsd=
.org/D51365</a><br>
---<br>
=C2=A0sys/fs/msdosfs/msdosfs_conv.c | 11 +++++++++--<br>
=C2=A01 file changed, 9 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/sys/fs/msdosfs/msdosfs_conv.c b/sys/fs/msdosfs/msdosfs_conv.c<=
br>
index da4848169173..208b64930e61 100644<br>
--- a/sys/fs/msdosfs/msdosfs_conv.c<br>
+++ b/sys/fs/msdosfs/msdosfs_conv.c<br>
@@ -797,19 +797,24 @@ mbsadjpos(const char **instr, size_t inlen, size_t ou=
tlen, int weight, int flag,<br>
=C2=A0static u_char *<br>
=C2=A0dos2unixchr(u_char *outbuf, const u_char **instr, size_t *ilen, int l=
ower, struct msdosfsmount *pmp)<br>
=C2=A0{<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0u_char c, *outp;<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0size_t len, olen;<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0u_char c, *outp, *outp1;<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0size_t i, len, olen;<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 outp =3D outbuf;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (pmp-&gt;pm_flags &amp; MSDOSFSMNT_KICONV &a=
mp;&amp; msdosfs_iconv) {<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 olen =3D len =3D 4;=
<br>
<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0outp1 =3D outp;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (lower &amp; (LC=
ASE_BASE | LCASE_EXT))<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 msdosfs_iconv-&gt;convchr_case(pmp-&gt;pm_d2u, (const char **)in=
str,<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ilen, (char **)&amp;outp, &amp;olen, KICONV_LOW=
ER);<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 else<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 msdosfs_iconv-&gt;convchr(pmp-&gt;pm_d2u, (const char **)instr,<=
br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0ilen, (char **)&amp;outp, &amp;olen);<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0for (i =3D 0; i &lt=
; outp - outp1; i++) {<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0if (outp1[i] =3D=3D &#39;/&#39;)<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0outp1[i] =3D &#39;?&#39;;<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 len -=3D olen;<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /*<br>
@@ -826,6 +831,8 @@ dos2unixchr(u_char *outbuf, const u_char **instr, size_=
t *ilen, int lower, struc<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 c =3D dos2unix[c];<=
br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (lower &amp; (LC=
ASE_BASE | LCASE_EXT))<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 c =3D u2l[c];<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (c =3D=3D &#39;/=
&#39;)<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0c =3D &#39;?&#39;;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *outp++ =3D c;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 outbuf[1] =3D &#39;=
\0&#39;;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br>
</blockquote></div></div>

--00000000000076cc48063a36510e--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOtMX2hdWCAzhieDJkzWZf-5bdw-%2Bycq0m_t0fdrqag11hPW0A>