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: <20140821234912.f007e2fb.akpm@linux-foundation.org>
Date:	Thu, 21 Aug 2014 23:49:12 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Cyrill Gorcunov <gorcunov@...il.com>
Cc:	linux-kernel@...r.kernel.org, keescook@...omium.org, tj@...nel.org,
	avagin@...nvz.org, ebiederm@...ssion.com, hpa@...or.com,
	serge.hallyn@...onical.com, xemul@...allels.com,
	segoon@...nwall.com, kamezawa.hiroyu@...fujitsu.com,
	mtk.manpages@...il.com, jln@...gle.com
Subject: Re: [patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP
 operation, v3

On Fri, 22 Aug 2014 10:32:42 +0400 Cyrill Gorcunov <gorcunov@...il.com> wrote:

> > > +	error |= __prctl_check_addr_space(start_code);
> > > +	error |= __prctl_check_addr_space(end_code);
> > > +	error |= __prctl_check_addr_space(start_data);
> > > +	error |= __prctl_check_addr_space(end_data);
> > > +	error |= __prctl_check_addr_space(start_stack);
> > > +	error |= __prctl_check_addr_space(start_brk);
> > > +	error |= __prctl_check_addr_space(brk);
> > > +	error |= __prctl_check_addr_space(arg_start);
> > > +	error |= __prctl_check_addr_space(arg_end);
> > > +	error |= __prctl_check_addr_space(env_start);
> > > +	error |= __prctl_check_addr_space(env_end);
> > 
> > Boy this is verbose.  I had a little fiddle and came up with
> ...
> > 
> > +
> > +		for (i = 0; i < ARRAY_SIZE(offsets); i++) {
> > +			u64 val = ((u64 *)prctl_map)[offsets[i]];
> > +
> > +			if (val < mmap_min_addr || val >= mmap_max_addr) {
> > +				error = -EINVAL;
> > +				goto out;
> > +			}
> > +		}
> > +	}
> > 
> > and it saved 400 bytes of text.
> > 
> > But it's a bit hacky.  Can anyone think of anything smarter?
> 
> Looks good to me and not that hacky actually.

Hacky :( I guess it's pretty safe because this is a userspace-visible
structure so we'll never be changing it.

Or will we?  What happens if we later decide that some additional field
needs to be added?  Do we version the interface?  Add a new prctl()
mode?  Let's cook up a plan for that and at least add to changelog?

> Should I update on top for -mm tree?

Spose so.  Let's see what the code savings are when the other two sites
are similarly changed?

To save a bit more space offsets[] could be an array of uchar, I guess.
A BUILD_BUG_ON(sizeof(struct prctl_map) >= 256) would keep that sane.

--
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