From 0ade8c4105985bc911b252ccf9f5665139829cbb Mon Sep 17 00:00:00 2001 From: Mukesh Ojha Date: Thu, 22 Apr 2021 14:44:52 +0530 Subject: [PATCH 1/9] ANDROID: ABI: update allowed list for QCOM Update the android/abi_gki_aarch64_qcom with rtc_add_group addition. No need to update the .xml file, as it is already updated with rtc_add_group symbol. Bug: 185539583 Change-Id: I581bcf83a02a4114a9e7a22397fb52934ea0c52b Signed-off-by: Mukesh Ojha --- android/abi_gki_aarch64_qcom | 1 + 1 file changed, 1 insertion(+) diff --git a/android/abi_gki_aarch64_qcom b/android/abi_gki_aarch64_qcom index af413ee22491..930a3de22c5a 100644 --- a/android/abi_gki_aarch64_qcom +++ b/android/abi_gki_aarch64_qcom @@ -2022,6 +2022,7 @@ rpmsg_set_signals rpmsg_trysend rpmsg_unregister_device + rtc_add_group rtc_class_close rtc_class_open rtc_read_time From b6221e349592ef2fd7a1b78cb3cc64459e8dc9c2 Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Thu, 22 Apr 2021 13:19:19 -0700 Subject: [PATCH 2/9] Revert "ANDROID: Incremental fs: Fix selinux issues" This reverts commit 75c93eb4397b3fdbc7587e48fb8bb884775747c5. Reason for revert: rolling the three fixes into one with feature flag Bug: 174692664 Test: incfs_test passes Signed-off-by: Paul Lawrence Change-Id: I838bed85d6682aba44165a58c22e6a0e10c49d58 --- fs/incfs/vfs.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/fs/incfs/vfs.c b/fs/incfs/vfs.c index d7a750290953..915d8eb6f9b1 100644 --- a/fs/incfs/vfs.c +++ b/fs/incfs/vfs.c @@ -898,7 +898,7 @@ static int init_new_file(struct mount_info *mi, struct dentry *dentry, .dentry = dentry }; new_file = dentry_open(&path, O_RDWR | O_NOATIME | O_LARGEFILE, - current_cred()); + mi->mi_owner); if (IS_ERR(new_file)) { error = PTR_ERR(new_file); @@ -1026,7 +1026,7 @@ static int dir_relative_path_resolve( if (dir_fd < 0) return dir_fd; - dir_f = dentry_open(base_path, O_RDONLY | O_NOATIME, current_cred()); + dir_f = dentry_open(base_path, O_RDONLY | O_NOATIME, mi->mi_owner); if (IS_ERR(dir_f)) { error = PTR_ERR(dir_f); @@ -1904,13 +1904,10 @@ static int file_open(struct inode *inode, struct file *file) struct file *backing_file = NULL; struct path backing_path = {}; int err = 0; - const struct cred *old_cred; get_incfs_backing_path(file->f_path.dentry, &backing_path); - old_cred = override_creds(mi->mi_owner); - backing_file = dentry_open(&backing_path, - O_RDWR | O_NOATIME | O_LARGEFILE, current_cred()); - revert_creds(old_cred); + backing_file = dentry_open( + &backing_path, O_RDWR | O_NOATIME | O_LARGEFILE, mi->mi_owner); path_put(&backing_path); if (IS_ERR(backing_file)) { From dbee4e7bc4e0816a6d84bd22ab6b9a0fbf2a4ab1 Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Thu, 22 Apr 2021 13:19:30 -0700 Subject: [PATCH 3/9] Revert "ANDROID: Incremental fs: Set credentials before reading/writing" This reverts commit 28688d32ed31a11f85ab649f344add1d92b739a2. Reason for revert: rolling the three fixes into one with feature flag Bug: 174692664 Test: incfs_test passes Signed-off-by: Paul Lawrence Change-Id: I85cb75b7acb5606659698a6d0e0918ffb731009d --- fs/incfs/data_mgmt.c | 29 +++++++++++++++-------------- fs/incfs/format.c | 33 +++++++++++---------------------- fs/incfs/format.h | 17 +++-------------- fs/incfs/vfs.c | 2 +- 4 files changed, 30 insertions(+), 51 deletions(-) diff --git a/fs/incfs/data_mgmt.c b/fs/incfs/data_mgmt.c index e0705be44fb2..386e4ced8b34 100644 --- a/fs/incfs/data_mgmt.c +++ b/fs/incfs/data_mgmt.c @@ -144,7 +144,7 @@ struct data_file *incfs_open_data_file(struct mount_info *mi, struct file *bf) if (!S_ISREG(bf->f_inode->i_mode)) return ERR_PTR(-EBADF); - bfc = incfs_alloc_bfc(mi, bf); + bfc = incfs_alloc_bfc(bf); if (IS_ERR(bfc)) return ERR_CAST(bfc); @@ -388,8 +388,8 @@ static void log_block_read(struct mount_info *mi, incfs_uuid_t *id, schedule_delayed_work(&log->ml_wakeup_work, msecs_to_jiffies(16)); } -static int validate_hash_tree(struct backing_file_context *bfc, struct file *f, - int block_index, struct mem_range data, u8 *buf) +static int validate_hash_tree(struct file *bf, struct file *f, int block_index, + struct mem_range data, u8 *buf) { struct data_file *df = get_incfs_data_file(f); u8 stored_digest[INCFS_MAX_HASH_SIZE] = {}; @@ -446,7 +446,7 @@ static int validate_hash_tree(struct backing_file_context *bfc, struct file *f, if (page) put_page(page); - res = incfs_kread(bfc, buf, INCFS_DATA_FILE_BLOCK_SIZE, + res = incfs_kread(bf, buf, INCFS_DATA_FILE_BLOCK_SIZE, hash_block_offset[lvl] + sig->hash_offset); if (res < 0) return res; @@ -919,7 +919,7 @@ ssize_t incfs_read_data_file_block(struct mem_range dst, struct file *f, ssize_t result; size_t bytes_to_read; struct mount_info *mi = NULL; - struct backing_file_context *bfc = NULL; + struct file *bf = NULL; struct data_file_block block = {}; struct data_file *df = get_incfs_data_file(f); @@ -930,7 +930,7 @@ ssize_t incfs_read_data_file_block(struct mem_range dst, struct file *f, return -ERANGE; mi = df->df_mount_info; - bfc = df->df_backing_file_context; + bf = df->df_backing_file_context->bc_file; result = wait_for_data_block(df, index, timeout_ms, &block); if (result < 0) @@ -939,20 +939,20 @@ ssize_t incfs_read_data_file_block(struct mem_range dst, struct file *f, pos = block.db_backing_file_data_offset; if (block.db_comp_alg == COMPRESSION_NONE) { bytes_to_read = min(dst.len, block.db_stored_size); - result = incfs_kread(bfc, dst.data, bytes_to_read, pos); + result = incfs_kread(bf, dst.data, bytes_to_read, pos); /* Some data was read, but not enough */ if (result >= 0 && result != bytes_to_read) result = -EIO; } else { bytes_to_read = min(tmp.len, block.db_stored_size); - result = incfs_kread(bfc, tmp.data, bytes_to_read, pos); + result = incfs_kread(bf, tmp.data, bytes_to_read, pos); if (result == bytes_to_read) { result = decompress(range(tmp.data, bytes_to_read), dst); if (result < 0) { const char *name = - bfc->bc_file->f_path.dentry->d_name.name; + bf->f_path.dentry->d_name.name; pr_warn_once("incfs: Decompression error. %s", name); @@ -964,7 +964,7 @@ ssize_t incfs_read_data_file_block(struct mem_range dst, struct file *f, } if (result > 0) { - int err = validate_hash_tree(bfc, f, index, dst, tmp.data); + int err = validate_hash_tree(bf, f, index, dst, tmp.data); if (err < 0) result = err; @@ -1027,13 +1027,14 @@ int incfs_process_new_data_block(struct data_file *df, unlock: mutex_unlock(&segment->blockmap_mutex); if (error) - pr_debug("%d error: %d\n", block->block_index, error); + pr_debug("incfs: %s %d error: %d\n", __func__, + block->block_index, error); return error; } int incfs_read_file_signature(struct data_file *df, struct mem_range dst) { - struct backing_file_context *bfc = df->df_backing_file_context; + struct file *bf = df->df_backing_file_context->bc_file; struct incfs_df_signature *sig; int read_res = 0; @@ -1047,7 +1048,7 @@ int incfs_read_file_signature(struct data_file *df, struct mem_range dst) if (dst.len < sig->sig_size) return -E2BIG; - read_res = incfs_kread(bfc, dst.data, sig->sig_size, sig->sig_offset); + read_res = incfs_kread(bf, dst.data, sig->sig_size, sig->sig_offset); if (read_res < 0) return read_res; @@ -1173,7 +1174,7 @@ static int process_file_signature_md(struct incfs_file_signature *sg, goto out; } - read = incfs_kread(df->df_backing_file_context, buf, + read = incfs_kread(df->df_backing_file_context->bc_file, buf, signature->sig_size, signature->sig_offset); if (read < 0) { error = read; diff --git a/fs/incfs/format.c b/fs/incfs/format.c index 193cd8f23792..c56e559b6893 100644 --- a/fs/incfs/format.c +++ b/fs/incfs/format.c @@ -15,8 +15,7 @@ #include "format.h" #include "data_mgmt.h" -struct backing_file_context *incfs_alloc_bfc(struct mount_info *mi, - struct file *backing_file) +struct backing_file_context *incfs_alloc_bfc(struct file *backing_file) { struct backing_file_context *result = NULL; @@ -25,7 +24,6 @@ struct backing_file_context *incfs_alloc_bfc(struct mount_info *mi, return ERR_PTR(-ENOMEM); result->bc_file = get_file(backing_file); - result->bc_cred = mi->mi_owner; mutex_init(&result->bc_mutex); return result; } @@ -118,7 +116,7 @@ static int append_zeros(struct backing_file_context *bfc, size_t len) static int write_to_bf(struct backing_file_context *bfc, const void *buf, size_t count, loff_t pos) { - ssize_t res = incfs_kwrite(bfc, buf, count, pos); + ssize_t res = incfs_kwrite(bfc->bc_file, buf, count, pos); if (res < 0) return res; @@ -533,7 +531,8 @@ int incfs_read_blockmap_entries(struct backing_file_context *bfc, if (start_index < 0 || bm_base_off <= 0) return -ENODATA; - result = incfs_kread(bfc, entries, bytes_to_read, bm_entry_off); + result = incfs_kread(bfc->bc_file, entries, bytes_to_read, + bm_entry_off); if (result < 0) return result; return result / sizeof(*entries); @@ -550,7 +549,7 @@ int incfs_read_file_header(struct backing_file_context *bfc, return -EFAULT; LOCK_REQUIRED(bfc->bc_mutex); - bytes_read = incfs_kread(bfc, &fh, sizeof(fh), 0); + bytes_read = incfs_kread(bfc->bc_file, &fh, sizeof(fh), 0); if (bytes_read < 0) return bytes_read; @@ -604,8 +603,8 @@ int incfs_read_next_metadata_record(struct backing_file_context *bfc, return -EPERM; memset(&handler->md_buffer, 0, max_md_size); - bytes_read = incfs_kread(bfc, &handler->md_buffer, max_md_size, - handler->md_record_offset); + bytes_read = incfs_kread(bfc->bc_file, &handler->md_buffer, + max_md_size, handler->md_record_offset); if (bytes_read < 0) return bytes_read; if (bytes_read < sizeof(*md_hdr)) @@ -681,22 +680,12 @@ int incfs_read_next_metadata_record(struct backing_file_context *bfc, return res; } -ssize_t incfs_kread(struct backing_file_context *bfc, void *buf, size_t size, - loff_t pos) +ssize_t incfs_kread(struct file *f, void *buf, size_t size, loff_t pos) { - const struct cred *old_cred = override_creds(bfc->bc_cred); - int ret = kernel_read(bfc->bc_file, buf, size, &pos); - - revert_creds(old_cred); - return ret; + return kernel_read(f, buf, size, &pos); } -ssize_t incfs_kwrite(struct backing_file_context *bfc, const void *buf, - size_t size, loff_t pos) +ssize_t incfs_kwrite(struct file *f, const void *buf, size_t size, loff_t pos) { - const struct cred *old_cred = override_creds(bfc->bc_cred); - int ret = kernel_write(bfc->bc_file, buf, size, &pos); - - revert_creds(old_cred); - return ret; + return kernel_write(f, buf, size, &pos); } diff --git a/fs/incfs/format.h b/fs/incfs/format.h index a6d3aef6b358..1a83349bb2eb 100644 --- a/fs/incfs/format.h +++ b/fs/incfs/format.h @@ -256,13 +256,6 @@ struct backing_file_context { * 0 means there are no metadata records. */ loff_t bc_last_md_record_offset; - - /* - * Credentials to set before reads/writes - * Note that this is a pointer to the mount_info mi_owner field so - * there is no need to get/put the creds - */ - const struct cred *bc_cred; }; struct metadata_handler { @@ -290,9 +283,7 @@ struct metadata_handler { loff_t incfs_get_end_offset(struct file *f); /* Backing file context management */ -struct mount_info; -struct backing_file_context *incfs_alloc_bfc(struct mount_info *mi, - struct file *backing_file); +struct backing_file_context *incfs_alloc_bfc(struct file *backing_file); void incfs_free_bfc(struct backing_file_context *bfc); @@ -343,9 +334,7 @@ int incfs_read_blockmap_entries(struct backing_file_context *bfc, int incfs_read_next_metadata_record(struct backing_file_context *bfc, struct metadata_handler *handler); -ssize_t incfs_kread(struct backing_file_context *bfc, void *buf, size_t size, - loff_t pos); -ssize_t incfs_kwrite(struct backing_file_context *bfc, const void *buf, - size_t size, loff_t pos); +ssize_t incfs_kread(struct file *f, void *buf, size_t size, loff_t pos); +ssize_t incfs_kwrite(struct file *f, const void *buf, size_t size, loff_t pos); #endif /* _INCFS_FORMAT_H */ diff --git a/fs/incfs/vfs.c b/fs/incfs/vfs.c index 915d8eb6f9b1..582448ccdaef 100644 --- a/fs/incfs/vfs.c +++ b/fs/incfs/vfs.c @@ -905,7 +905,7 @@ static int init_new_file(struct mount_info *mi, struct dentry *dentry, goto out; } - bfc = incfs_alloc_bfc(mi, new_file); + bfc = incfs_alloc_bfc(new_file); fput(new_file); if (IS_ERR(bfc)) { error = PTR_ERR(bfc); From a035201d12cbb16c17cd94e86d43802c47dc11f2 Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Thu, 22 Apr 2021 13:19:39 -0700 Subject: [PATCH 4/9] Revert "ANDROID: Incremental fs: Fix memory leak on closing file" This reverts commit 152fd8f04491a5ccf26c1f1adfb1b228b3082d2c. Reason for revert: rolling the three fixes into one with feature flag Bug: 174692664 Test: incfs_test passes Signed-off-by: Paul Lawrence Change-Id: I9a2e6faa0c2293b691efca8e985390fd94bcf01a --- fs/incfs/data_mgmt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/incfs/data_mgmt.c b/fs/incfs/data_mgmt.c index 386e4ced8b34..074a733c7001 100644 --- a/fs/incfs/data_mgmt.c +++ b/fs/incfs/data_mgmt.c @@ -199,7 +199,6 @@ void incfs_free_data_file(struct data_file *df) for (i = 0; i < ARRAY_SIZE(df->df_segments); i++) data_file_segment_destroy(&df->df_segments[i]); incfs_free_bfc(df->df_backing_file_context); - kfree(df->df_signature); kfree(df); } From fad2655cb7287ba2c5ed5f344a8cfa66bb9f52f7 Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Wed, 3 Feb 2021 10:33:05 -0800 Subject: [PATCH 5/9] ANDROID: Incremental fs: Set credentials before reading/writing Use same selinux scheme as incfs v2 Fix memory leak Bug: 174692664 Test: incfs_test passes Signed-off-by: Paul Lawrence Change-Id: I6058ddad9d43ba01b2eabd7d3c576f2cc9b42292 --- fs/incfs/data_mgmt.c | 30 +++++++++++++++--------------- fs/incfs/format.c | 34 ++++++++++++++++++++++------------ fs/incfs/format.h | 17 ++++++++++++++--- fs/incfs/main.c | 10 ++++++++++ fs/incfs/vfs.c | 13 ++++++++----- 5 files changed, 69 insertions(+), 35 deletions(-) diff --git a/fs/incfs/data_mgmt.c b/fs/incfs/data_mgmt.c index 074a733c7001..e0705be44fb2 100644 --- a/fs/incfs/data_mgmt.c +++ b/fs/incfs/data_mgmt.c @@ -144,7 +144,7 @@ struct data_file *incfs_open_data_file(struct mount_info *mi, struct file *bf) if (!S_ISREG(bf->f_inode->i_mode)) return ERR_PTR(-EBADF); - bfc = incfs_alloc_bfc(bf); + bfc = incfs_alloc_bfc(mi, bf); if (IS_ERR(bfc)) return ERR_CAST(bfc); @@ -199,6 +199,7 @@ void incfs_free_data_file(struct data_file *df) for (i = 0; i < ARRAY_SIZE(df->df_segments); i++) data_file_segment_destroy(&df->df_segments[i]); incfs_free_bfc(df->df_backing_file_context); + kfree(df->df_signature); kfree(df); } @@ -387,8 +388,8 @@ static void log_block_read(struct mount_info *mi, incfs_uuid_t *id, schedule_delayed_work(&log->ml_wakeup_work, msecs_to_jiffies(16)); } -static int validate_hash_tree(struct file *bf, struct file *f, int block_index, - struct mem_range data, u8 *buf) +static int validate_hash_tree(struct backing_file_context *bfc, struct file *f, + int block_index, struct mem_range data, u8 *buf) { struct data_file *df = get_incfs_data_file(f); u8 stored_digest[INCFS_MAX_HASH_SIZE] = {}; @@ -445,7 +446,7 @@ static int validate_hash_tree(struct file *bf, struct file *f, int block_index, if (page) put_page(page); - res = incfs_kread(bf, buf, INCFS_DATA_FILE_BLOCK_SIZE, + res = incfs_kread(bfc, buf, INCFS_DATA_FILE_BLOCK_SIZE, hash_block_offset[lvl] + sig->hash_offset); if (res < 0) return res; @@ -918,7 +919,7 @@ ssize_t incfs_read_data_file_block(struct mem_range dst, struct file *f, ssize_t result; size_t bytes_to_read; struct mount_info *mi = NULL; - struct file *bf = NULL; + struct backing_file_context *bfc = NULL; struct data_file_block block = {}; struct data_file *df = get_incfs_data_file(f); @@ -929,7 +930,7 @@ ssize_t incfs_read_data_file_block(struct mem_range dst, struct file *f, return -ERANGE; mi = df->df_mount_info; - bf = df->df_backing_file_context->bc_file; + bfc = df->df_backing_file_context; result = wait_for_data_block(df, index, timeout_ms, &block); if (result < 0) @@ -938,20 +939,20 @@ ssize_t incfs_read_data_file_block(struct mem_range dst, struct file *f, pos = block.db_backing_file_data_offset; if (block.db_comp_alg == COMPRESSION_NONE) { bytes_to_read = min(dst.len, block.db_stored_size); - result = incfs_kread(bf, dst.data, bytes_to_read, pos); + result = incfs_kread(bfc, dst.data, bytes_to_read, pos); /* Some data was read, but not enough */ if (result >= 0 && result != bytes_to_read) result = -EIO; } else { bytes_to_read = min(tmp.len, block.db_stored_size); - result = incfs_kread(bf, tmp.data, bytes_to_read, pos); + result = incfs_kread(bfc, tmp.data, bytes_to_read, pos); if (result == bytes_to_read) { result = decompress(range(tmp.data, bytes_to_read), dst); if (result < 0) { const char *name = - bf->f_path.dentry->d_name.name; + bfc->bc_file->f_path.dentry->d_name.name; pr_warn_once("incfs: Decompression error. %s", name); @@ -963,7 +964,7 @@ ssize_t incfs_read_data_file_block(struct mem_range dst, struct file *f, } if (result > 0) { - int err = validate_hash_tree(bf, f, index, dst, tmp.data); + int err = validate_hash_tree(bfc, f, index, dst, tmp.data); if (err < 0) result = err; @@ -1026,14 +1027,13 @@ int incfs_process_new_data_block(struct data_file *df, unlock: mutex_unlock(&segment->blockmap_mutex); if (error) - pr_debug("incfs: %s %d error: %d\n", __func__, - block->block_index, error); + pr_debug("%d error: %d\n", block->block_index, error); return error; } int incfs_read_file_signature(struct data_file *df, struct mem_range dst) { - struct file *bf = df->df_backing_file_context->bc_file; + struct backing_file_context *bfc = df->df_backing_file_context; struct incfs_df_signature *sig; int read_res = 0; @@ -1047,7 +1047,7 @@ int incfs_read_file_signature(struct data_file *df, struct mem_range dst) if (dst.len < sig->sig_size) return -E2BIG; - read_res = incfs_kread(bf, dst.data, sig->sig_size, sig->sig_offset); + read_res = incfs_kread(bfc, dst.data, sig->sig_size, sig->sig_offset); if (read_res < 0) return read_res; @@ -1173,7 +1173,7 @@ static int process_file_signature_md(struct incfs_file_signature *sg, goto out; } - read = incfs_kread(df->df_backing_file_context->bc_file, buf, + read = incfs_kread(df->df_backing_file_context, buf, signature->sig_size, signature->sig_offset); if (read < 0) { error = read; diff --git a/fs/incfs/format.c b/fs/incfs/format.c index c56e559b6893..d326415fc6de 100644 --- a/fs/incfs/format.c +++ b/fs/incfs/format.c @@ -15,7 +15,8 @@ #include "format.h" #include "data_mgmt.h" -struct backing_file_context *incfs_alloc_bfc(struct file *backing_file) +struct backing_file_context *incfs_alloc_bfc(struct mount_info *mi, + struct file *backing_file) { struct backing_file_context *result = NULL; @@ -24,6 +25,7 @@ struct backing_file_context *incfs_alloc_bfc(struct file *backing_file) return ERR_PTR(-ENOMEM); result->bc_file = get_file(backing_file); + result->bc_cred = mi->mi_owner; mutex_init(&result->bc_mutex); return result; } @@ -116,7 +118,7 @@ static int append_zeros(struct backing_file_context *bfc, size_t len) static int write_to_bf(struct backing_file_context *bfc, const void *buf, size_t count, loff_t pos) { - ssize_t res = incfs_kwrite(bfc->bc_file, buf, count, pos); + ssize_t res = incfs_kwrite(bfc, buf, count, pos); if (res < 0) return res; @@ -531,8 +533,7 @@ int incfs_read_blockmap_entries(struct backing_file_context *bfc, if (start_index < 0 || bm_base_off <= 0) return -ENODATA; - result = incfs_kread(bfc->bc_file, entries, bytes_to_read, - bm_entry_off); + result = incfs_kread(bfc, entries, bytes_to_read, bm_entry_off); if (result < 0) return result; return result / sizeof(*entries); @@ -548,8 +549,7 @@ int incfs_read_file_header(struct backing_file_context *bfc, if (!bfc || !first_md_off) return -EFAULT; - LOCK_REQUIRED(bfc->bc_mutex); - bytes_read = incfs_kread(bfc->bc_file, &fh, sizeof(fh), 0); + bytes_read = incfs_kread(bfc, &fh, sizeof(fh), 0); if (bytes_read < 0) return bytes_read; @@ -603,8 +603,8 @@ int incfs_read_next_metadata_record(struct backing_file_context *bfc, return -EPERM; memset(&handler->md_buffer, 0, max_md_size); - bytes_read = incfs_kread(bfc->bc_file, &handler->md_buffer, - max_md_size, handler->md_record_offset); + bytes_read = incfs_kread(bfc, &handler->md_buffer, max_md_size, + handler->md_record_offset); if (bytes_read < 0) return bytes_read; if (bytes_read < sizeof(*md_hdr)) @@ -680,12 +680,22 @@ int incfs_read_next_metadata_record(struct backing_file_context *bfc, return res; } -ssize_t incfs_kread(struct file *f, void *buf, size_t size, loff_t pos) +ssize_t incfs_kread(struct backing_file_context *bfc, void *buf, size_t size, + loff_t pos) { - return kernel_read(f, buf, size, &pos); + const struct cred *old_cred = override_creds(bfc->bc_cred); + int ret = kernel_read(bfc->bc_file, buf, size, &pos); + + revert_creds(old_cred); + return ret; } -ssize_t incfs_kwrite(struct file *f, const void *buf, size_t size, loff_t pos) +ssize_t incfs_kwrite(struct backing_file_context *bfc, const void *buf, + size_t size, loff_t pos) { - return kernel_write(f, buf, size, &pos); + const struct cred *old_cred = override_creds(bfc->bc_cred); + int ret = kernel_write(bfc->bc_file, buf, size, &pos); + + revert_creds(old_cred); + return ret; } diff --git a/fs/incfs/format.h b/fs/incfs/format.h index 1a83349bb2eb..a6d3aef6b358 100644 --- a/fs/incfs/format.h +++ b/fs/incfs/format.h @@ -256,6 +256,13 @@ struct backing_file_context { * 0 means there are no metadata records. */ loff_t bc_last_md_record_offset; + + /* + * Credentials to set before reads/writes + * Note that this is a pointer to the mount_info mi_owner field so + * there is no need to get/put the creds + */ + const struct cred *bc_cred; }; struct metadata_handler { @@ -283,7 +290,9 @@ struct metadata_handler { loff_t incfs_get_end_offset(struct file *f); /* Backing file context management */ -struct backing_file_context *incfs_alloc_bfc(struct file *backing_file); +struct mount_info; +struct backing_file_context *incfs_alloc_bfc(struct mount_info *mi, + struct file *backing_file); void incfs_free_bfc(struct backing_file_context *bfc); @@ -334,7 +343,9 @@ int incfs_read_blockmap_entries(struct backing_file_context *bfc, int incfs_read_next_metadata_record(struct backing_file_context *bfc, struct metadata_handler *handler); -ssize_t incfs_kread(struct file *f, void *buf, size_t size, loff_t pos); -ssize_t incfs_kwrite(struct file *f, const void *buf, size_t size, loff_t pos); +ssize_t incfs_kread(struct backing_file_context *bfc, void *buf, size_t size, + loff_t pos); +ssize_t incfs_kwrite(struct backing_file_context *bfc, const void *buf, + size_t size, loff_t pos); #endif /* _INCFS_FORMAT_H */ diff --git a/fs/incfs/main.c b/fs/incfs/main.c index 7c4ec4fa13d8..0fde230d5337 100644 --- a/fs/incfs/main.c +++ b/fs/incfs/main.c @@ -30,8 +30,18 @@ static ssize_t corefs_show(struct kobject *kobj, static struct kobj_attribute corefs_attr = __ATTR_RO(corefs); +static ssize_t mounter_context_for_backing_rw_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buff) +{ + return snprintf(buff, PAGE_SIZE, "supported\n"); +} + +static struct kobj_attribute mounter_context_for_backing_rw_attr = + __ATTR_RO(mounter_context_for_backing_rw); + static struct attribute *attributes[] = { &corefs_attr.attr, + &mounter_context_for_backing_rw_attr.attr, NULL, }; diff --git a/fs/incfs/vfs.c b/fs/incfs/vfs.c index 582448ccdaef..d7a750290953 100644 --- a/fs/incfs/vfs.c +++ b/fs/incfs/vfs.c @@ -898,14 +898,14 @@ static int init_new_file(struct mount_info *mi, struct dentry *dentry, .dentry = dentry }; new_file = dentry_open(&path, O_RDWR | O_NOATIME | O_LARGEFILE, - mi->mi_owner); + current_cred()); if (IS_ERR(new_file)) { error = PTR_ERR(new_file); goto out; } - bfc = incfs_alloc_bfc(new_file); + bfc = incfs_alloc_bfc(mi, new_file); fput(new_file); if (IS_ERR(bfc)) { error = PTR_ERR(bfc); @@ -1026,7 +1026,7 @@ static int dir_relative_path_resolve( if (dir_fd < 0) return dir_fd; - dir_f = dentry_open(base_path, O_RDONLY | O_NOATIME, mi->mi_owner); + dir_f = dentry_open(base_path, O_RDONLY | O_NOATIME, current_cred()); if (IS_ERR(dir_f)) { error = PTR_ERR(dir_f); @@ -1904,10 +1904,13 @@ static int file_open(struct inode *inode, struct file *file) struct file *backing_file = NULL; struct path backing_path = {}; int err = 0; + const struct cred *old_cred; get_incfs_backing_path(file->f_path.dentry, &backing_path); - backing_file = dentry_open( - &backing_path, O_RDWR | O_NOATIME | O_LARGEFILE, mi->mi_owner); + old_cred = override_creds(mi->mi_owner); + backing_file = dentry_open(&backing_path, + O_RDWR | O_NOATIME | O_LARGEFILE, current_cred()); + revert_creds(old_cred); path_put(&backing_path); if (IS_ERR(backing_file)) { From dd2e0a80f1bea3d0ac99df4b3256682e4324df5f Mon Sep 17 00:00:00 2001 From: Jilai Wang Date: Fri, 23 Apr 2021 16:55:03 -0400 Subject: [PATCH 6/9] ANDROID: ABI: Update allowed list for QCOM Add the following symbols to QCOM allowed-list: -- bitmap_release_region -- bitmap_find_free_region Bug: 186222705 Change-Id: I6dc24587c6e7db35ecac16e6e68d889f79e7dae6 Signed-off-by: Jilai Wang --- android/abi_gki_aarch64.xml | 1140 +++++++++++++++++----------------- android/abi_gki_aarch64_qcom | 2 + 2 files changed, 572 insertions(+), 570 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index c3d6fb4f3c40..c8cf7150a78c 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -8154,7 +8154,7 @@ - + @@ -11062,7 +11062,7 @@ - + @@ -20411,7 +20411,7 @@ - + @@ -23284,7 +23284,7 @@ - + @@ -23303,7 +23303,7 @@ - + @@ -23580,7 +23580,7 @@ - + @@ -23648,7 +23648,7 @@ - + @@ -23656,7 +23656,7 @@ - + @@ -25859,7 +25859,7 @@ - + @@ -26238,7 +26238,7 @@ - + @@ -26262,7 +26262,7 @@ - + @@ -26270,7 +26270,7 @@ - + @@ -26289,7 +26289,7 @@ - + @@ -26305,7 +26305,7 @@ - + @@ -26332,7 +26332,7 @@ - + @@ -26343,7 +26343,7 @@ - + @@ -28161,7 +28161,7 @@ - + @@ -28169,7 +28169,7 @@ - + @@ -28214,7 +28214,7 @@ - + @@ -28563,7 +28563,7 @@ - + @@ -30967,7 +30967,7 @@ - + @@ -31207,7 +31207,7 @@ - + @@ -31215,7 +31215,7 @@ - + @@ -31223,7 +31223,7 @@ - + @@ -31953,7 +31953,7 @@ - + @@ -32503,7 +32503,7 @@ - + @@ -32765,7 +32765,7 @@ - + @@ -51512,44 +51512,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -51850,6 +51812,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -108282,7 +108282,7 @@ - + @@ -108656,7 +108656,7 @@ - + @@ -108664,7 +108664,7 @@ - + @@ -108672,7 +108672,7 @@ - + @@ -108680,12 +108680,12 @@ - + - + @@ -111863,7 +111863,7 @@ - + @@ -111872,7 +111872,7 @@ - + @@ -111880,7 +111880,7 @@ - + @@ -111888,7 +111888,7 @@ - + @@ -111897,7 +111897,7 @@ - + @@ -111905,7 +111905,7 @@ - + @@ -112185,7 +112185,7 @@ - + @@ -112207,7 +112207,7 @@ - + @@ -112218,7 +112218,7 @@ - + @@ -112226,7 +112226,7 @@ - + @@ -112237,7 +112237,7 @@ - + @@ -112249,7 +112249,7 @@ - + @@ -112260,7 +112260,7 @@ - + @@ -112509,7 +112509,7 @@ - + @@ -112539,7 +112539,7 @@ - + @@ -112547,7 +112547,7 @@ - + @@ -112699,7 +112699,7 @@ - + @@ -112975,7 +112975,7 @@ - + @@ -113020,7 +113020,7 @@ - + @@ -113227,7 +113227,7 @@ - + @@ -113316,7 +113316,7 @@ - + @@ -113324,7 +113324,7 @@ - + @@ -113332,7 +113332,7 @@ - + @@ -113340,7 +113340,7 @@ - + @@ -113410,7 +113410,205 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -113598,7 +113796,7 @@ - + @@ -113677,7 +113875,7 @@ - + @@ -113726,7 +113924,7 @@ - + @@ -113902,204 +114100,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -114215,7 +114215,7 @@ - + @@ -114226,7 +114226,7 @@ - + @@ -114234,7 +114234,7 @@ - + @@ -114684,7 +114684,7 @@ - + @@ -165761,9 +165761,209 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -165899,7 +166099,18 @@ + + + + + + + + + + + @@ -166088,6 +166299,13 @@ + + + + + + + @@ -166095,6 +166313,10 @@ + + + + @@ -167614,7 +167836,7 @@ - + @@ -167622,7 +167844,7 @@ - + @@ -167630,7 +167852,7 @@ - + @@ -170267,7 +170489,7 @@ - + @@ -175900,9 +176122,15 @@ + + + + + + @@ -175956,7 +176184,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -176164,12 +176427,6 @@ - - - - - - @@ -176240,7 +176497,7 @@ - + @@ -176324,38 +176581,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -176370,7 +176595,7 @@ - + @@ -176432,9 +176657,6 @@ - - - @@ -177012,218 +177234,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -177307,17 +177318,6 @@ - - - - - - - - - - - diff --git a/android/abi_gki_aarch64_qcom b/android/abi_gki_aarch64_qcom index 930a3de22c5a..d706370b2b5c 100644 --- a/android/abi_gki_aarch64_qcom +++ b/android/abi_gki_aarch64_qcom @@ -45,10 +45,12 @@ backlight_device_unregister bin2hex __bitmap_clear + bitmap_find_free_region bitmap_find_next_zero_area_off bitmap_free bitmap_parselist bitmap_print_to_pagebuf + bitmap_release_region __bitmap_set __bitmap_subset bitmap_zalloc From ff320df3e0e9915797a3e762f1cbfc0b034c1a9b Mon Sep 17 00:00:00 2001 From: Giuliano Procida Date: Thu, 22 Apr 2021 14:31:03 +0100 Subject: [PATCH 7/9] ANDROID: power: export pm_system_cancel_wakeup This symbol is needed by a QCOM driver. Bug: 186084429 Change-Id: I8001f14a6fded9b58a6dfba424dfa6ebb83543a5 Signed-off-by: Venkata Kakani Signed-off-by: Giuliano Procida --- drivers/base/power/wakeup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index 911f1e85d44c..ffda3dad256a 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c @@ -922,6 +922,7 @@ void pm_system_cancel_wakeup(void) { atomic_dec_if_positive(&pm_abort_suspend); } +EXPORT_SYMBOL_GPL(pm_system_cancel_wakeup); void pm_wakeup_clear(bool reset) { From c8cd528e75550ac739bb0b774b9f84a895f20f4e Mon Sep 17 00:00:00 2001 From: Giuliano Procida Date: Thu, 22 Apr 2021 14:31:03 +0100 Subject: [PATCH 8/9] ANDROID: ABI: add pm_system_cancel_wakeup symbol Leaf changes summary: 1 artifact changed Changed leaf types summary: 0 leaf type changed Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 1 Added function Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable 1 Added function: [A] 'function void pm_system_cancel_wakeup()' Bug: 186084429 Change-Id: I5ec59917cb2a128b9d0605dd8b3cb8fa7e020af2 Signed-off-by: Venkata Kakani Signed-off-by: Giuliano Procida --- android/abi_gki_aarch64.xml | 518 ++++++++++++++++------------------- android/abi_gki_aarch64_qcom | 1 + 2 files changed, 237 insertions(+), 282 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index c8cf7150a78c..ced999ef6ac8 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -3168,6 +3168,7 @@ + @@ -30028,7 +30029,7 @@ - + @@ -30763,20 +30764,7 @@ - - - - - - - - - - - - - - + @@ -31952,7 +31940,6 @@ - @@ -31964,7 +31951,7 @@ - + @@ -32330,17 +32317,6 @@ - - - - - - - - - - - @@ -32427,7 +32403,7 @@ - + @@ -58527,6 +58503,9 @@ + + + @@ -111594,20 +111573,7 @@ - - - - - - - - - - - - - - + @@ -165761,209 +165727,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -166099,18 +165865,7 @@ - - - - - - - - - - - @@ -166299,13 +166054,6 @@ - - - - - - - @@ -166313,10 +166061,6 @@ - - - - @@ -167182,18 +166926,6 @@ - - - - - - - - - - - - @@ -174208,7 +173940,7 @@ - + @@ -177234,7 +176966,218 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -177318,6 +177261,17 @@ + + + + + + + + + + + @@ -178752,7 +178706,7 @@ - + @@ -178781,7 +178735,7 @@ - + @@ -179373,7 +179327,7 @@ - + @@ -180333,7 +180287,7 @@ - + diff --git a/android/abi_gki_aarch64_qcom b/android/abi_gki_aarch64_qcom index d706370b2b5c..13187bc671f8 100644 --- a/android/abi_gki_aarch64_qcom +++ b/android/abi_gki_aarch64_qcom @@ -1804,6 +1804,7 @@ __pm_runtime_use_autosuspend __pm_stay_awake pm_stay_awake + pm_system_cancel_wakeup pm_system_wakeup pm_wakeup_dev_event pm_wakeup_ws_event From 48ffcbf0b9e7f0280bfb8c32c68da0aaf0fdfef6 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 25 Apr 2021 15:24:07 +0900 Subject: [PATCH 9/9] FROMGIT: kbuild: update config_data.gz only when the content of .config is changed If the timestamp of the .config file is updated, config_data.gz is regenerated, then vmlinux is re-linked. This occurs even if the content of the .config has not changed at all. This issue was mitigated by commit 67424f61f813 ("kconfig: do not write .config if the content is the same"); Kconfig does not update the .config when it ends up with the identical configuration. The issue is remaining when the .config is created by *_defconfig with some config fragment(s) applied on top. This is typical for powerpc and mips, where several *_defconfig targets are constructed by using merge_config.sh. One workaround is to have the copy of the .config. The filechk rule updates the copy, kernel/config_data, by checking the content instead of the timestamp. With this commit, the second run with the same configuration avoids the needless rebuilds. $ make ARCH=mips defconfig all [ snip ] $ make ARCH=mips defconfig all *** Default configuration is based on target '32r2el_defconfig' Using ./arch/mips/configs/generic_defconfig as base Merging arch/mips/configs/generic/32r2.config Merging arch/mips/configs/generic/el.config Merging ./arch/mips/configs/generic/board-boston.config Merging ./arch/mips/configs/generic/board-ni169445.config Merging ./arch/mips/configs/generic/board-ocelot.config Merging ./arch/mips/configs/generic/board-ranchu.config Merging ./arch/mips/configs/generic/board-sead-3.config Merging ./arch/mips/configs/generic/board-xilfpga.config # # configuration written to .config # SYNC include/config/auto.conf CALL scripts/checksyscalls.sh CALL scripts/atomic/check-atomics.sh CHK include/generated/compile.h CHK include/generated/autoksyms.h Reported-by: Elliot Berman Signed-off-by: Masahiro Yamada Bug: 179648610 (cherry picked from commit b33976d90d1ea7652fff662dcc2234f352346a33 https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kbuild) [eberman: Fixed minor conflicts in kernel/.gitignore] Change-Id: I8c93147c8d5a48d0f5e9abf855870b10c1a24efc Signed-off-by: Elliot Berman --- kernel/.gitignore | 1 + kernel/Makefile | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/.gitignore b/kernel/.gitignore index 34d1e77ee9df..16670321c138 100644 --- a/kernel/.gitignore +++ b/kernel/.gitignore @@ -1,6 +1,7 @@ # # Generated files # +config_data kheaders.md5 timeconst.h hz.bc diff --git a/kernel/Makefile b/kernel/Makefile index 08652a850458..9e02af6edfd3 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -128,10 +128,15 @@ KCOV_INSTRUMENT_stackleak.o := n $(obj)/configs.o: $(obj)/config_data.gz -targets += config_data.gz -$(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE +targets += config_data config_data.gz +$(obj)/config_data.gz: $(obj)/config_data FORCE $(call if_changed,gzip) +filechk_cat = cat $< + +$(obj)/config_data: $(KCONFIG_CONFIG) FORCE + $(call filechk,cat) + $(obj)/kheaders.o: $(obj)/kheaders_data.tar.xz quiet_cmd_genikh = CHK $(obj)/kheaders_data.tar.xz