Skip to contentSkip to conversation

drm/atomic: do not branch based on the value of current->comm[0]

PATCH In review Jason A. Donenfeld 4 participants 6 messages Nov 5, 2022 – Nov 16, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/atomic: do not branch based on the value of current->comm[0]

This reverts 26b1d3b527e7 ("drm/atomic: Take the atomic toys away from X"), a rootkit-like kludge that has no business being inside of a general purpose kernel. It's the type of debugging hack I'll use momentarily but never commit, or a sort of babbies-first-process-hider malware trick.

The backstory is that some userspace code -- xorg-server -- has a modesetting DDX that isn't really coded right. With nobody wanting to maintain X11 anymore, rather than fixing the buggy code, the kernel was adjusted to avoid having to touch X11. A bummer, but fair enough: if the kernel doesn't want to support some userspace API any more, the right thing to do is to arrange for a graceful fallback where userspace thinks it's not available in a manageable way.

However, the *way* it goes about doing that is just to check current->comm[0] == 'X', and disable it for only that case. So that means it's *not* simply a matter of the kernel not wanting to support a particular userspace API anymore, but rather it's the kernel not wanting to support xorg-server, in theory, but actually, it turns out, that's all processes that begin with 'X'.

Playing games with current->comm like this is obviously wrong, and it's pretty shocking that this ever got committed.

Fortunately, since this was committed, somebody did actually disable the userspace side by default in X11:
https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/180 and this was three years ago. So userspace is mostly fine now for ordinary default usage. And people who opt into this -- since it does actually work fine for many use cases on i915 -- ostensibly know what they're getting themselves into (my case).

So let's just revert this comm[0] == 'X' business entirely, but still allow for value == 2, in case anybody actually started working on that part elsewhere.

Fixes 26b1d3b527e7 ("drm/atomic: Take the atomic toys away from X")
Cc Daniel Vetter <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ilia Mirkin <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Michel Dänzer <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Adam Jackson <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Sean Paul <[email protected]>
Cc David Airlie <[email protected]>
Cc Rob Clark <[email protected]>
Cc Sultan Alsawaf <[email protected]>
---
 drivers/gpu/drm/drm_ioctl.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/gpu/drm/drm_ioctl.c +0 -5
index ca2a6e6101dc..017f31e67179 100644
@@ -336,11 +336,6 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
 	case DRM_CLIENT_CAP_ATOMIC:
 		if (!drm_core_check_feature(dev, DRIVER_ATOMIC))
 			return -EOPNOTSUPP;
-		/* The modesetting DDX has a totally broken idea of atomic. */
-		if (current->comm[0] == 'X' && req->value == 1) {
-			pr_info("broken atomic modeset userspace detected, disabling atomic\n");
-			return -EOPNOTSUPP;
-		}
 		if (req->value > 2)
 			return -EINVAL;
 		file_priv->atomic = req->value;
Signature · 1 line
2.38.1
#1 lore raw

Hi David,

I'm a bit surprised that this patch was ignored. I had sort of assumed the response would be, "good god, I can't believe we're doing this. Applied to drm-next!" rather than crickets, but maybe it just got buried under a lot of other patches. So I thought I'd poke about this again. The original message is reproduced in full below.

Regards,
Jason

Quoted 75 lines · Jason A. Donenfeld

This reverts 26b1d3b527e7 ("drm/atomic: Take the atomic toys away from X"), a rootkit-like kludge that has no business being inside of a general purpose kernel. It's the type of debugging hack I'll use momentarily but never commit, or a sort of babbies-first-process-hider malware trick.

The backstory is that some userspace code -- xorg-server -- has a modesetting DDX that isn't really coded right. With nobody wanting to maintain X11 anymore, rather than fixing the buggy code, the kernel was adjusted to avoid having to touch X11. A bummer, but fair enough: if the kernel doesn't want to support some userspace API any more, the right thing to do is to arrange for a graceful fallback where userspace thinks it's not available in a manageable way.

However, the *way* it goes about doing that is just to check current->comm[0] == 'X', and disable it for only that case. So that means it's *not* simply a matter of the kernel not wanting to support a particular userspace API anymore, but rather it's the kernel not wanting to support xorg-server, in theory, but actually, it turns out, that's all processes that begin with 'X'.

Playing games with current->comm like this is obviously wrong, and it's pretty shocking that this ever got committed.

Fortunately, since this was committed, somebody did actually disable the userspace side by default in X11:
https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/180 and this was three years ago. So userspace is mostly fine now for ordinary default usage. And people who opt into this -- since it does actually work fine for many use cases on i915 -- ostensibly know what they're getting themselves into (my case).

So let's just revert this comm[0] == 'X' business entirely, but still allow for value == 2, in case anybody actually started working on that part elsewhere.

