Super Milestone 1

This may most probably be the final build for 4.2.2 mr1.1. The kernel is fully functional and stable and does not require further improvements or bugfixes anymore.
Further updates of this branch will only include Linux Vanilla patches/Android's tuna repository. Because there are many disrepancies with this version with AMPlug,
AMPlug is unfortunately discontinued for the addition into this kernel. Development will still continue on 4.3. With this commit, tweaking commits will now cease,
Updating of this branch will be only incremental with Linux vanilla.

Cheers.

Signed-off-by: Amperific <amperific@gmail.com>
Linux 3.0.89

Signed-off-by: Amperific <amperific@gmail.com>
SELinux: fix selinuxfs policy file on big endian systems

The /sys/fs/selinux/policy file is not valid on big endian systems like
ppc64 or s390.  Let's see why:

static int hashtab_cnt(void *key, void *data, void *ptr)
{
	int *cnt = ptr;
	*cnt = *cnt + 1;

	return 0;
}

static int range_write(struct policydb *p, void *fp)
{
	size_t nel;
[...]
	/* count the number of entries in the hashtab */
	nel = 0;
	rc = hashtab_map(p->range_tr, hashtab_cnt, &nel);
	if (rc)
		return rc;
	buf[0] = cpu_to_le32(nel);
	rc = put_entry(buf, sizeof(u32), 1, fp);

So size_t is 64 bits.  But then we pass a pointer to it as we do to
hashtab_cnt.  hashtab_cnt thinks it is a 32 bit int and only deals with
the first 4 bytes.  On x86_64 which is little endian, those first 4
bytes and the least significant, so this works out fine.  On ppc64/s390
those first 4 bytes of memory are the high order bits.  So at the end of
the call to hashtab_map nel has a HUGE number.  But the least
significant 32 bits are all 0's.

We then pass that 64 bit number to cpu_to_le32() which happily truncates
it to a 32 bit number and does endian swapping.  But the low 32 bits are
all 0's.  So no matter how many entries are in the hashtab, big endian
systems always say there are 0 entries because I screwed up the
counting.

The fix is easy.  Use a 32 bit int, as the hashtab_cnt expects, for nel.

Signed-off-by: Eric Paris <eparis@redhat.com>
Signed-off-by: Paul Moore <pmoore@redhat.com>

Signed-off-by: Amperific <amperific@gmail.com>
SELinux: remove crazy contortions around proc

We check if the fsname is proc and if so set the proc superblock security
struct flag.  We then check if the flag is set and use the string 'proc'
for the fsname instead of just using the fsname.  What's the point?  It's
always proc...  Get rid of the useless conditional.

Signed-off-by: Eric Paris <eparis@redhat.com>

Signed-off-by: Amperific <amperific@gmail.com>
SELinux: use define for number of bits in the mnt flags mask

We had this random hard coded value of '8' in the code (I put it there)
for the number of bits to check for mount options.  This is stupid.  Instead
use the #define we already have which tells us the number of mount
options.

Signed-off-by: Eric Paris <eparis@redhat.com>

Signed-off-by: Amperific <amperific@gmail.com>
SELinux: rename SE_SBLABELSUPP to SBLABEL_MNT

Just a flag rename as we prepare to make it not so special.

Signed-off-by: Eric Paris <eparis@redhat.com>

Signed-off-by: Amperific <amperific@gmail.com>
SELinux: do all flags twiddling in one place

Currently we set the initialize and seclabel flag in one place.  Do some
unrelated printk then we unset the seclabel flag.  Eww.  Instead do the flag
twiddling in one place in the code not seperated by unrelated printk.  Also
don't set and unset the seclabel flag.  Only set it if we need to.

Signed-off-by: Eric Paris <eparis@redhat.com>

Signed-off-by: Amperific <amperific@gmail.com>
SELinux: renumber the superblock options

Just to make it clear that we have mount time options and flags,
separate them.  Since I decided to move the non-mount options above
above 0x10, we need a short instead of a char.  (x86 padding says
this takes up no additional space as we have a 3byte whole in the
structure)

Signed-off-by: Eric Paris <eparis@redhat.com>

Signed-off-by: Amperific <amperific@gmail.com>
SELinux: change sbsec->behavior to short

We only have 6 options, so char is good enough, but use a short as that
packs nicely.  This shrinks the superblock_security_struct just a little
bit.

Signed-off-by: Eric Paris <eparis@redhat.com>

Signed-off-by: Amperific <amperific@gmail.com>
SELinux: do not handle seclabel as a special flag

Instead of having special code around the 'non-mount' seclabel mount option
just handle it like the mount options.

Signed-off-by: Eric Paris <eparis@redhat.com>

Signed-off-by: Amperific <amperific@gmail.com>
SELinux: pass a superblock to security_fs_use

Rather than passing pointers to memory locations, strings, and other
stuff just give up on the separation and give security_fs_use the
superblock.  It just makes the code easier to read (even if not easier to
reuse on some other OS)

Signed-off-by: Eric Paris <eparis@redhat.com>

Signed-off-by: Amperific <amperific@gmail.com>
SELinux: use a helper function to determine seclabel

Use a helper to determine if a superblock should have the seclabel flag
rather than doing it in the function.  I'm going to use this in the
security server as well.

Signed-off-by: Eric Paris <eparis@redhat.com>

Signed-off-by: Amperific <amperific@gmail.com>
selinux: fix problems in netnode when BUG() is compiled out

When the BUG() macro is disabled at compile time it can cause some
problems in the SELinux netnode code: invalid return codes and
uninitialized variables.  This patch fixes this by making sure we take
some corrective action after the BUG() macro.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Paul Moore <pmoore@redhat.com>
Signed-off-by: Eric Paris <eparis@redhat.com>

Signed-off-by: Amperific <amperific@gmail.com>
Defconfig: ASKP Build 17

Signed-off-by: Amperific <amperific@gmail.com>