Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3280629pxb; Sun, 29 Aug 2021 20:32:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLDLit2NxmO5famz4fn6cmeNVnfrlifLgQAxb/uzWsd/VVKMTh9z4BNgIFnwYaBJeS/58b X-Received: by 2002:a6b:7f42:: with SMTP id m2mr2633279ioq.86.1630294322386; Sun, 29 Aug 2021 20:32:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630294322; cv=none; d=google.com; s=arc-20160816; b=UODwlOjs+1uWb3iK42SwGoD6eh5g6Pp9kVY6hqjmMCg1vHa+2RWOsExo8RpCCz8Vul C3zDC9vu601U1PWWVpEwvQKrK5Y1ucgH9rsWchmNGPDrQCrFSWDyFL30imD4bAvjNpZz vCnSpWQLo6ODHmiVIZblcHifyQs97Hz1jRSS++E9VaXfFzsEd4KSQC2FM/Ii4A+cZjKn S4jKH4vjZus4raQaazXBI1pkC7rXYxC1ZkMgIwu6geX0xZTCUZTcSQZRIRcYoeqm0a6H g31n4X2MTFVM9UylmWUJbGJv5N1aTOgIz3jE7Meyrz30LmRaT/Jn0uL+cm0giC7/7yK6 VlWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=LVrIEBdknSQXfx0VWfJkptFor1oJQkXATIr1CLgYdbo=; b=jYtNLai1wfk9RfwV2+TzR8ioVEY+rTyiH1HZaJftob6hvtF+8TQF0Z/0oM3rOqH/W8 iAgtMI5JHFX1twcUdgAi0s8e0JxR6/62NdXwYdHKY11YuSz+jwxoFARgXqNpnbLPFDxY 6tBNx6ifPO32vnKcWuOxxiaQk3NEksOtyVd66MmAUuUk/sZKWaTIVUUo/kDbIz0IXoj3 S9QrIBJ1+7TC3RkdFLzdOUI2xW6QMn1cZNUJbwujgJOAVeVTV8aIsvnbx+ajH2xDOIW5 YMNYPyB6dNqYoTXgOg3UPuuJDBHWGfqzDKE/dM1h8OxOdGAOoq19sV/8TVSDlmQMLrgs kEvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Rx5ngJvk; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t4si17944192iof.69.2021.08.29.20.31.49; Sun, 29 Aug 2021 20:32:02 -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=@gmail.com header.s=20161025 header.b=Rx5ngJvk; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229660AbhH3Dbu (ORCPT + 99 others); Sun, 29 Aug 2021 23:31:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229548AbhH3Dbt (ORCPT ); Sun, 29 Aug 2021 23:31:49 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D576CC061575; Sun, 29 Aug 2021 20:30:56 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id k24so12100372pgh.8; Sun, 29 Aug 2021 20:30:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=LVrIEBdknSQXfx0VWfJkptFor1oJQkXATIr1CLgYdbo=; b=Rx5ngJvkMPbn+t9gQ+9VQUcXzvxVRWcJ2tjxNgrBTxmU8Xt1uvHrSbgQE+UcCB7YHV rFPp2YHE4RBUQSKnYVU5J9VAdcySGI+iGbZeiFqgpuOztwBsAEWUeR2BYLDdtZgA2LgD YCya/h6gd/JnKYwrlGFqBi5SrZskqdrwVkpkQ/UkOEnv5t/CrSnLcwqZu2yjeSyC+PA8 ky7W5gjOJbxG+26zITFMTB0JtssZKkznOXUJh1H1DIZaqXiZuDqqXvnPgWWStL5gJxN3 5DMygP+sp5m/+Y9DznBKubMtCs5vd1a/snq8wF7hXV5sGJxQFy0/qxnPCSKR9htneYKt PZ3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LVrIEBdknSQXfx0VWfJkptFor1oJQkXATIr1CLgYdbo=; b=mEbr0yhFXypSyaNmQkzUtl9LkO+deN0Lhan1C6SJxRsyfipxOfhNSfCZsLDXB7Kvqx U5BSml6sPM2lKw5j8KYu88lK31SYFlbfOW+V6QyAlvy4SXcuTKfHQvk5QVp923dbF3Q/ 7PNd5MfpKA3Mth8NYJas+lEEL+z6XFwmoFe/L2yg1/rHlP2cDNLCzK+9JMWXjWHYfYDX MObNyGqrCvZSzOFXhJz1W1v71EFlavdjVKI1vsT2ZleqhwbfrT16bXwNAPcOvbbtjvAf /1Qa3sbOqRAvVwofEjl4JM+mLfwiY14v5/PZsNNB5qQyD4ZukriRPtrP1WWbkBBHyvKh rFdg== X-Gm-Message-State: AOAM530W0eIHt6GJF7aNKv0Gatrdde7bIF0mVmOvc2WHZSqNB8ZHXXQd aABMwhShl456vNGFmItHL64= X-Received: by 2002:a05:6a00:84d:b0:3ff:24a6:1d9b with SMTP id q13-20020a056a00084d00b003ff24a61d9bmr3938605pfk.14.1630294256191; Sun, 29 Aug 2021 20:30:56 -0700 (PDT) Received: from localhost.localdomain ([162.14.21.36]) by smtp.gmail.com with ESMTPSA id 20sm13139989pfi.170.2021.08.29.20.30.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Aug 2021 20:30:55 -0700 (PDT) From: tcs.kernel@gmail.com X-Google-Original-From: tcs_kernel@tencent.com To: daniel.vetter@ffwll.ch, willy@infradead.org, george.kennedy@oracle.com, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org, penguin-kernel@I-love.SAKURA.ne.jp Cc: Haimin Zhang , Tetsuo Handa Subject: [PATCH V4] fbcon: fix fbcon out-of-bounds write in sys_imageblit Date: Mon, 30 Aug 2021 11:30:23 +0800 Message-Id: <1630294223-7225-1-git-send-email-tcs_kernel@tencent.com> X-Mailer: git-send-email 1.8.3.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Haimin Zhang yres and vyres can be controlled by user mode parameters, and cause p->vrows to become a negative value. While this value be passed to real_y function, the ypos will be out of screen range.This is an out-of-bounds write bug. some driver will check xres and yres in fb_check_var callback,but some not so we add a common check after that callback. Signed-off-by: Haimin Zhang Signed-off-by: Tetsuo Handa --- drivers/video/fbdev/core/fbmem.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 1c85514..5599372 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1013,6 +1013,10 @@ static int fb_check_caps(struct fb_info *info, struct fb_var_screeninfo *var, if (ret) return ret; + /* virtual resolution cannot be smaller than visible resolution. */ + if (var->yres_virtual < var->yres || var->xres_virtual < var->xres) + return -EINVAL; + if ((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NOW) return 0; -- 1.8.3.1