All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Williams <patrick@stwcx.xyz>
To: CS20 CTCchien <CTCCHIEN@nuvoton.com>
Cc: "openbmc@lists.ozlabs.org" <openbmc@lists.ozlabs.org>
Subject: Re: phosphor-host-ipmid will crash on aarch64
Date: Wed, 19 May 2021 21:36:46 -0500	[thread overview]
Message-ID: <YKXLPghzZKn+GV7r@heinlein> (raw)
In-Reply-To: <HK0PR03MB3954243C26C79A3E8586CFFCDF2D9@HK0PR03MB3954.apcprd03.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 1590 bytes --]

On Mon, May 17, 2021 at 03:21:14AM +0000, CS20 CTCchien wrote:
> Hi Rthomaiy,  Vmauery,  Pstrinkle, Jayaprakashmutyala,
> 
> When I build phosphor-host-ipmid for aarch64 platform, size_t will be 8 bytes, but in aarch32 sizte_t will be 4 bytes, so ipmid will crash at https://github.com/openbmc/phosphor-host-ipmid/blob/master/user_channel/passwd_mgr.cpp#L323, due to the data size of hashsize and ivsize and padsize and macsize is 4 bytes in /etc/ipmi_pass, but ipmid will read those data as 8 bytes.

Why does the data end up being only 4 bytes in the file?  As best I can
tell line 538 is where the data is written and it also uses
sizeof(MetaPassStruct) to determine the amount to write.

> /*
> * Meta data struct for encrypted password file
> */
> struct MetaPassStruct
> {
>     char signature[10];
>     unsigned char reseved[2];
>     size_t hashSize;
>     size_t ivSize;
>     size_t dataSize;
>     size_t padSize;
>     size_t macSize;
> };
> 
> If I replace size_t in this structure with unsigned int, then ipmid will not crash at this point.

We generally want to use 'size_t' for things which are sizes.  The code
here is a little dangerous in that it is doing a raw cast to/from the
in-memory structure rather than doing a real serialization.

I'm not really seeing where the code is inconsistent with itself though
that would contribut to a crash.

> But those fields in this structure are also used to store the return value from other functions, like EVP_MD_block_size(),
> And the return type is also size_t.
> 
-- 
Patrick Williams

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2021-05-20  2:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17  3:21 phosphor-host-ipmid will crash on aarch64 CS20 CTCchien
2021-05-20  2:36 ` Patrick Williams [this message]
2021-05-20  2:42   ` William Kennington

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=YKXLPghzZKn+GV7r@heinlein \
    --to=patrick@stwcx.xyz \
    --cc=CTCCHIEN@nuvoton.com \
    --cc=openbmc@lists.ozlabs.org \
    /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.