lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.0804272200090.18184@alien.or.mcafeemobile.com>
Date:	Sun, 27 Apr 2008 22:11:28 -0700 (PDT)
From:	Davide Libenzi <davidel@...ilserver.org>
To:	Ulrich Drepper <drepper@...hat.com>
cc:	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH v2] eventfd, signalfd, timerfd, epoll_create w/flags

On Sun, 27 Apr 2008, Ulrich Drepper wrote:

> +	int fflags = 0;
> +
> +	if (flags) {
> +		if ((flags & EFD_CLOEXEC) != 0) {
> +			fflags |= O_CLOEXEC;
> +			flags &= ~EFD_CLOEXEC;
> +		}
> +		if (flags)
> +			return -EINVAL;
> +	}

...

> +	int fflags = 0;
> +
> +	if (flags) {
> +		if ((flags & EPOLL_CLOEXEC) != 0) {
> +			fflags |= O_CLOEXEC;
> +			flags &= ~EPOLL_CLOEXEC;
> +		}
> +		if (flags)
> +			return -EINVAL;
> +	}

...

> +	int fflags = 0;
> +
> +	if (flags) {
> +		if ((flags & SFD_CLOEXEC) != 0 && ufd == -1) {
> +			fflags |= O_CLOEXEC;
> +			flags &= ~SFD_CLOEXEC;
> +		}
> +		if (flags)
> +			return -EINVAL;
> +	}

...

> +	int fflags = 0;
>  
> -	if (flags)
> -		return -EINVAL;
> +	if (flags) {
> +		if ((flags & TFD_CLOEXEC) != 0) {
> +			fflags |= O_CLOEXEC;
> +			flags &= ~TFD_CLOEXEC;
> +		}
> +		if (flags)
> +			return -EINVAL;
> +	}

Maybe something like:

struct oflags_rmap {
	int f, of;
};

unsigned int oflags_remap(const struct oflags_rmap *m, int n,
			  int f, int *rf)
{
	int i;
	for (i = 0, *rf = 0; i < n; i++, m++)
		if (f & m->f) {
			*rf |= m->of;
			f &= ~m->f;
		}
	return f ? -EINVAL: 0;
}

Then, in all the cases above (modulo different "struct oflags_rmap" 
fillings):

const struct oflags_rmap ormap[] = {
	{ TFD_CLOEXEC, O_CLOEXEC }
};

error = oflags_remap(ormap, ARRAY_SIZE(ormap), flags, &fflags);




- Davide


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