Commit graph

99 commits

Author SHA1 Message Date
Paul Lawrence
60dec16c50 Correctly remove asecs for full disk encryption
Previously this would fail if the framework wasn't stopped. The failure
would then stop full disk encryption. The fact that the unmount worked,
however, would then stop the second attempt from achieving anything.

Fix in line with current retry philosophy

We still need to figure out why Devmapper::destroy() fails at first.

Bug: 17301843
Change-Id: I405a36c832ccdebf2d904bef77f15eea174a6bfb
2014-09-02 18:25:26 +00:00
Jeff Sharkey
43ed123d3f ASEC resize tweaking, allow read-write mounting.
Resize is no-op when sector count is unchanged; the caller can't
anticipate how vold does its sector calculations.

After resizing, we need to mount the container read-write, so allow
the caller to request "ro" or "rw" mode.

Handle ENOTSUP when trying to fallocate() on some filesystems

Bug: 16514385
Change-Id: I0d3a378280d4c36d14f8108ff428102283d583fa
2014-08-22 15:39:41 -07:00
JP Abgrall
40b64a6841 vold: support "volume list [broadcast]" command
Sometimes when an sdcard is already mounted,
some info like uuid and label are not re-broadcast to new listeners.
The extra argument to list allows late listeners to catch up by asking
volume list to broadcast that info again.

Bug: 16253597
Bug: 16306775
Change-Id: Ie7d0c1132c22d307a5b2a0e50075a3716138d00b
Signed-off-by: Benson Huang <benson.huang@mediatek.com>
(cherry picked from commit 85f4700f44170b772697e627b3075dcb9137e1b7)
2014-07-25 01:46:26 +00:00
Daniel Rosenberg
e9196fecbb Increase asec image size for reflecting ext4 reserved clusters
From Shawn Heo's patch:

