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

Backport patch for increased rowhammer resistance from OpenBSD #124

Open
wants to merge 1 commit into
base: master
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
16 changes: 10 additions & 6 deletions doas.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@ permit(uid_t uid, gid_t *groups, int ngroups, const struct rule **lastr,
*lastr = rules[i];
}
if (!*lastr)
return -1;
if ((*lastr)->action == PERMIT)
return 0;
return (*lastr)->action == PERMIT;
return -1;
}

static void
Expand Down Expand Up @@ -184,16 +186,17 @@ checkconfig(const char *confpath, int argc, char **argv,
uid_t uid, gid_t *groups, int ngroups, uid_t target)
{
const struct rule *rule;
int rv;

if (setresuid(uid, uid, uid) != 0)
err(1, "setresuid");

parseconfig(confpath, 0);
if (!argc)
exit(0);

if (permit(uid, groups, ngroups, &rule, target, argv[0],
(const char **)argv + 1)) {
rv = permit(uid, groups, ngroups, &rule, target, argv[0],
(const char **)argv + 1);
if (rv == 0) {
printf("permit%s\n", (rule->options & NOPASS) ? " nopass" : "");
exit(0);
} else {
Expand Down Expand Up @@ -342,8 +345,9 @@ main(int argc, char **argv)
}

cmd = argv[0];
if (!permit(uid, groups, ngroups, &rule, target, cmd,
(const char **)argv + 1)) {
rv = permit(uid, groups, ngroups, &rule, target, cmd,
(const char **)argv + 1);
if (rv != 0) {
syslog(LOG_AUTHPRIV | LOG_NOTICE,
"command not permitted for %s: %s", mypw->pw_name, cmdline);
errc(1, EPERM, NULL);
Expand Down
2 changes: 1 addition & 1 deletion doas.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct passwd;
char **prepenv(const struct rule *, const struct passwd *,
const struct passwd *);

#define PERMIT 1
#define PERMIT -1
#define DENY 2

#define NOPASS 0x1
Expand Down