Skip to content

Commit fe6c633

Browse files
committedOct 13, 2024··
upstream: don't start the ObscureKeystrokeTiming mitigations if
there has been traffic on a X11 forwarding channel recently. Should fix X11 forwarding performance problems when this setting is enabled. Patch from Antonio Larrosa via bz3655 OpenBSD-Commit-ID: 820284a92eb4592fcd3d181a62c1b86b08a4a7ab
1 parent 538cd28 commit fe6c633

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed
 

‎channels.c

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: channels.c,v 1.439 2024/07/25 22:40:08 djm Exp $ */
1+
/* $OpenBSD: channels.c,v 1.440 2024/10/13 22:20:06 djm Exp $ */
22
/*
33
* Author: Tatu Ylonen <ylo@cs.hut.fi>
44
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -5336,3 +5336,22 @@ x11_request_forwarding_with_spoofing(struct ssh *ssh, int client_session_id,
53365336
fatal_fr(r, "send x11-req");
53375337
free(new_data);
53385338
}
5339+
5340+
/*
5341+
* Returns whether an x11 channel was used recently (less than a second ago)
5342+
*/
5343+
int
5344+
x11_channel_used_recently(struct ssh *ssh) {
5345+
u_int i;
5346+
Channel *c;
5347+
time_t lastused = 0;
5348+
5349+
for (i = 0; i < ssh->chanctxt->channels_alloc; i++) {
5350+
c = ssh->chanctxt->channels[i];
5351+
if (c == NULL || c->ctype == NULL || c->lastused == 0 ||
5352+
strcmp(c->ctype, "x11-connection") != 0)
5353+
continue;
5354+
lastused = c->lastused;
5355+
}
5356+
return lastused != 0 && monotime() > lastused + 1;
5357+
}

‎channels.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: channels.h,v 1.157 2024/07/25 22:40:08 djm Exp $ */
1+
/* $OpenBSD: channels.h,v 1.158 2024/10/13 22:20:06 djm Exp $ */
22

33
/*
44
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -382,6 +382,7 @@ int x11_connect_display(struct ssh *);
382382
int x11_create_display_inet(struct ssh *, int, int, int, u_int *, int **);
383383
void x11_request_forwarding_with_spoofing(struct ssh *, int,
384384
const char *, const char *, const char *, int);
385+
int x11_channel_used_recently(struct ssh *ssh);
385386

386387
/* channel close */
387388

‎clientloop.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: clientloop.c,v 1.408 2024/07/01 04:31:17 djm Exp $ */
1+
/* $OpenBSD: clientloop.c,v 1.409 2024/10/13 22:20:06 djm Exp $ */
22
/*
33
* Author: Tatu Ylonen <ylo@cs.hut.fi>
44
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -659,9 +659,10 @@ obfuscate_keystroke_timing(struct ssh *ssh, struct timespec *timeout,
659659
if (just_started)
660660
return 1;
661661

662-
/* Don't arm output fd for poll until the timing interval has elapsed */
662+
/* Don't arm output fd for poll until the timing interval has elapsed... */
663663
if (timespeccmp(&now, &next_interval, <))
664-
return 0;
664+
/* ...unless there's x11 communicattion happening */
665+
return x11_channel_used_recently(ssh);
665666

666667
/* Calculate number of intervals missed since the last check */
667668
n = (now.tv_sec - next_interval.tv_sec) * 1000LL * 1000 * 1000;

0 commit comments

Comments
 (0)
Please sign in to comment.