Chanho Park [Fri, 23 Jan 2015 16:22:35 +0000 (01:22 +0900)]
tizen: arm64: enable permissive mode of smack
Signed-off-by: Chanho Park <parkch98@gmail.com>
Chanho Park [Tue, 3 Jun 2014 10:54:53 +0000 (19:54 +0900)]
smack: add permissive mode for debugging purpose
Change-Id: I4389736181c63ae5af670695784cedd21631ba89
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
Chanho Park [Fri, 23 Jan 2015 15:08:34 +0000 (00:08 +0900)]
tizen: arm64: add tizen_defconfig
Signed-off-by: Chanho Park <parkch98@gmail.com>
Andrey Ryabinin [Sat, 8 Nov 2014 14:48:05 +0000 (17:48 +0300)]
security: smack: fix out-of-bounds access in smk_parse_smack()
Setting smack label on file (e.g. 'attr -S -s SMACK64 -V "test" test')
triggered following spew on the kernel with KASan applied:
==================================================================
BUG: AddressSanitizer: out of bounds access in strncpy+0x28/0x60 at addr
ffff8800059ad064
=============================================================================
BUG kmalloc-8 (Not tainted): kasan error
-----------------------------------------------------------------------------
Disabling lock debugging due to kernel taint
INFO: Slab 0xffffea0000166b40 objects=128 used=7 fp=0xffff8800059ad080 flags=0x4000000000000080
INFO: Object 0xffff8800059ad060 @offset=96 fp=0xffff8800059ad080
Bytes b4
ffff8800059ad050: a0 df 9a 05 00 88 ff ff 5a 5a 5a 5a 5a 5a 5a 5a ........ZZZZZZZZ
Object
ffff8800059ad060: 74 65 73 74 6b 6b 6b a5 testkkk.
Redzone
ffff8800059ad068: cc cc cc cc cc cc cc cc ........
Padding
ffff8800059ad078: 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ
CPU: 0 PID: 528 Comm: attr Tainted: G B 3.18.0-rc1-mm1+ #5
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
0000000000000000 ffff8800059ad064 ffffffff81534cf2 ffff880005a5bc40
ffffffff8112fe1a 0000000100800006 0000000f059ad060 ffff880006000f90
0000000000000296 ffffea0000166b40 ffffffff8107ca97 ffff880005891060
Call Trace:
? dump_stack (lib/dump_stack.c:52)
? kasan_report_error (mm/kasan/report.c:102 mm/kasan/report.c:178)
? preempt_count_sub (kernel/sched/core.c:2651)
? __asan_load1 (mm/kasan/kasan.h:50 mm/kasan/kasan.c:248 mm/kasan/kasan.c:358)
? strncpy (lib/string.c:121)
? strncpy (lib/string.c:121)
? smk_parse_smack (security/smack/smack_access.c:457)
? setxattr (fs/xattr.c:343)
? smk_import_entry (security/smack/smack_access.c:514)
? smack_inode_setxattr (security/smack/smack_lsm.c:1093 (discriminator 1))
? security_inode_setxattr (security/security.c:602)
? vfs_setxattr (fs/xattr.c:134)
? setxattr (fs/xattr.c:343)
? setxattr (fs/xattr.c:360)
? get_parent_ip (kernel/sched/core.c:2606)
? preempt_count_sub (kernel/sched/core.c:2651)
? __percpu_counter_add (arch/x86/include/asm/preempt.h:98 lib/percpu_counter.c:90)
? get_parent_ip (kernel/sched/core.c:2606)
? preempt_count_sub (kernel/sched/core.c:2651)
? __mnt_want_write (arch/x86/include/asm/preempt.h:98 fs/namespace.c:359)
? path_setxattr (fs/xattr.c:380)
? SyS_lsetxattr (fs/xattr.c:397)
? system_call_fastpath (arch/x86/kernel/entry_64.S:423)
Read of size 1 by task attr:
Memory state around the buggy address:
ffff8800059ace80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff8800059acf00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff8800059acf80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>
ffff8800059ad000: 00 fc fc fc 00 fc fc fc 05 fc fc fc 04 fc fc fc
^
ffff8800059ad080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8800059ad100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8800059ad180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
strncpy() copies one byte more than the source string has.
Fix this by passing the correct length to strncpy().
Now we can remove initialization of the last byte in 'smack' string
because kzalloc() already did this for us.
Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>
Change-Id: I7bb84eed3c348711312434d98d6cc13cbe8f5d76
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Łukasz Stelmach [Wed, 10 Dec 2014 06:29:46 +0000 (07:29 +0100)]
smack: introduce a special case for tmpfs in smack_d_instantiate()
Files created with __shmem_file_stup() appear to have somewhat fake
dentries which make them look like root directories and not get
the label the current process or ("*") star meant for tmpfs files.
Change-Id: If0e2e3ceddeff55d5121e76e85dbea60414b786a
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Casey Schaufler [Thu, 19 Dec 2013 21:23:26 +0000 (13:23 -0800)]
Smack: change rule cap check
smk_write_change_rule() is calling capable rather than
the more correct smack_privileged(). This allows for setting
rules in violation of the onlycap facility. This is the
simple repair.
Change-Id: Icb5321b5b5355d64b0b029d9131cf60b5e97d356
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Casey Schaufler [Mon, 23 Dec 2013 19:07:10 +0000 (11:07 -0800)]
Smack: Make the syslog control configurable
The syslog control requires that the calling proccess
have the floor ("_") Smack label. Tizen does not run any
processes except for kernel helpers with the floor label.
This changes allows the admin to configure a specific
label for syslog. The default value is the star ("*")
label, effectively removing the restriction. The value
can be set using smackfs/syslog for anyone who wants
a more restrictive behavior.
Change-Id: Ia4270bf8864bd8342e585bbdd4791fb8359e8916
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Casey Schaufler [Thu, 21 Nov 2013 08:55:10 +0000 (10:55 +0200)]
Smack: Cgroup filesystem access
The cgroup filesystems are not mounted using conventional
mechanisms. This prevents the use of mount options to
set Smack attributes. This patch makes the behavior
of cgroup filesystems compatable with the way systemd
uses them.
Change-Id: I1e0429f133db9e14117dc754d682dec08221354c
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Casey Schaufler [Tue, 22 Oct 2013 18:47:45 +0000 (11:47 -0700)]
Smack: Ptrace access check mode
When the ptrace security hooks were split the addition of
a mode parameter was not taken advantage of in the Smack
ptrace access check. This changes the access check from
always looking for read and write access to using the
passed mode. This will make use of /proc much happier.
Targeted for git://git.gitorious.org/smack-next/kernel.git
Change-Id: I979f36da1b26d0fba5d73744f340422aaae5cc74
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Casey Schaufler [Sat, 12 Oct 2013 01:06:39 +0000 (18:06 -0700)]
Smack: Implement lock security mode
Linux file locking does not follow the same rules
as other mechanisms. Even though it is a write operation
a process can set a read lock on files which it has open
only for read access. Two programs with read access to
a file can use read locks to communicate.
This is not acceptable in a Mandatory Access Control
environment. Smack treats setting a read lock as the
write operation that it is. Unfortunately, many programs
assume that setting a read lock is a read operation.
These programs are unhappy in the Smack environment.
This patch introduces a new access mode (lock) to address
this problem. A process with lock access to a file can
set a read lock. A process with write access to a file can
set a read lock or a write lock. This prevents a situation
where processes are granted write access just so they can
set read locks.
Targeted for git://git.gitorious.org/smack-next/kernel.git
Change-Id: I9bf4df25088d2dd49aadfa0ced844b147ad1c81d
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Rafal Krypa [Fri, 9 Aug 2013 09:47:07 +0000 (11:47 +0200)]
Smack: parse multiple rules per write to load2, up to PAGE_SIZE-1 bytes
Smack interface for loading rules has always parsed only single rule from
data written to it. This requires user program to call one write() per
each rule it wants to load.
This change makes it possible to write multiple rules, separated by new
line character. Smack will load at most PAGE_SIZE-1 characters and properly
return number of processed bytes. In case when user buffer is larger, it
will be additionally truncated. All characters after last \n will not get
parsed to avoid partial rule near input buffer boundary.
Change-Id: I81766925a9522fcb811fe3046850cdc45067838a
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Casey Schaufler [Mon, 5 Aug 2013 20:21:22 +0000 (13:21 -0700)]
Smack: IPv6 casting error fix for 3.11
The original implementation of the Smack IPv6 port based
local controls works most of the time using a sockaddr as
a temporary variable, but not always as it overflows in
some circumstances. The correct data is a sockaddr_in6.
A struct sockaddr isn't as large as a struct sockaddr_in6.
There would need to be casting one way or the other. This
patch gets it the right way.
Change-Id: Iac627fa0ddb77e3ff4b8c9c81bd838141a5638e9
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Casey Schaufler [Fri, 28 Jun 2013 20:47:07 +0000 (13:47 -0700)]
Smack: network label match fix
The Smack code that matches incoming CIPSO tags with Smack labels
reaches through the NetLabel interfaces and compares the network
data with the CIPSO header associated with a Smack label. This was
done in a ill advised attempt to optimize performance. It works
so long as the categories fit in a single capset, but this isn't
always the case.
This patch changes the Smack code to use the appropriate NetLabel
interfaces to compare the incoming CIPSO header with the CIPSO
header associated with a label. It will always match the CIPSO
headers correctly.
Targeted for git://git.gitorious.org/smack-next/kernel.git
Change-Id: I22a2fd758b5a7764cbeb3ebf9f4dadd12d5b170b
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Tomasz Stanislawski [Tue, 11 Jun 2013 12:55:13 +0000 (14:55 +0200)]
security: smack: add a hash table to quicken smk_find_entry()
Accepted for the smack-next tree after changing the number of
slots from 128 to 16.
This patch adds a hash table to quicken searching of a smack label by its name.
Basically, the patch improves performance of SMACK initialization. Parsing of
rules involves translation from a string to a smack_known (aka label) entity
which is done in smk_find_entry().
The current implementation of the function iterates over a global list of
smack_known resulting in O(N) complexity for smk_find_entry(). The total
complexity of SMACK initialization becomes O(rules * labels). Therefore it
scales quadratically with a complexity of a system.
Applying the patch reduced the complexity of smk_find_entry() to O(1) as long
as number of label is in hundreds. If the number of labels is increased please
update SMACK_HASH_SLOTS constant defined in security/smack/smack.h. Introducing
the configuration of this constant with Kconfig or cmdline might be a good
idea.
The size of the hash table was adjusted experimentally. The rule set used by
TIZEN contains circa 17K rules for 500 labels. The table above contains
results of SMACK initialization using 'time smackctl apply' bash command.
The 'Ref' is a kernel without this patch applied. The consecutive values
refers to value of SMACK_HASH_SLOTS. Every measurement was repeated three
times to reduce noise.
| Ref | 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 | 256 | 512
--------------------------------------------------------------------------------------------
Run1 | 1.156 | 1.096 | 0.883 | 0.764 | 0.692 | 0.667 | 0.649 | 0.633 | 0.634 | 0.629 | 0.620
Run2 | 1.156 | 1.111 | 0.885 | 0.764 | 0.694 | 0.661 | 0.649 | 0.651 | 0.634 | 0.638 | 0.623
Run3 | 1.160 | 1.107 | 0.886 | 0.764 | 0.694 | 0.671 | 0.661 | 0.638 | 0.631 | 0.624 | 0.638
AVG | 1.157 | 1.105 | 0.885 | 0.764 | 0.693 | 0.666 | 0.653 | 0.641 | 0.633 | 0.630 | 0.627
Surprisingly, a single hlist is slightly faster than a double-linked list.
The speed-up saturates near 64 slots. Therefore I chose value 128 to provide
some margin if more labels were used.
It looks that IO becomes a new bottleneck.
Change-Id: Ib1f7bf9f52337b07ccfab10e8fdf52014bd3b466
Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Tomasz Stanislawski [Thu, 6 Jun 2013 07:30:50 +0000 (09:30 +0200)]
security: smack: fix memleak in smk_write_rules_list()
The smack_parsed_rule structure is allocated. If a rule is successfully
installed then the last reference to the object is lost. This patch fixes this
leak. Moreover smack_parsed_rule is allocated on stack because it no longer
needed ofter smk_write_rules_list() is finished.
Change-Id: I5b4dcadc6a9d675ab630b23c00edeaf595b5b857
Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Tetsuo Handa [Wed, 24 Jul 2013 20:44:02 +0000 (05:44 +0900)]
xattr: Constify ->name member of "struct xattr".
Since everybody sets kstrdup()ed constant string to "struct xattr"->name but
nobody modifies "struct xattr"->name , we can omit kstrdup() and its failure
checking by constifying ->name member of "struct xattr".
Change-Id: I6cb5cd7f29c01956dd0d1579af81a518a5936071
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reviewed-by: Joel Becker <jlbec@evilplan.org> [ocfs2]
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Acked-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Reviewed-by: Paul Moore <paul@paul-moore.com>
Tested-by: Paul Moore <paul@paul-moore.com>
Acked-by: Eric Paris <eparis@redhat.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
David Quigley [Wed, 22 May 2013 16:50:35 +0000 (12:50 -0400)]
Security: Add Hook to test if the particular xattr is part of a MAC model.
The interface to request security labels from user space is the xattr
interface. When requesting the security label from an NFS server it is
important to make sure the requested xattr actually is a MAC label. This allows
us to make sure that we get the desired semantics from the attribute instead of
something else such as capabilities or a time based LSM.
Change-Id: I283f116953f958877826ba772661b5755986ac99
Acked-by: Eric Paris <eparis@redhat.com>
Acked-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: Matthew N. Dodd <Matthew.Dodd@sparta.com>
Signed-off-by: Miguel Rodel Felipe <Rodel_FM@dsi.a-star.edu.sg>
Signed-off-by: Phua Eu Gene <PHUA_Eu_Gene@dsi.a-star.edu.sg>
Signed-off-by: Khin Mi Mi Aung <Mi_Mi_AUNG@dsi.a-star.edu.sg>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Passion,Zhao [Mon, 3 Jun 2013 03:42:24 +0000 (11:42 +0800)]
Smack: Fix the bug smackcipso can't set CIPSO correctly
Bug report: https://tizendev.org/bugs/browse/TDIS-3891
The reason is userspace libsmack only use "smackfs/cipso2" long-label interface,
but the code's logical is still for orginal fixed length label. Now update
smack_cipso_apply() to support flexible label (<=256 including tailing '\0')
There is also a bug in kernel/security/smack/smackfs.c:
When smk_set_cipso() parsing the CIPSO setting from userspace, the offset of
CIPSO level should be "strlen(label)+1" instead of "strlen(label)"
Change-Id: I7be85b4ade557e25569970e61c9e09ca01b5f2d9
Signed-off-by: Passion,Zhao <passion.zhao@intel.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Tetsuo Handa [Mon, 27 May 2013 11:11:27 +0000 (20:11 +0900)]
Smack: Fix possible NULL pointer dereference at smk_netlbl_mls()
netlbl_secattr_catmap_alloc(GFP_ATOMIC) can return NULL.
Change-Id: Id67f7f66a61a05e7e45b66a50b5d0869ef7e5117
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Casey Schaufler [Thu, 23 May 2013 01:43:07 +0000 (18:43 -0700)]
Smack: Add smkfstransmute mount option
Suppliment the smkfsroot mount option with another, smkfstransmute,
that does the same thing but also marks the root inode as
transmutting. This allows a freshly created filesystem to
be mounted with a transmutting heirarchy.
Targeted for git://git.gitorious.org/smack-next/kernel.git
Change-Id: I3d7238ca1c5251fcfc96a6a61bec47bdf9466152
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Casey Schaufler [Thu, 23 May 2013 01:43:03 +0000 (18:43 -0700)]
Smack: Improve access check performance
Each Smack label that the kernel has seen is added to a
list of labels. The list of access rules for a given subject
label hangs off of the label list entry for the label.
This patch changes the structures that contain subject
labels to point at the label list entry rather that the
label itself. Doing so removes a label list lookup in
smk_access() that was accounting for the largest single
chunk of Smack overhead.
Targeted for git://git.gitorious.org/smack-next/kernel.git
Change-Id: I15f3cde6f0c3db9af056d35fc224d6295dff130c
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Casey Schaufler [Thu, 23 May 2013 01:42:56 +0000 (18:42 -0700)]
Smack: Local IPv6 port based controls
Smack does not provide access controls on IPv6 communications.
This patch introduces a mechanism for maintaining Smack lables
for local IPv6 communications. It is based on labeling local ports.
The behavior should be compatible with any future "real" IPv6
support as it provides no interfaces for users to manipulate
the labeling. Remote IPv6 connections use the ambient label
the same way that unlabeled IPv4 packets are treated.
Targeted for git://git.gitorious.org/smack-next/kernel.git
Change-Id: I6c00966cc88b36611214cc438c47ecdab63077c7
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Christoffer Dall [Thu, 30 Oct 2014 10:25:59 +0000 (11:25 +0100)]
goldfish_pipe: Squash warnings on 32-bit systems
The goldfish_pipe driver casts a pointer to a (u64), but this will
generate a warning on 32-bit systems, because we are casting a pointer
to a type with a different size. Instead, cast the pointer to an
unsigned long, which will work on both 32-bit and 64-bit systems, and
then cast that to a 32-bit value which the backend expects.
Also wrap this in a pipe_id() function to make it clear that we are not
expecting the backend to use the pointer for anything but that we are
merely using it as an identifier. Perhaps it would be possible to use a
simple running allocation scheme of IDs instead.
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Christoffer Dall [Wed, 29 Oct 2014 15:04:02 +0000 (16:04 +0100)]
arm: defconfig: Add ranchu_defconfig for Android QEMU emulator
Add a defconfig for the ranchu baord emulated by recent QEMU versions to
serve as a base for the Android emulator.
This is basically a tweaked vexpress_defconfig with ARCH_VIRT, virtio
drivers, and Android drivers enabled plus other bits needed by Android
(like ipfilter). A pure ARCH_VIRT configuration would be nice, but that
currenly doesn't permit inclusion of AMBA devices like the pl011 used
for the console, and changing the config system on a stable kernel to
allow that is not worth the effort and intrusiveness for a slightly
smaller kernel binary. Newer versions of Linux will allow for a more
compact kernel/config.
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Christoffer Dall [Wed, 29 Oct 2014 14:58:57 +0000 (15:58 +0100)]
arm: Retreive the machine name from the device tree
Instead of using the mdesc descriptive name for the userspace exported
machine name, use the name from the device tree file. This is
particularly useful for multi-flavored device-tree driven boards like
the ranchu board using the mach-virt board files.
Note that this patch is not intended for newer kernels that rework all
of the mach-virt logic to let a non-board machine be virt by default,
but it is useful in the context of Linux v3.10-based Android kernels.
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Christoffer Dall [Wed, 29 Oct 2014 14:57:37 +0000 (15:57 +0100)]
of: Add of_flat_dt_get_machine_name to device tree library
Add a function to retreive the machine name from the device tree once
the device tree has been unflattened. This is particularly useful for
multi-flavored virtual machine boards (like the Xen, virt, and ranchu
boards) where it is useful for user space to know which flavor of a
device-tree driven board you are running.
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Christoffer Dall [Wed, 29 Oct 2014 14:55:19 +0000 (15:55 +0100)]
arm: virt: Support the ranchu machine name as a virt board
The QEMU ranchu board is a variant of the virt board, it is completely
device-tree driven, but should be matched by the virt board. It
contains a pl011 serial port for console output, but the virt board
doesn't currently initialize the of clock framework, which is required
for this device to be probed, so add this logic to the virt board as
well.
Note that for newer kernels, this has all been reworked to not have a
board file for mach-virt, so it should not be neccessary in that context
and this patch should not be carried foward into newer kernels, but it
is useful for Linux v3.10-based Android kernels.
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Greg Hackmann [Fri, 12 Dec 2014 00:28:26 +0000 (16:28 -0800)]
Merge branch 'android-goldfish-3.10-mips' into android-goldfish-3.10
Miodrag Dinic [Wed, 3 Dec 2014 10:53:17 +0000 (11:53 +0100)]
Add Goldfish RTC DT enabled device driver
Goldfish real-time clock (RTC) device
Taken from
<AOSP>/external/qemu/docs/GOLDFISH-VIRTUAL-HARDWARE.TXT
Relevant files:
$QEMU/hw/timer/goldfish_timer.c
$KERNEL/drivers/rtc/rtc-goldfish.c
Device properties:
Name: goldfish_rtc
Id: -1
IrqCount: 1
I/O Registers:
0x00 R TIME_LOW - Get current time low-order 32-bits.
0x04 R TIME_HIGH - Return current time high 32-bits.
0x08 W ALARM_LOW - Set low 32-bit value or alarm and arm it.
0x0c W ALARM_HIGH - Set high 32-bit value of alarm.
0x10 W CLEAR_INTERRUPT - Lower device's irq level.
This device is _very_ similar to the Goldfish timer one,
with the following important differences:
- Values reported are still 64-bit nanoseconds, but
they have a granularity of 1 second, and represent
host-specific values (really 'time() * 1e9')
- The alarm is non-functioning, i.e. writing to
ALARM_LOW / ALARM_HIGH will work, but will never
arm any alarm.
Device tree initialisation example:
goldfish_rtc@
1f006000 {
interrupts = <0xe>;
reg = <0x1f006000 0x1000>;
compatible = "generic,goldfish-rtc";
};
Signed-off-by: Miodrag Dinic <miodrag.dinic@imgtec.com>
Change-Id: I724c35508ba65dae526c3b05229629cb9f81559f
Miodrag Dinic [Wed, 3 Dec 2014 10:50:50 +0000 (11:50 +0100)]
[MIPS] Enable platform support for Goldfish virtual devices
Enable CONFIG_GOLDFISH for MIPS platforms.
Signed-off-by: Miodrag Dinic <miodrag.dinic@imgtec.com>
Miodrag Dinic [Thu, 27 Nov 2014 15:09:11 +0000 (16:09 +0100)]
[MIPS64] Add ranchu64_defconfig for Ranchu kernel
Use "ranchu64_defconfig" to configure the kernel for
QEMU "ranchu" machine. This will be default configuration
for MIPS64R6 kernel used for bringing up Android.
Change-Id: I6076b9655f97dfb63dbc5072cb4365fd191a161f
Reviewed-on: https://mipsia.review.mips.com/2861
Reviewed-by: Raghu Gandham <raghu.gandham@imgtec.com>
Tested-by: Raghu Gandham <raghu.gandham@imgtec.com>
Miodrag Dinic [Tue, 25 Nov 2014 17:31:30 +0000 (18:31 +0100)]
[MIPS] Ranchu platform Appended DTB support
With CONFIG_MIPS_APPENDED_DTB=y option enabled, the boot code
will look for a device tree binary (dtb) appended to raw
vmlinux.bin (without decompressor).
(e.g. cat vmlinux.bin <filename>.dtb > vmlinux_w_dtb).
Beware that there is very little in terms of protection against
this option being confused by leftover garbage in memory that might
look like a DTB header after a reboot if no actual DTB is appended
to vmlinux.bin.
Change-Id: Ia1d7e0e4fe3848385b84cb06b04ea480897946f9
Reviewed-on: https://mipsia.review.mips.com/2860
Reviewed-by: Raghu Gandham <raghu.gandham@imgtec.com>
Tested-by: Raghu Gandham <raghu.gandham@imgtec.com>
Miodrag Dinic [Thu, 27 Nov 2014 15:08:16 +0000 (16:08 +0100)]
[MIPS] Ranchu Virtual platform with DT support
Ranchu Virtual platform is a Goldfish based platform
enriched with device tree support. This platform is
backed up by QEMU with the "ranchu" machine which
represents the new virtual board which will be used for
running Android.
The new Ranchu platform introduces support for running Virtio
devices in purpose of reducing the number of Goldfish devices
used by the old Goldfish platform. For example, it uses
virtio-block devices to emulate the Goldfish NAND.
Change-Id: I3a508d0a0ddc3c9d5bf777445ab739f465ab9471
Reviewed-on: https://mipsia.review.mips.com/2859
Reviewed-by: Raghu Gandham <raghu.gandham@imgtec.com>
Tested-by: Raghu Gandham <raghu.gandham@imgtec.com>
Miodrag Dinic [Mon, 24 Nov 2014 13:15:48 +0000 (14:15 +0100)]
[MIPS64] Handle additional O32 syscall args in 64bit kernel
The kernel should not access the user stack unless it has to.
This patch adds the number of parameters that each system call
takes (cf scall32-o32.S) and uses this information to control
how many access are made to the user stack.
This issue was exposed by the Android threads code which
unmaps the thread stack before calling exit(2).
This commit also includes a fix for build issue introduced by
the following commit:
commit
2c6d7de579c2cfebbc9378e5209c641a93839f0a
Author: Kees Cook <keescook@chromium.org>
Date: Tue Jun 10 15:45:09 2014 -0700
MIPS: add seccomp syscall
Wires up the new seccomp syscall.
Change-Id: Ie33adaf716a1855d1cb59c2f974cc44febbb41dc
Reviewed-on: https://mipsia.review.mips.com/2855
Reviewed-by: Raghu Gandham <raghu.gandham@imgtec.com>
Tested-by: Raghu Gandham <raghu.gandham@imgtec.com>
Raghu Gandham [Tue, 2 Dec 2014 23:31:21 +0000 (15:31 -0800)]
MIPS: R6 sets FR1 as default
MIPS R6 has only FR1 FPU. So, applications are ran under
this default now.
If MIPS R2 emulation happens then thread flag is switched back to FR0.
Signed-off-by: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
Leonid Yegoshin [Thu, 20 Nov 2014 01:30:51 +0000 (17:30 -0800)]
MIPS: build fix: sprinkle hardfloat into macros and embedded ASM
GCC before 4.9 haven't passed CFLAGS to the assembler properly,
in this case that flag is -msoft-float.
GCC 4.9 now passes all the CFLAGS to assembler as it should,
but that caused assembler errors in a lot of files:
"Error: opcode not supported on this processor"
This patch fixes it by explicitly setting the hardfloat
attribute in those files.
.set hardfloat
Squashed with
bdf828255a2e [MIPS] Fix build issue with 4.9 GCC
Change-Id: I82bfcd4a0d677eebd0fd380e01f018d9bdbf3d34
Signed-off-by: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
Reviewed-on: https://mipsia.review.mips.com/2610
Reviewed-by: Raghu Gandham <raghu.gandham@imgtec.com>
Tested-by: Raghu Gandham <raghu.gandham@imgtec.com>
Leonid Yegoshin [Tue, 18 Nov 2014 01:50:17 +0000 (17:50 -0800)]
MIPS: Setup an instruction emulation in VDSO protected page instead of user stack
Historically, during FPU emulation MIPS runs live BD-slot instruction in stack.
This is needed because it was the only way to correctly handle branch
exceptions with unknown COP2 instructions in BD-slot. Now there is
an eXecuteInhibit feature and it is desirable to protect stack from execution
for security reasons.
This patch moves FPU emulation from stack area to VDSO-located page which is set
write-protected for application access. VDSO page itself is now per-thread and
it's addresses and offsets are stored in thread_info.
Small stack of emulation blocks is supported because nested traps are possible
in MIPS32/64 R6 emulation mix with FPU emulation.
Explanation of problem (current state before patch):
If I set eXecute-disabled stack in ELF binary initialisation then GLIBC ignores
it and may change stack protection at library load. If this library has
eXecute-disabled stack then anything is OK, but if this section (PT_GNU_STACK)
is just missed as usual, then GLIBC applies it's own default == eXecute-enabled
stack.
So, ssh_keygen is built explicitly with eXecute-disabled stack. But GLIBC
ignores it and set stack executable. And because of that - anything works,
FPU emulation and hacker tools.
However, if I use all *.SO libraries with eXecute-disabled stack in PT_GNU_STACK
section then GLIBC keeps stack non-executable but things fails at FPU emulation
later.
Here are two issues which are bind together and to solve an incorrect
behaviour of GLIBC (ignoring X ssh-keygen intention) the splitting both issues
is needed. So, I did a kernel emulation protected and out of stack.
Signed-off-by: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
Leonid Yegoshin [Thu, 20 Nov 2014 01:44:31 +0000 (17:44 -0800)]
MIPS: R6: emulation of MIPS R2 removed instructions.
MIPS R6 architecture has deleted some MIPS R2 instructions.
This patch does emulation of that instructions in kernel.
Squashed:
5465a192ac70 R6 emulation of MIPS R2: restore MIPS32 R6 build
1cdef69e7305 MIPS: R6: R2 emulation optimisation
ece19295b50e MIPS: R6: FRE mode support for R2 emulation
666439e519f1 MIPS: Build: bind R2 and incompatible FPU emulation together
3be8d0f9a1d8 MIPS: R6: R2 emulation bugfixes in negative signal return
aefc61dfb88a MIPS: R6: R2 emulation bugfix of address in process_fpemu_return
8b7d02f5263b MIPS: R6: R2 emulation bugfix of EVA by LLE/SCE opcodes
7f403f401c6d MIPS: R6 emulation of R2 bugfix of LWR instruction
07c2979e66b3 MIPS: bugfix of FR0/1 setup failure processing
Signed-off-by: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
Leonid Yegoshin [Tue, 18 Nov 2014 01:44:26 +0000 (17:44 -0800)]
MIPS: bugfix of TLB refill optimisation
Patch
748e787e replaced SRL(4)->ROTR(2) sequence in TLB refill handler
during loading EntryLo from PTE by a single ROTR(6).
It prevents running MIPS32 kernel on MIPS64 CPU and even running MIPS32
kernel on system with 36 bits physical address CPU, even with 256MB.
That patch just doesn't clear 4 high-order bits 29:26 and CPU tries
to use a high memory due to SW bits in this field.
This patch restores an original SRL+ROTR sequence if CPU is able to use
that 4 bits of physical address (36:32 in 4K system).
Signed-off-by: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
Leonid Yegoshin [Thu, 20 Nov 2014 01:37:18 +0000 (17:37 -0800)]
MIPS: First MIPS R6 architecture implementation
Many changes in many files, but all functional set under CONFIG_CPU_MIPSR6
preprocessor macro or similar (CONFIG_CPU_MIPS32_R6/CONFIG_CPU_MIPS64_R6).
However, some definitions may be unconditional.
Squashed:
b3f685f35a1b MIPS: R6 compiler may require "memory" constraint in ASM
70c9d5dafffe MIPS: R6 buildtool restriction fix
5bb1b13b4219 MIPS: MIPS R6 basic MAAR support
17446a9a8be1 MIPS: R6 MAAR bugfix
9e06287f7d4d MIPS: Support of R6 architecture CP0 changes
15c77e709963 MIPS: R6: support of separate TLB RI/XI exceptions
01c3083740e1 MIPS: R6 asm of LL/SC optimization fix
72535c6169d2 MIPS: R6 - added CM2 L2 Prefetch support
709763f2eae8 MIPS: R6 emulation of branches
115e5660aad3 MIPS: R6: fixing jumps in get_frame_info
cf733bf4aa01 MIPS: R6: removed SPRAM support
e9656337c82f MIPS: R6: added L2 cache processing
a92ea7efa46c MIPS: R6 - use SYNCI in trampoline instead of IPI
57db20cbc0b9 MIPS: Enforce using of ERETNC instead of ERET in MIPS R6
73c7d199e237 MIPS: R6 bugfix of MIPS32 save/restore on Status.FR1 mode
a7f651f0c1a6 MIPS: restore CP0_WIRED register handling
c359d52036c2 MIPS: R6 bugfix of R6 PREF instruction opcode
b1080dd82704 MIPS: Bugfix of MAAR setup for 2nd core
a869049afa9e MIPS: R6: memcpy has PREF with offset bigger 256B
0e5a04a55192 MIPS: R6 bugfix of unaligned handler store
b1242efec8a5 MIPS: R6: unaligned LWU on MIPS64 R6 should not sign-extend
Signed-off-by: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
Kees Cook [Tue, 18 Nov 2014 01:51:27 +0000 (17:51 -0800)]
MIPS: add seccomp syscall
Wires up the new seccomp syscall.
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Conflicts:
arch/mips/include/uapi/asm/unistd.h
arch/mips/kernel/scall32-o32.S
arch/mips/kernel/scall64-64.S
arch/mips/kernel/scall64-n32.S
arch/mips/kernel/scall64-o32.S
Change-Id: I7031bdbec7c90292aeb7e255c73cb36e6ec43af2
Leonid Yegoshin [Sat, 22 Nov 2014 01:42:05 +0000 (17:42 -0800)]
MIPS: conglomerate of multiple MIPS bugfixes and improvements
MIPS R6 is built on top of 3.10 for real HW and this patch
combines the missed patches. It is needed to do a clean and working
MIPS R6 kernel.
Squashed patches:
MIPS: Expose missing pci_io{map,unmap} declarations
MIPS: kernel: mcount.S: Drop FRAME_POINTER codepath
MIPS: malta: Move defines of reset registers and values.
MIPS: malta: Remove software reset defines from generic header.
MIPS: Boot: Compressed: Remove -fstack-protector from CFLAGS
MIPS: GIC: Fix gic_set_affinity infinite loop
MIPS: Only set cpu_has_mmips if SYS_SUPPORTS_MICROMIPS
MIPS: Don't try to decode microMIPS branch instructions where they cannot exist.
MIPS: APSP: Remove <asm/kspd.h>
Revert "MIPS: make CAC_ADDR and UNCAC_ADDR account for PHYS_OFFSET"
MIPS: Malta: Update GCMP detection.
MIPS: Fix multiple definitions of UNCAC_BASE.
MIPS: R4k clock source initialization bug fix
MIPS: use generic-y where possible
MIPS: Kconfig: Drop obsolete NR_CPUS_DEFAULT_{1,2} options
MIPS: add <dt-bindings/> symlink
MIPS: Refactor boot and boot/compressed rules
MIPS: Refactor load/entry address calculations
MIPS: Add uImage build target
MIPS: Export copy_from_user_page() (needed by lustre)
MIPS: kdump: Skip walking indirection page for crashkernels
MIPS: kexec: Fix random crashes while loading crashkernel
MIPS: Fix SMP core calculations when using MT support.
MIPS: Fix accessing to per-cpu data when flushing the cache
MIPS: Fix VGA_MAP_MEM macro.
MIPS: 74K/1074K: Correct erratum workaround.
MIPS: cpu-features.h: s/MIPS53/MIPS64/
MIPS: Kconfig: CMP support needs to select SMP as well
MIPS: Remove bogus BUG_ON()
MIPS: Always register R4K clock when selected.
MIPS: bugfix of stack trace dump.
MIPS: Add printing of ES bit when cache error occurs.
MIPS: rearrange PTE bits into fixed positions for MIPS32 R2.
MIPS: removal of X bit in page tables for HEAP/BSS.
MIPS: Add -mfp64 support to FPU emulator.
MIPS: -mfp64 for abi=o32 ELF binaries support.
MIPS: FPU2 IEEE754-2008 SNaN support
MIPS: Revert fixrange_init() limiting to the FIXMAP region.
MIPS: 64bit address support on MIPS64 R2
MIPS: Add proAPTIV CPU support.
MIPS: MIPS32R2 Segment/EVA support upto 3GB
MIPS: Cache flush functions are reworked.
MIPS: Fix bug in using flush_cache_vunmap
MIPS: EVA CACHEE instruction implementation in kernel
MIPS: bugfix of mips_flush_data_cache_range
MIPS: Add interAptiv CPU support.
MIPS: EVA SMP support for Malta board
MIPS: Malta new memory map support
MIPS: Malta: check memory map type - legacy or new
MIPS: bugfix of Malta PCI bridges loop.
MIPS: BEV overlay segment location and size verification.
MIPS: MIPS32 R2 SYNC optimization
MIPS: configs: Add Malta EVA defconfig
MIPS: GIC: Send IPIs using the GIC.
MIPS: Malta: Remove ttyS2 serial.
MIPS/Perf-events: Fix 74K cache map
MIPS/Perf-events: Support proAptiv/interAptiv cores
MIPS: Fix more section mismatch warnings
MIPS: EVA: Fix encoding for the UUSK AM bits on the SegCtl registers.
MIPS: Malta: Enable DEVTMPFS
MIPS: Clean up MIPS MT platform configuration options.
MIPS: Fix forgotten preempt_enable() when CPU has inclusive pcaches
MIPS: malta: Fix GIC interrupt offsets
Malta default config is generated by ARCH=mips scripts/kconfig/merge_config.sh arch/mips/config/malta_defconfig android/configs/android-base.cfg android/configs/android-recommended.cfg
Input: i8042-io - Exclude mips platforms when allocating/deallocating IO regions.
MIPS: Malta buildfix of 8042 keyboard controller
Modify Malta config with the required options for booting Android
MIPS: bugfix - missed hazard barrier in xcontext setup
MIPS: proAptiv tlb exeption handler improvement - remove an excessive EHB.
MIPS: printk more cpuinfo stuff
MIPS: sead3: Remove command line from SEAD-3 device tree file.
MIPS: Added Virtuoso basic support
MIPS: Cleanup of TMR and PERFCOUNT IRQ handling
MIPS: bugfix of "core" and "vpe_id" setup for MT ASE w/out GCMP
MIPS: bugfix of force-bev-location parsing
MIPS: bugfix of ebase WG bit mask
MIPS: bugfix of coherentio variable default setup
MIPS: Accelerate LDC1/SDC1 unaligned x4 emulation
MIPS: unaligned FPU failures fix
MIPS: asm: uaccess: fix EVA support for str*_user operation
MIPS: Exclude mips platforms when allocating/deallocating IO regions by i8042
MIPS: Malta emulation: avoid using
BFC00000 for L2-SYNC only feature.
MIPS: futex: Use LLE and SCE for EVA
MIPS: Bugfix of address conversion between bus and kernel virtual address
MIPS: Remove a temporary hack for debugging cache flushes in SMTC configuration
MIPS: Malta: bugfix of CPU0 status masks setup for timer and perf interrupts
MIPS: bugfix of CP0 timer/GIC clockevent driver mix
MIPS: Malta: bugfix of GIC availability check.
MIPS: Added missed GIC registers definitions
MIPS: GIC registers can be obtained now via /sys FS
MIPS: bugfix of L2-SYNC only support for CM1 cores
MIPS: CM support cleanup
MIPS: Added GCR missed register definitions
MIPS: GCR registers can be obtained now via /sys FS
MIPS: Basic CPC support
MIPS: bugfix of instruction PREFX in FPU emulator
MIPS: bugfix of CONFIG_CPU_MIPSR2 usage
MIPS: bugfix of CONFIG_CPU_MIPS64 usage
MIPS: bugfix of local atomic ops in arch/mips/include/asm/local.h
MIPS: buildfix of local atomic operations
MIPS: QEMU generic CPU support is added
MIPS: Added P5600 CPU support
MIPS: bugfix - remove unconditional R6 on P5600
MIPS: bugfix of printing 64bit address in /proc/cpuinfo
MIPS: bugfix of branch-likely emulation in branch.c
MIPS: Malta: universal memory map initialisation
MIPS: bugfix: remove a double call of decode_configs for MIPS/IMG CPUs
MIPS: bugfix of FPU save/restore for MIPS32 context on MIPS64
MIPS: msc: Prevent out-of-bounds writes to MIPS SC ioremap'd region
MIPS: bugfix: missed cache flush of TLB refill handler
MIPS: PTE bit positions slightly changed to prepare a more simple swap/file presentation
MIPS: bugfix of PTE formats for swap and file entries
MIPS: bugfix of -mfp64 in signal/signal32 context save
MIPS: yet another bugfix of -mfp64 in signal/signal32 context restore)
Signed-off-by: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
Leonid Yegoshin [Tue, 18 Nov 2014 01:05:09 +0000 (17:05 -0800)]
MIPS HIGHMEM fixes for cache aliasing and non-DMA I/O.
This patch fixes MIPS HIGHMEM for cache aliasing and non-DMA device
I/O. It does the following:
1. Uses only colored page addresses while allocating by kmap*(),
page address in HIGHMEM zone matches a kernel address by color.
It allows easy re-allocation before flushing cache.
It does it for kmap() and kmap_atomic().
2. Fixes instruction cache flush by right color address via
kmap_coherent() in case of I-cache aliasing.
3. Flushes D-cache before page is provided for process as I-page.
It is required for swapped-in pages in case of non-DMA I/O.
4. Some optimization is done... more comes.
Signed-off-by: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
Lee Campbell [Wed, 8 Oct 2014 22:43:13 +0000 (15:43 -0700)]
Merge android-3.10 into android-goldfish-3.10 (seccomp-tsync)
| *
900e9fd 2014-10-08 leecam@chromium.org seccomp: fix syscall numbers for x86 and x86_64
| *
9ac8600 2014-08-10 linux@roeck-us.net seccomp: Replace BUG(!spin_is_locked()) with assert_spin_lock
| *
f14a5db 2014-06-05 keescook@chromium.org seccomp: implement SECCOMP_FILTER_FLAG_TSYNC
| *
c852ef7 2014-06-27 keescook@chromium.org seccomp: allow mode setting across threads
| *
61b6b88 2014-06-27 keescook@chromium.org seccomp: introduce writer locking
| *
b6a12bf 2014-06-27 keescook@chromium.org seccomp: split filter prep from check and apply
| *
9d0ff69 2014-05-21 keescook@chromium.org sched: move no_new_privs into new atomic flags
| *
e985fd4 2014-06-25 keescook@chromium.org seccomp: add "seccomp" syscall
| *
8908dde 2014-06-25 keescook@chromium.org seccomp: split mode setting routines
| *
b8a9cff 2014-06-25 keescook@chromium.org seccomp: extract check/assign mode helpers
| *
2a30a43 2014-05-21 keescook@chromium.org seccomp: create internal mode-setting function
| *
987a0f1 2014-01-21 oleg@redhat.com introduce for_each_thread() to replace the buggy while_each_thread()
| *
a03a242 2013-11-06 peterz@infradead.org arch: Introduce smp_load_acquire(), smp_store_release()
| *
210957c 2014-09-04 takahiro.akashi@linaro.org arm64: add seccomp support
| *
9499cd2 2014-03-11 eparis@redhat.com syscall_get_arch: remove useless function arguments
| *
7722723 2014-09-04 takahiro.akashi@linaro.org arm64: add SIGSYS siginfo for compat task
| *
4f12b53 2014-09-04 takahiro.akashi@linaro.org add seccomp syscall for compat task
| *
dab1073 2014-09-04 takahiro.akashi@linaro.org asm-generic: add generic seccomp.h for secure computing mode 1
| *
feb2843 2014-09-04 takahiro.akashi@linaro.org arm64: ptrace: allow tracer to skip a system call
| *
abbfed9 2014-09-04 takahiro.akashi@linaro.org arm64: ptrace: add PTRACE_SET_SYSCALL
Conflicts:
arch/arm64/Kconfig
Signed-off-by: Lee Campbell <leecam@chromium.org>
Lee Campbell [Wed, 8 Oct 2014 21:40:22 +0000 (14:40 -0700)]
seccomp: fix syscall numbers for x86 and x86_64
Correcting syscall numbers for seccomp
Signed-off-by: Lee Campbell <leecam@chromium.org>
Guenter Roeck [Mon, 11 Aug 2014 03:50:30 +0000 (20:50 -0700)]
seccomp: Replace BUG(!spin_is_locked()) with assert_spin_lock
Current upstream kernel hangs with mips and powerpc targets in
uniprocessor mode if SECCOMP is configured.
Bisect points to commit
dbd952127d11 ("seccomp: introduce writer locking").
Turns out that code such as
BUG_ON(!spin_is_locked(&list_lock));
can not be used in uniprocessor mode because spin_is_locked() always
returns false in this configuration, and that assert_spin_locked()
exists for that very purpose and must be used instead.
Fixes: dbd952127d11 ("seccomp: introduce writer locking")
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Kees Cook <keescook@chromium.org>
Kees Cook [Thu, 5 Jun 2014 07:23:17 +0000 (00:23 -0700)]
seccomp: implement SECCOMP_FILTER_FLAG_TSYNC
Applying restrictive seccomp filter programs to large or diverse
codebases often requires handling threads which may be started early in
the process lifetime (e.g., by code that is linked in). While it is
possible to apply permissive programs prior to process start up, it is
difficult to further restrict the kernel ABI to those threads after that
point.
This change adds a new seccomp syscall flag to SECCOMP_SET_MODE_FILTER for
synchronizing thread group seccomp filters at filter installation time.
When calling seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_TSYNC,
filter) an attempt will be made to synchronize all threads in current's
threadgroup to its new seccomp filter program. This is possible iff all
threads are using a filter that is an ancestor to the filter current is
attempting to synchronize to. NULL filters (where the task is running as
SECCOMP_MODE_NONE) are also treated as ancestors allowing threads to be
transitioned into SECCOMP_MODE_FILTER. If prctrl(PR_SET_NO_NEW_PRIVS,
...) has been set on the calling thread, no_new_privs will be set for
all synchronized threads too. On success, 0 is returned. On failure,
the pid of one of the failing threads will be returned and no filters
will have been applied.
The race conditions against another thread are:
- requesting TSYNC (already handled by sighand lock)
- performing a clone (already handled by sighand lock)
- changing its filter (already handled by sighand lock)
- calling exec (handled by cred_guard_mutex)
The clone case is assisted by the fact that new threads will have their
seccomp state duplicated from their parent before appearing on the tasklist.
Holding cred_guard_mutex means that seccomp filters cannot be assigned
while in the middle of another thread's exec (potentially bypassing
no_new_privs or similar). The call to de_thread() may kill threads waiting
for the mutex.
Changes across threads to the filter pointer includes a barrier.
Based on patches by Will Drewry.
Suggested-by: Julien Tinnes <jln@chromium.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Kees Cook [Fri, 27 Jun 2014 22:01:35 +0000 (15:01 -0700)]
seccomp: allow mode setting across threads
This changes the mode setting helper to allow threads to change the
seccomp mode from another thread. We must maintain barriers to keep
TIF_SECCOMP synchronized with the rest of the seccomp state.
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Conflicts:
kernel/seccomp.c
Kees Cook [Fri, 27 Jun 2014 22:18:48 +0000 (15:18 -0700)]
seccomp: introduce writer locking
Normally, task_struct.seccomp.filter is only ever read or modified by
the task that owns it (current). This property aids in fast access
during system call filtering as read access is lockless.
Updating the pointer from another task, however, opens up race
conditions. To allow cross-thread filter pointer updates, writes to the
seccomp fields are now protected by the sighand spinlock (which is shared
by all threads in the thread group). Read access remains lockless because
pointer updates themselves are atomic. However, writes (or cloning)
often entail additional checking (like maximum instruction counts)
which require locking to perform safely.
In the case of cloning threads, the child is invisible to the system
until it enters the task list. To make sure a child can't be cloned from
a thread and left in a prior state, seccomp duplication is additionally
moved under the sighand lock. Then parent and child are certain have
the same seccomp state when they exit the lock.
Based on patches by Will Drewry and David Drysdale.
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Conflicts:
kernel/fork.c
Kees Cook [Fri, 27 Jun 2014 22:16:33 +0000 (15:16 -0700)]
seccomp: split filter prep from check and apply
In preparation for adding seccomp locking, move filter creation away
from where it is checked and applied. This will allow for locking where
no memory allocation is happening. The validation, filter attachment,
and seccomp mode setting can all happen under the future locks.
For extreme defensiveness, I've added a BUG_ON check for the calculated
size of the buffer allocation in case BPF_MAXINSN ever changes, which
shouldn't ever happen. The compiler should actually optimize out this
check since the test above it makes it impossible.
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Conflicts:
kernel/seccomp.c
Kees Cook [Wed, 21 May 2014 22:23:46 +0000 (15:23 -0700)]
sched: move no_new_privs into new atomic flags
Since seccomp transitions between threads requires updates to the
no_new_privs flag to be atomic, the flag must be part of an atomic flag
set. This moves the nnp flag into a separate task field, and introduces
accessors.
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Conflicts:
kernel/sys.c
Kees Cook [Wed, 25 Jun 2014 23:08:24 +0000 (16:08 -0700)]
seccomp: add "seccomp" syscall
This adds the new "seccomp" syscall with both an "operation" and "flags"
parameter for future expansion. The third argument is a pointer value,
used with the SECCOMP_SET_MODE_FILTER operation. Currently, flags must
be 0. This is functionally equivalent to prctl(PR_SET_SECCOMP, ...).
In addition to the TSYNC flag later in this patch series, there is a
non-zero chance that this syscall could be used for configuring a fixed
argument area for seccomp-tracer-aware processes to pass syscall arguments
in the future. Hence, the use of "seccomp" not simply "seccomp_add_filter"
for this syscall. Additionally, this syscall uses operation, flags,
and user pointer for arguments because strictly passing arguments via
a user pointer would mean seccomp itself would be unable to trivially
filter the seccomp syscall itself.
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Conflicts:
arch/x86/syscalls/syscall_32.tbl
arch/x86/syscalls/syscall_64.tbl
include/uapi/asm-generic/unistd.h
kernel/seccomp.c
And fixup of unistd32.h to truly enable sys_secomp.
Change-Id: I95bea02382c52007d22e5e9dc563c7d055c2c83f
Kees Cook [Wed, 25 Jun 2014 22:55:25 +0000 (15:55 -0700)]
seccomp: split mode setting routines
Separates the two mode setting paths to make things more readable with
fewer #ifdefs within function bodies.
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Kees Cook [Wed, 25 Jun 2014 22:38:02 +0000 (15:38 -0700)]
seccomp: extract check/assign mode helpers
To support splitting mode 1 from mode 2, extract the mode checking and
assignment logic into common functions.
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Kees Cook [Wed, 21 May 2014 22:02:11 +0000 (15:02 -0700)]
seccomp: create internal mode-setting function
In preparation for having other callers of the seccomp mode setting
logic, split the prctl entry point away from the core logic that performs
seccomp mode setting.
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Oleg Nesterov [Tue, 21 Jan 2014 23:49:56 +0000 (15:49 -0800)]
introduce for_each_thread() to replace the buggy while_each_thread()
while_each_thread() and next_thread() should die, almost every lockless
usage is wrong.
1. Unless g == current, the lockless while_each_thread() is not safe.
while_each_thread(g, t) can loop forever if g exits, next_thread()
can't reach the unhashed thread in this case. Note that this can
happen even if g is the group leader, it can exec.
2. Even if while_each_thread() itself was correct, people often use
it wrongly.
It was never safe to just take rcu_read_lock() and loop unless
you verify that pid_alive(g) == T, even the first next_thread()
can point to the already freed/reused memory.
This patch adds signal_struct->thread_head and task->thread_node to
create the normal rcu-safe list with the stable head. The new
for_each_thread(g, t) helper is always safe under rcu_read_lock() as
long as this task_struct can't go away.
Note: of course it is ugly to have both task_struct->thread_node and the
old task_struct->thread_group, we will kill it later, after we change
the users of while_each_thread() to use for_each_thread().
Perhaps we can kill it even before we convert all users, we can
reimplement next_thread(t) using the new thread_head/thread_node. But
we can't do this right now because this will lead to subtle behavioural
changes. For example, do/while_each_thread() always sees at least one
task, while for_each_thread() can do nothing if the whole thread group
has died. Or thread_group_empty(), currently its semantics is not clear
unless thread_group_leader(p) and we need to audit the callers before we
can change it.
So this patch adds the new interface which has to coexist with the old
one for some time, hopefully the next changes will be more or less
straightforward and the old one will go away soon.
Bug
200004307
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Sergey Dyasly <dserrg@gmail.com>
Tested-by: Sergey Dyasly <dserrg@gmail.com>
Reviewed-by: Sameer Nanda <snanda@chromium.org>
Acked-by: David Rientjes <rientjes@google.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mandeep Singh Baines <msb@chromium.org>
Cc: "Ma, Xindong" <xindong.ma@intel.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: "Tu, Xiaobing" <xiaobing.tu@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit
0c740d0afc3bff0a097ad03a1c8df92757516f5c)
Signed-off-by: Sri Krishna chowdary <schowdary@nvidia.com>
Change-Id: Id689cb1383ceba2561b66188d88258619b68f5c6
Reviewed-on: http://git-master/r/419041
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Peter Zijlstra [Wed, 6 Nov 2013 13:57:36 +0000 (14:57 +0100)]
arch: Introduce smp_load_acquire(), smp_store_release()
A number of situations currently require the heavyweight smp_mb(),
even though there is no need to order prior stores against later
loads. Many architectures have much cheaper ways to handle these
situations, but the Linux kernel currently has no portable way
to make use of them.
This commit therefore supplies smp_load_acquire() and
smp_store_release() to remedy this situation. The new
smp_load_acquire() primitive orders the specified load against
any subsequent reads or writes, while the new smp_store_release()
primitive orders the specifed store against any prior reads or
writes. These primitives allow array-based circular FIFOs to be
implemented without an smp_mb(), and also allow a theoretical
hole in rcu_assign_pointer() to be closed at no additional
expense on most architectures.
In addition, the RCU experience transitioning from explicit
smp_read_barrier_depends() and smp_wmb() to rcu_dereference()
and rcu_assign_pointer(), respectively resulted in substantial
improvements in readability. It therefore seems likely that
replacing other explicit barriers with smp_load_acquire() and
smp_store_release() will provide similar benefits. It appears
that roughly half of the explicit barriers in core kernel code
might be so replaced.
[Changelog by PaulMck]
(cherry picked from commit
47933ad41a86a4a9b50bed7c9b9bd2ba242aac63)
Reviewed-by: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Will Deacon <will.deacon@arm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Michael Ellerman <michael@ellerman.id.au>
Cc: Michael Neuling <mikey@neuling.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Victor Kaplansky <VICTORK@il.ibm.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Link: http://lkml.kernel.org/r/20131213150640.908486364@infradead.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
AKASHI Takahiro [Thu, 4 Sep 2014 15:01:08 +0000 (16:01 +0100)]
arm64: add seccomp support
Note: This patch is from v6 of Takahiro's proposed
"arm64: add seccomp support" patchset (leecam@google.com)
secure_computing() is called first in syscall_trace_enter() so that a system
call will be aborted quickly without doing succeeding syscall tracing,
contrary to other cases, if seccomp rules deny that system call.
On compat task, syscall numbers for system calls allowed in seccomp mode 1
are different from those on normal tasks, and so _NR_seccomp_xxx_32's need
to be redefined.
Signed-off-by: AKASHI Takahiro <takahiro.akashi <at> linaro.org>
Conflicts:
arch/arm64/Kconfig
arch/arm64/kernel/entry.S
Change-Id: I5ec44507d7e536df7ec9d62d30a418c26ef15100
Eric Paris [Tue, 11 Mar 2014 16:48:43 +0000 (12:48 -0400)]
syscall_get_arch: remove useless function arguments
Every caller of syscall_get_arch() uses current for the task and no
implementors of the function need args. So just get rid of both of
those things. Admittedly, since these are inline functions we aren't
wasting stack space, but it just makes the prototypes better.
Signed-off-by: Eric Paris <eparis@redhat.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mips@linux-mips.org
Cc: linux390@de.ibm.com
Cc: x86@kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-s390@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Conflicts:
arch/mips/include/asm/syscall.h
arch/mips/kernel/ptrace.c
AKASHI Takahiro [Thu, 4 Sep 2014 14:48:01 +0000 (15:48 +0100)]
arm64: add SIGSYS siginfo for compat task
Note: This patch is from v6 of Takahiro's proposed
"arm64: add seccomp support" patchset (leecam@google.com)
SIGSYS is primarily used in secure computing to notify tracer.
This patch allows signal handler on compat task to get correct information
with SA_SYSINFO specified when this signal is delivered.
Signed-off-by: AKASHI Takahiro <takahiro.akashi <at> linaro.org>
AKASHI Takahiro [Thu, 4 Sep 2014 14:39:13 +0000 (15:39 +0100)]
add seccomp syscall for compat task
Note: This patch is from v6 of Takahiro's proposed
"arm64: add seccomp support" patchset (leecam@google.com)
This patch allows compat task to issue seccomp() system call.
Signed-off-by: AKASHI Takahiro <takahiro.akashi <at> linaro.org>
Conflicts:
arch/arm64/include/asm/unistd32.h
Change-Id: I63d38f68da72b3333327256b4cacba2c3ddb39fc
AKASHI Takahiro [Thu, 4 Sep 2014 14:34:14 +0000 (15:34 +0100)]
asm-generic: add generic seccomp.h for secure computing mode 1
Note: This patch is from v6 of Takahiro's proposed
"arm64: add seccomp support" patchset (leecam@google.com)
Those values (__NR_seccomp_*) are used solely in secure_computing()
to identify mode 1 system calls. If compat system calls have different
syscall numbers, asm/seccomp.h may override them.
Acked-by: Arnd Bergmann <arnd <at> arndb.de>
Signed-off-by: AKASHI Takahiro <takahiro.akashi <at> linaro.org>
AKASHI Takahiro [Thu, 4 Sep 2014 14:20:53 +0000 (15:20 +0100)]
arm64: ptrace: allow tracer to skip a system call
Note: This patch is from v6 of Takahiro's proposed
"arm64: add seccomp support" patchset (leecam@google.com)
If tracer specifies -1 as a syscall number, this traced system call should
be skipped with a value in x0 used as a return value.
This patch enables this semantics, but there is a restriction here:
when syscall(-1) is issued by user, tracer cannot skip this system call
and modify a return value at syscall entry.
In order to ease this flavor, we need to treat whatever value in x0 as
a return value, but this might result in a bogus value being returned,
especially when tracer doesn't do anything at this syscall.
So we always return ENOSYS instead, while we have another chance to change
a return value at syscall exit.
Please also note:
* syscall entry tracing and syscall exit tracing (ftrace tracepoint and
audit) are always executed, if enabled, even when skipping a system call
(that is, -1).
In this way, we can avoid a potential bug where audit_syscall_entry()
might be called without audit_syscall_exit() at the previous system call
being called, that would cause OOPs in audit_syscall_entry().
* syscallno may also be set to -1 if a fatal signal (SIGKILL) is detected
in tracehook_report_syscall_entry(), but since a value set to x0 (ENOSYS)
is not used in this case, we may neglect the case.
Signed-off-by: AKASHI Takahiro <takahiro.akashi <at> linaro.org>
Conflicts:
arch/arm64/kernel/entry.S
Change-Id: Ifcdcdbcb7c8cf97e5b5f1086a1ea4107e1d4f9a8
AKASHI Takahiro [Thu, 4 Sep 2014 13:54:29 +0000 (14:54 +0100)]
arm64: ptrace: add PTRACE_SET_SYSCALL
Note: This patch is from v6 of Takahiro's proposed
"arm64: add seccomp support" patchset (leecam@google.com)
To allow tracer to be able to change/skip a system call by re-writing
a syscall number, there are several approaches:
(1) modify x8 register with ptrace(PTRACE_SETREGSET), and handle this case
later on in syscall_trace_enter(), or
(2) support ptrace(PTRACE_SET_SYSCALL) as on arm
Thinking of the fact that user_pt_regs doesn't expose 'syscallno' to
tracer as well as that secure_computing() expects a changed syscall number
to be visible, especially case of -1, before this function returns in
syscall_trace_enter(), we'd better take (2).
Signed-off-by: AKASHI Takahiro <takahiro.akashi <at> linaro.org>
JP Abgrall [Tue, 7 Oct 2014 02:45:14 +0000 (19:45 -0700)]
Merge 'common/android-3.10' into android-goldfish-3.10
*
|\
| *
88835a3 2014-09-24 Badhri@google.com USB: f_rndis: fix compile error
| *
12407bb 2014-09-04 xerox_lin@htc.com USB: gadget: rndis: Add module parameter for DL max packets per xfer
| *
5cf9479 2014-09-18 Badhri@google.com ndis: Add debug support to disable RNDIS Multipacket Feature
| *
f9039de 2014-09-18 Badhri@google.com RNDIS: Add Data aggregation (multi packet) support
| *
91da92a 2014-09-18 Badhri@google.com USB: gadget: u_ether: Fix data stall issue in RNDIS tethering mode
| *
9c861db 2012-09-14 taeju.park@lge.com usb: gadget: prevent change of Host MAC address of 'usb0' interface
| *
555f3ed 2014-09-24 Badhri@google.com usb: u_ether: Add workqueue as bottom half handler for rx data path
| *
f884d7f 2014-09-17 jpa@google.com arm64: Fixup __NR_* compat syscalls count.
| *
ba27127 2014-04-30 takahiro.akashi@linaro.org arm64: is_compat_task is defined both in asm/compat.h and linux/compat.h
| *
4b373563 2014-04-30 takahiro.akashi@linaro.org arm64: Add regs_return_value() in syscall.h
| *
3e21c0b 2014-09-17 jpa@google.com arm64: audit: Add audit hook in syscall_trace_enter/exit()
| *
bf11863 2014-07-04 takahiro.akashi@linaro.org arm64: Add audit support
| *
4f2f36a 2013-08-28 alonid@stratoscale.com Move the EM_ARM and EM_AARCH64 definitions to uapi/linux/elf-em.h
| *
cfc7e99e9 2014-09-17 jpa@google.com arm64: Add __NR_* definitions for compat syscalls
| *
26108f2 2014-04-30 takahiro.akashi@linaro.org arm64: split syscall_trace() into separate functions for enter/exit
| *
f91c274 2014-04-30 takahiro.akashi@linaro.org arm64: make a single hook to syscall_trace() for all syscall features
| *
4149e0d 2014-09-17 jpa@google.com seccomp: revert previous patches in prep for updated ones
| *
8fdfc48 2013-09-02 catalin.marinas@arm.com arm64: Remove unused cpu_name ascii in arch/arm64/mm/proc.S
| *
eaa22ea 2013-12-16 ard.biesheuvel@linaro.org arm64: drop redundant macros from read_cpuid()
| *
39fdc30 2014-09-15 ghackmann@google.com android: base-cfg: enable ARMV7_COMPAT
Conflicts:
arch/arm64/Kconfig
arch/arm64/kernel/hw_breakpoint.c
Signed-off-by: JP Abgrall <jpa@google.com>
JP Abgrall [Tue, 7 Oct 2014 00:26:57 +0000 (17:26 -0700)]
Revert "goldfish: Disable Seccomp for Intel builds."
This reverts commit
43dbfdb838603e823d75cec871f0c317e8c20fc9.
Badhri Jagan Sridharan [Thu, 25 Sep 2014 02:36:33 +0000 (19:36 -0700)]
USB: f_rndis: fix compile error
Change-Id: Ied5dd8ef905bdf84d176a5e560b09e292b68fbc5
Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
xerox_lin [Thu, 4 Sep 2014 08:01:59 +0000 (16:01 +0800)]
USB: gadget: rndis: Add module parameter for DL max packets per xfer
Currently DL aggregation is supported in RNDIS driver and is set to
3 by default. And there is no support to change downlink maximum
packets per transfer at runtime through module parameter. Hence add
module parameter for DL maximum packets per transfer to change it at
runtime.
echo 6 > /sys/module/g_android/parameters/rndis_dl_max_pkt_per_xfer
To disable DL aggregation during runtime,
echo 1 > /sys/module/g_android/parameters/rndis_dl_max_pkt_per_xfer
Change-Id: I3a1d0bc97358e2b6f233df7ae8725fb507de50db
Signed-off-by: Xerox Lin <xerox_lin@htc.com>
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
Badhri Jagan Sridharan [Thu, 18 Sep 2014 17:48:48 +0000 (10:48 -0700)]
ndis: Add debug support to disable RNDIS Multipacket Feature
This change adds module param which allows to disable RNDIS
Multi-packet Feature (Aggregation support in Downlink path)
as this feature is enabled by default.
To disable use this param before moving to RNDIS Composition:
echo 1 > /sys/module/g_android/parameters/rndis_multipacket_dl_disable
Also counts errors as Rx errors if received RNDIS packets are
not following RNDIS message format as those packets are being
discarded.
Change-Id: I764430da78f2204af92e14bb279c11b24c7e4c67
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Badhri Jagan Sridharan [Thu, 18 Sep 2014 17:46:08 +0000 (10:46 -0700)]
RNDIS: Add Data aggregation (multi packet) support
Add data aggregation support using RNDIS Multi Packet feature
to achieve better UDP Downlink throughput. Max 3 RNDIS Packets
aggregated into one RNDIS Packet with this implementation.
With this change, seeing UDP Downlink throughput increase
from 90 Mbps to above 100 Mbps when using Iperf and sending
data more than 100 Mbps.
Change-Id: I21c39482718944bb1b1068bdd02f626531e58f08
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Signed-off-by: Rajkumar Raghupathy <raghup@codeaurora.org>
Badhri Jagan Sridharan [Thu, 18 Sep 2014 17:42:41 +0000 (10:42 -0700)]
USB: gadget: u_ether: Fix data stall issue in RNDIS tethering mode
For dual speed gadget, with current no. of request(10), there is
possibility of corner case occurence where all 10 reuqests are queued
to HW without setting IOC bit, which could lead to data stall in
RNDIS tethering and RNDIS local networking.
With this patch, counter will be incremented before queueing request to
HW and sets IOC bit for every nth request due to which the corner case
of all requests queued to HW without IOC bit set will be avoided.
Change-Id: I26515bfd9bbc8f7af38be7835692143f7093118a
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
taeju.park [Fri, 14 Sep 2012 05:09:03 +0000 (14:09 +0900)]
usb: gadget: prevent change of Host MAC address of 'usb0' interface
On windows 7 platform, previously allocated ip address is maintained.
However, Host MAC address of 'usb0' interface is changed when the
tethering driver re-enumerated. Thus, the tethering network driver
can't be allocated ip address from dhcp. It causes connection delay
between host and phone for usb tethering.
This patch prevents from changing Host MAC address of 'usb0' interface.
In other words, this patch maintains the Host MAC address allocated when
first tethering driver although the driver is re-enumerated. However,
after reboot, the Host MAC address can be changed.
Change-Id: I43add9925e9d6d90c56cffbd3ed999104448f818
Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Badhri Jagan Sridharan [Thu, 25 Sep 2014 01:58:23 +0000 (18:58 -0700)]
usb: u_ether: Add workqueue as bottom half handler for rx data path
u_ether driver passes rx data to network layer and resubmits the
request back to usb hardware in interrupt context. Network layer
processes rx data by scheduling tasklet. For high throughput
scenarios on rx data path driver is spending lot of time in interrupt
context due to rx data processing by tasklet and continuous completion
and re-submission of the usb requests which results in watchdog bark.
Hence move the rx data processing and usb request submission to a
workqueue bottom half handler.
Change-Id: I316de8e267997137ac189a8b7b2846fa325f4a5a
Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
JP Abgrall [Thu, 18 Sep 2014 02:26:43 +0000 (19:26 -0700)]
arm64: Fixup __NR_* compat syscalls count.
Should have gone in the cherry-pick
cfc7e99e9e3900056028a7d90072e9ea0d886f8d
arm64: Add __NR_* definitions for compat syscalls
Change-Id: I69a69e4b1f206aad4ece1a8b06f9e23e99adcbfb
AKASHI Takahiro [Wed, 30 Apr 2014 09:51:32 +0000 (10:51 +0100)]
arm64: is_compat_task is defined both in asm/compat.h and linux/compat.h
Some kernel files may include both linux/compat.h and asm/compat.h directly
or indirectly. Since both header files contain is_compat_task() under
!CONFIG_COMPAT, compiling them with !CONFIG_COMPAT will eventually fail.
Such files include kernel/auditsc.c, kernel/seccomp.c and init/do_mountfs.c
(do_mountfs.c may read asm/compat.h via asm/ftrace.h once ftrace is
implemented).
So this patch proactively
1) removes is_compat_task() under !CONFIG_COMPAT from asm/compat.h
2) replaces asm/compat.h to linux/compat.h in kernel/*.c,
but asm/compat.h is still necessary in ptrace.c and process.c because
they use is_compat_thread().
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Conflicts:
arch/arm64/kernel/hw_breakpoint.c
arch/arm64/kernel/ptrace.c
Change-Id: I5b8330e43ab8bdd383cd410d8223d6c1a39fa0fc
AKASHI Takahiro [Wed, 30 Apr 2014 09:51:31 +0000 (10:51 +0100)]
arm64: Add regs_return_value() in syscall.h
This macro, regs_return_value, is used mainly for audit to record system
call's results, but may also be used in test_kprobes.c.
Acked-by: Will Deacon <will.deacon@arm.com>
Acked-by: Richard Guy Briggs <rgb@redhat.com>
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
JP Abgrall [Thu, 18 Sep 2014 01:18:11 +0000 (18:18 -0700)]
arm64: audit: Add audit hook in syscall_trace_enter/exit()
This patch adds auditing functions on entry to or exit from
every system call invocation.
Acked-by: Richard Guy Briggs <rgb@redhat.com>
Acked-by Will Deacon <will.deacon@arm.com>
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Conflicts:
arch/arm64/kernel/ptrace.c
Change-Id: I7ebff5df4acbdab56c74e584dbc5fef5d8bfc9a8
AKASHI Takahiro [Fri, 4 Jul 2014 07:28:30 +0000 (08:28 +0100)]
arm64: Add audit support
On AArch64, audit is supported through generic lib/audit.c and
compat_audit.c, and so this patch adds arch specific definitions required.
Acked-by Will Deacon <will.deacon@arm.com>
Acked-by: Richard Guy Briggs <rgb@redhat.com>
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Conflicts:
arch/arm64/Kconfig
include/uapi/linux/audit.h
Change-Id: Ia6d7b25786843d43191e67d514928e3ecba11e2f
Dan Aloni [Wed, 28 Aug 2013 13:24:53 +0000 (14:24 +0100)]
Move the EM_ARM and EM_AARCH64 definitions to uapi/linux/elf-em.h
Signed-off-by: Dan Aloni <alonid@stratoscale.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
JP Abgrall [Thu, 18 Sep 2014 00:59:28 +0000 (17:59 -0700)]
arm64: Add __NR_* definitions for compat syscalls
This patch adds __NR_* definitions to asm/unistd32.h, moves the
__NR_compat_* definitions to asm/unistd.h and removes all the explicit
unistd32.h includes apart from the one building the compat syscall
table. The aim is to have the compat __NR_* definitions available but
without colliding with the native syscall definitions (required by
lib/compat_audit.c to avoid duplicating the audit header files between
native and compat).
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Conflicts:
arch/arm64/include/asm/unistd32.h
arch/arm64/kernel/kuser32.S
Change-Id: I8776881b5beb39769aadc4c4f14a51ea54325112
AKASHI Takahiro [Wed, 30 Apr 2014 09:51:30 +0000 (10:51 +0100)]
arm64: split syscall_trace() into separate functions for enter/exit
As done in arm, this change makes it easy to confirm we invoke syscall
related hooks, including syscall tracepoint, audit and seccomp which would
be implemented later, in correct order. That is, undoing operations in the
opposite order on exit that they were done on entry.
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
AKASHI Takahiro [Wed, 30 Apr 2014 09:51:29 +0000 (10:51 +0100)]
arm64: make a single hook to syscall_trace() for all syscall features
Currently syscall_trace() is called only for ptrace.
With additional TIF_xx flags defined, it is now called in all the cases
of audit, ftrace and seccomp in addition to ptrace.
Acked-by: Richard Guy Briggs <rgb@redhat.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Conflicts:
arch/arm64/include/asm/thread_info.h
arch/arm64/kernel/entry.S
Change-Id: Iee71c44c45b363194a1cc7182906c0afa6b5348b
JP Abgrall [Wed, 17 Sep 2014 22:01:45 +0000 (15:01 -0700)]
seccomp: revert previous patches in prep for updated ones
This reverts the seccomp related patches committed around 2014-08-27.
This allows for a cleaner cherry-pick of newly landed upstream patches.
f56b1aa arm: fixup NR_syscalls to accommodate the new seccomp syscall
81ff7fa seccomp: implement SECCOMP_FILTER_FLAG_TSYNC
d924727 seccomp: allow mode setting across threads
743266a seccomp: introduce writer locking
3497a88 seccomp: split filter prep from check and apply
2c6d7de MIPS: add seccomp syscall
83f1ccba ARM: add seccomp syscall
a75a29b seccomp: add "seccomp" syscall
1a63bce seccomp: split mode setting routines
c208e4e seccomp: extract check/assign mode helpers
6862b01 seccomp: create internal mode-setting function
1ba2ccb MAINTAINERS: create seccomp entry
c2da3eb seccomp: fix memory leak on filter attach
945a225 ARM: 7888/1: seccomp: not compatible with ARM OABI
Change-Id: I3f129263d68a7b3c206d79f84f7f9908d13064f6
Signed-off-by: JP Abgrall <jpa@google.com>
Catalin Marinas [Mon, 2 Sep 2013 15:33:54 +0000 (16:33 +0100)]
arm64: Remove unused cpu_name ascii in arch/arm64/mm/proc.S
This string has been moved to arch/arm64/kernel/cputable.c.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Ard Biesheuvel [Mon, 16 Dec 2013 21:04:35 +0000 (21:04 +0000)]
arm64: drop redundant macros from read_cpuid()
asm/cputype.h contains a bunch of #defines for CPU id registers
that essentially map to themselves. Remove the #defines and pass
the tokens directly to the inline asm() that reads the registers.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
David 'Digit' Turner [Tue, 16 Sep 2014 20:36:56 +0000 (22:36 +0200)]
goldfish: Enable multinetwork kernel feature.
These are required for Android L and beyond. The following changes
were generated by doing the following:
1) For each CPU architecture, append the following to its _defconfig
file:
CONFIG_IPV6=y
CONFIG_IPV6_MULTIPLE_TABLES=y
CONFIG_IP_ADVANCED_ROUTER=y
CONFIG_IP_MULTIPLE_TABLES=y
CONFIG_NETFILTER=y
CONFIG_NETFILTER_ADVANCED=y
CONFIG_NETFILTER_XTABLES=y
CONFIG_NETFILTER_XT_MARK=y
CONFIG_NETFILTER_XT_TARGET_MARK=y
CONFIG_IP_NF_IPTABLES=y
CONFIG_IP_NF_MANGLE=y
CONFIG_IP6_NF_IPTABLES=y
CONFIG_IP6_NF_MANGLE=y
2) For each CPU architecture, run:
$AOSP/external/qemu/distrib/rebuild-kernel.sh --arch=$ARCH --savedefconfig
The --savedefconfig option ensures the _defconfig is modified to only
contain the minimal amount of changes required, and removes un-necessary
definitions too.
BUG=
17516983
Signed-off-by: David 'Digit' Turner <digit@android.com>
David 'Digit' Turner [Tue, 16 Sep 2014 20:12:31 +0000 (22:12 +0200)]
goldfish: Disable Seccomp for Intel builds.
For some reason, the kernel doesn't build if CONFIG_SECCOMP is
enabled, which is the default for x86 and x86_64 builds. This
patch disables the feature explicitly to work around this.
BUG=
17527409
Signed-off-by: David 'Digit' Turner <digit@android.com>
Greg Hackmann [Tue, 16 Sep 2014 18:13:31 +0000 (11:13 -0700)]
arm64: ranchu: enable ARMV7_COMPAT
Change-Id: Id6162ab5debc431d7577b65d9bc89e9b22d00e72
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Greg Hackmann [Tue, 16 Sep 2014 18:11:13 +0000 (11:11 -0700)]
Merge branch 'android-3.10' into android-goldfish-3.10
Conflicts:
arch/arm64/Kconfig
arch/arm64/include/asm/ptrace.h
arch/arm64/kernel/Makefile
arch/arm64/kernel/debug-monitors.c
arch/arm64/kernel/traps.c
Change-Id: Ifb43a8bad9636ee48ff52a29592af95e959a4399
Greg Hackmann [Mon, 15 Sep 2014 22:34:55 +0000 (15:34 -0700)]
android: base-cfg: enable ARMV7_COMPAT
Enables backwards-compatibility features on arm64, and has no effect
(does not exist) on other architectures
Change-Id: I6fc2f6567437750a0032f8a39a9cde1fb92d4ef4
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Greg Hackmann [Tue, 5 Aug 2014 23:14:27 +0000 (16:14 -0700)]
arm64: restrict effects of ARMV7_COMPAT_CPUINFO to ARMv7 tasks
Since ARMV7_COMPAT_CPUINFO only exists to support existing ARMv7
binaries, restrict its effects to compat tasks
Bug:
16819658
Change-Id: I1092de596c7822d23f5f3f8a05b417a3cb49f593
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Alex Van Brunt [Thu, 20 Feb 2014 18:46:21 +0000 (10:46 -0800)]
arm64: report vfpv3 instead of vfpv3d16
vfpv3 is the correct version for an ARMv8 processor and it is the
version reported by an A15.
Change-Id: I486f3af21a352c27775888cca332a48d7e0c59ce
Signed-off-by: Alex Van Brunt <avanbrunt@nvidia.com>
Reviewed-on: http://git-master/r/370076
Alex Van Brunt [Thu, 9 Jan 2014 20:51:05 +0000 (12:51 -0800)]
arm64: cpuinfo: ARMv7 compatable cpuinfo option
To be backwards compatable with the output of cpuinfo on an ARMv7,
print the features that were optional in ARMv7 but are required in
ARMv8.
Change-Id: Ic728f71be4a971adc79ef552f25cfbf95a4dac29
Signed-off-by: Alex Van Brunt <avanbrunt@nvidia.com>
Reviewed-on: http://git-master/r/366095
Reviewed-by: Richard Wiley <rwiley@nvidia.com>
Tested-by: Oskari Jaaskelainen <oskarij@nvidia.com>
Rich Wiley [Wed, 4 Jun 2014 18:44:03 +0000 (11:44 -0700)]
arm64: enable deprecated SETEND instruction in SCTLR compat config
Change-Id: I703d4843f8aab2ec63324f04cc13aaabae88e163
Signed-off-by: Rich Wiley <rwiley@nvidia.com>
Reviewed-on: http://git-master/r/422174
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alexander Van Brunt <avanbrunt@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>
Rich Wiley [Wed, 4 Jun 2014 18:41:53 +0000 (11:41 -0700)]
arm64: make SCTLR compat config depend on CONFIG_ARMV7_COMPAT
Conflicts:
arch/arm64/mm/proc.S
Change-Id: I76e0067839c96e3082b42c80d3fc670cf3d371b5
Signed-off-by: Rich Wiley <rwiley@nvidia.com>
Reviewed-on: http://git-master/r/422173
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alexander Van Brunt <avanbrunt@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>
Alex Van Brunt [Tue, 28 Jan 2014 20:40:10 +0000 (12:40 -0800)]
arm64: optionally set CP15BEN in SCTLR
Setting CP15BEN allows legacy applications running in AArch32 mode
that use CP15 DMB as similar instructions to continue running.
Change-Id: If76d3c6ee12865ff8c4b4e7aed01146bead87773
Signed-off-by: Alex Van Brunt <avanbrunt@nvidia.com>
Reviewed-on: http://git-master/r/366096
Reviewed-by: Richard Wiley <rwiley@nvidia.com>
Tested-by: Oskari Jaaskelainen <oskarij@nvidia.com>
Rich Wiley [Mon, 10 Mar 2014 21:01:06 +0000 (14:01 -0700)]
arm64: fix SWP instruction emulation
initial variable values may get overwritten
if they're listed as an output in ASM, even if
they're not explicitly written to.
Change-Id: I2a239e1819850a2a7005a46e83d82deac4ca303b
Signed-off-by: Rich Wiley <rwiley@nvidia.com>
Reviewed-on: http://git-master/r/379646
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Li Li (SW-TEGRA) <lli5@nvidia.com>
Tested-by: Li Li (SW-TEGRA) <lli5@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alexander Van Brunt <avanbrunt@nvidia.com>
Alex Van Brunt [Fri, 21 Feb 2014 02:18:53 +0000 (18:18 -0800)]
arm64: add fault handling to SWP emulation
Add excpetion table and fixup for SWP/SWPB instruction emulation.
This prevents the kernel from panicing when emulating a SWP/SWPB
instruction that access unmapped memory.
Change-Id: I4a9ca34fa161a0f306cdb663827d9bee39cec733
Signed-off-by: Alex Van Brunt <avanbrunt@nvidia.com>
Reviewed-on: http://git-master/r/370278
Alex Van Brunt [Wed, 19 Feb 2014 01:50:57 +0000 (17:50 -0800)]
arm64: fix a warning and a typo in SWP emulation
The store-release-exclusive is missing the "L" that makes it a
release rather than a normal store-exclusive.
Remove a variable that is not used and causes a compiler warning.
Change-Id: I91633a352b805ed9af450b632c9ee394235637c4
Signed-off-by: Alex Van Brunt <avanbrunt@nvidia.com>
Reviewed-on: http://git-master/r/369076
Reviewed-by: Richard Wiley <rwiley@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Alex Van Brunt [Thu, 30 Jan 2014 23:10:39 +0000 (15:10 -0800)]
arm64: emulate the swp/swpb instruction
The swp and spwb instructions were deprecated in ARMv6. ARMv8
obsoleted the instruction. Despite this, many applications rely on
these instruuctions.
This patch starts with the version present in the arm architecture.
However, it uses the ldx*()/stx*() functions to implement the handler
in C code. It also removes a lot of code that is not needed.
Change-Id: I6882fbe5f71bfa8f9e9a75d067b2111188c6f2fa
Signed-off-by: Alex Van Brunt <avanbrunt@nvidia.com>
Reviewed-on: http://git-master/r/366097
Reviewed-by: Richard Wiley <rwiley@nvidia.com>
Tested-by: Oskari Jaaskelainen <oskarij@nvidia.com>
Conflicts:
arch/arm64/Kconfig
arch/arm64/kernel/Makefile