]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ipmi:msghandler: Fix potential memory corruption in ipmi_create_user()
authorDan Carpenter <dan.carpenter@linaro.org>
Mon, 5 May 2025 14:34:15 +0000 (17:34 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Jul 2025 16:35:12 +0000 (18:35 +0200)
commite2d5c005dfc96fe857676d1d8ac46b29275cb89b
treeb94e6d1e39d43cd2bb88b0aa418e4c4f4788e51e
parentefc1b2b7c1a308b60df8f36bc2d7ce16d3999364
ipmi:msghandler: Fix potential memory corruption in ipmi_create_user()

commit fa332f5dc6fc662ad7d3200048772c96b861cf6b upstream.

The "intf" list iterator is an invalid pointer if the correct
"intf->intf_num" is not found.  Calling atomic_dec(&intf->nr_users) on
and invalid pointer will lead to memory corruption.

We don't really need to call atomic_dec() if we haven't called
atomic_add_return() so update the if (intf->in_shutdown) path as well.

Fixes: 8e76741c3d8b ("ipmi: Add a limit on the number of users that may use IPMI")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Message-ID: <aBjMZ8RYrOt6NOgi@stanley.mountain>
Signed-off-by: Corey Minyard <corey@minyard.net>
[ - Dropped change to the `if (intf->in_shutdown)` block since that logic
    doesn't exist yet.
  - Modified out_unlock to release the srcu lock instead of the mutex
    since we don't have the mutex here yet. ]
Signed-off-by: Brendan Jackman <jackmanb@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/ipmi/ipmi_msghandler.c