Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'driver-core-5.13-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core fixes from Greg KH:
"Here are three small driver core / debugfs fixes for 5.13-rc4:

- debugfs fix for incorrect "lockdown" mode for selinux accesses

- two device link changes, one bugfix and one cleanup

All of these have been in linux-next for over a week with no reported
problems"

* tag 'driver-core-5.13-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
drivers: base: Reduce device link removal code duplication
drivers: base: Fix device link removal
debugfs: fix security_locked_down() call for SELinux

+44 -39
+36 -32
drivers/base/core.c
··· 194 194 { 195 195 return srcu_read_lock_held(&device_links_srcu); 196 196 } 197 + 198 + static void device_link_synchronize_removal(void) 199 + { 200 + synchronize_srcu(&device_links_srcu); 201 + } 202 + 203 + static void device_link_remove_from_lists(struct device_link *link) 204 + { 205 + list_del_rcu(&link->s_node); 206 + list_del_rcu(&link->c_node); 207 + } 197 208 #else /* !CONFIG_SRCU */ 198 209 static DECLARE_RWSEM(device_links_lock); 199 210 ··· 235 224 return lockdep_is_held(&device_links_lock); 236 225 } 237 226 #endif 227 + 228 + static inline void device_link_synchronize_removal(void) 229 + { 230 + } 231 + 232 + static void device_link_remove_from_lists(struct device_link *link) 233 + { 234 + list_del(&link->s_node); 235 + list_del(&link->c_node); 236 + } 238 237 #endif /* !CONFIG_SRCU */ 239 238 240 239 static bool device_is_ancestor(struct device *dev, struct device *target) ··· 466 445 }; 467 446 ATTRIBUTE_GROUPS(devlink); 468 447 469 - static void device_link_free(struct device_link *link) 448 + static void device_link_release_fn(struct work_struct *work) 470 449 { 450 + struct device_link *link = container_of(work, struct device_link, rm_work); 451 + 452 + /* Ensure that all references to the link object have been dropped. */ 453 + device_link_synchronize_removal(); 454 + 471 455 while (refcount_dec_not_one(&link->rpm_active)) 472 456 pm_runtime_put(link->supplier); 473 457 ··· 481 455 kfree(link); 482 456 } 483 457 484 - #ifdef CONFIG_SRCU 485 - static void __device_link_free_srcu(struct rcu_head *rhead) 486 - { 487 - device_link_free(container_of(rhead, struct device_link, rcu_head)); 488 - } 489 - 490 458 static void devlink_dev_release(struct device *dev) 491 459 { 492 460 struct device_link *link = to_devlink(dev); 493 461 494 - call_srcu(&device_links_srcu, &link->rcu_head, __device_link_free_srcu); 462 + INIT_WORK(&link->rm_work, device_link_release_fn); 463 + /* 464 + * It may take a while to complete this work because of the SRCU 465 + * synchronization in device_link_release_fn() and if the consumer or 466 + * supplier devices get deleted when it runs, so put it into the "long" 467 + * workqueue. 468 + */ 469 + queue_work(system_long_wq, &link->rm_work); 495 470 } 496 - #else 497 - static void devlink_dev_release(struct device *dev) 498 - { 499 - device_link_free(to_devlink(dev)); 500 - } 501 - #endif 502 471 503 472 static struct class devlink_class = { 504 473 .name = "devlink", ··· 867 846 } 868 847 EXPORT_SYMBOL_GPL(device_link_add); 869 848 870 - #ifdef CONFIG_SRCU 871 849 static void __device_link_del(struct kref *kref) 872 850 { 873 851 struct device_link *link = container_of(kref, struct device_link, kref); ··· 876 856 877 857 pm_runtime_drop_link(link); 878 858 879 - list_del_rcu(&link->s_node); 880 - list_del_rcu(&link->c_node); 859 + device_link_remove_from_lists(link); 881 860 device_unregister(&link->link_dev); 882 861 } 883 - #else /* !CONFIG_SRCU */ 884 - static void __device_link_del(struct kref *kref) 885 - { 886 - struct device_link *link = container_of(kref, struct device_link, kref); 887 - 888 - dev_info(link->consumer, "Dropping the link to %s\n", 889 - dev_name(link->supplier)); 890 - 891 - pm_runtime_drop_link(link); 892 - 893 - list_del(&link->s_node); 894 - list_del(&link->c_node); 895 - device_unregister(&link->link_dev); 896 - } 897 - #endif /* !CONFIG_SRCU */ 898 862 899 863 static void device_link_put_kref(struct device_link *link) 900 864 {
+6 -3
fs/debugfs/inode.c
··· 45 45 static int debugfs_setattr(struct user_namespace *mnt_userns, 46 46 struct dentry *dentry, struct iattr *ia) 47 47 { 48 - int ret = security_locked_down(LOCKDOWN_DEBUGFS); 48 + int ret; 49 49 50 - if (ret && (ia->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID))) 51 - return ret; 50 + if (ia->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID)) { 51 + ret = security_locked_down(LOCKDOWN_DEBUGFS); 52 + if (ret) 53 + return ret; 54 + } 52 55 return simple_setattr(&init_user_ns, dentry, ia); 53 56 } 54 57
+2 -4
include/linux/device.h
··· 570 570 * @flags: Link flags. 571 571 * @rpm_active: Whether or not the consumer device is runtime-PM-active. 572 572 * @kref: Count repeated addition of the same link. 573 - * @rcu_head: An RCU head to use for deferred execution of SRCU callbacks. 573 + * @rm_work: Work structure used for removing the link. 574 574 * @supplier_preactivated: Supplier has been made active before consumer probe. 575 575 */ 576 576 struct device_link { ··· 583 583 u32 flags; 584 584 refcount_t rpm_active; 585 585 struct kref kref; 586 - #ifdef CONFIG_SRCU 587 - struct rcu_head rcu_head; 588 - #endif 586 + struct work_struct rm_work; 589 587 bool supplier_preactivated; /* Owned by consumer probe. */ 590 588 }; 591 589