diff options
| author | Daniel Rosenberg <drosen@google.com> | 2017-04-24 16:11:03 -0700 |
|---|---|---|
| committer | Daniel Rosenberg <drosen@google.com> | 2017-04-26 16:56:27 -0700 |
| commit | 33fddbee41d511bd1f1946f3dd66351d6895c30f (patch) | |
| tree | a05f76b019156c7fcd1fdd96744d51e441915ff2 /fs/sdcardfs/multiuser.h | |
| parent | 46d925efcc72a2b52d404ad8a457a5bdc7c18b83 (diff) | |
ANDROID: sdcardfs: Avoid setting GIDs outside of valid ranges
When setting up the ownership of files on the lower filesystem,
ensure that these values are in reasonable ranges for apps. If
they aren't, default to AID_MEDIA_RW
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 37516160
Change-Id: I0bec76a61ac72aff0b993ab1ad04be8382178a00
Diffstat (limited to 'fs/sdcardfs/multiuser.h')
| -rw-r--r-- | fs/sdcardfs/multiuser.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/sdcardfs/multiuser.h b/fs/sdcardfs/multiuser.h index d0c925cda299..85341e753f8c 100644 --- a/fs/sdcardfs/multiuser.h +++ b/fs/sdcardfs/multiuser.h @@ -35,6 +35,13 @@ static inline uid_t multiuser_get_uid(userid_t user_id, appid_t app_id) return (user_id * AID_USER_OFFSET) + (app_id % AID_USER_OFFSET); } +static inline bool uid_is_app(uid_t uid) +{ + appid_t appid = uid % AID_USER_OFFSET; + + return appid >= AID_APP_START && appid <= AID_APP_END; +} + static inline gid_t multiuser_get_ext_cache_gid(uid_t uid) { return uid - AID_APP_START + AID_EXT_CACHE_GID_START; |
