mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bean Huo <huobean@gmail.com>
To: Alexey Charkov <alchark@flipper.net>,
	Alim Akhtar <alim.akhtar@samsung.com>,
	 Avri Altman <avri.altman@wdc.com>,
	Bart Van Assche <bvanassche@acm.org>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Bean Huo <beanhuo@micron.com>, Can Guo <can.guo@oss.qualcomm.com>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	 stable@vger.kernel.org
Subject: Re: [PATCH] scsi: ufs: core: Fix RPMB region size detection for UFS 2.2
Date: Thu, 29 Jan 2026 17:53:41 +0100	[thread overview]
Message-ID: <8149b8cb5a7b36a1543ca05666f33a6373674e0e.camel@gmail.com> (raw)
In-Reply-To: <20260129-ufs-rpmb-v1-1-691534ab723f@flipper.net>

On Thu, 2026-01-29 at 11:38 +0400, Alexey Charkov wrote:
> +                       hba->dev_info.rpmb_region_size[0] =
> +                               get_unaligned_be64(desc_buf
> +                                       +
> RPMB_UNIT_DESC_PARAM_LOGICAL_BLK_COUNT)
> +                               <<
> desc_buf[RPMB_UNIT_DESC_PARAM_LOGICAL_BLK_SIZE]
> +                               >> 17; /* convert to 128 kBytes units */
> +               }
>         }

Hi Alexey, 

thanks for your fix, I didn't notice there is UFS 2.x on the market which will
use UFS OP-TEE RPMB framework.


here is potential u8 Overflow, since for the UFS3.x+, it is u8 in unit
descriptor, but                                                                
                                                                                                        

The calculation can overflow for larger RPMB regions (>32MB):                  
  - A u8 can only represent up to 255 × 128KB = ~32MB                          
  - The shift result is assigned directly without bounds checking


Kind regards,
Bean                 

  reply	other threads:[~2026-01-29 16:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-29  7:38 Alexey Charkov
2026-01-29 16:53 ` Bean Huo [this message]
2026-01-29 17:10   ` Alexey Charkov
2026-01-30 10:26     ` Bean Huo
2026-01-30 14:49       ` Alexey Charkov
2026-02-04  8:37         ` Bean Huo
2026-02-05  8:32           ` Alexey Charkov

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=8149b8cb5a7b36a1543ca05666f33a6373674e0e.camel@gmail.com \
    --to=huobean@gmail.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=alchark@flipper.net \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=can.guo@oss.qualcomm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=stable@vger.kernel.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 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®