Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5161333pxj; Wed, 26 May 2021 04:26:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxi3p0dVDHC7YyrFBPT1o3loAUI1TgSXPFl2GlmwLxeq25sK0zLHzIT3jSkgFKHPceKdh9p X-Received: by 2002:a5d:814d:: with SMTP id f13mr23585492ioo.203.1622028367825; Wed, 26 May 2021 04:26:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622028367; cv=none; d=google.com; s=arc-20160816; b=JzH1TqKeqH3LXoP6FjKJ6ElzXa2IqSwqomGrr3pqbsRCS+I9DYN4yxxgjP8/uqVv+L 08dmdjRzJHId3ohhu+IY35PUMRB21v1ud0VDbCXzEnLBfSVcFr7jumTFEA1ike2o7NyJ oLDk/XpYd41s/Y3lkhLEBGQvyU1ne/+FfPOXEL5qfh/BD1C+joq/belG3OWLFtmLnjuy 4xBMSCVBvg2+sBe4dmniMBZdNJssGMqOd3ysgnMNR7xJEUQpFvOTHjZahFMhT1S/NzQ/ bI24O9SbIWauTlDtZHHjqBFEzApsr6iBLs9uLm/nwzLgibEJQGFXuglQIVYTMkDekpm0 a7kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6u8GNofNAb/t1gMEcPye0iJHwrRX3gHnArpFUM2tefA=; b=Gck9hXKUuJDT3PsTD1V90qwqcBD8ATThMAnfxmvsXXN9awRbj6Uq5XGGUiU6Kfkn+s IA9tFeWroKqR/lHHTAzGPD8MYq2PYvgjPG3jxKOUzxkhGpDkakHQmOM7KbFH7VCxmAXx ZGufWt0+YS9cFpwUPxXaBrU70xuVygg5Vn7oJs2LfCyX+yO6RbcR/LvQu/v1Eqzlui6B v74s4y154elbXAWrcPKjga/shvTmwxPLSJwIXu7HISGuOZ8wTun+3rv0JDsmFYBt9V4c +1KaH7FZGxARXRC+71DUsfcHyNFGluMyNe/4nWUOjBmgt2kZYaQQTX10Zm9CVld7s621 Jmww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Xok57HNc; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x20si19683719iov.56.2021.05.26.04.25.53; Wed, 26 May 2021 04:26:07 -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=@linuxfoundation.org header.s=korg header.b=Xok57HNc; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232943AbhEZHOl (ORCPT + 99 others); Wed, 26 May 2021 03:14:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:34346 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232933AbhEZHO3 (ORCPT ); Wed, 26 May 2021 03:14:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3E2ED6138C; Wed, 26 May 2021 07:12:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622013161; bh=k9arDdstTg+dErXlKKRgWXiQeI0XgpdsxR3Vbwv+9IA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Xok57HNca//G/NCMBezDnPz+GkQ2NPiZbpVq0+NJLsKpPYlhPff4vaAH84gf0dpZC Yt+Nj93vEy4BqL4OgrSRLLJxuddy5zZGrOmBAgakGpLOS0Bvfc06bPH/Bp2KLPhvIx zCVJSx+bW+Goh+lNi+Y/XVDRsTPFKHcx8uo7CIoA= Date: Wed, 26 May 2021 09:12:39 +0200 From: Greg Kroah-Hartman To: Igor Torrente Cc: Pavel Machek , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Ferenc Bakonyi , Bartlomiej Zolnierkiewicz Subject: Re: [PATCH 4.4 28/31] video: hgafb: fix potential NULL pointer dereference Message-ID: References: <20210524152322.919918360@linuxfoundation.org> <20210524152323.833888129@linuxfoundation.org> <20210525204704.GA12631@duo.ucw.cz> <2a22a7ec-3a47-92dc-5052-c9e7bb2d604b@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2a22a7ec-3a47-92dc-5052-c9e7bb2d604b@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 25, 2021 at 06:06:15PM -0300, Igor Torrente wrote: > Hi Pavel, > > On 5/25/21 5:47 PM, Pavel Machek wrote: > > Hi! > > > > > From: Igor Matheus Andrade Torrente > > > > > > commit dc13cac4862cc68ec74348a80b6942532b7735fa upstream. > > > > > > The return of ioremap if not checked, and can lead to a NULL to be > > > assigned to hga_vram. Potentially leading to a NULL pointer > > > dereference. > > > > > > The fix adds code to deal with this case in the error label and > > > changes how the hgafb_probe handles the return of hga_card_detect. > > > > This will break hgafb completely, right? And crash system without hga > > card as a bonus. > > > > > +++ b/drivers/video/fbdev/hgafb.c > > > @@ -285,6 +285,8 @@ static int hga_card_detect(void) > > > hga_vram_len = 0x08000; > > > hga_vram = ioremap(0xb0000, hga_vram_len); > > > + if (!hga_vram) > > > + return -ENOMEM; > > > if (request_region(0x3b0, 12, "hgafb")) > > > release_io_ports = 1; > > > @@ -344,13 +346,18 @@ static int hga_card_detect(void) > > > hga_type_name = "Hercules"; > > > break; > > > } > > > - return 1; > > > + return 0; > > > > Ok, so calling convention is now "0 means detected". > > > > > > > @@ -548,13 +555,11 @@ static struct fb_ops hgafb_ops = { > > > static int hgafb_probe(struct platform_device *pdev) > > > { > > > struct fb_info *info; > > > + int ret; > > ... > > > + ret = hga_card_detect(); > > > + if (!ret) > > > + return ret; > > > printk(KERN_INFO "hgafb: %s with %ldK of memory detected.\n", > > > hga_type_name, hga_vram_len/1024); > > > > > > > If the card is detected, 0 is returned, !0 is true, and we abort > > detection.... > > Yes, you are right! There's a patch that fixes it: > > https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git/commit/?h=char-misc-linus&id=02625c965239b71869326dd0461615f27307ecb3 > > As far as I know, this patch should be queue up soon to all stable branches. > > Greg should have more details about it. Good catch, I'll go queue that up now, thanks. greg k-h