Re: Bug report - slab-out-of-bounds in vcs_scr_readw

From: Jiri Slaby
Date: Tue Nov 05 2019 - 04:14:08 EST


On 05. 11. 19, 10:03, Or Cohen wrote:
> @Nicolas Pitre - I agree with you, "vcs_size" may return a negative
> error code, so the patch is correct but as @jslaby@xxxxxxxx said it
> won't fix the issue.
> In my debugging session, "vcs_size" returns a positive integer ( 8000
> decimal ) and the bug still triggers.
>
> Maybe it's related to the following logic in "vcs_size"? ( not sure
> about that.. )
>
> 221 if (use_attributes(inode)) {
> 222 if (use_unicode(inode))
> 223 return -EOPNOTSUPP;
> 224 size = 2*size + HEADER_SIZE;
> 225 } else if (use_unicode(inode))
> 226 size *= 4;
> 227 return size;
>
> Why in the case of "use_unicode(inode)" size is multiplied by 4 and
> not 2? ( as we can see in line 224 )

Because unicode uses 4 bytes. The issue is that there is no handling for
unicode in vcs_write at all. (Compare with vcs_read.)

thanks,
--
js
suse labs