mpid/ch_gm/smppriv.c (version 1.2..3) smpi_init() changes
Mitch Sukalski <[email protected]>
| Newsgroups | gmane.network.myrinet.general |
|---|---|
| Organization | Los Alamos National Laboratory |
| Message-ID | <[email protected]> |
I'm attaching a patch file below of some changes that might be useful in other people's environments. We run our multiprocessor nodes using space scheduling with most of the underlying MPI/PBS/etc. "machinery" hidden from the user. Version 1.2..3 smpi_init() will open a shared memory file with mode 0777 & ~umask, and does not unlink the file. With our rather restrictive default umask around here, we found that some folks could not open an old shared memory file still lying around (mpirun.ch_gm by default uses a file name that is only unique to the Myrinet board/ports being used). I also don't like having these things lying around taking up disk space in general. So, the patch does two things: the umask is temporarily set to 0 around the open() call for the shared memory file, and the "master" process (local_id = 0) will unlink() the file as soon as all of the other processes have opened the shared memory file and written their pids into it. So, there is a temporary permissions vulnerability (the file's mode is 0777), but the file will disappear from view quite quickly. If the file is still left around because of some system problem, then the next processes that come along can open the file...without bombing out... Cheers, Mitch -- Mitch Sukalski <[email protected]> Los Alamos National Laboratory Advanced Computing Laboratory Cluster Team (Group CIC-ACL) P.O. Box 1663, Mail Stop B287 Los Alamos, New Mexico 87545 office tel: (505) 665-5668 fax: (505) 665-4939 ** secure email information ** -> registered with the LANL Entrust system -> PGP key registered at ldap://certserver.pgp.com, and http://pgpkeys.mit.edu:11371
smppriv.c.diff.txt
(text/plain, 1.9 KB)
In the top-level directory of the source distribution,
patch -p0 <patch_file
*** ./mpid/ch_gm/smppriv.c.orig Thu Jul 13 13:14:30 2000
--- ./mpid/ch_gm/smppriv.c Thu Sep 7 11:56:01 2000
***************
*** 706,711 ****
--- 706,714 ----
struct stat file_status;
char * shmem_file;
gm_status_t status;
+ /* LANL */
+ mode_t oldumask;
+ /* LANL */
if (smpi.num_local_nodes > SMPI_MAX_NUMLOCALNODES) {
fprintf(stderr,"ERROR: mpi node %d, too many local processes (%d
processes, %d maximum). Change the SMPI_MAX_NUMLOCALNODES value in
smpi.h\n", MPID_MyWorldRank, smpi.num_local_nodes, SMPI_MAX_NUMLOCALNODES );
***************
*** 737,748 ****
--- 740,761 ----
fprintf(stderr, "Error: Need to obtain shared memory file name in
GMPI_SHMEM_FILE\n");
exit(1);
}
+
+ /* LANL - set the umask to 0 */
+ oldumask = umask((mode_t)0);
+ /* LANL */
+
/* open the shared memory file */
smpi.fd = open(shmem_file, O_RDWR | O_CREAT, S_IRWXU | S_IRWXG |
S_IRWXO);
if (smpi.fd < 0) {
fprintf(stderr, "[%d] smpi_init:error in opening shared memory file:
%d\n", MPID_MyWorldRank, errno);
exit(1);
}
+
+ /* LANL - reset the umask */
+ umask(oldumask);
+ /* LANL */
+
/* compute the size of this file */
size = SMPI_CACHE_LINE_SIZE+sizeof(struct
shared_mem)+(smpi.num_local_nodes*smpi.num_local_nodes*(SMPI_LENGTH_QUEUE+SMPI_CACHE_LINE_SIZE));
***************
*** 791,796 ****
--- 804,816 ----
if (smpi_shmem->pid[i] == 0)
wait = 1;
}
+
+ /* LANL - id = 0, unlink the shared memory file, so that it is cleaned
up when everyone exits */
+ if (unlink(shmem_file) != 0)
+ fprintf(stderr,"[%d] smpi_init:error in unlinking shmem file, %s:
%d\n", MPID_MyWorldRank,
+ shmem_file, errno);
+ /* LANL */
+
pid = getpid();
if (pid == 0) {
fprintf(stderr, "[%d] smpi_init:error in geting pid\n",
MPID_MyWorldRank);