Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2864215pxj; Mon, 17 May 2021 11:36:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVVaq39N2ZnbA4CW2pghPuX+liN88KUM4IwUog42nMiYprud5Oc86BK/o9HPvcBoKG9b6j X-Received: by 2002:a17:906:584e:: with SMTP id h14mr1370726ejs.432.1621276603248; Mon, 17 May 2021 11:36:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621276603; cv=none; d=google.com; s=arc-20160816; b=YXKXkMtq5XUrgiswwL0Tm6ExZkj8G/Ect+LPXkU87J8w+WTUGEf7/Tix3ZntuVtvZn UM94rg2xTj8WjyKRVUeJ0TxiCxO5NLiG22QcFQUg7gHjGMH1Bb+co/bBKiP9H7M2pxLr SBSBkX0m70jf+8VcmV67cUHwoh+L+R9wgOlqal8vCs8W52zWKdOWj+nJ4oo9s5NXxzlF Vn9vupoWhG6qIBez5UD4yh9hZ5jkNTnrvSA1kwtTImpq8syMxW8+wjNEbStyKzgPIzNm 51KQHWaCeD6PclRQWQfG5RZ1c4ovbxKeE6leXQUKqvVuEOXiQQmiL2kHJYTivCJSzL6O bRcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=PAwEga9MsVbe/5u0H4dGqnZ+LwHKVSj8ppgsSx/dwXA=; b=lBMDZrDNtych70b1R04j4F8s7NzlRS7nwDrR1RvXkMJ43p+t/JnuXZ34L+Vl5glKAS wRlQAu5k/pxjUTiASxMr1VI5bIsv0s/4XHgs4QzZQN8EhulEC3IkwIBrOMfR+JalbgTF 4G4XQxXgpXLGgQfn0mv9c1MSlGh2Uh/Miy9CuIyp86Z9j9/UCmEd3uBkxKbBWB9HoWOq /eTQ2AeyGRLhQ+Jht+rSvhP21py4LTDscXb8E1qgyxaOqO0d3egUmieHIMuhf+ouznlH TLm0jWQVkZEJm6rnYEsjdiRP9QoSqaO4I1qu4fPuL73AAogMjXtIU0J1c3jxJqgtsJkY luQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=OqI9STlk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ga4si835354ejc.497.2021.05.17.11.36.19; Mon, 17 May 2021 11:36:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=OqI9STlk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237262AbhEQNMG (ORCPT + 99 others); Mon, 17 May 2021 09:12:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235505AbhEQNL4 (ORCPT ); Mon, 17 May 2021 09:11:56 -0400 Received: from mail-oo1-xc33.google.com (mail-oo1-xc33.google.com [IPv6:2607:f8b0:4864:20::c33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0653C06138B for ; Mon, 17 May 2021 06:10:30 -0700 (PDT) Received: by mail-oo1-xc33.google.com with SMTP id o66-20020a4a44450000b029020d44dea886so1450888ooa.5 for ; Mon, 17 May 2021 06:10:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PAwEga9MsVbe/5u0H4dGqnZ+LwHKVSj8ppgsSx/dwXA=; b=OqI9STlkR7u8mi0tTXuV5SyeZialb8aH253QDX1o+zeoCJ+S5gkI85n74dHCZFGZBj ciyUa3BieaaWvJ/XofZxNU4eItL61acH6SFLNcUyfjmgkFxOv0X3HqAsEYSRKc8UaEPb CR56j6NK/wn5NCcRHFQktnOm55tx52mvWG/RA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PAwEga9MsVbe/5u0H4dGqnZ+LwHKVSj8ppgsSx/dwXA=; b=NiGvuH+I9pHb2VmAA4OaLcMsjWZtR4Dxe2Wgd8Q4DgJnVgdlS8MS2f2BldjHglF9BC gbsR/w9SDrUX7SJy4D5cIIX9wrRJ38MApJxOgUPb3yIRg33MIq7UcXCaKV7SWm921Kcb 7Le+gjVSF5drIkBJXQWVFfynDFod11f/SxzZNdOFupphU4+WLElC3ajFTXnP+U88Qq2z Nd9X89FKnv1bZNwzhoOMc4e3yxog6Thnbz4eOGYHYe/jh1K8WmGbcJfmW63mbbcjG+Op c3ceRnrrkYm6mFiLf/FZtic4flidcTPZOzeodFl2zFkjCgQaN5/fWsnEK71XxhHMsY3P IckQ== X-Gm-Message-State: AOAM532Gmu2DNJHToOibNa+XoUwcUtFS4dD1FcoME8LpUkiQnraGqUCY tsNKbaVscPV/I7jiSwVXa0AnfFszCCuo97aXzVxMcA== X-Received: by 2002:a4a:8e04:: with SMTP id q4mr1459797ook.28.1621257030052; Mon, 17 May 2021 06:10:30 -0700 (PDT) MIME-Version: 1.0 References: <0000000000006bbd0c05c14f1b09@google.com> <6e21483c-06f6-404b-4018-e00ee85c456c@i-love.sakura.ne.jp> <87d928e4-b2b9-ad30-f3f0-1dfb8e4e03ed@i-love.sakura.ne.jp> <05acdda8-dc1c-5119-4326-96eed24bea0c@i-love.sakura.ne.jp> In-Reply-To: From: Daniel Vetter Date: Mon, 17 May 2021 15:10:19 +0200 Message-ID: Subject: Re: [PATCH] video: fbdev: vga16fb: fix OOB write in vga16fb_imageblit() To: Linus Torvalds Cc: "Maciej W. Rozycki" , Tetsuo Handa , dri-devel , Linux Fbdev development list , Linux Kernel Mailing List , syzbot , Bartlomiej Zolnierkiewicz , Colin King , Greg Kroah-Hartman , Jani Nikula , Jiri Slaby , syzkaller-bugs , "Antonino A. Daplas" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 17, 2021 at 3:07 PM Daniel Vetter wrote: > > On Fri, May 14, 2021 at 10:33 PM Linus Torvalds > wrote: > > > > On Fri, May 14, 2021 at 1:25 PM Maciej W. Rozycki wrote: > > > > > > Overall I think it does make sense to resize the text console at any > > > time, even if the visible console (VT) chosen is in the graphics mode, > > > > It might make sense, but only if we call the function to update the > > low-level data. > > > > Not calling it, and then starting to randomly use the (wrong) > > geometry, and just limiting it so that it's all within the buffer - > > THAT does not make sense. > > > > So I think your patch is fundamentally wrong. It basically says "let's > > use random stale incorrect data, but just make sure that the end > > result is still within the allocated buffer". > > > > My patch is at least conceptually sane. > > > > An alternative would be to just remove the "vcmode != KD_GRAPHICS" > > check entirely, and always call con_resize() to update the low-level > > data, but honestly, that seems very likelty to break something very > > fundamentally, since it's not how any of fbcon has ever been tested, > > Just an aside: I think with fbdev drivers this would go boom, because > you'd have fbcon interferring with a direct /dev/fb/* user. Boom here means a bit of screen corruption, because fbcon overdraws your X sessions. Fixed by the next redraw of X. > But if your fbdev driver is actually a drm modeset driver, then we > have additional limitations: If the userspace accesses the display > through /dev/dri/card0, then the kernel blocks all access through > /dev/fb/* (including fbcon) to the actual display (it only goes into > the buffer used for fbdev emulation). And everything would be fine. > > Also generally you'd get away with this even in problematic cases, > since usually you resize your console when looking at it, not when X > or something else is using your fbdev direct access. > > The one thing that's left out here a bit in the cold is userspace > modeset drivers in X. Those would get hosed. But also, we stopped > supporting those in at least i915/amd/radeon/nouveau drivers, > automatically falling back to the fbdev stuff in most cases (with or > without the drm drivers underneath that), and no one screamed. So > probably not many users left. This one could lead to incosistent hw state, which would be worse. > So I /think/ we could wager this, if it's the least intrusive fix from > the kernel pov. But it has some risks that we need to revert again if > we break some of the really old use-cases here. Cheers, Daniel > > Another alternative would be to just delay the resize to when vcmode > > is put back to text mode again. That sounds somewhat reasonable to me, > > but it's a pretty big thing. > > > > But no, your patch to just "knowingly use entirely wrong values, then > > add a limit check because we know the values are possibly garbage and > > not consistent with reality" is simply not acceptable. > > > > Linus > > > > -- > Daniel Vetter > Software Engineer, Intel Corporation > http://blog.ffwll.ch -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch