Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp140716rdb; Wed, 17 Jan 2024 21:29:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IHpLDIM1PbMn+BWZecCFLnT6pTdb/LFYPqsPG52AnJk8mrJuIkIRNdRcz3kB3N0tVKzrNFu X-Received: by 2002:a05:6870:8309:b0:206:9a23:9532 with SMTP id p9-20020a056870830900b002069a239532mr313012oae.101.1705555778470; Wed, 17 Jan 2024 21:29:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705555778; cv=pass; d=google.com; s=arc-20160816; b=XFu4ykJNRzsWamQW+jSer/xa1/tUiO14gY39MEcJZsNLvIrJy7yF4Uq4uIeK/KQa3h YNYQ1ssHOQMNOqkSu20zlcDwLir8Xf60tvoIERm9y8wgxQ2+45zE9BdTloGfqUFqT4KP Wdv1z8NpXHbjZDCyVWLWiDxWbunMiCqXzeGQN+waq/Hc3jVGm5MknN38uCmFGTI+FwDQ z5XxEkjHz05g7BVjFFOytSP9Y1qXX7bOqAIOXDCqqGEWe5oi++ngS4ULi0aEWO1pVl9z PNG4qy+PhdxpqFemMRaN9jsP2sWlxlq+aEVjk4iH/QQAfB2A4k7U69+0gkXuik5WQyBK CA6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wWVOjE9eG7LQZ1p5rDtepmpo2WIDbMJDdYV1+1m1FBU=; fh=XcA0wBZ1DO5DmAUFENoGROA77eS+lxFvuZMITQj1N2A=; b=yoGWGvZESjXQtjK1wt1Qjs1K6C622iLzph0EwkDvuHdWEYsUGcd9eFrft8vgxqrTjn R9jGDKYJIImvhFT0HTK7TaNZKny9eI2ssAiAzja6TYNUHFf+SIvNkJqWNuaTegee16uS 1MEuUxRQOxrpXABVJEnyHYTm2elauxLHborHNW9vLElKdZWd/ybgyX+OxtNFLtj+IFA3 2EbBVTSZ7u5LuvQVWzmUyc1Yi9aPWShvLkzB4uXHwQTlb5gdYgWL5HREWuOIWpkBitRy q8cHPxnB959XXgIucO4beoE22ayT2hG6hCHmgimaZZa6YEuu7heT8JBr80LsoPY1tteL 44/A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bies4SxQ; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-29719-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29719-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l33-20020a635721000000b005c6b4e190b0si839848pgb.530.2024.01.17.21.29.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 21:29:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29719-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; dkim=pass header.i=@linaro.org header.s=google header.b=Bies4SxQ; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-29719-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29719-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 96FFA286B6E for ; Thu, 18 Jan 2024 05:29:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B5CB48F74; Thu, 18 Jan 2024 05:29:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Bies4SxQ" Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 4E7FE63B5 for ; Thu, 18 Jan 2024 05:29:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705555767; cv=none; b=D9csiXa0DdEgUfP5UmJQWQze0YpEeid/pMvYPe6IT5EI6B0FrYBQrQCngPTWayu26pjknMXdPcp21Yh16UCqymH+TFyoBXJj5SURW7De6oFzYLL0X0vYqpyv/+UZyBQ4sNy6NZgRwI55oG+lxFctUqQXb9benn4ExophHuCGqe8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705555767; c=relaxed/simple; bh=SBVMA/CPQNcVCfcURUzuwVBCE1qUg3c5WG0zdMGFPQg=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:Received:Date: From:To:Cc:Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:Content-Transfer-Encoding:In-Reply-To; b=G9afj1eCuwoH9xY5OZtyFTewHWtl6276rb82i2GZOtmX0HpVpPzcDeeu1kaTbmiu/D1quffw0rjss86VMJPi3rnx8llJrXll/ChoZfA0LZN/h2UwgV3injt/6zyi8LJAzDFI/IY+U6jztOQbFK//1+1Yv3dfcDqiO0pLNyhfaS0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Bies4SxQ; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-40e800461baso31788065e9.3 for ; Wed, 17 Jan 2024 21:29:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705555764; x=1706160564; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=wWVOjE9eG7LQZ1p5rDtepmpo2WIDbMJDdYV1+1m1FBU=; b=Bies4SxQOMm2y9Btq51UiXzVZwhtvjN5NVmtvQJ0eMUe5gfREJdCIWlM2FxjYkiBL3 viV/JtBvnRgvSaTfwEus92WDyzUb3MfLjJ5O9zlh/ZVwvyVQBv9ZeiJiF1E7DFlkoLLO 63j7Xl9jQkNSOsfYa7Ts9+OTe+0uab+XRsZ5WD7dEzWzmQQ+NdTwQcWCyP+4CkAEiz+r ORCWpnC38A/1yZmryV8RrfSfvJ57rWs9JR8xGuX/rZYA8bP39uLvGBOE2VJtukBhe+Tc C7nh4w/yN1i/HRgsTCxOEl+pkZ6R/0O2RS9YvtIv8EHNK1rY8hSfBv0GqE2qbHOeuljq YHeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705555764; x=1706160564; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wWVOjE9eG7LQZ1p5rDtepmpo2WIDbMJDdYV1+1m1FBU=; b=AmHS4oDe4VRYhaR9Prm//GufKo+f0CoqNQcSjkjQqZ2rhA2mKPA1PNYXlePu9sk23/ kIACPf2D1VtDPbJQdRICtiYDhIod4+qesjlHMJ7aQi7qVRrm92a/ucYT76ZDJM1C0cPA 3YxheZqTUd9jlhmkDnzS0WEPJP3zJC2JElv0oQGUvJ0oud175eabG0zw3bL0YhPf6zCM T5u9GyIZfVNijr+Qu/YlZmNZaCDaf36TfHEKWMQvmOOybc5aJnJX/rbnRYy6yq32Ao3P EYVfMCTxjK7uRXqu9gJ4PmEpzEiyBkMLHn6Ck8I7eab9qXRR7HO2Ij4iyVP0kwV41KN2 KJdA== X-Gm-Message-State: AOJu0Yw5+wFKQnWy+a6dZOnUmaP+jtwA0jnvRZAaQNkE3xJe/jJBRPKx 9XgNqG8W7bodyskPLLEjhtA9JY1WV2wGzBfaJnq4lD06Y+BgnaDNvwSMLeS89mg= X-Received: by 2002:a05:600c:880e:b0:40e:4799:8a81 with SMTP id gy14-20020a05600c880e00b0040e47998a81mr66295wmb.281.1705555764049; Wed, 17 Jan 2024 21:29:24 -0800 (PST) Received: from localhost ([102.140.209.237]) by smtp.gmail.com with ESMTPSA id o21-20020a05600c4fd500b0040e34ca648bsm24586127wmq.0.2024.01.17.21.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 21:29:23 -0800 (PST) Date: Thu, 18 Jan 2024 08:29:20 +0300 From: Dan Carpenter To: Markus Elfring Cc: linux-hardening@vger.kernel.org, kernel-janitors@vger.kernel.org, "Guilherme G. Piccoli" , Joel Fernandes , Kees Cook , Tony Luck , LKML , =?iso-8859-1?Q?G=FCnter_R=F6ck?= , Sai Prakash Ranjan , Kunwu Chan Subject: Re: [PATCH] pstore/ram: Return directly after a failed kasprintf() call in ramoops_init_prz() Message-ID: <26759e3b-ff74-4b04-b06f-4d68fbc5f606@moroto.mountain> References: <644f44ad-7e2b-4a1a-bbd7-ccc79d479242@web.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <644f44ad-7e2b-4a1a-bbd7-ccc79d479242@web.de> On Wed, Jan 17, 2024 at 09:24:12PM +0100, Markus Elfring wrote: > From: Markus Elfring > Date: Wed, 17 Jan 2024 21:09:22 +0100 > > The result from a call of the function “kasprintf” 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. > > Thus return directly after a failed kasprintf() call. > > Fixes: 1227daa43bce1 ("pstore/ram: Clarify resource reservation labels") > Signed-off-by: Markus Elfring > --- > fs/pstore/ram.c | 3 +++ > 1 file changed, 3 insertions(+) > > 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, > } > > label = kasprintf(GFP_KERNEL, "ramoops:%s", name); > + if (!label) > + return -ENOMEM; > + > *prz = persistent_ram_new(*paddr, sz, sig, &cxt->ecc_info, > cxt->memtype, PRZ_FLAG_ZAP_OLD, label); > kfree(label); This patch is fine as a clean up, but I think it's useful to say that if you pass a NULL label to persistent_ram_new() then it will return an error. It won't crash. So this patch is a nice cleanup but it's not a bug fix. regards, dan carpenter