Fixes 26b1d3b527e7 ("drm/atomic: Take the atomic toys away from X")
Cc Daniel Vetter <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ilia Mirkin <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Michel Dänzer <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Adam Jackson <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Sean Paul <[email protected]>
Cc David Airlie <[email protected]>
Cc Rob Clark <[email protected]>
Cc Sultan Alsawaf <[email protected]>
---
 drivers/gpu/drm/drm_ioctl.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/gpu/drm/drm_ioctl.c +0 -5
index ca2a6e6101dc..017f31e67179 100644
@@ -336,11 +336,6 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
 	case DRM_CLIENT_CAP_ATOMIC:
 		if (!drm_core_check_feature(dev, DRIVER_ATOMIC))
 			return -EOPNOTSUPP;
-		/* The modesetting DDX has a totally broken idea of atomic. */
-		if (current->comm[0] == 'X' && req->value == 1) {
-			pr_info("broken atomic modeset userspace detected, disabling atomic\n");
-			return -EOPNOTSUPP;
-		}
 		if (req->value > 2)
 			return -EINVAL;
 		file_priv->atomic = req->value;
Signature · 1 line
2.38.1
#2 lore raw

Hey again,

Quoted 1 line · Jason A. Donenfeld

I'm a bit surprised that this patch was ignored. I had sort of assumed

Mystery solved: this message to you bounced from this linux.ie address I somehow wound up with in the recipients list. Fixing now by using the one in MAINTAINERS. Sorry about that.

Jason

Quoted 75 lines · Jason A. Donenfeld
Quoted 74 lines

This reverts 26b1d3b527e7 ("drm/atomic: Take the atomic toys away from X"), a rootkit-like kludge that has no business being inside of a general purpose kernel. It's the type of debugging hack I'll use momentarily but never commit, or a sort of babbies-first-process-hider malware trick.

The backstory is that some userspace code -- xorg-server -- has a modesetting DDX that isn't really coded right. With nobody wanting to maintain X11 anymore, rather than fixing the buggy code, the kernel was adjusted to avoid having to touch X11. A bummer, but fair enough: if the kernel doesn't want to support some userspace API any more, the right thing to do is to arrange for a graceful fallback where userspace thinks it's not available in a manageable way.

However, the *way* it goes about doing that is just to check current->comm[0] == 'X', and disable it for only that case. So that means it's *not* simply a matter of the kernel not wanting to support a particular userspace API anymore, but rather it's the kernel not wanting to support xorg-server, in theory, but actually, it turns out, that's all processes that begin with 'X'.

Playing games with current->comm like this is obviously wrong, and it's pretty shocking that this ever got committed.

Fortunately, since this was committed, somebody did actually disable the userspace side by default in X11:
https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/180 and this was three years ago. So userspace is mostly fine now for ordinary default usage. And people who opt into this -- since it does actually work fine for many use cases on i915 -- ostensibly know what they're getting themselves into (my case).

So let's just revert this comm[0] == 'X' business entirely, but still allow for value == 2, in case anybody actually started working on that part elsewhere.

Fixes 26b1d3b527e7 ("drm/atomic: Take the atomic toys away from X")
Cc Daniel Vetter <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ilia Mirkin <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Michel Dänzer <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Adam Jackson <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Sean Paul <[email protected]>
Cc David Airlie <[email protected]>
Cc Rob Clark <[email protected]>
Cc Sultan Alsawaf <[email protected]>
---
 drivers/gpu/drm/drm_ioctl.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/gpu/drm/drm_ioctl.c +0 -5
index ca2a6e6101dc..017f31e67179 100644
@@ -336,11 +336,6 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
 	case DRM_CLIENT_CAP_ATOMIC:
 		if (!drm_core_check_feature(dev, DRIVER_ATOMIC))
 			return -EOPNOTSUPP;
-		/* The modesetting DDX has a totally broken idea of atomic. */
-		if (current->comm[0] == 'X' && req->value == 1) {
-			pr_info("broken atomic modeset userspace detected, disabling atomic\n");
-			return -EOPNOTSUPP;
-		}
 		if (req->value > 2)
 			return -EINVAL;
 		file_priv->atomic = req->value;
Signature · 1 line
2.38.1
maintainer
#3 lore raw
In reply to Jason A. Donenfeld
Quoted 22 lines · Jason A. Donenfeld

This reverts 26b1d3b527e7 ("drm/atomic: Take the atomic toys away from X"), a rootkit-like kludge that has no business being inside of a general purpose kernel. It's the type of debugging hack I'll use momentarily but never commit, or a sort of babbies-first-process-hider malware trick.

The backstory is that some userspace code -- xorg-server -- has a modesetting DDX that isn't really coded right. With nobody wanting to maintain X11 anymore, rather than fixing the buggy code, the kernel was adjusted to avoid having to touch X11. A bummer, but fair enough: if the kernel doesn't want to support some userspace API any more, the right thing to do is to arrange for a graceful fallback where userspace thinks it's not available in a manageable way.

