Hi Open MPI developers, I found another issue in Open MPI.
In MCA_PML_OB1_RECV_FRAG_INIT macro in ompi/mca/pml/ob1/pml_ob1_recvfrag.h file, we copy a PML header from an arrived message to another buffer, as follows: frag->hdr = *(mca_pml_ob1_hdr_t*)hdr; On this copy, we cast hdr to mca_pml_ob1_hdr_t, which is a union of all actual header structs such as mca_pml_ob1_match_hdr_t. This means we copy the buffer of the size of the largest header even if the arrived message is smaller than it. This can cause SEGV if the arrived message is small and it is laid on the bottom of the page. Actually, my tofu BTL, the BTL component of Fujitsu MPI for K computer, suffered from this. The attached patch will be one of possible fixes for this issue. This fix assume that the arrived header has at least segs[0].seg_len bytes. This is always true for current Open MPI code because hdr equals to segs[0].seg_addr.pval. There may exist a smarter fix. Regards, Takahiro Kawashima, MPI development team, Fujitsu
Index: ompi/mca/pml/ob1/pml_ob1_recvfrag.h =================================================================== --- ompi/mca/pml/ob1/pml_ob1_recvfrag.h (revision 27446) +++ ompi/mca/pml/ob1/pml_ob1_recvfrag.h (working copy) @@ -69,7 +69,9 @@ unsigned char* _ptr = (unsigned char*)frag->addr; \ /* init recv_frag */ \ frag->btl = btl; \ - frag->hdr = *(mca_pml_ob1_hdr_t*)hdr; \ + _size = (segs[0].seg_len < sizeof(mca_pml_ob1_hdr_t)) ? \ + segs[0].seg_len : sizeof(mca_pml_ob1_hdr_t); \ + memcpy( &frag->hdr, hdr, _size); \ frag->num_segments = 1; \ _size = segs[0].seg_len; \ for( i = 1; i < cnt; i++ ) { \
Copyright (c) 2012 FUJITSU LIMITED. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer listed in this license in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. The copyright holders provide no reassurances that the source code provided does not infringe any patent, copyright, or any other intellectual property rights of third parties. The copyright holders disclaim any liability to any recipient for claims brought against recipient by any third party for infringement of that parties intellectual property rights. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.