public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Vitezslav Crhonek <vcrhonek@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/kbd] rawhide: Make sure vlock -a holds the foreground VT
Date: Wed, 21 Oct 2026 07:22:34 GMT [thread overview]
Message-ID: <179256735452.1.2623555163879146030.rpms-kbd-1e4f932e58cf@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/kbd
Branch : rawhide
Commit : 1e4f932e58cf4a3ec76bc8d5c4dc3cef51cff413
Author : Vitezslav Crhonek <vcrhonek@redhat.com>
Date : 2026-10-21T09:22:12+02:00
Stats : +107/-1 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/kbd/c/1e4f932e58cf4a3ec76bc8d5c4dc3cef51cff413?branch=rawhide
Log:
Make sure vlock -a holds the foreground VT
Signed-off-by: Vitezslav Crhonek <vcrhonek@redhat.com>
---
diff --git a/kbd-2.10.0-vlock-foreground-vt.patch b/kbd-2.10.0-vlock-foreground-vt.patch
new file mode 100644
index 0000000..44c9f98
--- /dev/null
+++ b/kbd-2.10.0-vlock-foreground-vt.patch
@@ -0,0 +1,99 @@
+From 991f1caa678cbb5e486c5d847e1617f275e7184b Mon Sep 17 00:00:00 2001
+From: Alexey Gladkov <legion@kernel.org>
+Date: Mon, 19 Oct 2026 18:32:59 +0200
+Subject: [PATCH] vlock: ensure locked VT is active when locking all consoles
+
+vlock -a is documented to lock all console sessions and disable VT
+switching, telling the user that the entire console display is locked.
+This guarantee relies entirely on holding VT_PROCESS mode on the active
+VT because vlock refuses switch requests only when its own VT is in the
+foreground (change_console() in the kernel consults only fg_console).
+
+If a VT switch occurs before VT_SETMODE takes effect during startup,
+or if vlock -a is invoked on a background VT (e.g. "chvt 2; vlock -a" or
+via an idle timer), VT_SETMODE succeeds on the background terminal
+without protecting anything. Another console remains active with
+unrestricted switching, while vlock reports success and falsely claims
+the display is locked.
+
+Resolve the current VT number via TIOCGDEV and pull the terminal to
+the foreground using VT_ACTIVATE and VT_WAITACTIVE after entering
+VT_PROCESS mode. If the VT is already active, the kernel performs no
+switch. If activation or waiting fails, restore the previous VT mode and
+fail rather than claiming a lock that is not enforced.
+
+Reported-by: Vitezslav Crhonek <vcrhonek@redhat.com>
+Signed-off-by: Alexey Gladkov <legion@kernel.org>
+---
+ src/vlock/vt.c | 38 ++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 38 insertions(+)
+
+diff --git a/src/vlock/vt.c b/src/vlock/vt.c
+index e8bc5da..97aaca2 100644
+--- a/src/vlock/vt.c
++++ b/src/vlock/vt.c
+@@ -31,6 +31,7 @@
+ #include <signal.h>
+ #include <sys/vt.h>
+ #include <sys/ioctl.h>
++#include <sys/sysmacros.h>
+ #include <sys/wait.h>
+
+ #include "vlock.h"
+@@ -170,6 +171,21 @@ int init_vt(const char *tty)
+
+ if (o_lock_all) {
+ struct vt_mode vtm = ovtm;
++ unsigned int dev;
++
++ if (ioctl(vfd, TIOCGDEV, &dev) < 0) {
++ kbd_warning(errno, "ioctl TIOCGDEV");
++ fprintf(stderr,
++ _("The entire console display cannot be locked.\n"));
++ return 0;
++ }
++
++ if (!minor(dev) || minor(dev) > MAX_NR_CONSOLES) {
++ kbd_warning(0, "invalid virtual console number: %u", minor(dev));
++ fprintf(stderr,
++ _("The entire console display cannot be locked.\n"));
++ return 0;
++ }
+
+ vtm.mode = VT_PROCESS; /* Process controls switching. */
+ vtm.relsig = SIGUSR1; /* Signal to raise on release request, handled by release_vt(). */
+@@ -180,12 +196,34 @@ int init_vt(const char *tty)
+ kbd_warning(errno, "ioctl VT_SETMODE");
+ return 0;
+ }
++
++ /*
++ * Ensure our VT is in the foreground. If it is already active,
++ * the kernel does nothing.
++ */
++ if (ioctl(vfd, VT_ACTIVATE, minor(dev)) < 0) {
++ kbd_warning(errno, "ioctl VT_ACTIVATE");
++ goto activate_fail;
++ }
++
++ while (ioctl(vfd, VT_WAITACTIVE, minor(dev)) < 0) {
++ if (errno != EINTR) {
++ kbd_warning(errno, "ioctl VT_WAITACTIVE");
++ goto activate_fail;
++ }
++ }
+ }
+
+ if (is_vt)
+ init_screen();
+
+ return 1;
++
++activate_fail:
++ ioctl(vfd, VT_SETMODE, &ovtm);
++ fprintf(stderr,
++ _("The entire console display cannot be locked.\n"));
++ return 0;
+ }
+
+ void restore_vt(void)
diff --git a/kbd.spec b/kbd.spec
index 29d9b31..2108438 100644
--- a/kbd.spec
+++ b/kbd.spec
@@ -5,7 +5,7 @@
Name: kbd
Version: 2.10.0
-Release: 3%{?dist}
+Release: 4%{?dist}
Summary: Tools for configuring the console (keyboard, virtual terminals, etc.)
License: GPL-2.0-or-later
URL: http://www.kbd-project.org/
@@ -34,6 +34,10 @@ Patch5: kbd-2.0.2-unicode-start-font.patch
Patch6: kbd-2.4.0-covscan-fixes.patch
# Patch7: adds vlock option to issue prompt before invokation of pam stack
Patch7: kbd-2.0.4-vlock-add-prompt-option.patch
+# Patch8: makes sure vlock -a holds the foreground VT, otherwise it reports
+# the console as locked without actually locking it
+# https://github.com/legionus/kbd/commit/991f1caa678cbb5e486c5d847e1617f275e7184b
+Patch8: kbd-2.10.0-vlock-foreground-vt.patch
BuildRequires: gcc, bison, flex, gettext, pam-devel, check-devel, automake, make
BuildRequires: console-setup, xkeyboard-config, libxkbcommon-devel
@@ -186,6 +190,9 @@ fi
%{kbd_datadir}/keymaps/legacy
%changelog
+* Wed Oct 21 2026 Vitezslav Crhonek <vcrhonek@redhat.com> - 2.10.0-4
+- Make sure vlock -a holds the foreground VT
+
* Fri Oct 02 2026 Adam Williamson <adamwill@fedoraproject.org> - 2.10.0-3
- Fix xkb conversion to include layouts with no variants
reply other threads:[~2026-10-21 7:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179256735452.1.2623555163879146030.rpms-kbd-1e4f932e58cf@fedoraproject.org \
--to=vcrhonek@redhat.com \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox