Skip to content

Commit

Permalink
Merge tag 'driver-core-6.7-rc1' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/gregkh/driver-core

Pull driver core updates from Greg KH:
 "Here is the set of driver core updates for 6.7-rc1. Nothing major in
  here at all, just a small number of changes including:

   - minor cleanups and updates from Andy Shevchenko

   - __counted_by addition

   - firmware_loader update for aborting loads cleaner

   - other minor changes, details in the shortlog

   - documentation update

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'driver-core-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (21 commits)
  firmware_loader: Abort all upcoming firmware load request once reboot triggered
  firmware_loader: Refactor kill_pending_fw_fallback_reqs()
  Documentation: security-bugs.rst: linux-distros relaxed their rules
  driver core: Release all resources during unbind before updating device links
  driver core: class: remove boilerplate code
  driver core: platform: Annotate struct irq_affinity_devres with __counted_by
  resource: Constify resource crosscheck APIs
  resource: Unify next_resource() and next_resource_skip_children()
  resource: Reuse for_each_resource() macro
  PCI: Implement custom llseek for sysfs resource entries
  kernfs: sysfs: support custom llseek method for sysfs entries
  debugfs: Fix __rcu type comparison warning
  device property: Replace custom implementation of COUNT_ARGS()
  drivers: base: test: Make property entry API test modular
  driver core: Add missing parameter description to __fwnode_link_add()
  device property: Clarify usage scope of some struct fwnode_handle members
  devres: rename the first parameter of devm_add_action(_or_reset)
  driver core: platform: Unify the firmware node type check
  driver core: platform: Use temporary variable in platform_device_add()
  driver core: platform: Refactor error path in a couple places
  ...
  • Loading branch information
torvalds committed Nov 4, 2023
2 parents d99b91a + effd7c7 commit b06f58a
Show file tree
Hide file tree
Showing 22 changed files with 195 additions and 101 deletions.
35 changes: 26 additions & 9 deletions Documentation/process/security-bugs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,32 @@ lifted, in perpetuity.
Coordination with other groups
------------------------------

The kernel security team strongly recommends that reporters of potential
security issues NEVER contact the "linux-distros" mailing list until
AFTER discussing it with the kernel security team. Do not Cc: both
lists at once. You may contact the linux-distros mailing list after a
fix has been agreed on and you fully understand the requirements that
doing so will impose on you and the kernel community.

The different lists have different goals and the linux-distros rules do
not contribute to actually fixing any potential security problems.
While the kernel security team solely focuses on getting bugs fixed,
other groups focus on fixing issues in distros and coordinating
disclosure between operating system vendors. Coordination is usually
handled by the "linux-distros" mailing list and disclosure by the
public "oss-security" mailing list, both of which are closely related
and presented in the linux-distros wiki:
<https://oss-security.openwall.org/wiki/mailing-lists/distros>

Please note that the respective policies and rules are different since
the 3 lists pursue different goals. Coordinating between the kernel
security team and other teams is difficult since for the kernel security
team occasional embargoes (as subject to a maximum allowed number of
days) start from the availability of a fix, while for "linux-distros"
they start from the initial post to the list regardless of the
availability of a fix.

As such, the kernel security team strongly recommends that as a reporter
of a potential security issue you DO NOT contact the "linux-distros"
mailing list UNTIL a fix is accepted by the affected code's maintainers
and you have read the distros wiki page above and you fully understand
the requirements that contacting "linux-distros" will impose on you and
the kernel community. This also means that in general it doesn't make
sense to Cc: both lists at once, except maybe for coordination if and
while an accepted fix has not yet been merged. In other words, until a
fix is accepted do not Cc: "linux-distros", and after it's merged do not
Cc: the kernel security team.

CVE assignment
--------------
Expand Down
6 changes: 2 additions & 4 deletions drivers/base/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,8 @@ int class_register(const struct class *cls)
lockdep_register_key(key);
__mutex_init(&cp->mutex, "subsys mutex", key);
error = kobject_set_name(&cp->subsys.kobj, "%s", cls->name);
if (error) {
kfree(cp);
return error;
}
if (error)
goto err_out;

