<div class="gmail_quote"><div>Hi</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><div><div>Chris will need to be final ruler on this but if the code is written
    to </div></div>
    assume that it is always passed a valid pointer, then you have to<br>
    honor this in the testing.  You can add a debug-enabled consistency<br>
    check that the control pointer is NULL. But you shouldn't pass it in<br>
    if it is not checked in a production build.<br></div></blockquote><div><br></div><div>I'm looking into RFS source and I think you are right. Most of this functions I tested with null control pointer is used in functions where bitmap control pointer is correct because it is initialized with bitmap_open function and there is check if it is successful. I invoked this functions with null control pointer to cause rtems_rfs_bitmap_load_map to fail. It can fail when control.buffer is null or when buffer handle request fail. </div>
<div><br></div><div>Do anyone know how could I cause rtems_rfs_buffer_handle_request to fail? :)</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
    <br>
    The question is.. is this code comparable to the score core<br>
    which is only invoked by trusted layers? If so, it doesn't need to<br>
    check for NULL and you shouldn't pass in a "control = NULL"<br>
    <br></div></blockquote><div>I think this code is comparable to score core. I check in RFS source where these functions are used and if there is possibility to pass bad pointer to these functions and below are results of my quick research:</div>
<div><br></div><div><div>bitmap_set</div><div>1. used in write_group. First there is opened buffer handle which is next passed to the rfs_bitmap_open and there are checks for both operations. So bitmap control pointer can't be null and is correct.</div>
<div><br></div><div>bitmap_map_clear</div><div>1. used in group_bitmap_free. bitmap control pointer is taken from fs->groups[group].(inode/block)_bitmap</div><div>So if fs pointer is correct bitmap control is also correct.</div>
<div><br></div><div>bitmap_map_clear_all</div><div>1. used in write group. Like map_set bitmap control pointer is always correct.</div><div><br></div><div>bitmap_map_test </div><div>1. used in group_bitmap_test. bitmap control pointer is taken from filesystem. So I think it is correct. </div>
<div><br></div><div>bitmap_create_search</div><div>1. used in bitmap_open. If bad buffer handle pointer would be passed to the function it could go bad path. </div><div><br></div><div>bitmap_map_alloc</div><div>1. used in group_bitmap_alloc. bitmap control pointer is taken from filesystem. I think I would have to corrupt filesystem structure to pass earlier checks and then it can break rfs_bitmap_map_Alloc.</div>
</div><div><br></div><div>From what I understand users don't invoke these functions. They would rather make use of posix functions like open(), write() etc. and these bitmap functions are the lowest layer of whole RFS. </div>
<div><br></div><div>Krzysztof Miesowicz</div></div>