mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Corey Minyard <corey@minyard.net>
To: weidongw@illinois.edu
Cc: Andrew Manley <andrew.manley@sealingtech.com>,
	openipmi-developer@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ipmi: ipmb: Limit received direct messages to the rsp buffer
Date: Sun, 6 Dec 2026 07:42:10 -0600	[thread overview]
Message-ID: <axVmMqo65nW89x47@mail.minyard.net> (raw)
In-Reply-To: <20261205-kbug-l2241-v1-1-34998f379a33@illinois.edu>

On Sat, Dec 05, 2026 at 10:43:00PM -0600, Weidong Wang via B4 Relay wrote:
> From: Weidong Wang <weidongw@illinois.edu>
> 
> ipmi_ipmb_check_msg_done() copies a received IPMB_DIRECT message, a
> command or a response to a direct request, into imsg->rsp + 1 with
> length rcvlen - 4, and rcvlen can be up to IPMI_MAX_MSG_LENGTH + 5. A
> checksum-valid frame of 276 or more bytes writes past the end of the
> 272-byte rsp[], into the done callback pointer that follows it, and
> sets rsp_size beyond the array. Ignore such frames.

This looks correct.  Queued for next release.

Thanks,

-corey

> 
> Found by a static analysis tool.
> 
> Fixes: 63c4eb347164 ("ipmi:ipmb: Add initial support for IPMI over IPMB")
> Signed-off-by: Weidong Wang <weidongw@illinois.edu>
> ---
> The fix and the changelog were drafted with AI assistance (Claude Code,
> with a second review by OpenAI Codex), then reviewed by the submitter.
> 
> Testing:
> - Compile-tested on x86_64 (allmodconfig, W=1):
>   drivers/char/ipmi/ipmi_ipmb.o; no new warnings.
> - checkpatch.pl --strict: no errors or warnings.
> ---
>  drivers/char/ipmi/ipmi_ipmb.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/char/ipmi/ipmi_ipmb.c b/drivers/char/ipmi/ipmi_ipmb.c
> index 1f1e5718f082..421b9f9f2981 100644
> --- a/drivers/char/ipmi/ipmi_ipmb.c
> +++ b/drivers/char/ipmi/ipmi_ipmb.c
> @@ -97,6 +97,12 @@ static bool valid_ipmb(struct ipmi_ipmb_dev *iidev)
>  	return true;
>  }
>  
> +/* A direct message stores rcvlen - 3 bytes in rsp. */
> +static bool direct_msg_fits(struct ipmi_ipmb_dev *iidev)
> +{
> +	return iidev->rcvlen - 3 <= IPMI_MAX_MSG_LENGTH;
> +}
> +
>  static void ipmi_ipmb_check_msg_done(struct ipmi_ipmb_dev *iidev)
>  {
>  	struct ipmi_smi_msg *imsg = NULL;
> @@ -115,6 +121,8 @@ static void ipmi_ipmb_check_msg_done(struct ipmi_ipmb_dev *iidev)
>  		/* Ignore commands until we are up. */
>  		if (!iidev->ready)
>  			goto done;
> +		if (!direct_msg_fits(iidev))
> +			goto done;
>  
>  		/* It's a command, allocate a message for it. */
>  		imsg = ipmi_alloc_smi_msg();
> @@ -132,9 +140,13 @@ static void ipmi_ipmb_check_msg_done(struct ipmi_ipmb_dev *iidev)
>  			 * Responses should carry the sequence we sent
>  			 * them with.  If it's a transmitted response,
>  			 * ignore it.  And if the message hasn't been
> -			 * transmitted, ignore it.
> +			 * transmitted, ignore it.  Ignore a direct
> +			 * response that does not fit in rsp.
>  			 */
> -			if (!xmit_rsp && seq == iidev->curr_seq) {
> +			if (!xmit_rsp && seq == iidev->curr_seq &&
> +			    (iidev->working_msg->type !=
> +			     IPMI_SMI_MSG_TYPE_IPMB_DIRECT ||
> +			     direct_msg_fits(iidev))) {
>  				iidev->curr_seq = (iidev->curr_seq + 1) & 0x3f;
>  
>  				imsg = iidev->working_msg;
> 
> ---
> base-commit: 551bbbed906516e04956e4de0896fb8c1317ea86
> change-id: 20261205-kbug-l2241-4eb8abfe6a75
> 
> Best regards,
> --  
> Weidong Wang <weidongw@illinois.edu>
> 
> 

      reply	other threads:[~2026-12-06 13:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-06  4:43 Weidong Wang via B4 Relay
2026-12-06 13:42 ` 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=axVmMqo65nW89x47@mail.minyard.net \
    --to=corey@minyard.net \
    --cc=andrew.manley@sealingtech.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=openipmi-developer@lists.sourceforge.net \
    --cc=weidongw@illinois.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®