Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp77250rdb; Wed, 17 Jan 2024 18:09:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEvQYAIrwY8SMY/WiWH46lIKKUFDfVg0t3sPFmu8ZZqJsYzsXI5sNg+6KeUAZr9EQhM91EQ X-Received: by 2002:a05:6a20:65e:b0:19b:748b:c9d7 with SMTP id 30-20020a056a20065e00b0019b748bc9d7mr160612pzm.64.1705543766412; Wed, 17 Jan 2024 18:09:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705543766; cv=pass; d=google.com; s=arc-20160816; b=JGlB8iB72o+YA45+BbmAxucZ9kP8R6lQpizvd14gtHLnn3MAuxWdV8OmST6wfJtBg0 +6uDO2/bhI1VLVhv34KCS2Bw/G0RD40c8DNfo/5kB7I0Ty0X/78zABAlgpDENb6aBGXF FbTNDXQ1mjZvXXdo8/g5JW+aF3yEsp79x5r8Gf8DasTcVRUCWxjo9fBteHNQAlqNe2Qx r1G2eOsMcSBI+1DGY3ZP2z44qTI92DVr9wTEEHWM9suslIFUuF3vbP4qMDEv+Egx5nv6 PjktY8IVlYqY6vP1Dq+mGUEK1rZPaf9rwr4/yG1L65V8myz0CD/wPFR4OBxV70OrEwHH wv/g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=HGwHFM7rrxdSPfePT9rzD5QFnd/h7ER+gQb+QiDXWII=; fh=qo4boHxnC3gqJ+U/1QcnnMsoIBqhkqxuSHmT1xskwyA=; b=SrVZWDU1yL+vhOH6GtWobfNTO5S8AE5WbEudZA4W7ZQF741d0JRSlWl5eP0SnrGH9O 3m97TFRL4KrTAf0gs9XfnlLbC3LLqnZegBzs2IchSxxBGuvFr1u6x/HgrzeJ9unreriU y7n1jG8RIc/IAeRQkQpbKJvFvyaqGGjh/K6ChDMDZhDUsOe7HwjjkcC8cPRtSo4wXtXF chuOGPkJQ3tIHRsVO78Hu29vfBdAY0ACOteg853Ynglk1ms7jUbCJvGBKe4JHEpS4+F3 ajVdDHxu4g6mLHjryUkcshoffyWBScoJS0+u/8WUzWg3XxsUlobdfNSGntfUMif2ZH7W hpSA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-29648-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29648-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k191-20020a636fc8000000b005c6bc2367ebsi628760pgc.216.2024.01.17.18.09.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 18:09:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29648-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-29648-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29648-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 07B48284320 for ; Thu, 18 Jan 2024 02:09:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8A7605390; Thu, 18 Jan 2024 02:09:13 +0000 (UTC) Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FBA42115; Thu, 18 Jan 2024 02:09:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705543753; cv=none; b=ej4d7ElJY/M0gG2UFAYJECbPPUcRWV0Zx5fRRha12G7bZ5K65o214/aT/XKi0GENT7rC1kEQ9AMLsoj9CzYX3xzmBqVFXUS5qwiZBr+i6fXFbEipStynkGoWFtxV9bFHjkfsz6/h8DNgprMz8VpFAefrpWh+otJEGCTXPyGgJqM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705543753; c=relaxed/simple; bh=z3G3oCbHidD8qynDWfVmNenXA6fw2hQV7eZGCKnPYyE=; h=X-UUID:X-CID-P-RULE:X-CID-O-INFO:X-CID-INFO:X-CID-META:X-CID-BVR: X-CID-BAS:X-CID-FACTOR:X-UUID:Received:Received:X-ns-mid:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; b=kpNAS1jXVZ/E25p6Ts3EdHPsmjzpWAEn8deAVsxM90f5HsuKXtCLlTETrJoSEzqbsltOUJ3qVymZMk0Mw1gwEunWCnLUA8WoOQrAcf5iu2OHtvSe0P36KOvKUAK3NzQE6bt5vaN8jtpYHrq0oZJIL9SC/7xGdNwRUfoDryZRTu4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 96769b9c0fbc46cd8ed79cbbd996c5c5-20240118 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:ee66016e-655b-450a-83d8-1a213d165016,IP:10, URL:0,TC:0,Content:0,EDM:0,RT:0,SF:-9,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:1 X-CID-INFO: VERSION:1.1.35,REQID:ee66016e-655b-450a-83d8-1a213d165016,IP:10,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:-9,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:1 X-CID-META: VersionHash:5d391d7,CLOUDID:1b50787f-4f93-4875-95e7-8c66ea833d57,B ulkID:240118100344LP7I44R2,BulkQuantity:0,Recheck:0,SF:66|38|24|17|19|42|7 4|64|102,TC:nil,Content:0,EDM:-3,IP:-2,URL:0,File:nil,Bulk:nil,QS:nil,BEC: nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: 96769b9c0fbc46cd8ed79cbbd996c5c5-20240118 Received: from mail.kylinos.cn [(39.156.73.10)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 696325700; Thu, 18 Jan 2024 10:03:42 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id D0A45E000EB9; Thu, 18 Jan 2024 10:03:41 +0800 (CST) X-ns-mid: postfix-65A886FD-772615417 Received: from [172.20.15.234] (unknown [172.20.15.234]) by mail.kylinos.cn (NSMail) with ESMTPA id 46FA7E000EB9; Thu, 18 Jan 2024 10:03:38 +0800 (CST) Message-ID: Date: Thu, 18 Jan 2024 10:03:37 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] pstore/ram: Return directly after a failed kasprintf() call in ramoops_init_prz() To: Markus Elfring , linux-hardening@vger.kernel.org, kernel-janitors@vger.kernel.org, "Guilherme G. Piccoli" , Joel Fernandes , Kees Cook , Tony Luck Cc: LKML , =?UTF-8?B?R8O8bnRlciBSw7Zjaw==?= , Sai Prakash Ranjan References: <644f44ad-7e2b-4a1a-bbd7-ccc79d479242@web.de> Content-Language: en-US From: Kunwu Chan In-Reply-To: <644f44ad-7e2b-4a1a-bbd7-ccc79d479242@web.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Hi Markus, Thanks for your patch. On 2024/1/18 04:24, Markus Elfring wrote: > From: Markus Elfring > Date: Wed, 17 Jan 2024 21:09:22 +0100 >=20 > The result from a call of the function =E2=80=9Ckasprintf=E2=80=9D was = passed to > a subsequent function call without checking for a null pointer before > (according to a memory allocation failure). > This issue was detected by using the Coccinelle software. >=20 > Thus return directly after a failed kasprintf() call. >=20 > Fixes: 1227daa43bce1 ("pstore/ram: Clarify resource reservation labels"= ) > Signed-off-by: Markus Elfring > --- > fs/pstore/ram.c | 3 +++ > 1 file changed, 3 insertions(+) >=20 > diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c > index 88b34fdbf759..1a673a4af17c 100644 > --- a/fs/pstore/ram.c > +++ b/fs/pstore/ram.c > @@ -595,6 +595,9 @@ static int ramoops_init_prz(const char *name, > } >=20 > label =3D kasprintf(GFP_KERNEL, "ramoops:%s", name); > + if (!label) > + return -ENOMEM; > + This part looks good to me. Commit 1227daa43bce1 ("pstore/ram: Clarify resource reservation labels") introduce another two more kasprintf in the ramoops_init_przs. Could you fix it together? > *prz =3D persistent_ram_new(*paddr, sz, sig, &cxt->ecc_info, > cxt->memtype, PRZ_FLAG_ZAP_OLD, label); > kfree(label); > -- > 2.43.0 >=20 --=20 Thanks, Kunwu