NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/55815: tar opens device files

The following reply was made to PR bin/55815; it has been noted by GNATS.

From: Jason Thorpe <>
To: Christos Zoulas <>
 "" <>
Subject: Re: bin/55815: tar opens device files
Date: Sat, 5 Jun 2021 07:14:39 -0700

 > On Jun 5, 2021, at 6:17 AM, Christos Zoulas <> =
 > Well, if you want to avoid TOCTOA, you need something like linux's =
 > which opens the file for "stat" like access only. But even linux does =
 not have
 > a way to "upgrade" that fd to be able to read, short of:
 > fd =3D open(path, O_PATH);
 > fstat(fd, &st);
 > if (is a device)
 > 	bail;
 > snprintf(buf, sizeof(buf), "/proc/self/fds/%d", fd);
 > nfd =3D open(buf, O_RDONLY);
 > We do have O_EXEC, but I am not sure if that is the same as O_PATH (if =
 > does not really open the device)
 If we=E2=80=99re talking about =E2=80=9Censure the file we=E2=80=99re =
 opening is a regular file=E2=80=9D, won=E2=80=99t O_REGULAR do that you =
 -- thorpej

Home | Main Index | Thread Index | Old Index