Linux Hardening
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Dan Carpenter <dan.carpenter@linaro.org>,
	linux-hardening@vger.kernel.org, kernel-janitors@vger.kernel.org,
	"Guilherme G. Piccoli" <gpiccoli@igalia.com>,
	Joel Fernandes <joel@joelfernandes.org>,
	Kees Cook <keescook@chromium.org>,
	Tony Luck <tony.luck@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	"Günter Röck" <groeck@chromium.org>,
	"Sai Prakash Ranjan" <saiprakash.ranjan@codeaurora.org>,
	"Kunwu Chan" <chentao@kylinos.cn>
Subject: Re: [PATCH] pstore/ram: Return directly after a failed kasprintf() call in ramoops_init_prz()
Date: Thu, 18 Jan 2024 09:38:49 +0100	[thread overview]
Message-ID: <ea4117d5-bc70-4f6d-9fe4-e70e0cc47a6c@web.de> (raw)
In-Reply-To: <26759e3b-ff74-4b04-b06f-4d68fbc5f606@moroto.mountain>

>> 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.
>> +++ 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.
…

Will it become helpful to annotate the corresponding function input parameter
for null pointer tolerance anyhow?

Regards,
Markus

      reply	other threads:[~2024-01-18  8:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-17 20:24 [PATCH] pstore/ram: Return directly after a failed kasprintf() call in ramoops_init_prz() Markus Elfring
2024-01-18  2:03 ` Kunwu Chan
2024-01-18  5:29 ` Dan Carpenter
2024-01-18  8:38   ` Markus Elfring [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ea4117d5-bc70-4f6d-9fe4-e70e0cc47a6c@web.de \
    --to=markus.elfring@web.de \
    --cc=chentao@kylinos.cn \
    --cc=dan.carpenter@linaro.org \
    --cc=gpiccoli@igalia.com \
    --cc=groeck@chromium.org \
    --cc=joel@joelfernandes.org \
    --cc=keescook@chromium.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=saiprakash.ranjan@codeaurora.org \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox