Page MenuHomeFreeBSD

Fix loading bad memory addresses from file
ClosedPublic

Authored by romain on Sun, Jul 20, 2:35 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Aug 6, 1:20 AM
Unknown Object (File)
Fri, Aug 1, 6:29 PM
Unknown Object (File)
Tue, Jul 29, 4:24 AM
Unknown Object (File)
Tue, Jul 29, 2:59 AM
Unknown Object (File)
Tue, Jul 29, 2:01 AM
Unknown Object (File)
Mon, Jul 28, 5:46 PM
Unknown Object (File)
Sat, Jul 26, 10:44 PM
Unknown Object (File)
Sat, Jul 26, 10:44 PM
Subscribers

Details

Summary

When loading bad memory addresses from a file, we are passed an end pointer that points on the first byte after the buffer. We want the buffer to be null-terminated (by changing the last byte to \0 if it is reasonable to do so), so adjust the end pointer to be on that byte.

In case the last byte cannot be changed safely, improve the diagnostic message to help the user figure out how to fix their config.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

romain retitled this revision from Fix loading bad bad memory addresses from file to Fix loading bad memory addresses from file.

Diff against the main branch (the previous one was from the releng/14.3 branch)

So why not fix vm_page_blacklist_load() instead, to pass proper end (which would be ptr + len - 1 if len > 0)?

romain edited the summary of this revision. (Show Details)

Implement the change suggested by @kib and reword the summary accordingly. Thanks!

Because that makes the patch very short, I could adjust it on my current non-FreeBSD system, but will only be able to test it to confirm that it indeed works as expected tonight / tomorrow.

Modulo the printf() string, this is fine.

sys/vm/vm_page.c
311–315

I suggest not to add this chunk, the documentation should be in man pages.

This revision is now accepted and ready to land.Fri, Jul 25, 3:27 AM

Nice! I tested the change successfully on my laptop after applying the diff on top or releng/14.3.
OK to not commit the diagnostic message change.

Maybe it is overkill, but I wanted to backport this change to -STABLE releases once it has hit the main branch. I think that if so, I should put a "MFC After:" in the commit message, but am not sure what duration to use. 2 weeks seems fine to me, but you will have better knowledge than me. The final commit message would be:

Fix loading bad memory addresses from file

When loading bad memory addresses from a file, we are passed an end
pointer that points on the first byte after the buffer. We want the
buffer to be null-terminated (by changing the last byte to \0 if it is
reasonable to do so), so adjust the end pointer to be on that byte.

Approved by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D51433

@kib does this look okay to you?

Nice! I tested the change successfully on my laptop after applying the diff on top or releng/14.3.
OK to not commit the diagnostic message change.

Maybe it is overkill, but I wanted to backport this change to -STABLE releases once it has hit the main branch. I think that if so, I should put a "MFC After:" in the commit message, but am not sure what duration to use. 2 weeks seems fine to me, but you will have better knowledge than me. The final commit message would be:

Fix loading bad memory addresses from file

When loading bad memory addresses from a file, we are passed an end
pointer that points on the first byte after the buffer. We want the
buffer to be null-terminated (by changing the last byte to \0 if it is
reasonable to do so), so adjust the end pointer to be on that byte.

Approved by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D51433

@kib does this look okay to you?

The message is completely ok. Merging to stable branches is completely ok. Going ahead is great.

For me, the default MFC period is 1 week, but use whatever period that makes you feel comfortable that the change got the good exposure. And note that putting the 'MFC' line does not obligate you do the merge, or to do the merge at specific time. The only consequence of it is that you would get the reminder.

Nitpicking about the commit message, but usually we prefix the commit message title with a subsystem name: https://docs.freebsd.org/en/articles/committers-guide/#_prefix_the_subject_line_with_a_component_if_applicable

Here I would thus use vm_page: Fix loading bad memory addresses from file. It is somewhat arbitrary, but it is nice to be consistent with other recent commits to the same file(s). The tags are somewhat useful when reading one-line commit summaries, e.g., when looking for possible causes of a regression.