From: David Hildenbrand <david@redhat.com>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Lance Yang <ioworker0@gmail.com>,
akpm@linux-foundation.org, 21cnbao@gmail.com,
Liam.Howlett@oracle.com, vbabka@suse.cz, jannh@google.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Lance Yang <lance.yang@linux.dev>
Subject: Re: [PATCH 1/1] mm/madvise: initialize prev pointer in madvise_walk_vmas
Date: Tue, 17 Jun 2025 10:28:58 +0200 [thread overview]
Message-ID: <f0a867eb-c66d-476d-8391-f8a4e9968c75@redhat.com> (raw)
In-Reply-To: <e61a7aea-a87a-441f-809c-10acdfb82df4@lucifer.local>
On 17.06.25 10:21, Lorenzo Stoakes wrote:
> On Tue, Jun 17, 2025 at 09:54:29AM +0200, David Hildenbrand wrote:
>> On 17.06.25 04:05, Lance Yang wrote:
>>> From: Lance Yang <lance.yang@linux.dev>
>>>
>>> The prev pointer was uninitialized, which could lead to undefined behavior
>>> where its address is taken and passed to the visit() callback without being
>>> assigned a value.
>>
>> So, we are passing the pointer value to visit(), which is not undefined
>> behavior.
>>
>> The issue would be if anybody takes a look at the value stored at that
>> pointer. Because, already passing an uninitialized value to a (non-inlined)
>> function is undefined behavior according to C.
>>
>> In madvise_update_vma()->vma_modify_flags_name() we do exactly that,
>> correct?
>
> Err the parameter there is struct vm_area_struct **prev...
>
> We deref to the prev ptr which is unassigned yes but the pointer to the pointer isn't...
>
struct vm_area_struct *prev;
is uninitialized.
We pass &prev -> prevp, which now points at something uninitialized.
Doing "*prevp =" is fine, because we will initialize.
Doing "= *prep" is not fine, because the value was not initialized.
>>
>> vma = vma_modify_flags_name(&vmi, *prev, ...
>>
>> We should use Fixes: then.
>
> So no we shouldn't...
>
>>
>>
>> Acked-by: David Hildenbrand <david@redhat.com>
>
> Sure? :)
Unless I am missing something important, yes :)
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-06-17 8:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-17 2:05 Lance Yang
2025-06-17 2:24 ` Barry Song
2025-06-17 4:57 ` Lance Yang
2025-06-17 5:19 ` Barry Song
2025-06-17 6:03 ` Lance Yang
2025-06-17 7:54 ` David Hildenbrand
2025-06-17 8:18 ` Lance Yang
2025-06-17 8:21 ` Lorenzo Stoakes
2025-06-17 8:28 ` David Hildenbrand [this message]
2025-06-17 8:34 ` Lorenzo Stoakes
2025-06-17 8:38 ` David Hildenbrand
2025-06-17 8:50 ` Lorenzo Stoakes
2025-06-17 8:53 ` David Hildenbrand
2025-06-17 8:43 ` Lorenzo Stoakes
2025-06-17 8:51 ` Lorenzo Stoakes
2025-06-17 8:26 ` Lorenzo Stoakes
2025-06-17 8:50 ` Lorenzo Stoakes
2025-06-17 9:21 ` Lance Yang
2025-06-17 9:26 ` Lorenzo Stoakes
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=f0a867eb-c66d-476d-8391-f8a4e9968c75@redhat.com \
--to=david@redhat.com \
--cc=21cnbao@gmail.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=ioworker0@gmail.com \
--cc=jannh@google.com \
--cc=lance.yang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=vbabka@suse.cz \
/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