From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 357241E0B9C for ; Tue, 23 Sep 2025 15:21:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758640900; cv=none; b=jkma/Cv1UQJZE8yKLJOzuY9TEEsD5flSORqD5AQW3sOX2ceCpKIpxI/aLSalSzY2FwnN7zZEjqc1FGJ4m7056cxgNowbw9tvgUXvAn+qt91J71JIOjnOPcrdUk5fAc9zZBlKXoU8hwSX1Qp7GMdAuGZR1LB9q/VDrvkkqDit8/0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758640900; c=relaxed/simple; bh=qt+6KRyKxPkORPP5QEsbIBjsuDn3dRtpoy1rgq8l/Xo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=YLfs3OgOxYkOw3FhTG6r7lkVnOdn8Bs6/Ihl6EeAA7m/SPAgwDCjIFqvVRMcOJGNii5n1UzN/EQuNMHUTe3lUljbzSU7Yufd5zl49a/AA+kPwgybpuFOVxtdEs296nxvn8S77jiwIfeKqFQpgKDzXyKwep1kTkXUKVS+3Tg1HaI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=A+gj0jP8; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=M9O4+V5H; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=A+gj0jP8; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=M9O4+V5H; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="A+gj0jP8"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="M9O4+V5H"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="A+gj0jP8"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="M9O4+V5H" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6C2881F7F4; Tue, 23 Sep 2025 15:21:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1758640897; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=49VtfWcgbDap/wiXADPZ3BMXozuzKI2e+wmDabn0Ky0=; b=A+gj0jP8IpXodEJAtAqqIcm+yqybcP8ofnj4kNvTsn5+osiEr3Vo2EztPp5hOfdde/qpwp xnkDsp6/cOeb1ILvpvlDQ97tg1bPob/AD6TQZUgsA1bGL33ERViBkw13kDNH1to4Bz7xmy EIUWp8lxb7XSNphbJesf0rlBHBPOCpo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1758640897; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=49VtfWcgbDap/wiXADPZ3BMXozuzKI2e+wmDabn0Ky0=; b=M9O4+V5HZH4bBeG27XOytmI/UqdnDJXq9IXjHTRauorPMvdvaINcEOVoMWuLsIBFQ0KysI 2KbRbnbp2qXlXJDA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=A+gj0jP8; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=M9O4+V5H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1758640897; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=49VtfWcgbDap/wiXADPZ3BMXozuzKI2e+wmDabn0Ky0=; b=A+gj0jP8IpXodEJAtAqqIcm+yqybcP8ofnj4kNvTsn5+osiEr3Vo2EztPp5hOfdde/qpwp xnkDsp6/cOeb1ILvpvlDQ97tg1bPob/AD6TQZUgsA1bGL33ERViBkw13kDNH1to4Bz7xmy EIUWp8lxb7XSNphbJesf0rlBHBPOCpo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1758640897; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=49VtfWcgbDap/wiXADPZ3BMXozuzKI2e+wmDabn0Ky0=; b=M9O4+V5HZH4bBeG27XOytmI/UqdnDJXq9IXjHTRauorPMvdvaINcEOVoMWuLsIBFQ0KysI 2KbRbnbp2qXlXJDA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 44C7F1388C; Tue, 23 Sep 2025 15:21:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id lTCbDwG70mjaVwAAD6G6ig (envelope-from ); Tue, 23 Sep 2025 15:21:37 +0000 Message-ID: Date: Tue, 23 Sep 2025 17:21:36 +0200 Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] fbcon: fix buffer overflow in fbcon_set_font To: Simon Richter , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: stable References: <20250923150642.2441-1-Simon.Richter@hogyros.de> Content-Language: en-US From: Thomas Zimmermann Autocrypt: addr=tzimmermann@suse.de; keydata= xsBNBFs50uABCADEHPidWt974CaxBVbrIBwqcq/WURinJ3+2WlIrKWspiP83vfZKaXhFYsdg XH47fDVbPPj+d6tQrw5lPQCyqjwrCPYnq3WlIBnGPJ4/jreTL6V+qfKRDlGLWFjZcsrPJGE0 BeB5BbqP5erN1qylK9i3gPoQjXGhpBpQYwRrEyQyjuvk+Ev0K1Jc5tVDeJAuau3TGNgah4Yc hdHm3bkPjz9EErV85RwvImQ1dptvx6s7xzwXTgGAsaYZsL8WCwDaTuqFa1d1jjlaxg6+tZsB 9GluwvIhSezPgnEmimZDkGnZRRSFiGP8yjqTjjWuf0bSj5rUnTGiyLyRZRNGcXmu6hjlABEB AAHNJ1Rob21hcyBaaW1tZXJtYW5uIDx0emltbWVybWFubkBzdXNlLmRlPsLAjgQTAQgAOAIb AwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgBYhBHIX+6yM6c9jRKFo5WgNwR1TC3ojBQJftODH AAoJEGgNwR1TC3ojx1wH/0hKGWugiqDgLNXLRD/4TfHBEKmx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KSVXAylqyQOW5zvPc4/sq9c= In-Reply-To: <20250923150642.2441-1-Simon.Richter@hogyros.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; MID_RHS_MATCH_FROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:mid,suse.de:dkim]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Flag: NO X-Spam-Level: X-Rspamd-Queue-Id: 6C2881F7F4 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -4.51 Hi, thanks for the patch. The fix at [1] has meanwhile been merged into the DRM tree. [1] https://patchwork.freedesktop.org/series/154848/ Best regards Thomas Am 23.09.25 um 17:06 schrieb Simon Richter: > Commit 1a194e6c8e1ee745e914b0b7f50fa86c89ed13fe introduced overflow > checking for the font allocation size calculation, but in doing so moved > the addition of the size for font housekeeping data out of the kmalloc > call. > > As a result, the calculated size now includes those extra bytes, which > marks the same number of bytes beyond the allocation as valid font data. > > The crc32() call and the later memcmp() in fbcon_set_font() already perform > an out-of-bounds read, the latter is flagged on ppc64el: > > memcmp: detected buffer overflow: 4112 byte read of buffer size 4096 > > when loading Lat15-Fixed16.psf.gz. > > Since the addition of the extra size should only go into the kmalloc() > call, calculate this size in a separate variable. > > Signed-off-by: Simon Richter > Fixes: 1a194e6c8e1e ("fbcon: fix integer overflow in fbcon_do_set_font") > Cc: stable #v5.9+ > --- > drivers/video/fbdev/core/fbcon.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c > index 5fade44931b8..a3fbf42c57d9 100644 > --- a/drivers/video/fbdev/core/fbcon.c > +++ b/drivers/video/fbdev/core/fbcon.c > @@ -2518,7 +2518,7 @@ static int fbcon_set_font(struct vc_data *vc, const struct console_font *font, > unsigned charcount = font->charcount; > int w = font->width; > int h = font->height; > - int size; > + int size, allocsize; > int i, csum; > u8 *new_data, *data = font->data; > int pitch = PITCH(font->width); > @@ -2551,10 +2551,10 @@ static int fbcon_set_font(struct vc_data *vc, const struct console_font *font, > return -EINVAL; > > /* Check for overflow in allocation size calculation */ > - if (check_add_overflow(FONT_EXTRA_WORDS * sizeof(int), size, &size)) > + if (check_add_overflow(FONT_EXTRA_WORDS * sizeof(int), size, &allocsize)) > return -EINVAL; > > - new_data = kmalloc(size, GFP_USER); > + new_data = kmalloc(allocsize, GFP_USER); > > if (!new_data) > return -ENOMEM; -- -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)