* efivarfs: Bad directory entry when variable has / in name
@ 2013-03-19 20:36 shea-yfkUTty7RcRWk0Htik3J/w
[not found] ` <4764b7f1f5e6d79938d476ea68b99199-yfkUTty7RcRWk0Htik3J/w@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: shea-yfkUTty7RcRWk0Htik3J/w @ 2013-03-19 20:36 UTC (permalink / raw)
To: linux-efi-u79uwXL29TY76Z2rM5mHXA
Hello,
When there is an EFI variable with a forward slash in its name,
/sys/firmware/efi/efivars contains a directory entry with a forward
slash, which of course causes all sorts of problems (e.g. EINVAL from
stat(2)). Off the top of my head, I can think of two ways to handle
this:
1. Simply skip such variables when making the sysfs entries
2. Come up with an escaping scheme, e.g. "a single backslash is
actually a forward slash, two backslashes are actually a single
backslash" or some such.
Thoughts?
Cheers,
Shea Levy
P.S. Here is the program I ran to get the problematic efi variable,
which worked on qemu+OMVF and a macbook pro 9,2:
EFI_STATUS EFIAPI Main(
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_GUID var_guid = { 0x38bd6e09, 0x70b3, 0x48f0, {0x8e, 0xa2,
0x87, 0x25, 0x0c, 0xc3, 0x27, 0x71} };
CHAR16 *var_name = L"a/directory";
CHAR8 data = '\0';
EFI_STATUS status;
return SystemTable->RuntimeServices->SetVariable(
var_name,
&var_guid,
EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,
sizeof data,
&data
);
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: efivarfs: Bad directory entry when variable has / in name
[not found] ` <4764b7f1f5e6d79938d476ea68b99199-yfkUTty7RcRWk0Htik3J/w@public.gmane.org>
@ 2013-03-20 8:41 ` Matt Fleming
[not found] ` <5149762D.6080907-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Matt Fleming @ 2013-03-20 8:41 UTC (permalink / raw)
To: shea-yfkUTty7RcRWk0Htik3J/w
Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA, Matthew Garrett, Jeremy Kerr,
mikew-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org
On 03/19/2013 08:36 PM, shea-yfkUTty7RcRWk0Htik3J/w@public.gmane.org wrote:
> Hello,
>
> When there is an EFI variable with a forward slash in its name,
> /sys/firmware/efi/efivars contains a directory entry with a forward
> slash, which of course causes all sorts of problems (e.g. EINVAL from
> stat(2)). Off the top of my head, I can think of two ways to handle
> this:
>
> 1. Simply skip such variables when making the sysfs entries
> 2. Come up with an escaping scheme, e.g. "a single backslash is
> actually a forward slash, two backslashes are actually a single
> backslash" or some such.
>
> Thoughts?
Right. Have you seen machines with such variable names in the wild?
There's nothing in the specification that prohibits the use of slashes
in variable names, so I'm not in favour of option 1 above and mangling
the variable name would likely cause too much confusion.
The best solution I can come up with is to create directories for any
variable names that contain "/" (which would also make it possible to
build filesystem hierarchies with EFI variables). The user could choose
to ignore the actual layout of the filesystem since opening the variable
"adirectory/file" with,
open("adirectory/file-<guid>");
would work without it being necessary for the user to handle slashes in
variable names.
What do you think?
Presumably this is also an issue with the old EFI vars sysfs code?
--
Matt Fleming, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: efivarfs: Bad directory entry when variable has / in name
[not found] ` <5149762D.6080907-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
@ 2013-03-20 17:02 ` shea-yfkUTty7RcRWk0Htik3J/w
0 siblings, 0 replies; 3+ messages in thread
From: shea-yfkUTty7RcRWk0Htik3J/w @ 2013-03-20 17:02 UTC (permalink / raw)
To: Matt Fleming
Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA, Matthew Garrett, Jeremy Kerr,
mikew-hpIqsD4AKlfQT0dZR+AlfA
On 2013-03-20 04:41, Matt Fleming wrote:
> On 03/19/2013 08:36 PM, shea-yfkUTty7RcRWk0Htik3J/w@public.gmane.org wrote:
>> Hello,
>>
>> When there is an EFI variable with a forward slash in its name,
>> /sys/firmware/efi/efivars contains a directory entry with a forward
>> slash, which of course causes all sorts of problems (e.g. EINVAL
>> from
>> stat(2)). Off the top of my head, I can think of two ways to handle
>> this:
>>
>> 1. Simply skip such variables when making the sysfs entries
>> 2. Come up with an escaping scheme, e.g. "a single backslash is
>> actually a forward slash, two backslashes are actually a single
>> backslash" or some such.
>>
>> Thoughts?
>
> Right. Have you seen machines with such variable names in the wild?
>
No, I just thought of testing it when I saw that variable names only
require null termination.
>
> There's nothing in the specification that prohibits the use of
> slashes
> in variable names, so I'm not in favour of option 1 above and
> mangling
> the variable name would likely cause too much confusion.
>
> The best solution I can come up with is to create directories for any
> variable names that contain "/" (which would also make it possible to
> build filesystem hierarchies with EFI variables). The user could
> choose
> to ignore the actual layout of the filesystem since opening the
> variable
> "adirectory/file" with,
>
> open("adirectory/file-<guid>");
>
> would work without it being necessary for the user to handle slashes
> in
> variable names.
>
> What do you think?
>
What happens when I create a variable starting with a slash or ending
with a slash, or something like "dir/../../../../root/private-file"?
Also, how would you create such a variable from linux, mkdir followed by
creating the file?
Looks like an escaping scheme (though of course my proposed one was
braindead and wouldn't work) might be the best option here, I might spin
up a patch this weekend.
>
> Presumably this is also an issue with the old EFI vars sysfs code?
Never used that directly myself (only through efibootmgr).
Cheers,
Shea Levy
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-20 17:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-19 20:36 efivarfs: Bad directory entry when variable has / in name shea-yfkUTty7RcRWk0Htik3J/w
[not found] ` <4764b7f1f5e6d79938d476ea68b99199-yfkUTty7RcRWk0Htik3J/w@public.gmane.org>
2013-03-20 8:41 ` Matt Fleming
[not found] ` <5149762D.6080907-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2013-03-20 17:02 ` shea-yfkUTty7RcRWk0Htik3J/w
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).