]> 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:32:07 +0000 (18:32 +0200)
commitcbc1670297f675854e982d23c8583900ff0cc67a
tree57b35e73d9f0b52c32f9827ea56f2e036bfecf39
parent2392494b07e2da4717b03054c81b69b74f0a6153
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