From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23D43C04AAF for ; Thu, 16 May 2019 15:11:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F23FB20657 for ; Thu, 16 May 2019 15:11:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727274AbfEPPL4 (ORCPT ); Thu, 16 May 2019 11:11:56 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:55298 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726857AbfEPPLz (ORCPT ); Thu, 16 May 2019 11:11:55 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4GF0EHJ012327 for ; Thu, 16 May 2019 11:11:54 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2sh92s3xqt-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 May 2019 11:11:54 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 May 2019 16:11:50 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 16 May 2019 16:11:48 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4GFBlnG59506780 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 May 2019 15:11:47 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 94C3C4C05C; Thu, 16 May 2019 15:11:47 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2A03D4C052; Thu, 16 May 2019 15:11:47 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.8.112]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Thu, 16 May 2019 15:11:47 +0000 (GMT) Date: Thu, 16 May 2019 18:11:45 +0300 From: Mike Rapoport To: Steven Price Cc: Andrew Morton , Christoph Hellwig , linux-kernel@vger.kernel.org, Mark Rutland Subject: Re: [PATCH] initramfs: Don't free a non-existent initrd References: <20190516143125.48948-1-steven.price@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190516143125.48948-1-steven.price@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-GCONF: 00 x-cbid: 19051615-0016-0000-0000-0000027C6901 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19051615-0017-0000-0000-000032D940C3 Message-Id: <20190516151145.GH19122@rapoport-lnx> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-05-16_12:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905160096 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 16, 2019 at 03:31:25PM +0100, Steven Price wrote: > Since 54c7a8916a88 ("initramfs: free initrd memory if opening > /initrd.image fails"), the kernel has unconditionally attempted to free > the initrd even if it doesn't exist. In the non-existent case this > causes a boot-time splat if CONFIG_DEBUG_VIRTUAL is enabled due to a > call to virt_to_phys() with a NULL address. > > Instead we should check that the initrd actually exists and only attempt > to free it if it does. > > Fixes: 54c7a8916a88 ("initramfs: free initrd memory if opening /initrd.image fails") > Reported-by: Mark Rutland > Tested-by: Mark Rutland > Signed-off-by: Steven Price > --- Reviewed-by: Mike Rapoport > init/initramfs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/init/initramfs.c b/init/initramfs.c > index 435a428c2af1..178130fd61c2 100644 > --- a/init/initramfs.c > +++ b/init/initramfs.c > @@ -669,7 +669,7 @@ static int __init populate_rootfs(void) > * If the initrd region is overlapped with crashkernel reserved region, > * free only memory that is not part of crashkernel region. > */ > - if (!do_retain_initrd && !kexec_free_initrd()) > + if (!do_retain_initrd && initrd_start && !kexec_free_initrd()) > free_initrd_mem(initrd_start, initrd_end); > initrd_start = 0; > initrd_end = 0; > -- > 2.20.1 > -- Sincerely yours, Mike.