Message ID | ZQSlyHKPdw/zsy4c@work |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1364337vqi; Fri, 15 Sep 2023 15:52:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF0RgStuGr0PfTYw1cBGpER8Ulb2O4wt1g+0HXAVbU8+BBE13fpBNTayAp2DkbCSjk4WYWp X-Received: by 2002:a05:6a00:80d:b0:68e:2478:d6c7 with SMTP id m13-20020a056a00080d00b0068e2478d6c7mr2991585pfk.32.1694818376574; Fri, 15 Sep 2023 15:52:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694818376; cv=none; d=google.com; s=arc-20160816; b=ffglg0p8ztfho1gXb2vwfkPDjRR2kg/P/FJ4patVFfZr+yVhehHBptBbJnMqw4Mx0p 6hoXy/dHq6eQbF/4+/sf8b6bnqrEqyXQd7n9IKzZuP8fH4c5ezv7Cwyr5agWFtswULen MiF0HSFYPyhmtELF60utH+kDrkG7qW5AH61EWjxQO3RSagDEYuevKaPqrWsn8uuw4K3Z 2lcSR5o6p76WLDv+TmkTObsMBQKn6bM+iwqq1mgo6Bz9yy8hlHbUk5t/XcqwSeBU7ynT 8sCSCsd5JmXLv9kGeCQ2nnsVjthTxWDG4IhPspcCyBLmJ8oPF89dJPBtl8EWty2zswNe fCYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=HnByv/GzCEWXY3H53+R5tPaXsJWSusA0ZBOZKSUCpLA=; fh=bkm0sTWecpsHRr3HHoqCFGZal/SbiL6Keq7IpLXS9Ts=; b=SXJSsn8UvsVcOP7ZfCnYlysAfEz57neS7D50OkJitTpYMwMqvjlnYJb0WMZ7WcbPGs GemHY0gQhUETwS8+Fk2MEKKbLud50w93wVgfhrjH1l4h3oqLu1OgPgyfoTQoxNDRAoPt prnw+2Ax7sewQIrso6INJweZBgdha6wuqnoQ4/6vsv9HFSomVeIL0PzkLwX2S5XOlMYs Ylg+U6KHsRSa8PQQexeqbD5/64jIxAmPetxZ/mjFGl5liYQP3g6CJ4CmMy+BWy7fy+wE R8S+jPBLFi8Ro70atWgJbNZrT9IujoWnz++oA2oq3GRS84LQ5QIONi4LXtaQuHAzIRrW WqYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XFdl61V6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id az1-20020a056a02004100b005783f4fa3a5si537944pgb.300.2023.09.15.15.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 15:52:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XFdl61V6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 581108040CC0; Fri, 15 Sep 2023 11:47:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236603AbjIOSq0 (ORCPT <rfc822;ruipengqi7@gmail.com> + 30 others); Fri, 15 Sep 2023 14:46:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236964AbjIOSp4 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 15 Sep 2023 14:45:56 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 936D52D5F; Fri, 15 Sep 2023 11:43:32 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46BA0C433C7; Fri, 15 Sep 2023 18:42:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694803346; bh=gNFALD/z17jDo7dWYiHKFKrb9ITT5wkuRQ8TLtfc84k=; h=Date:From:To:Cc:Subject:From; b=XFdl61V6dPWFIZAe1SZcvAqCiTByQo6msIs/RunUOGVbM+9UmWtKYpGeybnSZ8SOf XuiSlgD5sCBzwnqHs7ik7/vc5/PTkdlj0EPs8VmgAdpMuq87WmrxvUSxaQxMJH+iaT qiJRPa3lgh0bTwDxTfqf3UmfuUA2yjEcq6afHwUcZY2nlqnkgGZ6Vq3J9s4iw0kVpa inOeiOkkHnuWQnLsGOlzfTemYM6cdxxwkgNAT12dU+bAf7hl+xs3f21SDfO4ENO9Fu eYlxuGC0AAFoNB38MzF0yTAwrmcxgyZuFuSOX5PmOr04cb3YiUORxnc5AqRRUaKlHk x17yPmOSkJiuA== Date: Fri, 15 Sep 2023 12:43:20 -0600 From: "Gustavo A. R. Silva" <gustavoars@kernel.org> To: Noralf =?iso-8859-1?q?Tr=F8nnes?= <noralf@tronnes.org>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, Peter Stuge <peter@stuge.se> Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, linux-hardening@vger.kernel.org Subject: [PATCH][next] drm/gud: Use size_add() in call to struct_size() Message-ID: <ZQSlyHKPdw/zsy4c@work> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 15 Sep 2023 11:47:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777131854593428124 X-GMAIL-MSGID: 1777145873661217601 |
Series |
[next] drm/gud: Use size_add() in call to struct_size()
|
|
Commit Message
Gustavo A. R. Silva
Sept. 15, 2023, 6:43 p.m. UTC
If, for any reason, the open-coded arithmetic causes a wraparound, the
protection that `struct_size()` adds against potential integer overflows
is defeated. Fix this by hardening call to `struct_size()` with `size_add()`.
Fixes: 40e1a70b4aed ("drm: Add GUD USB Display driver")
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
drivers/gpu/drm/gud/gud_pipe.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Fri, 15 Sep 2023 12:43:20 -0600, Gustavo A. R. Silva wrote: > If, for any reason, the open-coded arithmetic causes a wraparound, the > protection that `struct_size()` adds against potential integer overflows > is defeated. Fix this by hardening call to `struct_size()` with `size_add()`. > > Applied to for-next/hardening, thanks! [1/1] drm/gud: Use size_add() in call to struct_size() https://git.kernel.org/kees/c/836ccb46073e Take care,
diff --git a/drivers/gpu/drm/gud/gud_pipe.c b/drivers/gpu/drm/gud/gud_pipe.c index d2f199ea3c11..a02f75be81f0 100644 --- a/drivers/gpu/drm/gud/gud_pipe.c +++ b/drivers/gpu/drm/gud/gud_pipe.c @@ -503,7 +503,7 @@ int gud_pipe_check(struct drm_simple_display_pipe *pipe, return -ENOENT; len = struct_size(req, properties, - GUD_PROPERTIES_MAX_NUM + GUD_CONNECTOR_PROPERTIES_MAX_NUM); + size_add(GUD_PROPERTIES_MAX_NUM, GUD_CONNECTOR_PROPERTIES_MAX_NUM)); req = kzalloc(len, GFP_KERNEL); if (!req) return -ENOMEM;