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

VT kbd reset check #12378

Merged
merged 2 commits into from May 16, 2019
Merged

VT kbd reset check #12378

merged 2 commits into from May 16, 2019

Conversation

rbalint
Copy link
Contributor

@rbalint rbalint commented Apr 24, 2019

No description provided.

@setharnold
Copy link

Is it ever okay for vt_reset_keyboard() or toggle_utf8() to run without checking vt_verify_kbmode() first? Should this call be moved into these two functions rather than into all the call sites?

Thanks

@rbalint
Copy link
Contributor Author

rbalint commented Apr 25, 2019

@setharnold I felt the code more descriptive having the checks and the actions separately rather than moving the extra checks to the actions. Also I did not add extra logging, because it is normal to have VTs in raw mode.
I can imagine that we may call vt_reset_keyboard() when the keyboard is really in the bad state, but did not find such scenario myself.

Copy link
Member

@poettering poettering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, just some nitpicks

src/basic/terminal-util.c Outdated Show resolved Hide resolved
src/basic/terminal-util.c Outdated Show resolved Hide resolved
@poettering
Copy link
Member

i think i agree with @setharnold though: if those checks are pre-condition to these operations they probably should move into the callee, not the caller. Encapsulation and terseness is nice, and the caller shouldn't need to know about that

@poettering poettering added login reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks util-lib vconsole labels Apr 30, 2019
@rbalint
Copy link
Contributor Author

rbalint commented Apr 30, 2019

@setharnold @poettering OK, made the requested changes.

Copy link
Member

@poettering poettering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, CI doesn't pass. Please always build and test before pushing. Thanks!

src/basic/terminal-util.c Show resolved Hide resolved
src/vconsole/vconsole-setup.c Outdated Show resolved Hide resolved
@rbalint rbalint changed the title VT kbd reset check WIP: VT kbd reset check Apr 30, 2019
@rbalint rbalint changed the title WIP: VT kbd reset check VT kbd reset check Apr 30, 2019
@rbalint
Copy link
Contributor Author

rbalint commented May 14, 2019

@poettering Would you like to see something else to be changed?

Copy link
Member

@poettering poettering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks pretty good, just some nitpcks

r = vt_verify_kbmode(fd);
if (r < 0) {
if (r == -EBUSY) {
log_debug_errno(-r, "Keyboard is not in XLATE or UNICODE mode, not resetting: %m");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to negate "r". log_debug_errno() (and its friends) generally do that internally if necessary.

Let's keep the indentation level small here, hence maybe write as:

if (r == -EBUSY) {
        …
} else if (r < 0)
        return r;

r = vt_verify_kbmode(fd);
if (r < 0) {
if (r == -EBUSY) {
log_debug_errno(-r, "Virtual console %s is not in K_XLATE or K_UNICODE: %m", name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above, no negation necessary

log_debug_errno(-r, "Virtual console %s is not in K_XLATE or K_UNICODE: %m", name);
return 0;
} else
return log_debug_errno(-r, "Failed to verify kbdmode on %s: %m", name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dito

return 0;
} else
return log_debug_errno(-r, "Failed to verify kbdmode on %s: %m", name);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and similar to above: small indentation levels are cool!

@poettering poettering added this to the v243 milestone May 14, 2019
log_debug_errno(r, "Virtual console %s is not in K_XLATE or K_UNICODE: %m", name);
return 0;
} else if (r < 0)
return log_debug_errno(r, "Failed to verify kbdmode on %s: %m", name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all other failure codepaths in this functions log loudly, this one should hence too, i.e. bump this one line from log_debug_errno() to log_warning_errno()

Copy link
Member

@poettering poettering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(btw, please always add a quick comment when you push a new version. For some reason github doesn't always notify us about pushes)

@rbalint rbalint force-pushed the vt-kbd-reset-check branch 2 times, most recently from e7e5b3e to de564ef Compare May 15, 2019 14:29
Switching to K_UNICODE from other than L_XLATE can make the keyboard
unusable and possibly leak keypresses from X.

BugLink: https://launchpad.net/bugs/1803993
@rbalint
Copy link
Contributor Author

rbalint commented May 16, 2019

@poettering I see bionic autopkgtests failing for other PR-s, too, and I ran autopkgtest successfully when I cherry-picked the change to Disco, thus I believe the failing tests are not related to this commit.

@poettering poettering merged commit 9725f1a into systemd:master May 16, 2019
@jackpot51
Copy link
Contributor

🎉

@setharnold
Copy link

Thanks everyone for working on this!

Use CVE-2018-20839.

Thanks

@mbiebl
Copy link
Contributor

mbiebl commented May 19, 2019

@rbalint seems like this has caused a regression.
Could you have a look at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=929229 ?
I've pulled this particular patch into 241-4.

@rbalint
Copy link
Contributor Author

rbalint commented May 21, 2019

Thanks, the regression is tracked in #12616 .

@fbuihuu
Copy link
Contributor

fbuihuu commented May 22, 2019

Sorry for coming late but I can't figure out how the initial issue that @rbalint fixed can happen in practice and the commit message of the relevant commit doesn't really help...

In my understanding logind resets the keyboard to K_UNICODE only when it has to acknowledge the VT-switch signal itself for a terminal which has no controlling process.

@rbalint did you manage to reproduce the issue ? If so can you tell how exactly ?

I'm asking because I can't here.

@keszybz keszybz removed the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label May 22, 2019
@jsoref
Copy link
Contributor

jsoref commented May 29, 2019

fwiw, github never notifies for force-pushes. Even though it's well aware of them. People can complain to github support and maybe they'll eventually fix it.

poettering added a commit that referenced this pull request Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

8 participants