Skip to contentSkip to conversation

vfs: Don't call attach_nobh_buffers() with an empty list

PATCH Dave Kleikamp 2 participants 4 messages Feb 6, 2009 VFS

lore
Share & tools
lore
#0 lore raw

vfs: Don't call attach_nobh_buffers() with an empty list

This is a modification of a patch by Bill Pemberton <[email protected]>

nobh_write_end() could call attach_nobh_buffers() with head == NULL. This would result in a trap when attach_nobh_buffers() attempted to access bh->b_this_page.

This can be illustrated by running the writev01 testcase from LTP on jfs.

This error was introduced by commit 5b41e74a "vfs: fix data leak in nobh_write_end()". That patch did not take into account that if PageMappedToDisk() is true upon entry to nobh_write_begin(), then no buffers will be allocated for the page. In that case, we won't have to worry about a failed write leaving unitialized data in the page.

Of course, head != NULL implies !page_has_buffers(page), so no need to test both.

Cc Bill Pemberton <[email protected]>
Cc Dmitri Monakhov <[email protected]>
fs/buffer.c +1 -1
index b58208f..665d446 100644
@@ -2688,7 +2688,7 @@ int nobh_write_end(struct file *file, struct address_space *mapping,
 	struct buffer_head *bh;
 	BUG_ON(fsdata != NULL && page_has_buffers(page));
 
-	if (unlikely(copied < len) && !page_has_buffers(page))
+	if (unlikely(copied < len) && head)
 		attach_nobh_buffers(page, head);
 	if (page_has_buffers(page))
 		return generic_write_end(file, mapping, pos, len,
Signature · 2 lines
David Kleikamp
IBM Linux Technology Center
#1 lore raw

Oops. Forgot to put [PATCH] in the subject.

Signature · 2 lines
David Kleikamp
IBM Linux Technology Center
#2 lore raw
Quoted 2 lines · Dave Kleikamp

Oops. Forgot to put [PATCH] in the subject.

Actually, more annoying is how the subject shows up twice: first as the subject, and then as the first line of the message.

So then I have to edit the email to not get it twice in the commit logs.

If you do want to put the one-liner description into the body of the email, that's ok, but put it like this:

Subject: one-liner summary
From: My Name <[email protected]>

(where either or both of the lines are obviously totally discretionary) because then all the automated tools (both mine and I presume Andrew's) will understand that you're repeating the subject in the body of the text, and you mean for just one of them to make it to the eventual commit.

Anyway, applied. With the manual edit to avoid duplication.

Linus

#3 lore raw
Quoted 7 lines · Linus Torvalds
Quoted 2 lines · Dave Kleikamp

Oops. Forgot to put [PATCH] in the subject.

Actually, more annoying is how the subject shows up twice: first as the subject, and then as the first line of the message.

Sorry. I should know better.

Quoted 1 line

Anyway, applied. With the manual edit to avoid duplication.

Thanks. I'll try to make it easier next time.

Signature · 2 lines
David Kleikamp
IBM Linux Technology Center