However, the *way* it goes about doing that is just to check current->comm[0] == 'X', and disable it for only that case. So that means it's *not* simply a matter of the kernel not wanting to support a particular userspace API anymore, but rather it's the kernel not wanting to support xorg-server, in theory, but actually, it turns out, that's all processes that begin with 'X'.

Quoted 2 lines

Playing games with current->comm like this is obviously wrong, and it's pretty shocking that this ever got committed.

I've been ignoring this because I don't really want to reintroduce a regression for deployed X servers. I don't see the value.

You use a lot of what I'd call overly not backed up language. Why is it obviously wrong though? Is it "playing games" or is it accessing the comm to see if the process starts with X.

Do we have lots of userspace processes starting with X that access this specific piece of the drm modesetting API. I suppose we might and if we have complaints about that I'd say let's try to fix it better.

Sometimes engineering is hard, It was a big enough problem that a big enough hammer was used.

I'd hope @Daniel Vetter can comment as well since the original patch was his.

Dave.

Acked-by on v1 1/1
#5 lore raw
In reply to Jason A. Donenfeld

Am 2022-11-05 23:20, schrieb Jason A. Donenfeld:

Quoted 1 line

This reverts 26b1d3b527e7 ("drm/atomic: Take the atomic toys away from X")

I'm in favor of reverting this commit. I've tried to get allowing to enable atomic in Xorg again in there in the past: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/533

I've no illusions of getting this through though, after all mostly the same people control what's merged into Xorg, what drm stuff gets into the kernel and who disabled it in the kernel in the first place. And there doesn't seem much interest in dealing with anything Xorg either, in the merge request I linked, someone even called Xorg "abandonware". This is also why I didn't respond here until now.

I do see value in enabling this. When I looked at this 2 years ago, there were situations where enabling atomic brought clear improvements, and I would expect that it can still improve performance on some special systems. I think the users should have the option to use it if they want or need to.

There is also the concern that this may cause a regression, but I would argue, that there never was a regression to be fixed here in the first place. There may have been that one broken application in the past, but it was just that, a broken application, not something broken by the kernel. I do not think the kernel should modify it's behavior just to work around bugs in a specific program, which have always existed, and didn't come from a changer in behavior of the kernel APIs. If a program was written wrongly, the program should be fixed, and in case of Xorg, I think it is fixed already.

This probably won't mean much coming from me, but:

#4 lore raw
In reply to Dave Airlie
Quoted 33 lines · Dave Airlie
Quoted 22 lines · Jason A. Donenfeld

This reverts 26b1d3b527e7 ("drm/atomic: Take the atomic toys away from X"), a rootkit-like kludge that has no business being inside of a general purpose kernel. It's the type of debugging hack I'll use momentarily but never commit, or a sort of babbies-first-process-hider malware trick.

The backstory is that some userspace code -- xorg-server -- has a modesetting DDX that isn't really coded right. With nobody wanting to maintain X11 anymore, rather than fixing the buggy code, the kernel was adjusted to avoid having to touch X11. A bummer, but fair enough: if the kernel doesn't want to support some userspace API any more, the right thing to do is to arrange for a graceful fallback where userspace thinks it's not available in a manageable way.

However, the *way* it goes about doing that is just to check current->comm[0] == 'X', and disable it for only that case. So that means it's *not* simply a matter of the kernel not wanting to support a particular userspace API anymore, but rather it's the kernel not wanting to support xorg-server, in theory, but actually, it turns out, that's all processes that begin with 'X'.

Quoted 2 lines

Playing games with current->comm like this is obviously wrong, and it's pretty shocking that this ever got committed.

I've been ignoring this because I don't really want to reintroduce a regression for deployed X servers. I don't see the value.

You use a lot of what I'd call overly not backed up language. Why is it obviously wrong though? Is it "playing games" or is it accessing the comm to see if the process starts with X.

Quoted 8 lines

Do we have lots of userspace processes starting with X that access this specific piece of the drm modesetting API. I suppose we might and if we have complaints about that I'd say let's try to fix it better.

Sometimes engineering is hard, It was a big enough problem that a big enough hammer was used.

I'd hope @Daniel Vetter can comment as well since the original patch was his.

Frankly I refrained from replying when I've seen the patch originally because I didn't manage to come up with a nice&constructive reply like you did here. The only thing novel here is the amount of backhanded insults folded into the commit message.

I very much welcome constructive contributions that actually solve the problem here, or at least move it forward a bit. This patch is neither.

What might be an option is a tainting module option that disables this check, since the amount of people willing&able to fix up Xorg is still zero. But that would need to come with a proper commit message and all that, and ideally a pile of acks from people who insist they really want this and need it.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch