alpine 3.6
access weakness #389

1

Weakness Breakdown


Definition:

An access weakness occurs when software does not properly implement permissions that could have unintended consequences if exploited by malicious actors. An example of this weakness is when a default username and password are set by the developer but do not get changed by the system administrator.

Warning code(s):

Ensure that umask is given most restrictive possible setting.

File Name:

lockdev/src/lockdev-0_git20130107/src/lockdev.c

Context:

The highlighted line of code below is the trigger point of this particular Alpine 3.6 access weakness.

 		if ( errno == EWOULDBLOCK ) {
			if ( flag2-- ) {
				sleep( 1);
				continue;
			}
			return EWOULDBLOCK;
		}
		return -1;
	}
#endif /* not USE_FCNTL */
	return 0;	/* file locked */
}

/* for internal use */
static int
_dl_unlock_semaphore (int value)
{
	if ( semaphore != -1 ) {
		_debug( 1, "_dl_unlock_semaphore(return=%d)=%d\n", value, semaphore);
		unlink( sem_name);
		close( semaphore);
		semaphore = -1;
	}
	if (oldmask != -1 ) {
		umask( oldmask);	/* restore original mask value */
		oldmask = -1;
	}
	return( value);
}

/* for internal use */
static inline int
_dl_lock_semaphore (void)
{
	return  _dl_get_semaphore( 0);
}

/* for internal use */
static inline int
_dl_block_semaphore (void)
{
	return  _dl_get_semaphore( 3);
}

static pid_t pid_read = 0; /* read also by dev_testlock */

/* for internal use */
/* zero means: we don't own the lock; maybe someone else */
static pid_t
_dl_check_lock(const char *lockname) 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.