Skip to content

Commit

Permalink
Changes representative of linux-3.10.0-1160.11.1.el7.tar.xz
Browse files Browse the repository at this point in the history
  • Loading branch information
da-x committed Nov 30, 2020
1 parent e300c48 commit 8212174
Show file tree
Hide file tree
Showing 44 changed files with 518 additions and 236 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ EXTRAVERSION =
NAME = Unicycling Gorilla
RHEL_MAJOR = 7
RHEL_MINOR = 9
RHEL_RELEASE = 1160.6.1
RHEL_RELEASE = 1160.11.1

#
# DRM backport version
Expand Down
66 changes: 40 additions & 26 deletions arch/powerpc/platforms/powernv/opal-dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,19 @@ static int64_t dump_send_ack(uint32_t dump_id)
return rc;
}

static void delay_release_kobj(void *kobj)
{
kobject_put((struct kobject *)kobj);
}

static ssize_t dump_ack_store(struct dump_obj *dump_obj,
struct dump_attribute *attr,
const char *buf,
size_t count)
{
dump_send_ack(dump_obj->id);
sysfs_schedule_callback(&dump_obj->kobj, delay_release_kobj,
&dump_obj->kobj, THIS_MODULE);
/*
* Try to self remove this attribute. If we are successful,
* delete the kobject itself.
*/
if (sysfs_remove_file_self(&dump_obj->kobj, &attr->attr)) {
dump_send_ack(dump_obj->id);
kobject_put(&dump_obj->kobj);
}
return count;
}

Expand Down Expand Up @@ -324,15 +324,14 @@ static ssize_t dump_attr_read(struct file *filep, struct kobject *kobj,
return count;
}

