From: Wang Zhaolong <wangzhaolong1@huawei.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: <amir73il@gmail.com>, <linux-unionfs@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <yi.zhang@huawei.com>,
<yangerkun@huawei.com>
Subject: Re: [PATCH] overlayfs: fix potential NULL pointer dereferences in file handle code
Date: Wed, 30 Apr 2025 17:56:12 +0800 [thread overview]
Message-ID: <8f76ec4f-fb8e-46cf-b59f-ef95c500a85a@huawei.com> (raw)
In-Reply-To: <CAJfpegvKvHwU69F0wazk_TyrKPCcrcVU+Z+5=UNpg29CJGH84w@mail.gmail.com>
Thank you for your valuable feedback.
> On Tue, 29 Apr 2025 at 02:13, Wang Zhaolong <wangzhaolong1@huawei.com> wrote:
>>
>> Several locations in overlayfs file handle code fail to check if a file
>> handle pointer is NULL before accessing its members. A NULL file handle
>> can occur when the lower filesystem doesn't support export operations,
>> as seen in ovl_get_origin_fh() which explicitly returns NULL in this case.
>
> Have you tried to trigger these conditions?
>
> If you find a bug by code inspection, try to recreate it, by that you
> can also verify that the patch works. If you cannot reproduce it, at
> least prove that triggering the bug is possible.
>
> Without a proof the patch may turn out to do nothing at best and
> introduce new bugs at worst.
>
I haven't yet been able to reproduce these conditions in a live environment.
My analysis started when I noticed the inconsistency in ovl_set_origin_fh()
where it accesses fh->buf without checking if fh is NULL, but then immediately
checks "fh ?" in the next parameter. Following the code paths, I found that
ovl_get_origin_fh() can explicitly return NULL when the lower filesystem
doesn't support export operations.
>>
>> The following locations are vulnerable to NULL pointer dereference:
>>
>> 1. ovl_set_origin_fh() accesses fh->buf without checking if fh is NULL
>
> Hint: fh->buf is equivalent to &fh->buf in this case, the latter
> obviously not being a dereference.
>
>> 2. ovl_verify_fh() uses fh->fb members without NULL check
>> 3. ovl_get_index_name_fh() accesses fh->fb.len without NULL check
>
> These are called in the "index=on" case, which verifies at mount time
> that all layers support file handles.
>
> Thanks,
> Miklos
Thank you for pointing out that. I'll work on creating test cases to verify
whether these NULL dereferences can actually occur in practice.
Thanks again for the guidance.
Regards,
Wang Zhaolong
next prev parent reply other threads:[~2025-04-30 9:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-29 0:13 Wang Zhaolong
2025-04-29 12:01 ` Miklos Szeredi
2025-04-30 9:56 ` Wang Zhaolong [this message]
2025-04-29 18:34 ` Markus Elfring
-- strict thread matches above, loose matches on Subject: below --
2025-04-28 11:11 Wang Zhaolong
2025-04-28 11:48 ` Markus Elfring
2025-04-28 13:01 ` Wang Zhaolong
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=8f76ec4f-fb8e-46cf-b59f-ef95c500a85a@huawei.com \
--to=wangzhaolong1@huawei.com \
--cc=amir73il@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.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
all inboxes | Powered by JetHome®