From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B91A606A337 for ; Fri, 4 Dec 2026 16:28:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JfG/SawR Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E060610E130; Fri, 4 Dec 2026 16:28:20 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id F198D10E130 for ; Fri, 4 Dec 2026 16:28:14 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 9835343C18; Fri, 4 Dec 2026 16:28:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67D681F00933; Fri, 4 Dec 2026 16:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796401694; bh=LG7faIKHSQijnm7kwfhQH12h5H7b8iObn+UVJtSxCGM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=JfG/SawR0pKvHBWuXkB6fUqUcaNrgTSph9F1QX4iy7LtNLqIIhvrvOZtnhjNcXUQV DcaJR2ghER1jSVPdkGOAOxTf7qWz/ASwmxFXUOOATj1tmfrA0iWlk6zJkE5Cidigfs ZA2bKaUhskOHGVvdPgO4y9tY+yxuDeexcsrIhNkxgKRYXYPAW548raVzlzgRXTHQ3s IKmIct/pbPjD66ccFoyVax9FIG+iJTKmX3VvzdkHIlsRtnkIW34n8Hulqvgio1PmYI hAPoteQTg70FS5a7F3S+pBMP/A6nd2pqWEzigBjAsiyaPvku2tUKXGS/OBXHE2nzt0 51hoQTo7Ovn8w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 1/2] fbdev: udlfb: fix shadow buffer handling when the framebuffer grows To: "YuanZhe Liu" <25031212351@stu.xidian.edu.cn> Cc: dri-devel@lists.freedesktop.org In-Reply-To: <20261204160835.16470-1-25031212351@stu.xidian.edu.cn> References: <20261204093601.9900-1-25031212351@stu.xidian.edu.cn> <20261204160835.16470-1-25031212351@stu.xidian.edu.cn> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 16:28:14 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] fbdev: udlfb: TOCTOU race on fix.line_length bypasses damage bounds check -- commit 6373d803390e810d07fa3293f989ab90570a3e4c Author: YuanZhe Liu <25031212351@stu.xidian.edu.cn> fbdev: udlfb: fix shadow buffer handling when the framebuffer grows This commit allocates the new shadow buffer before publishing the new framebuffer and geometry under dlfb->render_mutex, frees the old shadow buffer directly, and adds a bounds check against info->fix.smem_len in dlfb_handle_damage(). > diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c > index 8b7b4bdac4fbf..66d30cdfbe606 100644 > --- a/drivers/video/fbdev/udlfb.c > +++ b/drivers/video/fbdev/udlfb.c > @@ -646,6 +646,18 @@ static int dlfb_handle_damage(struct dlfb_data *dlfb= , int x, int y, int width, i > goto unlock_ret; > } > =20 > + /* > + * info->var can describe the new mode before dlfb_ops_set_par() > + * installs the matching framebuffer. Reject damage that does not > + * fit into the framebuffer that is currently installed. > + */ > + if (height > 0 && > + ((u64)y + height - 1) * dlfb->info->fix.line_length + > + (u64)(x + width) * BPP > dlfb->info->fix.smem_len) { > + ret =3D -EINVAL; > + goto unlock_ret; > + } [Severity: High] Can a concurrent update to info->fix.line_length bypass this bounds check? dlfb_ops_set_par() updates info->fix.line_length without holding dlfb->render_mutex, while dlfb_handle_damage() reloads dlfb->info->fix.line_length on every scanline iteration across sleepable dlfb_get_urb() calls: CPU0 (dlfb_damage_work) CPU1 (FBIOPUT_VSCREENINFO) dlfb_handle_damage() mutex_lock(&dlfb->render_mutex) bounds check (old line_length) dlfb_get_urb() (sleeps) dlfb_ops_set_par() dlfb_realloc_framebuffer() (new_len <=3D old_len, skips lock) info->fix.line_length =3D new_stride for (i =3D y; i < y + height; i++) line_offset =3D line_length * i dlfb_render_hline() dlfb_compress_hline() <-- out-of-bounds read/write When switching to a wider, shorter mode that fits in the existing allocation, dlfb_realloc_framebuffer() skips dlfb->render_mutex, and dlfb_damage_work() runs without info->lock. Once info->fix.line_length grows mid-loop, dlfb_compress_hline() reads past info->fix.smem_start and writes past dlfb->backing_buffer, which can oops or corrupt adjacent vmalloc allocations. Updating info->fix.line_length under dlfb->render_mutex in dlfb_ops_set_par() and snapshotting line_length locally in dlfb_handle_damage() would close this race. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204093601.9900= -1-25031212351@stu.xidian.edu.cn?part=3D1