Re: [PATCH v2] ext4: fix NULL pointer dereference from orig_data infill_super and remount.

From: NamJae Jeon
Date: Mon Nov 07 2011 - 18:42:55 EST


2011/11/8 Theodore Tso <tytso@xxxxxxx>:
>
> On Nov 7, 2011, at 6:06 PM, NamJae Jeon wrote:
>
>> Âif(data) {
>> Â Â Â Â Â Â Â Âorig_data = kstrdup(data, GFP_KERNEL);
>> Â Â Â Â Â Â Â Âif(!orig_data)
>> Â Â Â Â Â Â Â Â Â Â Â Âreturn ret;
>> Â Â Â Â}
>
> As I said earlier, the use of kstrdup() in the ext4 mount code is so that we can print the mount options used in the mount request. Â So if the kstrdup() fails, the worst that will happen is that the printk will print the the mount had no mount options, instead of the mount options which had been passed this might be misleading, but it's not the end of the world; it's only a cosmetic issue. ÂBut if the kstrdup() failed, the other memory allocations (that in general will be for much more memory) will also fail, so the mount will return ENOMEM before ever getting to the printjk. Â So a pendant might make the above change, but in practice it's not really that important to do that particular checking in this case.
>
> This is why it's important to really understand the code in question instead of just posting patches without understanding the underlying code, and understanding what might or might not go wrong both before applying the patch, and after applying the patch. Â And of course, testing all of the use cases is also really important.
Okay, I understand clearly.
Thanks.
>
> Best regards,
>
> -- Ted
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/