cp->subsys.kobj.kset = class_kset;
cp->subsys.kobj.ktype = &class_ktype;
Expand Down
1 change: 1 addition & 0 deletions drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ static bool fw_devlink_best_effort;
* __fwnode_link_add - Create a link between two fwnode_handles.
* @con: Consumer end of the link.
* @sup: Supplier end of the link.
* @flags: Link flags.
*
* Create a fwnode link between fwnode handles @con and @sup. The fwnode link
* represents the detail that the firmware lists @sup fwnode as supplying a
Expand Down
2 changes: 1 addition & 1 deletion drivers/base/dd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1274,8 +1274,8 @@ static void __device_release_driver(struct device *dev, struct device *parent)
if (dev->bus && dev->bus->dma_cleanup)
dev->bus->dma_cleanup(dev);

device_links_driver_cleanup(dev);
device_unbind_cleanup(dev);
device_links_driver_cleanup(dev);

klist_remove(&dev->p->knode_driver);
device_pm_check_callbacks(dev);
Expand Down
10 changes: 7 additions & 3 deletions drivers/base/firmware_loader/fallback.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,21 @@ static inline int fw_sysfs_wait_timeout(struct fw_priv *fw_priv, long timeout)

static LIST_HEAD(pending_fw_head);

void kill_pending_fw_fallback_reqs(bool only_kill_custom)
void kill_pending_fw_fallback_reqs(bool kill_all)
{
struct fw_priv *fw_priv;
struct fw_priv *next;

mutex_lock(&fw_lock);
list_for_each_entry_safe(fw_priv, next, &pending_fw_head,
pending_list) {
if (!fw_priv->need_uevent || !only_kill_custom)
if (kill_all || !fw_priv->need_uevent)
__fw_load_abort(fw_priv);
}

if (kill_all)
fw_load_abort_all = true;

mutex_unlock(&fw_lock);
}

Expand Down Expand Up @@ -86,7 +90,7 @@ static int fw_load_sysfs_fallback(struct fw_sysfs *fw_sysfs, long timeout)
}

