Re: [PATCH] inotify: Ensure we alwasy write the terminating NULL.
From: Brian Rogers
Date: Fri Aug 28 2009 - 09:29:45 EST
This is a multi-part message in MIME format.Eric W. Biederman wrote:
Before the rewrite copy_event_to_user always wrote a terqminating '\0'
byte to user space after the filename. Since the rewrite that
terminating byte was skipped if your filename is exactly a multiple of
event_size. Ouch!
So add one byte to name_size before we round up and use clear_user to
set userspace to zero like /dev/zero does instead of copying the
strange nul_inotify_event. I can't quite convince myself len_to_zero
will never exceed 16 and even if it doesn't clear_user should be more
efficient and a more accurate reflection of what the code is trying to
do.
Signed-off-by: Eric W. Biederman <ebiederm@xxxxxxxxxxxxxxxxxx>
I found that this change prevents my Ubuntu Karmic system from booting.
It just idles forever very early in the process. Probably a boot script
is waiting for an event that it doesn't receive properly.
- name_len = roundup(event->name_len, event_size);
+ name_len = roundup(event->name_len + 1, event_size);
This means the test later on will now always evaluate to true:
if (name_len) {
And in cases where that test previously would have failed, the code now
outputs a block full of zeros. Assuming that's bad and the test was
important, I coded the attached naive fix, which is working for me.