mirror of
https://github.com/torvalds/linux.git
synced 2026-06-07 22:14:04 +02:00
Merge 18a3c5f7ab ("Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost") into android-mainline
Steps on the way to 5.12-final Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: Ib4abdf9a0eb4ad5cfa7190e5b32793c8a4022402
This commit is contained in:
commit
6edc8254a3
|
|
@ -247,8 +247,9 @@ static void meson_mmc_get_transfer_mode(struct mmc_host *mmc,
|
|||
*/
|
||||
for_each_sg(data->sg, sg, data->sg_len, i) {
|
||||
if (sg->length % data->blksz) {
|
||||
WARN_ONCE(1, "unaligned sg len %u blksize %u\n",
|
||||
sg->length, data->blksz);
|
||||
dev_warn_once(mmc_dev(mmc),
|
||||
"unaligned sg len %u blksize %u, disabling descriptor DMA for transfer\n",
|
||||
sg->length, data->blksz);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -278,8 +278,10 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr
|
|||
mr->log_size = log_entity_size;
|
||||
mr->nsg = nsg;
|
||||
mr->nent = dma_map_sg_attrs(dma, mr->sg_head.sgl, mr->nsg, DMA_BIDIRECTIONAL, 0);
|
||||
if (!mr->nent)
|
||||
if (!mr->nent) {
|
||||
err = -ENOMEM;
|
||||
goto err_map;
|
||||
}
|
||||
|
||||
err = create_direct_mr(mvdev, mr);
|
||||
if (err)
|
||||
|
|
|
|||
|
|
@ -745,9 +745,11 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev,
|
|||
const struct vdpa_config_ops *ops = vdpa->config;
|
||||
int r = 0;
|
||||
|
||||
mutex_lock(&dev->mutex);
|
||||
|
||||
r = vhost_dev_check_owner(dev);
|
||||
if (r)
|
||||
return r;
|
||||
goto unlock;
|
||||
|
||||
switch (msg->type) {
|
||||
case VHOST_IOTLB_UPDATE:
|
||||
|
|
@ -768,6 +770,8 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev,
|
|||
r = -EINVAL;
|
||||
break;
|
||||
}
|
||||
unlock:
|
||||
mutex_unlock(&dev->mutex);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,9 @@ struct user_namespace {
|
|||
kgid_t group;
|
||||
struct ns_common ns;
|
||||
unsigned long flags;
|
||||
/* parent_could_setfcap: true if the creator if this ns had CAP_SETFCAP
|
||||
* in its effective capability set at the child ns creation time. */
|
||||
bool parent_could_setfcap;
|
||||
|
||||
#ifdef CONFIG_KEYS
|
||||
/* List of joinable keyrings in this namespace. Modification access of
|
||||
|
|
|
|||
|
|
@ -333,7 +333,8 @@ struct vfs_ns_cap_data {
|
|||
|
||||
#define CAP_AUDIT_CONTROL 30
|
||||
|
||||
/* Set or remove capabilities on files */
|
||||
/* Set or remove capabilities on files.
|
||||
Map uid=0 into a child user namespace. */
|
||||
|
||||
#define CAP_SETFCAP 31
|
||||
|
||||
|
|
|
|||
|
|
@ -3546,7 +3546,11 @@ static char *trace_iter_expand_format(struct trace_iterator *iter)
|
|||
{
|
||||
char *tmp;
|
||||
|
||||
if (iter->fmt == static_fmt_buf)
|
||||
/*
|
||||
* iter->tr is NULL when used with tp_printk, which makes
|
||||
* this get called where it is not safe to call krealloc().
|
||||
*/
|
||||
if (!iter->tr || iter->fmt == static_fmt_buf)
|
||||
return NULL;
|
||||
|
||||
tmp = krealloc(iter->fmt, iter->fmt_size + STATIC_FMT_BUF_SIZE,
|
||||
|
|
@ -3567,7 +3571,7 @@ const char *trace_event_format(struct trace_iterator *iter, const char *fmt)
|
|||
if (WARN_ON_ONCE(!fmt))
|
||||
return fmt;
|
||||
|
||||
if (iter->tr->trace_flags & TRACE_ITER_HASH_PTR)
|
||||
if (!iter->tr || iter->tr->trace_flags & TRACE_ITER_HASH_PTR)
|
||||
return fmt;
|
||||
|
||||
p = fmt;
|
||||
|
|
@ -9725,7 +9729,7 @@ void __init early_trace_init(void)
|
|||
{
|
||||
if (tracepoint_printk) {
|
||||
tracepoint_print_iter =
|
||||
kmalloc(sizeof(*tracepoint_print_iter), GFP_KERNEL);
|
||||
kzalloc(sizeof(*tracepoint_print_iter), GFP_KERNEL);
|
||||
if (MEM_FAIL(!tracepoint_print_iter,
|
||||
"Failed to allocate trace iterator\n"))
|
||||
tracepoint_printk = 0;
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ int create_user_ns(struct cred *new)
|
|||
if (!ns)
|
||||
goto fail_dec;
|
||||
|
||||
ns->parent_could_setfcap = cap_raised(new->cap_effective, CAP_SETFCAP);
|
||||
ret = ns_alloc_inum(&ns->ns);
|
||||
if (ret)
|
||||
goto fail_free;
|
||||
|
|
@ -841,6 +842,60 @@ static int sort_idmaps(struct uid_gid_map *map)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* verify_root_map() - check the uid 0 mapping
|
||||
* @file: idmapping file
|
||||
* @map_ns: user namespace of the target process
|
||||
* @new_map: requested idmap
|
||||
*
|
||||
* If a process requests mapping parent uid 0 into the new ns, verify that the
|
||||
* process writing the map had the CAP_SETFCAP capability as the target process
|
||||
* will be able to write fscaps that are valid in ancestor user namespaces.
|
||||
*
|
||||
* Return: true if the mapping is allowed, false if not.
|
||||
*/
|
||||
static bool verify_root_map(const struct file *file,
|
||||
struct user_namespace *map_ns,
|
||||
struct uid_gid_map *new_map)
|
||||
{
|
||||
int idx;
|
||||
const struct user_namespace *file_ns = file->f_cred->user_ns;
|
||||
struct uid_gid_extent *extent0 = NULL;
|
||||
|
||||
for (idx = 0; idx < new_map->nr_extents; idx++) {
|
||||
if (new_map->nr_extents <= UID_GID_MAP_MAX_BASE_EXTENTS)
|
||||
extent0 = &new_map->extent[idx];
|
||||
else
|
||||
extent0 = &new_map->forward[idx];
|
||||
if (extent0->lower_first == 0)
|
||||
break;
|
||||
|
||||
extent0 = NULL;
|
||||
}
|
||||
|
||||
if (!extent0)
|
||||
return true;
|
||||
|
||||
if (map_ns == file_ns) {
|
||||
/* The process unshared its ns and is writing to its own
|
||||
* /proc/self/uid_map. User already has full capabilites in
|
||||
* the new namespace. Verify that the parent had CAP_SETFCAP
|
||||
* when it unshared.
|
||||
* */
|
||||
if (!file_ns->parent_could_setfcap)
|
||||
return false;
|
||||
} else {
|
||||
/* Process p1 is writing to uid_map of p2, who is in a child
|
||||
* user namespace to p1's. Verify that the opener of the map
|
||||
* file has CAP_SETFCAP against the parent of the new map
|
||||
* namespace */
|
||||
if (!file_ns_capable(file, map_ns->parent, CAP_SETFCAP))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static ssize_t map_write(struct file *file, const char __user *buf,
|
||||
size_t count, loff_t *ppos,
|
||||
int cap_setid,
|
||||
|
|
@ -848,7 +903,7 @@ static ssize_t map_write(struct file *file, const char __user *buf,
|
|||
struct uid_gid_map *parent_map)
|
||||
{
|
||||
struct seq_file *seq = file->private_data;
|
||||
struct user_namespace *ns = seq->private;
|
||||
struct user_namespace *map_ns = seq->private;
|
||||
struct uid_gid_map new_map;
|
||||
unsigned idx;
|
||||
struct uid_gid_extent extent;
|
||||
|
|
@ -895,7 +950,7 @@ static ssize_t map_write(struct file *file, const char __user *buf,
|
|||
/*
|
||||
* Adjusting namespace settings requires capabilities on the target.
|
||||
*/
|
||||
if (cap_valid(cap_setid) && !file_ns_capable(file, ns, CAP_SYS_ADMIN))
|
||||
if (cap_valid(cap_setid) && !file_ns_capable(file, map_ns, CAP_SYS_ADMIN))
|
||||
goto out;
|
||||
|
||||
/* Parse the user data */
|
||||
|
|
@ -965,7 +1020,7 @@ static ssize_t map_write(struct file *file, const char __user *buf,
|
|||
|
||||
ret = -EPERM;
|
||||
/* Validate the user is allowed to use user id's mapped to. */
|
||||
if (!new_idmap_permitted(file, ns, cap_setid, &new_map))
|
||||
if (!new_idmap_permitted(file, map_ns, cap_setid, &new_map))
|
||||
goto out;
|
||||
|
||||
ret = -EPERM;
|
||||
|
|
@ -1086,6 +1141,10 @@ static bool new_idmap_permitted(const struct file *file,
|
|||
struct uid_gid_map *new_map)
|
||||
{
|
||||
const struct cred *cred = file->f_cred;
|
||||
|
||||
if (cap_setid == CAP_SETUID && !verify_root_map(file, ns, new_map))
|
||||
return false;
|
||||
|
||||
/* Don't allow mappings that would allow anything that wouldn't
|
||||
* be allowed without the establishment of unprivileged mappings.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ int tpm2_seal_trusted(struct tpm_chip *chip,
|
|||
if (i == ARRAY_SIZE(tpm2_hash_map))
|
||||
return -EINVAL;
|
||||
|
||||
rc = tpm_buf_init(&buf, TPM2_ST_SESSIONS, TPM2_CC_CREATE);
|
||||
rc = tpm_try_get_ops(chip);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user