static struct dump_obj *create_dump_obj(uint32_t id, size_t size,
uint32_t type)
static void create_dump_obj(uint32_t id, size_t size, uint32_t type)
{
struct dump_obj *dump;
int rc;

dump = kzalloc(sizeof(*dump), GFP_KERNEL);
if (!dump)
return NULL;
return;

dump->kobj.kset = dump_kset;

Expand All @@ -352,34 +351,51 @@ static struct dump_obj *create_dump_obj(uint32_t id, size_t size,
rc = kobject_add(&dump->kobj, NULL, "0x%x-0x%x", type, id);
if (rc) {
kobject_put(&dump->kobj);
return NULL;
return;
}

/*
* As soon as the sysfs file for this dump is created/activated there is
* a chance the opal_errd daemon (or any userspace) might read and
* acknowledge the dump before kobject_uevent() is called. If that
* happens then there is a potential race between
* dump_ack_store->kobject_put() and kobject_uevent() which leads to a
* use-after-free of a kernfs object resulting in a kernel crash.
*
* To avoid that, we need to take a reference on behalf of the bin file,
* so that our reference remains valid while we call kobject_uevent().
* We then drop our reference before exiting the function, leaving the
* bin file to drop the last reference (if it hasn't already).
*/

/* Take a reference for the bin file */
kobject_get(&dump->kobj);
rc = sysfs_create_bin_file(&dump->kobj, &dump->dump_attr);
if (rc) {
if (rc == 0) {
kobject_uevent(&dump->kobj, KOBJ_ADD);

pr_info("%s: New platform dump. ID = 0x%x Size %u\n",
__func__, dump->id, dump->size);
} else {
/* Drop reference count taken for bin file */
kobject_put(&dump->kobj);
return NULL;
}

pr_info("%s: New platform dump. ID = 0x%x Size %u\n",
__func__, dump->id, dump->size);

kobject_uevent(&dump->kobj, KOBJ_ADD);

return dump;
/* Drop our reference */
kobject_put(&dump->kobj);
return;
}

static irqreturn_t process_dump(int irq, void *data)
{
int rc;
uint32_t dump_id, dump_size, dump_type;
struct dump_obj *dump;
char name[22];
struct kobject *kobj;

rc = dump_read_info(&dump_id, &dump_size, &dump_type);
if (rc != OPAL_SUCCESS)
return rc;
return IRQ_HANDLED;

sprintf(name, "0x%x-0x%x", dump_type, dump_id);

Expand All @@ -391,12 +407,10 @@ static irqreturn_t process_dump(int irq, void *data)
if (kobj) {
/* Drop reference added by kset_find_obj() */
kobject_put(kobj);
return 0;
return IRQ_HANDLED;
}

dump = create_dump_obj(dump_id, dump_size, dump_type);
if (!dump)
return -1;
create_dump_obj(dump_id, dump_size, dump_type);

return IRQ_HANDLED;
}
Expand Down
66 changes: 39 additions & 27 deletions arch/powerpc/platforms/powernv/opal-elog.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ static ssize_t elog_ack_show(struct elog_obj *elog_obj,
return sprintf(buf, "ack - acknowledge log message\n");
}

static void delay_release_kobj(void *kobj)
{
kobject_put((struct kobject *)kobj);
}

static ssize_t elog_ack_store(struct elog_obj *elog_obj,
struct elog_attribute *attr,
const char *buf,
size_t count)
{
opal_send_ack_elog(elog_obj->id);
sysfs_schedule_callback(&elog_obj->kobj, delay_release_kobj,
&elog_obj->kobj, THIS_MODULE);
/*
* Try to self remove this attribute. If we are successful,
* delete the kobject itself.
*/
if (sysfs_remove_file_self(&elog_obj->kobj, &attr->attr)) {
opal_send_ack_elog(elog_obj->id);
kobject_put(&elog_obj->kobj);
}
return count;
}

Expand Down Expand Up @@ -188,14 +188,14 @@ static ssize_t raw_attr_read(struct file *filep, struct kobject *kobj,
return count;
}

static struct elog_obj *create_elog_obj(uint64_t id, size_t size, uint64_t type)
static void create_elog_obj(uint64_t id, size_t size, uint64_t type)
{
struct elog_obj *elog;
int rc;

elog = kzalloc(sizeof(*elog), GFP_KERNEL);
if (!elog)
return NULL;
return;

elog->kobj.kset = elog_kset;

Expand Down Expand Up @@ -228,21 +228,40 @@ static struct elog_obj *create_elog_obj(uint64_t id, size_t size, uint64_t type)
rc = kobject_add(&elog->kobj, NULL, "0x%llx", id);
if (rc) {
kobject_put(&elog->kobj);
return NULL;
return;
}

/*
* As soon as the sysfs file for this elog is created/activated there is
* a chance the opal_errd daemon (or any userspace) might read and
* acknowledge the elog before kobject_uevent() is called. If that
* happens then there is a potential race between
* elog_ack_store->kobject_put() and kobject_uevent() which leads to a
* use-after-free of a kernfs object resulting in a kernel crash.
*
* To avoid that, we need to take a reference on behalf of the bin file,
* so that our reference remains valid while we call kobject_uevent().
* We then drop our reference before exiting the function, leaving the
* bin file to drop the last reference (if it hasn't already).
*/

/* Take a reference for the bin file */
kobject_get(&elog->kobj);
rc = sysfs_create_bin_file(&elog->kobj, &elog->raw_attr);
if (rc) {
if (rc == 0) {
kobject_uevent(&elog->kobj, KOBJ_ADD);
} else {
/* Drop the reference taken for the bin file */
kobject_put(&elog->kobj);
return NULL;
}

kobject_uevent(&elog->kobj, KOBJ_ADD);
/* Drop our reference */
kobject_put(&elog->kobj);

return elog;
return;
}

static void elog_work_fn(struct work_struct *work)
static irqreturn_t elog_event(int irq, void *data)
{
__be64 size;
__be64 id;
Expand All @@ -257,7 +276,7 @@ static void elog_work_fn(struct work_struct *work)
rc = opal_get_elog_size(&id, &size, &type);
if (rc != OPAL_SUCCESS) {
pr_err("ELOG: OPAL log info read failed\n");
return;
return IRQ_HANDLED;
}

elog_size = be64_to_cpu(size);
Expand All @@ -279,17 +298,10 @@ static void elog_work_fn(struct work_struct *work)
if (kobj) {
/* Drop reference added by kset_find_obj() */
kobject_put(kobj);
return;
return IRQ_HANDLED;
}

create_elog_obj(log_id, elog_size, elog_type);
}

static DECLARE_WORK(elog_work, elog_work_fn);

static irqreturn_t elog_event(int irq, void *data)
{
schedule_work(&elog_work);
return IRQ_HANDLED;
}

Expand All @@ -314,8 +326,8 @@ int __init opal_elog_init(void)
return irq;
}

rc = request_irq(irq, elog_event,
IRQ_TYPE_LEVEL_HIGH, "opal-elog", NULL);
rc = request_threaded_irq(irq, NULL, elog_event,
IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "opal-elog", NULL);
if (rc) {
pr_err("%s: Can't request OPAL event irq (%d)\n",
__func__, rc);
Expand Down
27 changes: 19 additions & 8 deletions arch/x86/kernel/cpu/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,16 @@ static void init_speculation_control(struct cpuinfo_x86 *c)
}
}

static void apply_forced_caps(struct cpuinfo_x86 *c)
{
int i;

for (i = 0; i < NCAPINTS + NBUGINTS; i++) {
c->x86_capability[i] &= ~cpu_caps_cleared[i];
c->x86_capability[i] |= cpu_caps_set[i];
}
}

void get_cpu_cap(struct cpuinfo_x86 *c)
{
u32 eax, ebx, ecx, edx;
Expand Down Expand Up @@ -873,6 +883,13 @@ void get_cpu_cap(struct cpuinfo_x86 *c)

init_scattered_cpuid_features(c);
init_speculation_control(c);

/*
* Clear/Set all flags overridden by options, after probe.
* This needs to happen each time we re-probe, which may happen
* several times during CPU initialization.
*/
apply_forced_caps(c);
}

static void identify_cpu_without_cpuid(struct cpuinfo_x86 *c)
Expand Down Expand Up @@ -1298,10 +1315,7 @@ static void identify_cpu(struct cpuinfo_x86 *c)
this_cpu->c_identify(c);

/* Clear/Set all flags overriden by options, after probe */
for (i = 0; i < NCAPINTS + NBUGINTS; i++) {
c->x86_capability[i] &= ~cpu_caps_cleared[i];
c->x86_capability[i] |= cpu_caps_set[i];
}
apply_forced_caps(c);

#ifdef CONFIG_X86_64
c->apicid = apic->phys_pkg_id(c->initial_apicid, 0);
Expand Down Expand Up @@ -1361,10 +1375,7 @@ static void identify_cpu(struct cpuinfo_x86 *c)
* Clear/Set all flags overriden by options, need do it
* before following smp all cpus cap AND.
*/
for (i = 0; i < NCAPINTS + NBUGINTS; i++) {
c->x86_capability[i] &= ~cpu_caps_cleared[i];
c->x86_capability[i] |= cpu_caps_set[i];
}
apply_forced_caps(c);

/*
* On SMP, boot_cpu_data holds the common feature set between
Expand Down
14 changes: 11 additions & 3 deletions crypto/authenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,22 @@ int crypto_authenc_extractkeys(struct crypto_authenc_keys *keys, const u8 *key,
return -EINVAL;
if (rta->rta_type != CRYPTO_AUTHENC_KEYA_PARAM)
return -EINVAL;
if (RTA_PAYLOAD(rta) < sizeof(*param))

/*
* RTA_OK() didn't align the rtattr's payload when validating that it
* fits in the buffer. Yet, the keys should start on the next 4-byte
* aligned boundary. To avoid confusion, require that the rtattr
* payload be exactly the param struct, which has a 4-byte aligned size.
*/
if (RTA_PAYLOAD(rta) != sizeof(*param))
return -EINVAL;
BUILD_BUG_ON(sizeof(*param) % RTA_ALIGNTO);

param = RTA_DATA(rta);
keys->enckeylen = be32_to_cpu(param->enckeylen);

key += RTA_ALIGN(rta->rta_len);
keylen -= RTA_ALIGN(rta->rta_len);
key += rta->rta_len;
keylen -= rta->rta_len;

if (keylen < keys->enckeylen)
return -EINVAL;
Expand Down
Loading

0 comments on commit 8212174

Please sign in to comment.