mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zijun Hu <zijun_hu@icloud.com>
To: Christian Brauner <brauner@kernel.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
	David Howells <dhowells@redhat.com>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Zijun Hu <quic_zijuhu@quicinc.com>
Subject: Re: [PATCH 3/5] fs/fs_parse: Fix 3 issues for validate_constant_table()
Date: Fri, 11 Apr 2025 22:48:40 +0800	[thread overview]
Message-ID: <1d59d38a-5674-4591-a866-27dfbc410b93@icloud.com> (raw)
In-Reply-To: <20250411-beteuern-fusionieren-2a3d24f055d0@brauner>

On 2025/4/11 22:37, Christian Brauner wrote:
>> - Potential NULL pointer dereference.
> I really dislike "potential NULL deref" without an explanation. Please
> explain how this supposed NULL deref can happen.
> 

okay.

>> Fixes: 31d921c7fb96 ("vfs: Add configuration parser helpers")
>> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
>> ---
>>  fs/fs_parser.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/fs_parser.c b/fs/fs_parser.c
>> index e635a81e17d965df78ffef27f6885cd70996c6dd..ef7876340a917876bc40df9cdde9232204125a75 100644
>> --- a/fs/fs_parser.c
>> +++ b/fs/fs_parser.c
>> @@ -399,6 +399,9 @@ bool validate_constant_table(const struct constant_table *tbl, size_t tbl_size,
>>  	}
>>  
>>  	for (i = 0; i < tbl_size; i++) {
>> +		if (!tbl[i].name && (i + 1 == tbl_size))
>> +			break;
>> +
>>  		if (!tbl[i].name) {
>>  			pr_err("VALIDATE C-TBL[%zu]: Null\n", i);
>>  			good = false;
>> @@ -411,13 +414,13 @@ bool validate_constant_table(const struct constant_table *tbl, size_t tbl_size,
>>  				good = false;
>>  			}
>>  			if (c > 0) {
>> -				pr_err("VALIDATE C-TBL[%zu]: Missorted %s>=%s\n",
>> +				pr_err("VALIDATE C-TBL[%zu]: Missorted %s>%s\n",
>>  				       i, tbl[i-1].name, tbl[i].name);
>>  				good = false;
>>  			}
>>  		}
>>  
>> -		if (tbl[i].value != special &&
>> +		if (tbl[i].name && tbl[i].value != special &&
>>  		    (tbl[i].value < low || tbl[i].value > high)) {
>>  			pr_err("VALIDATE C-TBL[%zu]: %s->%d const out of range (%d-%d)\n",
>>  			       i, tbl[i].name, tbl[i].value, low, high);

for good constant table which ends with empty entry. for original logic,
when loop reach the last empty entry.  above pr_err() may access NULL
pointer tbl[i].name.


i find out this validate_constant_table() also has no callers.
fix it or remove it ?


  reply	other threads:[~2025-04-11 14:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-10 11:45 [PATCH 0/5] fs: bug fixes Zijun Hu
2025-04-10 11:45 ` [PATCH 1/5] fs/filesystems: Fix potential unsigned integer underflow in fs_name() Zijun Hu
2025-04-11 14:34   ` (subset) " Christian Brauner
2025-04-11 14:35   ` Christian Brauner
2025-04-11 14:52     ` Zijun Hu
2025-04-10 11:45 ` [PATCH 2/5] fs/fs_parse: Fix macro fsparam_u32hex() definition Zijun Hu
2025-04-11 14:17   ` Christian Brauner
2025-04-11 14:25     ` Zijun Hu
2025-04-10 11:45 ` [PATCH 3/5] fs/fs_parse: Fix 3 issues for validate_constant_table() Zijun Hu
2025-04-11 14:37   ` Christian Brauner
2025-04-11 14:48     ` Zijun Hu [this message]
2025-04-14 12:39       ` Jan Kara
2025-04-10 11:45 ` [PATCH 4/5] fs/fs_parse: Correct comments of fs_validate_description() Zijun Hu
2025-04-11 14:20   ` (subset) " Christian Brauner
2025-04-10 11:45 ` [PATCH 5/5] fs/fs_context: Mark an unlikely if condition with unlikely() in vfs_parse_monolithic_sep() Zijun Hu
2025-04-11 14:24   ` (subset) " Christian Brauner
2025-04-11 15:34 ` [PATCH 1/5] fs/filesystems: Fix potential unsigned integer underflow in fs_name() David Howells
2025-04-11 16:06   ` Zijun Hu

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=1d59d38a-5674-4591-a866-27dfbc410b93@icloud.com \
    --to=zijun_hu@icloud.com \
    --cc=brauner@kernel.org \
    --cc=dhowells@redhat.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_zijuhu@quicinc.com \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®