Ext4 introduced reserved clusters to prevent costly zeroout, or
unexpected ENOSPC. The size is 2% or 4096 clusters, whichever
is smaller (http://lwn.net/Articles/546473/).

So, we need to allocate additionally this amount of free space
to asecs when vold create asec images. This is required when
Android runs on Linux kernel 3.10 or later.

see: https://android-review.git.corp.google.com/#/c/96160

Change-Id: Iacff16b8cf0314493c355fa741bcfa519f744d6c
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2014-06-11 00:50:53 +00:00
Daniel Rosenberg
fcd34a0ddd Added support for ext4 ASEC resizing.
ASECs formatted as ext4 can now be resized using vdc asec resize.
Refactored some common code.
Requires resize2fs.

Change-Id: Ie78bb6015114a7bc4af42b16d1f299322ffc1e2a
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2014-06-10 22:15:33 +00:00
Daniel Rosenberg
6a74dcaa6e Fixed bugs with ASEC filesystem.
Changed ext4 to be 4kb aligned, and fat to be 32kb aligned.
Fixed issue that could potentially cause unencrypted ext4
ASECS to overwrite the ASEC super block when filled.

Change-Id: I890426c82ac9cbc65add85a8e3f5063504193c31
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2014-05-28 23:23:47 +00:00
Cylen Yao
27cfee3fa4 avoid fs_mkdirs when SD card removed
Must limit vold calls to fs_mkdirs() only when the volume is mounted.
If NOT, it will trigger selinux warning as follows.
audit(1398835637.785:8): avc:  denied  { write } for  pid=137 comm="vold" name="sdcard0" dev="rootfs" ino=3191 scontext=u:r:vold:s0 tcontext=u:object_r:rootfs:s0 tclass=dir

Change-Id: I1113fc961cbdd8bbd2fcbf740c2f504628c8399d
Signed-off-by: Cylen Yao <cylen.yao@mediatek.com>
2014-05-14 20:42:13 -07:00
Nick Kralevich
3214d1f5a4 am 3c0d02aa: Merge "Convert all selinux_android_restorecon and _setfilecon calls to new API."
* commit '3c0d02aa03118713e6e770b54d1c530ff866f156':
  Convert all selinux_android_restorecon and _setfilecon calls to new API.
2014-02-12 23:19:02 +00:00
Stephen Smalley
5093e6187d Convert all selinux_android_restorecon and _setfilecon calls to new API.
libselinux selinux_android_restorecon API is changing to the more
general interface with flags and dropping the older variants.

Also get rid of the old, no longer used selinux_android_setfilecon API
and rename selinux_android_setfilecon2 to it as it is the only API in use.

Change-Id: I1e71ec398ccdc24cac4ec76f1b858d0f680f4925
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2014-02-12 09:43:08 -05:00
Nick Kralevich
ca3593df3d am 311edc8c: Merge "Add SELinux restorecon calls on ASEC containers."
* commit '311edc8cb2dd5c86bad49f9696333874b400f9c4':
  Add SELinux restorecon calls on ASEC containers.
2014-02-11 17:20:39 +00:00
Nick Kralevich
311edc8cb2 Merge "Add SELinux restorecon calls on ASEC containers." 2014-02-11 17:13:46 +00:00
Colin Cross
e985c9ab10 am 1d8e3ce8: Merge "vold: fix errors inside ALOGV"
* commit '1d8e3ce8da962e5ff98d36e75f6b02873fdddb70':
  vold: fix errors inside ALOGV
2014-02-07 21:31:53 +00:00
Colin Cross
59846b654e vold: fix errors inside ALOGV
Fix errors exposed by adding compile-time checking to disabled ALOGVs.

Change-Id: I29bd6e9a7648ccca02e0e9a96b79ee0ea7b5cfc6
2014-02-06 20:34:29 -08:00
Robert Craig
b9e3ba56cb Add SELinux restorecon calls on ASEC containers.
This will allow fine-grained labeling of the
contents of ASEC containers. Some of the contents
need to be world readable and thus should be
distinguishable in policy.

Change-Id: Iefee74214d664acd262edecbb4f981d633ff96ce
Signed-off-by: rpcraig <rpcraig@tycho.ncsc.mil>
2014-02-06 07:10:43 -05:00
Nick Kralevich
e8e1d80c64 am 4d5d99ce: am 7cf05b15: am 2f0a1d66: am 7f6932df: am 35ab6119: am 3e03bf8a: am fd2dcf90: am f4770dcf: am 0de7c611: Validate asec names.
* commit '4d5d99ce39b5edd0b78c47a93563aed6b3d56356':
  Validate asec names.
2014-01-28 14:11:06 +00:00
Nick Kralevich
4d5d99ce39 am 7cf05b15: am 2f0a1d66: am 7f6932df: am 35ab6119: am 3e03bf8a: am fd2dcf90: am f4770dcf: am 0de7c611: Validate asec names.
* commit '7cf05b15b76b91aa07182e86a730d7552b23130c':
  Validate asec names.
2014-01-28 14:06:00 +00:00
Nick Kralevich
7f6932df89 am 35ab6119: am 3e03bf8a: am fd2dcf90: am f4770dcf: am 0de7c611: Validate asec names.
* commit '35ab611925aea29fc4088b5c3de7c8c77d956b8b':
  Validate asec names.
2014-01-27 19:25:27 -08:00
Nick Kralevich
fd2dcf905a am f4770dcf: am 0de7c611: Validate asec names.
* commit 'f4770dcf6ffe2baba16cbb290aba16f735c51962':
  Validate asec names.
2014-01-27 19:17:13 -08:00
Nick Kralevich
0de7c61102 Validate asec names.
Make sure asec names only contain alphanumeric, underscores,
dots, or dashes. Don't allow double dots.

Bug: 12504045

(cherry picked from commit 6696260965)

Change-Id: Ia9d04f373aa95878b2e81584c4167dc2d4aa0c78
2014-01-27 15:21:17 -08:00
Colin Cross
346c5b20cb vold: fix warnings for 64-bit
Replace MINOR(dev_t) and MAJOR(dev_t) with minor and major,
which cast to int.
Cast int to uintptr_t before casting to pointer

Change-Id: I59375518f15d27f400fcd4f8a8dfe5ebdd8350e6
2014-01-24 10:42:27 -08:00
Jeff Sharkey
8c2c15b1c6 Clean up ASEC unmounting on physical storage.
When physical devices are unsafely removed, unmountAllAsecsInDir()
fails to find any ASECs, and leaves them all mounted, preventing the
rest of volume from going down.

Now we examine all ASEC containers, and remove when on external
storage, or when the storage media is no longer found.

Bug: 11175082
Change-Id: Iffa38ea43f7e5ad78b598374ebeb60a8727d99fd
2013-10-17 15:30:30 -07:00
Marco Nelissen
5ab02e787a DO NOT MERGE. Fix crash in vold
b/11239345

Change-Id: I46a8d6b38e3c093e20e1e5c4f01efc13d1960ad4
2013-10-16 10:52:29 -07:00
Jeff Sharkey
ba6ae8db13 Add support for more expressive SD card permissions
We now run an sdcard fuse daemon on top of a physical SD card.
Add support for that.

Bug: 10330128

Change-Id: I6a291f861ccb0f2911c07cc8f659e2cec4e6d76c
2013-10-08 10:13:04 -07:00
Jeff Sharkey
71ebe154a5 Add mkdirs() command.
Apps without sdcard_r or sdcard_rw need to have someone create
package-specific directories on their behalf.  If apps have trouble
creating on their own, they now delegate through system to have
vold create the paths.

Requires that the requested path is actually managed by vold.

Bug: 10577808
Change-Id: I6835fc8f52240f9de07f89742a426a153e3ca32a
2013-09-20 14:29:59 -07:00
Ken Sumrall
9caab76c6b vold: Add an optional wipe paramter to the volume format command
The new wipe option to the vold format command will invoke BLKDISCARD
on the partition before invoking newfs_msdos.  This will be used whenever
a full wipe of the device is wanted, as this is more secure than just
doing newfs_msdos.

Bug: 9392982
Change-Id: Ie106f1b9cc70abc61206006d1821641c27c7ccae
2013-06-12 18:42:02 -07:00
Elliott Hughes
29e55ef83d am edf4e179: Merge "Fix vold\'s use of readdir_r(3)."
* commit 'edf4e17940c6d3887e9009b23ffca5be8116fbe9':
  Fix vold's use of readdir_r(3).
2012-10-29 17:15:00 -07:00
Elliott Hughes
8c480f73ee Fix vold's use of readdir_r(3).
Change-Id: I805a1799755429dd1f6f3bdc2e6a02f483587b35
2012-10-26 16:57:19 -07:00
Nick Kralevich
2e0d70f98d am 678d556f: Merge "Add snprintf truncation and output error checks."
* commit '678d556f439cae504c343c15d77e9ec020a9385c':
  Add snprintf truncation and output error checks.
2012-10-19 11:09:59 -07:00
rpcraig
d1c226fce3 Add snprintf truncation and output error checks.
Change-Id: If7fc9bba4b6cd4b01d2c19e967105ffc57169e97
Signed-off-by: rpcraig <rpcraig@tycho.ncsc.mil>
2012-10-19 05:56:00 -04:00
Kenny Root
bb67b67cc7 am fd5b29be: Merge "Extend vold support for creating ext4 images."
* commit 'fd5b29be8c572058ed9ab0198f5603e96c585d3c':
  Extend vold support for creating ext4 images.
2012-10-17 12:58:57 -07:00
Kenny Root
fd5b29be8c Merge "Extend vold support for creating ext4 images." 2012-10-17 11:53:41 -07:00
Jeff Sharkey
6947904a76 Handle multi-user mountObb() requests.
Mount OBB containers using shared app GID, so that an app can read
the mount point across users.

Bug: 7212801
Change-Id: Ia1be52df9854c259b20728111f3a2c9facf4beaa
2012-09-25 16:14:57 -07:00
rpcraig
a54e13a3dc Extend vold support for creating ext4 images.
Augment the Ext4::format function to take
a mountpoint parameter. This will then
be passed to make_ext4fs through the
-a option to allow proper security labeling.

Change-Id: Ic26703406a2c463c12e32c8103a0c75c727b7d29
2012-09-21 15:44:55 -04:00
Kenny Root
eacf7e03d6 Only cleanup ASECs in external storage DO NOT MERGE
Any ASEC or OBB files were unmounted when USB storage was set to UMS
mode. This changes it so only ASEC files on external storage and OBB
files mounted from external storage are unmounted.

(Cherry-pick of 93ecb38dad)

Bug: 6948035
Change-Id: Ib60727bd360caa32173797ff5b4e1e21fcf20054
2012-08-13 09:49:55 -07:00
Kenny Root
93ecb38dad Only cleanup ASECs in external storage
Any ASEC or OBB files were unmounted when USB storage was set to UMS
mode. This changes it so only ASEC files on external storage and OBB
files mounted from external storage are unmounted.

Bug: 6948035
Change-Id: I91bc09ee5b792970b0eef895f6886f3ffad00e8f
2012-08-09 15:50:58 -07:00
Ken Sumrall
425524dba1 Unmount all asec apps before encrypting
Now that forward locked apps are stored on /data as asec image files
that are mounted, they need to be unmounted before /data can be unmounted
so it can be encrypted.

Change-Id: I7c87deb52aaed21c8ad8ce8aceb7c15c2338620a
2012-06-15 14:46:53 -07:00
Kenny Root
418367112c Merge "Sleep to wait for dm to create node" into jb-dev 2012-05-10 23:30:35 -07:00
Kenny Root
cdc2a1c835 Sleep to wait for dm to create node
There appears to be a race condition from when the device mapper is
asked to create a device and when it actually appears. When we moved
ASECs to use Ext4, mount started winning the race more often.

Just insert a sleep-retry loop here to counter-act this race. We should
ideally look at the uevent replies, but it takes a bit more effort to
separate them out.

Change-Id: Ie8a5b36b1c9a26f2320a178d37312059d03a1281
2012-05-10 17:27:30 -07:00
Kenny Root
1a673c868c Native library loading needs to read directory
When calling System.loadLibrary(), it needs to be able to read the
directory to load the file. We could probably fix that, but changing
permissions here is faster.

Bug: 6478606
Change-Id: I296b0805839da5a19950157f9a16755a4d258ca8
2012-05-10 16:47:24 -07:00
Kenny Root
348c8aba0d Only set permissions on dirs or files
Traversal would mark directories with the correct permissions, but
they're visited again in post-order which is a different fts_info flag.
Then it would set that to regular file permissions.

Explicitly check to make sure we're looking at a file instead.

Bug: 6478606
Change-Id: I13cab3e69f451da6a994fa974d575ef366f82025
2012-05-10 15:41:16 -07:00
Kenny Root
344ca10856 Add in ext4 support for ASEC containers
Now forward locked applications will be in ASEC containers both internal
to the system and externally.

This change adds support for putting applications in ext4-based ASECs.

Change-Id: I8d6765b72dd2606e429c067b47a2dbcaa8bef37d
2012-04-25 14:15:15 -07:00
Ken Sumrall
0b8b597193 Add the ability to revert a crypto mapping when unmounting a volume
Add the force_and_revert option to the unmount command which will force
the unmount, and revert a crypto mapping.  This is used during factory
reset so that when the internal sdcard volume is formatted, it formats
the raw device, not the encrypted mapping.

Change-Id: I36b6ff9bb54863b121de635472a303bf4a2334a9
2011-08-31 18:09:35 -07:00
Ken Sumrall
3b17005083 Prevent sharing or formatting of a vold managed volumes during encryption.
Mounting was already not allowed, but also unshare before starting
encryption, and don't allow sharing or formatting to be initiated
during encrytion.

Change-Id: Ida188d81f025739ba4dd90492b3e66088735991e
2011-07-11 15:38:57 -07:00
Dianne Hackborn
736910ca99 Add new vold call to get the path to an asec fs.
Change-Id: Ife15628ed6e2493c9e85a2ade6d59a194fdddde5
2011-06-27 13:37:28 -07:00
Mike Lockwood
97f2fc110b Update path for seting USB mass storage backing store
Change-Id: I0e5fab1624e5ef5d2f55e2584d8adc1b6bab91b0
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-17 23:57:12 -04:00
Mike Lockwood
6b715592ec Merge "Remove obsolete code for monitoring USB status" 2011-06-17 20:55:07 -07:00
Ken Sumrall
319b1043bb Don't abort the encryption process if an internal volume is present but unmounted.
It is not a failure if the SD card is not mounted.

Change-Id: If954f77c55ac124b9b7b39c89ffbafb4e5ea9e98
2011-06-14 14:01:55 -07:00
Mike Lockwood
a976656ff9 Remove obsolete code for monitoring USB status
Change-Id: I8ac8900b3135f03b7717540b825ff6df76f31c0b
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-07 08:34:08 -07:00
Ken Sumrall
29d8da8cef vold: allow to store key in a file on another partition
Add support for keeping the keys in a separate file on another partition,
for devices with no space reserved for a footer after the userdata filesystem.

Add support for encrypting the volumes managed by vold, if they meet certain
criteria, namely being marked as nonremovable and encryptable in vold.fstab.
A bit of trickiness is required to keep vold happy.

Change-Id: Idf0611f74b56c1026c45742ca82e0c26e58828fe
2011-06-02 16:30:14 -07:00
Mike Lockwood
3c9a73f643 Stifle "Ignoring unknown switch" logging
Change-Id: I9770ab880f379e2f7f6a93d3c84990edec60a116
Signed-off-by: Mike Lockwood <lockwood@android.com>
2010-12-10 15:07:14 -08:00