Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp154348ybg; Mon, 27 Jul 2020 18:48:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfpw7o55rKkWW46Yrf4g8k3lVhkt4pfEqv4IfzUSygdQ3vRUT2By8OE6XU9B2D3GiIhT6a X-Received: by 2002:aa7:c656:: with SMTP id z22mr24774819edr.101.1595900922677; Mon, 27 Jul 2020 18:48:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595900922; cv=none; d=google.com; s=arc-20160816; b=SX48C00O8eH6OwA9mQ/70UveFv1kauEApkSfMxMiV/qDd4k9qCEZdkB7lKU/bGRJJU B53BoyEiXDT7LNSlxlVIyWGTfJDKjJ4/ouBjiAt9sAOM+xVn29WkMtb4R60sXtFJoRS8 BtjYtYe5ZhMvnH02RkXzTgTu5PwkFoq34fG/YW2MPkTdDx7agc+5aRZyjwBUmV2/Dbsq Z2zZ5ogMZKT96LH6eTyIqH/iBlcm52RHOvvvyPS6D1Gz7M2LUbHH6zFcSOVxLjfulM6o wPvdirnaMdWAt61pX4k20qsml4jCBKCmBzdiA49oDskGPLWPKSGoFrPIBJZkCvCG/kNB u6Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=YjnA1D1K7ElpFXMn7MlHX1aExmoTvW00G3z3st5LogM=; b=FEXotg0hGBfyj1t6oh7Mxq4WEu/iO2bRAO804E+LTkLgn+jT1HtW9DcrF9GbHFhG7r 3QuX0m9FZD0CrcwxlKHT5/0bvHtTXT+frjcl80P+Z0Z9F+cBcfT8RHAf91ybV+CTYxEN c8bHyEkSZZIcekGEluTiAv3p2VlgpbBJ9V4g0wmE4rcGSlpn0762Ri6HZ5jv5teMwxk6 WrfBSTZB/ZbrKVDMGb6I4B0wAYVHH1Xn1pszKVsz1bou/WBTVO0jMNbCr5rUt79RC1li s56F6A766q6EoLun3ulMr4vRKwnTIZYfhSwKYGh4A7aunDWuwCLU7Ou+G+N2mjL4a89C kLQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qPuGtMvX; 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 k13si3764219ejr.354.2020.07.27.18.48.19; Mon, 27 Jul 2020 18:48:42 -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=qPuGtMvX; 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 S1726820AbgG1Bpc (ORCPT + 99 others); Mon, 27 Jul 2020 21:45:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbgG1Bpc (ORCPT ); Mon, 27 Jul 2020 21:45:32 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04700C061794 for ; Mon, 27 Jul 2020 18:45:32 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id l23so17332737qkk.0 for ; Mon, 27 Jul 2020 18:45:31 -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:mime-version :content-transfer-encoding; bh=YjnA1D1K7ElpFXMn7MlHX1aExmoTvW00G3z3st5LogM=; b=qPuGtMvXjFKTqPMP4hVzimuIwTZQ1FlTw4vqUKaNSKU99KqaO6Im988hL6y6XkP5V2 qVOFVZeATU9MV0hSUENBapGZ7GLtyN/Zblmf/4fCo1UH9ehlDGFpi9aqTjRKGiQ6zRBU ZnBAzkC5VY3aa0sUUqOhdrf+7j42xFbvu//GIiSzF9TiQsOp/yfcYIX1oGvGIKFyxM9S k6HkJu8JFS6URc1k9uYTJoCOa4PJ5UY0inf+26gI6iMl69ihRgNzPEzBeVcRFFJQcV9I jbLBMpuzcqx06gqVV3mMyG3T5p5MGCTM/NG7cd9z8NytqeSC9Ht4zrrYiKX3jZsT64Y/ p3Fg== 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:mime-version :content-transfer-encoding; bh=YjnA1D1K7ElpFXMn7MlHX1aExmoTvW00G3z3st5LogM=; b=C16gzsBZGpXES8XKv/d+b5CcLMNNTq5HjHibJWiE9qKny+TztyWvhtJTnjRxsNbxWJ c/CReLYeow3CHwt506hxamqaLGBnN8w4DD+YvsjUMHII98qFwffjKykMRCGDTnaEHwLO VDOC+6RokWp9R4+FLqYmx6wPfMfUqu9ozHUu3+lFNFL+AxhlPBo8x38R3MmCGrPPbJRR OPSiGVV0sGbOEwTBbVsmTPgCxFovrbY34WWvTE83yVXW/b6UnNOzy4muAbr6frMjrkxa s0oXE2xBDcDZemQiMeOsCtisf9lartHG1BM8MzLa5gipJYep2B1YCKFw0vxYZXJQ+Rct +i2A== X-Gm-Message-State: AOAM532BifX0QJlmcuT4JxPeOOab+y6g8n+I38uPUkhk/B65Aur+1LMs sCfEaxqkIDoSH6Esnso4Hg== X-Received: by 2002:a05:620a:553:: with SMTP id o19mr24583291qko.46.1595900731268; Mon, 27 Jul 2020 18:45:31 -0700 (PDT) Received: from localhost.localdomain (c-76-119-149-155.hsd1.ma.comcast.net. [76.119.149.155]) by smtp.gmail.com with ESMTPSA id d14sm16585473qti.41.2020.07.27.18.45.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 18:45:30 -0700 (PDT) From: Peilin Ye To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: Peilin Ye , David Airlie , Daniel Vetter , Dan Carpenter , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel-mentees@lists.linuxfoundation.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [Linux-kernel-mentees] [PATCH] drm/bufs: Prevent kernel-infoleak in copy_one_buf() Date: Mon, 27 Jul 2020 21:43:43 -0400 Message-Id: <20200728014343.341303-1-yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org copy_one_buf() is copying uninitialized stack memory to userspace due to the compiler not initializing holes in statically allocated structures. Fix it by initializing `v` with memset(). Cc: stable@vger.kernel.org Fixes: 5c7640ab6258 ("switch compat_drm_infobufs() to drm_ioctl_kernel()") Suggested-by: Dan Carpenter Signed-off-by: Peilin Ye --- drivers/gpu/drm/drm_bufs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c index a0735fbc144b..f99cd4a3f951 100644 --- a/drivers/gpu/drm/drm_bufs.c +++ b/drivers/gpu/drm/drm_bufs.c @@ -1349,10 +1349,14 @@ static int copy_one_buf(void *data, int count, struct drm_buf_entry *from) { struct drm_buf_info *request = data; struct drm_buf_desc __user *to = &request->list[count]; - struct drm_buf_desc v = {.count = from->buf_count, - .size = from->buf_size, - .low_mark = from->low_mark, - .high_mark = from->high_mark}; + struct drm_buf_desc v; + + memset(&v, 0, sizeof(v)); + + v.count = from->buf_count; + v.size = from->buf_size; + v.low_mark = from->low_mark; + v.high_mark = from->high_mark; if (copy_to_user(to, &v, offsetof(struct drm_buf_desc, flags))) return -EFAULT; -- 2.25.1