Message ID | 20221105222012.4226-1-Jason@zx2c4.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1204452wru; Sat, 5 Nov 2022 15:37:31 -0700 (PDT) X-Google-Smtp-Source: AA0mqf4cLdYfrMxZ6S9DaWJtnh0NtBV/2jvsYref2BhNTbyOVvrER4BHpFf5LlqeKT5nhCg/352z X-Received: by 2002:a63:f94d:0:b0:470:5d17:100c with SMTP id q13-20020a63f94d000000b004705d17100cmr2370007pgk.615.1667687851367; Sat, 05 Nov 2022 15:37:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667687851; cv=none; d=google.com; s=arc-20160816; b=toogxFwceukbNO5F9NUjGW6QI91UaWbUthjsmT8K69dupb+caYFvMo/lnMhR2HY3p5 dwTL3oobXaOfbKYBon/pcg3irnYjNPxu3gHt8fA7m3AEcytRXTSxHt32OXqZU6NRBWlq GnBGNWXOA2Axe6Qdgk35kVU/b/14bP1EhqWp5RAuDFxzFsO4m3mNqFcC9DRE9Uf3qykP V04nxYfYvTWmeaq5MCljCMFVl8kNOAz59fkf8cl5CQkz2FDhHLUDL+KsGn1UsAijOZp9 l+GRj1P1yu8Tb94QyZ9o6zVGEFqhEwOTemSDyDShcS7e8HKLey+TzySD9oYe/5p2EJq9 rjRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=GokT8QcZOOF1Sj+w1E78zsAC5vdLp3dZxLPEamRZIQc=; b=BRR5SmjfC6zajUJPurfvzUEfc4/KQygNqmvBAFruSgQmRiw1+/8wKNN5cLpDqBTtTD RRB/XvmdeIlYoOA7XRzp1ljz/PtIU4CjXXQltGVXMnW3zTP78wBZbnnXeuI6CMwWQwGN qBQ7jkCf7RvSExgBEXCSO0aU74BwZZ/DxnDtwblKlRkk8Lw56ZfX4EPYV9hl/7eA4zmC oSgYnuS7tc9aE0m0IHlJTv6hLABYiNGZva9jYTKE2Nl2W1M2WzrvYzYBsZNyFi2lRpjE eE3giTceEMnCiXf7QTT6Z9jj89ruwDD5ZqaRsG2d8yYIKykztHiHnwMOAoDfezBcFK1T BQbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=NiluAsAW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pg5-20020a17090b1e0500b00212ce534ef7si5152199pjb.22.2022.11.05.15.37.01; Sat, 05 Nov 2022 15:37:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=NiluAsAW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229822AbiKEWVB (ORCPT <rfc822;hjfbswb@gmail.com> + 99 others); Sat, 5 Nov 2022 18:21:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbiKEWVA (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 5 Nov 2022 18:21:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F02D11470; Sat, 5 Nov 2022 15:20:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D0E4DB80064; Sat, 5 Nov 2022 22:20:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEF3EC433D7; Sat, 5 Nov 2022 22:20:54 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="NiluAsAW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1667686852; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GokT8QcZOOF1Sj+w1E78zsAC5vdLp3dZxLPEamRZIQc=; b=NiluAsAWGU9q2YBTgfIqH7nw2j4QXLI9zVeGdjIIsiTzIQF6J69JxnxlXhrGVgPJYsTlNf m2iE8C353WC3NFDPhvgr3yf7e8dr5Up3F5jyaGu5chUUnWd3HCjhX+7PdW1ogHNlCnFFUk +6XrN1/n8nwHh1xBkhJAboxHjNS2tOg= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 969eda74 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sat, 5 Nov 2022 22:20:52 +0000 (UTC) From: "Jason A. Donenfeld" <Jason@zx2c4.com> To: dri-devel@lists.freedesktop.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>, Daniel Vetter <daniel.vetter@intel.com>, Peter Zijlstra <peterz@infradead.org>, Ilia Mirkin <imirkin@alum.mit.edu>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>, Christian Brauner <brauner@kernel.org>, =?utf-8?q?Michel_D=C3=A4nzer?= <michel@daenzer.net>, Alex Deucher <alexdeucher@gmail.com>, Adam Jackson <ajax@redhat.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Sean Paul <sean@poorly.run>, David Airlie <airlied@linux.ie>, Rob Clark <robdclark@gmail.com>, Sultan Alsawaf <sultan@kerneltoast.com> Subject: [PATCH] drm/atomic: do not branch based on the value of current->comm[0] Date: Sat, 5 Nov 2022 23:20:12 +0100 Message-Id: <20221105222012.4226-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748697456510948491?= X-GMAIL-MSGID: =?utf-8?q?1748697456510948491?= |
Series |
drm/atomic: do not branch based on the value of current->comm[0]
|
|
Commit Message
Jason A. Donenfeld
Nov. 5, 2022, 10:20 p.m. UTC
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 <daniel.vetter@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Michel Dänzer <michel@daenzer.net>
Cc: Alex Deucher <alexdeucher@gmail.com>
Cc: Adam Jackson <ajax@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Sean Paul <sean@poorly.run>
Cc: David Airlie <airlied@linux.ie>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
drivers/gpu/drm/drm_ioctl.c | 5 -----
1 file changed, 5 deletions(-)
Comments
Hey again, On Wed, Nov 16, 2022 at 01:36:00AM +0100, Jason A. Donenfeld wrote: > 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 > On Sat, Nov 05, 2022 at 11:20:12PM +0100, Jason A. Donenfeld wrote: > > 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 <daniel.vetter@intel.com> > > Cc: Peter Zijlstra <peterz@infradead.org> > > Cc: Ilia Mirkin <imirkin@alum.mit.edu> > > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> > > Cc: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com> > > Cc: Christian Brauner <brauner@kernel.org> > > Cc: Michel Dänzer <michel@daenzer.net> > > Cc: Alex Deucher <alexdeucher@gmail.com> > > Cc: Adam Jackson <ajax@redhat.com> > > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > > Cc: Sean Paul <sean@poorly.run> > > Cc: David Airlie <airlied@linux.ie> > > Cc: Rob Clark <robdclark@gmail.com> > > Cc: Sultan Alsawaf <sultan@kerneltoast.com> > > Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> > > --- > > drivers/gpu/drm/drm_ioctl.c | 5 ----- > > 1 file changed, 5 deletions(-) > > > > diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c > > index ca2a6e6101dc..017f31e67179 100644 > > --- a/drivers/gpu/drm/drm_ioctl.c > > +++ b/drivers/gpu/drm/drm_ioctl.c > > @@ -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; > > -- > > 2.38.1
On Sun, 6 Nov 2022 at 08:21, Jason A. Donenfeld <Jason@zx2c4.com> wrote: > > 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. 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.
Am 2022-11-05 23:20, schrieb Jason A. Donenfeld: > 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: Acked-by: Daniel Abrecht <public@danielabrecht.ch>
On Wed, Nov 16, 2022 at 01:49:43PM +1000, Dave Airlie wrote: > On Sun, 6 Nov 2022 at 08:21, Jason A. Donenfeld <Jason@zx2c4.com> wrote: > > > > 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. > > 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. 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
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index ca2a6e6101dc..017f31e67179 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -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;