Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove extraneous and broken self-imposed 20ms sleep (nominally-50/s-rate limit) for each EFI variable read #258

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions src/efivarfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,6 @@ efivarfs_get_variable(efi_guid_t guid, const char *name, uint8_t **data,
int fd = -1;
char *path = NULL;
int rc;
int ratelimit;

/*
* The kernel rate limiter hits us if we go faster than 100 efi
* variable reads per second as non-root. So if we're not root, just
* delay this long after each read. The user is not going to notice.
*
* 1s / 100 = 10000us.
*/
ratelimit = geteuid() == 0 ? 0 : 10000;

rc = make_efivarfs_path(&path, guid, name);
if (rc < 0) {
Expand All @@ -269,14 +259,12 @@ efivarfs_get_variable(efi_guid_t guid, const char *name, uint8_t **data,
goto err;
}

usleep(ratelimit);
rc = read(fd, &ret_attributes, sizeof (ret_attributes));
if (rc < 0) {
efi_error("read failed");
goto err;
}

usleep(ratelimit);
rc = read_file(fd, &ret_data, &size);
if (rc < 0) {
efi_error("read_file failed");
Expand Down
11 changes: 0 additions & 11 deletions src/vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,6 @@ vars_get_variable(efi_guid_t guid, const char *name, uint8_t **data,
char *path = NULL;
int rc;
int fd = -1;
int ratelimit;

/*
* The kernel rate limiter hits us if we go faster than 100 efi
* variable reads per second as non-root. So if we're not root, just
* delay this long after each read. The user is not going to notice.
*
* 1s / 100 = 10000us.
*/
ratelimit = geteuid() == 0 ? 0 : 10000;

rc = asprintf(&path, "%s%s-" GUID_FORMAT "/raw_var", get_vars_path(),
name, GUID_FORMAT_ARGS(&guid));
Expand All @@ -314,7 +304,6 @@ vars_get_variable(efi_guid_t guid, const char *name, uint8_t **data,
goto err;
}

usleep(ratelimit);
rc = read_file(fd, &buf, &bufsize);
if (rc < 0) {
efi_error("read_file(%s) failed", path);
Expand Down
Loading