lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=McBUKZR+esuyXzPdpM=DVK3EQqQXa=eH8hn_RvhO-JZSA@mail.gmail.com>
Date:   Wed, 11 Oct 2023 16:37:48 +0200
From:   Bartosz Golaszewski <brgl@...ev.pl>
To:     Andrew Halaney <ahalaney@...hat.com>
Cc:     Andy Gross <agross@...nel.org>,
        Bjorn Andersson <andersson@...nel.org>,
        Konrad Dybcio <konrad.dybcio@...aro.org>,
        Elliot Berman <quic_eberman@...cinc.com>,
        Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
        Guru Das Srinagesh <quic_gurus@...cinc.com>,
        Maximilian Luz <luzmaximilian@...il.com>,
        Alex Elder <elder@...aro.org>,
        Srini Kandagatla <srinivas.kandagatla@...aro.org>,
        linux-arm-msm@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, kernel@...cinc.com,
        Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: Re: [PATCH v3 11/15] firmware: qcom: qseecom: convert to using the TZ allocator

On Wed, Oct 11, 2023 at 3:56 PM Andrew Halaney <ahalaney@...hat.com> wrote:
>
> On Wed, Oct 11, 2023 at 09:44:54AM +0200, Bartosz Golaszewski wrote:
> > On Wed, Oct 11, 2023 at 12:49 AM Andrew Halaney <ahalaney@...hat.com> wrote:
> > >
> > > On Mon, Oct 09, 2023 at 05:34:23PM +0200, Bartosz Golaszewski wrote:
> > > > From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
> > > >
> > > > Drop the DMA mapping operations from qcom_scm_qseecom_app_send() and
> > > > convert all users of it in the qseecom module to using the TZ allocator
> > > > for creating SCM call buffers. Together with using the cleanup macros,
> > > > it has the added benefit of a significant code shrink. As this is
> > > > largely a module separate from the SCM driver, let's use a separate
> > > > memory pool.
> > > >
> > > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
> > >
> > > <snip>
> > >
> > > > @@ -567,20 +529,14 @@ static efi_status_t qsee_uefi_get_next_variable(struct qcuefi_client *qcuefi,
> > > >               return EFI_INVALID_PARAMETER;
> > > >
> > > >       status = qcom_qseecom_app_send(qcuefi->client, req_data, req_size, rsp_data, rsp_size);
> > > > -     if (status) {
> > > > -             efi_status = EFI_DEVICE_ERROR;
> > > > -             goto out_free;
> > > > -     }
> > > > +     if (status)
> > > > +             return EFI_DEVICE_ERROR;
> > > >
> > > > -     if (rsp_data->command_id != QSEE_CMD_UEFI_GET_NEXT_VARIABLE) {
> > > > -             efi_status = EFI_DEVICE_ERROR;
> > > > -             goto out_free;
> > > > -     }
> > > > +     if (rsp_data->command_id != QSEE_CMD_UEFI_GET_NEXT_VARIABLE)
> > > > +             return EFI_DEVICE_ERROR;
> > > >
> > > > -     if (rsp_data->length < sizeof(*rsp_data)) {
> > > > -             efi_status = EFI_DEVICE_ERROR;
> > > > -             goto out_free;
> > > > -     }
> > > > +     if (rsp_data->length < sizeof(*rsp_data))
> > > > +             return EFI_DEVICE_ERROR;
> > > >
> > > >       if (rsp_data->status) {
> > > >               dev_dbg(qcuefi_dev(qcuefi), "%s: uefisecapp error: 0x%x\n",
> > > > @@ -595,77 +551,59 @@ static efi_status_t qsee_uefi_get_next_variable(struct qcuefi_client *qcuefi,
> > > >               if (efi_status == EFI_BUFFER_TOO_SMALL)
> > > >                       *name_size = rsp_data->name_size;
> > > >
> > > > -             goto out_free;
> > > > +             return efi_status;
> > > >       }
> > > >
> > > > -     if (rsp_data->length > rsp_size) {
> > > > -             efi_status = EFI_DEVICE_ERROR;
> > > > -             goto out_free;
> > > > -     }
> > > > +     if (rsp_data->length > rsp_size)
> > > > +             return EFI_DEVICE_ERROR;
> > > >
> > > > -     if (rsp_data->name_offset + rsp_data->name_size > rsp_data->length) {
> > > > -             efi_status = EFI_DEVICE_ERROR;
> > > > -             goto out_free;
> > > > -     }
> > > > +     if (rsp_data->name_offset + rsp_data->name_size > rsp_data->length)
> > > > +             return EFI_DEVICE_ERROR;
> > > >
> > > > -     if (rsp_data->guid_offset + rsp_data->guid_size > rsp_data->length) {
> > > > -             efi_status = EFI_DEVICE_ERROR;
> > > > -             goto out_free;
> > > > -     }
> > > > +     if (rsp_data->guid_offset + rsp_data->guid_size > rsp_data->length)
> > > > +             return EFI_DEVICE_ERROR;
> > > >
> > > >       if (rsp_data->name_size > *name_size) {
> > > >               *name_size = rsp_data->name_size;
> > > > -             efi_status = EFI_BUFFER_TOO_SMALL;
> > > > -             goto out_free;
> > > > +             return EFI_BUFFER_TOO_SMALL;
> > > >       }
> > > >
> > > > -     if (rsp_data->guid_size != sizeof(*guid)) {
> > > > -             efi_status = EFI_DEVICE_ERROR;
> > > > -             goto out_free;
> > > > -     }
> > > > +     if (rsp_data->guid_size != sizeof(*guid))
> > > > +             return EFI_DEVICE_ERROR;
> > > >
> > > >       memcpy(guid, ((void *)rsp_data) + rsp_data->guid_offset, rsp_data->guid_size);
> > > >       status = ucs2_strscpy(name, ((void *)rsp_data) + rsp_data->name_offset,
> > > >                             rsp_data->name_size / sizeof(*name));
> > > >       *name_size = rsp_data->name_size;
> > > >
> > > > -     if (status < 0) {
> > > > +     if (status < 0)
> > > >               /*
> > > >                * Return EFI_DEVICE_ERROR here because the buffer size should
> > > >                * have already been validated above, causing this function to
> > > >                * bail with EFI_BUFFER_TOO_SMALL.
> > > >                */
> > > >               return EFI_DEVICE_ERROR;
> > > > -     }
> > >
> > > Personally (no idea what the actual style guide says) leaving braces
> > > around the multiline if statement would be nice.... that being said,
> > > that's my opinion :)
> > >
> > > <snip>
> > > > @@ -704,12 +635,7 @@ static efi_status_t qsee_uefi_query_variable_info(struct qcuefi_client *qcuefi,
> > > >       if (max_variable_size)
> > > >               *max_variable_size = rsp_data->max_variable_size;
> > > >
> > > > -out_free:
> > > > -     kfree(rsp_data);
> > > > -out_free_req:
> > > > -     kfree(req_data);
> > > > -out:
> > > > -     return efi_status;
> > > > +     return EFI_SUCCESS;
> > > >  }
> > > >
> > > >  /* -- Global efivar interface. ---------------------------------------------- */
> > > > @@ -838,6 +764,10 @@ static int qcom_uefisecapp_probe(struct auxiliary_device *aux_dev,
> > > >       if (status)
> > > >               qcuefi_set_reference(NULL);
> > > >
> > > > +     qcuefi->mempool = devm_qcom_tzmem_pool_new(&aux_dev->dev, SZ_256K);
> > >
> > > Any particular reason for this size? Just curious, it was (one) of the
> > > reasons I had not marked patch 4 yet (it looks good, but I wanted to get
> > > through the series to digest the Kconfig as well).
> > >
> >
> > I cannot test this. Do you know what the minimum correct size would be?
>
> I've got no insight into these firmware interfaces unfortunately. Was
> mostly curious if Qualcomm had provided a suggestion behind the scenes
> or if this was picked as a "sufficiently large" pool size.
>

No, I chose a small but reasonable value and intend to see if it
breaks anything. :)

But if anyone from QCom reading knows a better value - be it smaller
or larger, please let me know.

Bartosz

> >
> > Bart
> >
> > > Reviewed-by: Andrew Halaney <ahalaney@...hat.com>
> > >
> >
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