mutex_lock(&fw_lock);
if (fw_state_is_aborted(fw_priv)) {
if (fw_load_abort_all || fw_state_is_aborted(fw_priv)) {
mutex_unlock(&fw_lock);
retval = -EINTR;
goto out;
Expand Down
4 changes: 2 additions & 2 deletions drivers/base/firmware_loader/fallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int firmware_fallback_sysfs(struct firmware *fw, const char *name,
struct device *device,
u32 opt_flags,
int ret);
void kill_pending_fw_fallback_reqs(bool only_kill_custom);
void kill_pending_fw_fallback_reqs(bool kill_all);

void fw_fallback_set_cache_timeout(void);
void fw_fallback_set_default_timeout(void);
Expand All @@ -28,7 +28,7 @@ static inline int firmware_fallback_sysfs(struct firmware *fw, const char *name,
return ret;
}

static inline void kill_pending_fw_fallback_reqs(bool only_kill_custom) { }
static inline void kill_pending_fw_fallback_reqs(bool kill_all) { }
static inline void fw_fallback_set_cache_timeout(void) { }
static inline void fw_fallback_set_default_timeout(void) { }
#endif /* CONFIG_FW_LOADER_USER_HELPER */
Expand Down
1 change: 1 addition & 0 deletions drivers/base/firmware_loader/firmware.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ struct fw_priv {

extern struct mutex fw_lock;
extern struct firmware_cache fw_cache;
extern bool fw_load_abort_all;

static inline bool __fw_state_check(struct fw_priv *fw_priv,
enum fw_status status)
Expand Down
9 changes: 5 additions & 4 deletions drivers/base/firmware_loader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ static inline struct fw_priv *to_fw_priv(struct kref *ref)
DEFINE_MUTEX(fw_lock);

struct firmware_cache fw_cache;
bool fw_load_abort_all;

void fw_state_init(struct fw_priv *fw_priv)
{
Expand Down Expand Up @@ -1524,10 +1525,10 @@ static int fw_pm_notify(struct notifier_block *notify_block,
case PM_SUSPEND_PREPARE:
case PM_RESTORE_PREPARE:
/*
* kill pending fallback requests with a custom fallback
* to avoid stalling suspend.
* Here, kill pending fallback requests will only kill
* non-uevent firmware request to avoid stalling suspend.
*/
kill_pending_fw_fallback_reqs(true);
kill_pending_fw_fallback_reqs(false);
device_cache_fw_images();
break;

Expand Down Expand Up @@ -1612,7 +1613,7 @@ static int fw_shutdown_notify(struct notifier_block *unused1,
* Kill all pending fallback requests to avoid both stalling shutdown,
* and avoid a deadlock with the usermode_lock.
*/
kill_pending_fw_fallback_reqs(false);
kill_pending_fw_fallback_reqs(true);

return NOTIFY_DONE;
}
Expand Down
71 changes: 36 additions & 35 deletions drivers/base/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,19 @@ int platform_get_irq_optional(struct platform_device *dev, unsigned int num)
ret = dev->archdata.irqs[num];
goto out;
#else
struct fwnode_handle *fwnode = dev_fwnode(&dev->dev);
struct resource *r;

if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node) {
ret = of_irq_get(dev->dev.of_node, num);
if (is_of_node(fwnode)) {
ret = of_irq_get(to_of_node(fwnode), num);
if (ret > 0 || ret == -EPROBE_DEFER)
goto out;
}

r = platform_get_resource(dev, IORESOURCE_IRQ, num);
if (has_acpi_companion(&dev->dev)) {
if (is_acpi_device_node(fwnode)) {
if (r && r->flags & IORESOURCE_DISABLED) {
ret = acpi_irq_get(ACPI_HANDLE(&dev->dev), num, r);
ret = acpi_irq_get(ACPI_HANDLE_FWNODE(fwnode), num, r);
if (ret)
goto out;
}
Expand Down Expand Up @@ -222,8 +223,8 @@ int platform_get_irq_optional(struct platform_device *dev, unsigned int num)
* the device will only expose one IRQ, and this fallback
* allows a common code path across either kind of resource.
*/
if (num == 0 && has_acpi_companion(&dev->dev)) {
ret = acpi_dev_gpio_irq_get(ACPI_COMPANION(&dev->dev), num);
if (num == 0 && is_acpi_device_node(fwnode)) {
ret = acpi_dev_gpio_irq_get(to_acpi_device_node(fwnode), num);
/* Our callers expect -ENXIO for missing IRQs. */
if (ret >= 0 || ret == -EPROBE_DEFER)
goto out;
Expand Down Expand Up @@ -291,7 +292,7 @@ EXPORT_SYMBOL_GPL(platform_irq_count);

struct irq_affinity_devres {
unsigned int count;
unsigned int irq[];
unsigned int irq[] __counted_by(count);
};

static void platform_disable_acpi_irq(struct platform_device *pdev, int index)
Expand All @@ -312,7 +313,7 @@ static void devm_platform_get_irqs_affinity_release(struct device *dev,
for (i = 0; i < ptr->count; i++) {
irq_dispose_mapping(ptr->irq[i]);

if (has_acpi_companion(dev))
if (is_acpi_device_node(dev_fwnode(dev)))
platform_disable_acpi_irq(to_platform_device(dev), i);
}
}
Expand Down Expand Up @@ -655,23 +656,21 @@ EXPORT_SYMBOL_GPL(platform_device_add_data);
*/
int platform_device_add(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
u32 i;
int ret;

if (!pdev)
return -EINVAL;

if (!pdev->dev.parent)
pdev->dev.parent = &platform_bus;
if (!dev->parent)
dev->parent = &platform_bus;

pdev->dev.bus = &platform_bus_type;
dev->bus = &platform_bus_type;

switch (pdev->id) {
default:
dev_set_name(&pdev->dev, "%s.%d", pdev->name, pdev->id);
dev_set_name(dev, "%s.%d", pdev->name, pdev->id);
break;
case PLATFORM_DEVID_NONE:
dev_set_name(&pdev->dev, "%s", pdev->name);
dev_set_name(dev, "%s", pdev->name);
break;
case PLATFORM_DEVID_AUTO:
/*
Expand All @@ -681,18 +680,18 @@ int platform_device_add(struct platform_device *pdev)
*/
ret = ida_alloc(&platform_devid_ida, GFP_KERNEL);
if (ret < 0)
goto err_out;
return ret;
pdev->id = ret;
pdev->id_auto = true;
dev_set_name(&pdev->dev, "%s.%d.auto", pdev->name, pdev->id);
dev_set_name(dev, "%s.%d.auto", pdev->name, pdev->id);
break;
}

for (i = 0; i < pdev->num_resources; i++) {
struct resource *p, *r = &pdev->resource[i];

if (r->name == NULL)
r->name = dev_name(&pdev->dev);
r->name = dev_name(dev);

p = r->parent;
if (!p) {
Expand All @@ -705,18 +704,20 @@ int platform_device_add(struct platform_device *pdev)
if (p) {
ret = insert_resource(p, r);
if (ret) {
dev_err(&pdev->dev, "failed to claim resource %d: %pR\n", i, r);
dev_err(dev, "failed to claim resource %d: %pR\n", i, r);
goto failed;
}
}
}

pr_debug("Registering platform device '%s'. Parent at %s\n",
dev_name(&pdev->dev), dev_name(pdev->dev.parent));
pr_debug("Registering platform device '%s'. Parent at %s\n", dev_name(dev),
dev_name(dev->parent));

ret = device_add(&pdev->dev);
if (ret == 0)
return ret;
ret = device_add(dev);
if (ret)
goto failed;

return 0;

failed:
if (pdev->id_auto) {
Expand All @@ -730,7 +731,6 @@ int platform_device_add(struct platform_device *pdev)
release_resource(r);
}

err_out:
return ret;
}
EXPORT_SYMBOL_GPL(platform_device_add);
Expand Down Expand Up @@ -1447,21 +1447,22 @@ static void platform_shutdown(struct device *_dev)
static int platform_dma_configure(struct device *dev)
{
struct platform_driver *drv = to_platform_driver(dev->driver);
struct fwnode_handle *fwnode = dev_fwnode(dev);
enum dev_dma_attr attr;
int ret = 0;

if (dev->of_node) {
ret = of_dma_configure(dev, dev->of_node, true);
} else if (has_acpi_companion(dev)) {
attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
if (is_of_node(fwnode)) {
ret = of_dma_configure(dev, to_of_node(fwnode), true);
} else if (is_acpi_device_node(fwnode)) {
attr = acpi_get_dma_attr(to_acpi_device_node(fwnode));
ret = acpi_dma_configure(dev, attr);
}
if (ret || drv->driver_managed_dma)
return ret;

if (!ret && !drv->driver_managed_dma) {
ret = iommu_device_use_default_domain(dev);
if (ret)
arch_teardown_dma_ops(dev);
}
ret = iommu_device_use_default_domain(dev);
if (ret)
arch_teardown_dma_ops(dev);

return ret;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/base/test/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ config DM_KUNIT_TEST
depends on KUNIT

config DRIVER_PE_KUNIT_TEST
bool "KUnit Tests for property entry API" if !KUNIT_ALL_TESTS
depends on KUNIT=y
tristate "KUnit Tests for property entry API" if !KUNIT_ALL_TESTS
depends on KUNIT
default KUNIT_ALL_TESTS
4 changes: 4 additions & 0 deletions drivers/base/test/property-entry-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,7 @@ static struct kunit_suite property_entry_test_suite = {
};

kunit_test_suite(property_entry_test_suite);

MODULE_DESCRIPTION("Test module for the property entry API");
MODULE_AUTHOR("Dmitry Torokhov <[email protected]>");
MODULE_LICENSE("GPL");
Loading

0 comments on commit b06f58a

Please sign in to comment.