/* * Copyright (C) 2012 * Sachin Bhamare * Boaz Harrosh * * This file is part of exofs. * * exofs is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License 2 as published by * the Free Software Foundation. * * exofs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with exofs; if not, write to the: * Free Software Foundation */ #include #include #include "exofs.h" struct odev_attr { struct attribute attr; ssize_t (*show)(struct exofs_dev *, char *); ssize_t (*store)(struct exofs_dev *, const char *, size_t); }; static ssize_t odev_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct exofs_dev *edp = container_of(kobj, struct exofs_dev, ed_kobj); struct odev_attr *a = container_of(attr, struct odev_attr, attr); return a->show ? a->show(edp, buf) : 0; } static ssize_t odev_attr_store(struct kobject *kobj, struct attribute *attr, const char *buf, size_t len) { struct exofs_dev *edp = container_of(kobj, struct exofs_dev, ed_kobj); struct odev_attr *a = container_of(attr, struct odev_attr, attr); return a->store ? a->store(edp, buf, len) : len; } static const struct sysfs_ops odev_attr_ops = { .show = odev_attr_show, .store = odev_attr_store, }; static struct kset *exofs_kset; static ssize_t osdname_show(struct exofs_dev *edp, char *buf) { struct osd_dev *odev = edp->ored.od; const struct osd_dev_info *odi = osduld_device_info(odev); return snprintf(buf, odi->osdname_len + 1, "%s", odi->osdname); } static ssize_t systemid_show(struct exofs_dev *edp, char *buf) { struct osd_dev *odev = edp->ored.od; const struct osd_dev_info *odi = osduld_device_info(odev); memcpy(buf, odi->systemid, odi->systemid_len); return odi->systemid_len; } static ssize_t uri_show(struct exofs_dev *edp, char *buf) { return snprintf(buf, edp->urilen, "%s", edp->uri); } static ssize_t uri_store(struct exofs_dev *edp, const char *buf, size_t len) { uint8_t *new_uri; edp->urilen = strlen(buf) + 1; new_uri = krealloc(edp->uri, edp->urilen, GFP_KERNEL); if (new_uri == NULL) return -ENOMEM; edp->uri = new_uri; strncpy(edp->uri, buf, edp->urilen); return edp->urilen; } #define OSD_ATTR(name, mode, show, store) \ static struct odev_attr odev_attr_##name = \ __ATTR(name, mode, show, store) OSD_ATTR(osdname, S_IRUGO, osdname_show, NULL); OSD_ATTR(systemid, S_IRUGO, systemid_show, NULL); OSD_ATTR(uri, S_IRWXU, uri_show, uri_store); static struct attribute *odev_attrs[] = { &odev_attr_osdname.attr, &odev_attr_systemid.attr, &odev_attr_uri.attr, NULL, }; static struct kobj_type odev_ktype = { .default_attrs = odev_attrs, .sysfs_ops = &odev_attr_ops, }; static struct kobj_type uuid_ktype = { }; void exofs_sysfs_dbg_print(void) { #ifdef CONFIG_EXOFS_DEBUG struct kobject *k_name, *k_tmp; list_for_each_entry_safe(k_name, k_tmp, &exofs_kset->list, entry) { printk(KERN_INFO "%s: name %s ref %d\n", __func__, kobject_name(k_name), (int)atomic_read(&k_name->kref.refcount)); } #endif } /* * This function removes all kobjects under exofs_kset * At the end of it, exofs_kset kobject will have a refcount * of 1 which gets decremented only on exofs module unload */ void exofs_sysfs_sb_del(struct exofs_sb_info *sbi) { struct kobject *k_name, *k_tmp; struct kobject *s_kobj = &sbi->s_kobj; list_for_each_entry_safe(k_name, k_tmp, &exofs_kset->list, entry) { /* Remove all that are children of this SBI */ if (k_name->parent == s_kobj) kobject_put(k_name); } kobject_put(s_kobj); } /* * This function creates sysfs entries to hold the current exofs cluster * instance (uniquely identified by osdname,pid tuple). * This function gets called once per exofs mount instance. */ int exofs_sysfs_sb_add(struct exofs_sb_info *sbi, struct exofs_dt_device_info *dt_dev) { struct kobject *s_kobj; int retval = 0; uint64_t pid = sbi->one_comp.obj.partition; /* allocate new uuid dirent */ s_kobj = &sbi->s_kobj; s_kobj->kset = exofs_kset; retval = kobject_init_and_add(s_kobj, &uuid_ktype, &exofs_kset->kobj, "%s_%llx", dt_dev->osdname, pid); if (retval) { EXOFS_ERR("ERROR: Failed to create sysfs entry for " "uuid-%s_%llx => %d\n", dt_dev->osdname, pid, retval); return -ENOMEM; } return 0; } int exofs_sysfs_odev_add(struct exofs_dev *edev, struct exofs_sb_info *sbi) { struct kobject *d_kobj; int retval = 0; /* create osd device group which contains following attributes * osdname, systemid & uri */ d_kobj = &edev->ed_kobj; d_kobj->kset = exofs_kset; retval = kobject_init_and_add(d_kobj, &odev_ktype, &sbi->s_kobj, "dev%u", edev->did); if (retval) { EXOFS_ERR("ERROR: Failed to create sysfs entry for " "device dev%u\n", edev->did); return retval; } return 0; } int exofs_sysfs_init(void) { exofs_kset = kset_create_and_add("exofs", NULL, fs_kobj); if (!exofs_kset) { EXOFS_ERR("ERROR: kset_create_and_add exofs failed\n"); return -ENOMEM; } return 0; } void exofs_sysfs_uninit(void) { kset_unregister(exofs_kset); } a907686f5298220ece53423e38ba3aed'>net/core/secure_seq.c parente6e7b48b295afa5a5ab440de0a94d9ad8b3ce2d0 (diff)
drm/atomic: Fix double free in drm_atomic_state_default_clear
drm_atomic_helper_page_flip and drm_atomic_ioctl set their own events in crtc_state->event. But when it's set the event is freed in 2 places. Solve this by only freeing the event in the atomic ioctl when it allocated its own event. This has been broken twice. The first time when the code was introduced, but only in the corner case when an event is allocated, but more crtc's were included by atomic check and then failing. This can mostly happen when you do an atomic modeset in i915 and the display clock is changed, which forces all crtc's to be included to the state. This has been broken worse by adding in-fences support, which caused the double free to be done unconditionally. [IGT] kms_rotation_crc: starting subtest primary-rotation-180 ============================================================================= BUG kmalloc-128 (Tainted: G U ): Object already free ----------------------------------------------------------------------------- Disabling lock debugging due to kernel taint INFO: Allocated in drm_atomic_helper_setup_commit+0x285/0x2f0 [drm_kms_helper] age=0 cpu=3 pid=1529 ___slab_alloc+0x308/0x3b0 __slab_alloc+0xd/0x20 kmem_cache_alloc_trace+0x92/0x1c0 drm_atomic_helper_setup_commit+0x285/0x2f0 [drm_kms_helper] intel_atomic_commit+0x35/0x4f0 [i915] drm_atomic_commit+0x46/0x50 [drm] drm_mode_atomic_ioctl+0x7d4/0xab0 [drm] drm_ioctl+0x2b3/0x490 [drm] do_vfs_ioctl+0x69c/0x700 SyS_ioctl+0x4e/0x80 entry_SYSCALL_64_fastpath+0x13/0x94 INFO: Freed in drm_event_cancel_free+0xa3/0xb0 [drm] age=0 cpu=3 pid=1529 __slab_free+0x48/0x2e0 kfree+0x159/0x1a0 drm_event_cancel_free+0xa3/0xb0 [drm] drm_mode_atomic_ioctl+0x86d/0xab0 [drm] drm_ioctl+0x2b3/0x490 [drm] do_vfs_ioctl+0x69c/0x700 SyS_ioctl+0x4e/0x80 entry_SYSCALL_64_fastpath+0x13/0x94 INFO: Slab 0xffffde1f0997b080 objects=17 used=2 fp=0xffff92fb65ec2578 flags=0x200000000008101 INFO: Object 0xffff92fb65ec2578 @offset=1400 fp=0xffff92fb65ec2ae8 Redzone ffff92fb65ec2570: bb bb bb bb bb bb bb bb ........ Object ffff92fb65ec2578: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec2588: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec2598: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec25a8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec25b8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec25c8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec25d8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec25e8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b a5 kkkkkkkkkkkkkkk. Redzone ffff92fb65ec25f8: bb bb bb bb bb bb bb bb ........ Padding ffff92fb65ec2738: 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ CPU: 3 PID: 180 Comm: kworker/3:2 Tainted: G BU 4.10.0-rc6-patser+ #5039 Hardware name: /NUC5PPYB, BIOS PYBSWCEL.86A.0031.2015.0601.1712 06/01/2015 Workqueue: events intel_atomic_helper_free_state [i915] Call Trace: dump_stack+0x4d/0x6d print_trailer+0x20c/0x220 free_debug_processing+0x1c6/0x330 ? drm_atomic_state_default_clear+0xf7/0x1c0 [drm] __slab_free+0x48/0x2e0 ? drm_atomic_state_default_clear+0xf7/0x1c0 [drm] kfree+0x159/0x1a0 drm_atomic_state_default_clear+0xf7/0x1c0 [drm] ? drm_atomic_state_clear+0x30/0x30 [drm] intel_atomic_state_clear+0xd/0x20 [i915] drm_atomic_state_clear+0x1a/0x30 [drm] __drm_atomic_state_free+0x13/0x60 [drm] intel_atomic_helper_free_state+0x5d/0x70 [i915] process_one_work+0x260/0x4a0 worker_thread+0x2d1/0x4f0 kthread+0x127/0x130 ? process_one_work+0x4a0/0x4a0 ? kthread_stop+0x120/0x120 ret_from_fork+0x29/0x40 FIX kmalloc-128: Object at 0xffff92fb65ec2578 not freed Fixes: 3b24f7d67581 ("drm/atomic: Add struct drm_crtc_commit to track async updates") Fixes: 9626014258a5 ("drm/fence: add in-fences support") Cc: <stable@vger.kernel.org> # v4.8+ Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/1485854725-27640-1-git-send-email-maarten.lankhorst@linux.intel.com
Diffstat (limited to 'net/core/secure_seq.c')