All of lore.kernel.org
 help / color / mirror / Atom feed
From: Corey Minyard <corey@minyard.net>
To: anhnh.4work@gmail.com
Cc: openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ipmi:msghandler: Put the interface on the BMC changed retry
Date: Fri, 4 Dec 2026 06:18:58 -0600	[thread overview]
Message-ID: <axKvskwx8ViIajqD@mail.minyard.net> (raw)
In-Reply-To: <20261203-kbug-l1316-v1-1-233b33545491@gmail.com>

On Thu, Dec 03, 2026 at 08:53:38PM -0600, Anh Nguyen Hoang via B4 Relay wrote:
> From: Anh Nguyen Hoang <anhnh.4work@gmail.com>
> 
> When __bmc_get_device_id() is called without an interface, it takes a
> reference on the first interface of the BMC. If the BMC's device id or
> GUID has changed, it re-registers the BMC and jumps back to
> retry_bmc_lock without dropping that reference, so the interface is
> never freed. Drop the reference before retrying, as the other retry in
> this function does.

Correct, this is in my for-next tree for next release.

Thank you,

-corey

> 
> Found by a static analysis tool.
> 
> Fixes: b2cfd8ab4add ("ipmi: Rework device id and guid handling to catch changing BMCs")
> Signed-off-by: Anh Nguyen Hoang <anhnh.4work@gmail.com>
> ---
> Runtime test: QEMU, x86_64 defconfig + IPMI_HANDLER + IPMI_SI +
> KPROBE_EVENTS, on next-20261202 (its ipmi_msghandler.c is the same as
> the one in ipmi for-next). A scripted BMC behind ipmi-bmc-extern changes
> its product id while the guest runs. A read of ipmi_bmc.0/product_id by
> uid 1000 then takes this retry. The interface is then removed through
> the ipmi_si hotmod parameter, with kprobes on ipmi_unregister_smi() and
> intf_free().
> Before the patch: the refcount is 2 when entering ipmi_unregister_smi()
> and intf_free() is never called.
> After the patch: the refcount is 1 and intf_free() is called.
> Same result with two KCS interfaces on one BMC. With an unchanged BMC,
> both kernels free the interface.
> 
> This patch was drafted with AI assistance (Claude, claude-fable-5-2).
> 
> Testing:
> - Compile-tested on x86_64 (allmodconfig, W=1):
>   drivers/char/ipmi/ipmi_msghandler.o; no new warnings.
> - checkpatch.pl --strict: no errors or warnings.
> ---
>  drivers/char/ipmi/ipmi_msghandler.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
> index 52e95e1949b9..f80d16dce449 100644
> --- a/drivers/char/ipmi/ipmi_msghandler.c
> +++ b/drivers/char/ipmi/ipmi_msghandler.c
> @@ -2770,6 +2770,7 @@ static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,
>  			 * the next interface for the BMC.
>  			 */
>  			mutex_unlock(&intf->bmc_reg_mutex);
> +			kref_put(&intf->refcount, intf_free);
>  			mutex_lock(&bmc->dyn_mutex);
>  			goto retry_bmc_lock;
>  		}
> 
> ---
> base-commit: 551bbbed906516e04956e4de0896fb8c1317ea86
> change-id: 20261203-kbug-l1316-6fcc56d75287
> 
> Best regards,
> --  
> Anh Nguyen Hoang <anhnh.4work@gmail.com>
> 
> 

      reply	other threads:[~2026-12-04 12:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  2:53 [PATCH] ipmi:msghandler: Put the interface on the BMC changed retry Anh Nguyen Hoang
2026-12-04  2:53 ` Anh Nguyen Hoang via B4 Relay
2026-12-04 12:18 ` Corey Minyard [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=axKvskwx8ViIajqD@mail.minyard.net \
    --to=corey@minyard.net \
    --cc=anhnh.4work@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=openipmi-developer@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.