From 2dd66f4962436fe0f90790278a15c5ce88e85ff0 Mon Sep 17 00:00:00 2001 From: nijel8 Date: Sat, 18 Feb 2017 21:15:41 -0500 Subject: cryptfs: Fix encryption issue due to stack corruption. Ioctl BLKGETSIZE expects pointer to unsigned long as argument. On 64bit target using pointer to unsigned int can cause stack corruption due to type mismatch. props to https://github.com/aopp/android_system_vold/commit/f8b8787317fc94439b63bc891eeda83f7ae2f4f6 Change-Id: I1d76c65e29479c8f0cd44b6892069b21b8249b95 --- crypto/lollipop/cryptfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto/lollipop/cryptfs.c b/crypto/lollipop/cryptfs.c index 986507e22..f0822063e 100644 --- a/crypto/lollipop/cryptfs.c +++ b/crypto/lollipop/cryptfs.c @@ -713,13 +713,13 @@ static void get_device_scrypt_params(struct crypt_mnt_ftr *ftr) { static unsigned int get_blkdev_size(int fd) { - unsigned int nr_sec; + unsigned long nr_sec; if ( (ioctl(fd, BLKGETSIZE, &nr_sec)) == -1) { nr_sec = 0; } - return nr_sec; + return (unsigned int) nr_sec; } static int get_crypt_ftr_info(char **metadata_fname, off64_t *off) -- cgit v1.2.3