Skip to content

Implements LOGIN_APPLICATION and LOGIN_USER_APPLICATION #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: optee
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
cd30df4
arm64: dt: Remove timer from mt8173 **not for mainline**
jbech-linaro Apr 1, 2016
80fa328
arm64: dt: OP-TEE for foundation-v8 **not for mainline**
jenswi-linaro Aug 17, 2016
77807de
arm64: dt: OP-TEE for Juno **not for mainline**
jenswi-linaro Mar 29, 2016
8896662
arm64: dt: Add no-map to the reserved-memory node for OP-TEE for foun…
jenswi-linaro Dec 2, 2016
cc033c2
arm64: dt: Add no-map to the reserved-memory node for OP-TEE for juno…
jenswi-linaro Jan 3, 2017
f3ac939
arm64: dt: Add OP-TEE firmware to mt8173 **not for mainline**
jbech-linaro Mar 24, 2016
36ea285
arm64: dts: hi3798cv200-poplar: memreserve for bootloader
igoropaniuk May 11, 2020
d01ca7e
arm64: dts: hi3798cv200-poplar: add optee node
igoropaniuk May 11, 2020
53aff13
ARM: dts: stm32: Define OP-TEE resources on stm32mp15 and enable on DK2
etienne-lms May 27, 2020
5d92e7f
Enable Microsoft fTPM driver on Arm Foundation v8 models.
javieralso-arm Feb 2, 2021
57841ba
stm32mp157c-ev1.dts: Fix optee status to 'okay'
Mar 2, 2021
d0ab07c
arm: dts: define OP-TEE resources for STM32MP1 ED1 and EV1
etienne-lms Apr 27, 2021
9eda7bf
arm64: dt: OP-TEE for FVP Base RevC
jenswi-linaro Jun 30, 2022
5f13fd3
arm: dts: define OP-TEE resources for STM32MP15 DHCOM based boards
jneuhauser Feb 16, 2022
b39bb52
arm: dts: define OP-TEE resources for STM32MP15 DHCOR based boards
jneuhauser Jul 13, 2022
ca2a2ef
arm64: dt: rockpi4: disable node usbdrd_dwc3_0 **not for mainline**
jforissier Nov 14, 2022
4da2533
arm64: dt: rockpi4: add OP-TEE nodes **not for mainline**
jforissier Nov 15, 2022
a267ac0
Implements LOGIN_APPLICATION and LOGIN_USER_APPLICATION
Kh-Oleg Feb 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions arch/arm/boot/dts/st/stm32mp151.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
method = "smc";
};

firmware {
optee: optee {
compatible = "linaro,optee-tz";
method = "smc";
status = "disabled";
};
};

intc: interrupt-controller@a0021000 {
compatible = "arm,cortex-a7-gic";
#interrupt-cells = <3>;
Expand Down
11 changes: 11 additions & 0 deletions arch/arm/boot/dts/st/stm32mp157c-dk2.dts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
model = "STMicroelectronics STM32MP157C-DK2 Discovery Board";
compatible = "st,stm32mp157c-dk2", "st,stm32mp157";

reserved-memory {
optee_memory: optee@0xde000000 {
reg = <0xde000000 0x02000000>;
no-map;
};
};

aliases {
ethernet0 = &ethernet0;
serial3 = &usart2;
Expand Down Expand Up @@ -91,3 +98,7 @@
pinctrl-2 = <&usart2_idle_pins_c>;
status = "disabled";
};

&optee {
status = "okay";
};
9 changes: 9 additions & 0 deletions arch/arm/boot/dts/st/stm32mp157c-ed1.dts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
reg = <0x38000000 0x10000>;
no-map;
};

optee_memory: optee@fe000000 {
reg = <0xfe000000 0x2000000>;
no-map;
};
};

led {
Expand Down Expand Up @@ -333,6 +338,10 @@
status = "okay";
};

&optee {
status = "okay";
};

&pwr_regulators {
vdd-supply = <&vdd>;
vdd_3v3_usbfs-supply = <&vdd_usb>;
Expand Down
9 changes: 9 additions & 0 deletions arch/arm/boot/dts/st/stm32mp15xx-dhcom-som.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
reg = <0x38000000 0x10000>;
no-map;
};

optee_memory: optee@fe000000 {
reg = <0xfe000000 0x2000000>;
no-map;
};
};

ethernet_vio: vioregulator {
Expand Down Expand Up @@ -423,6 +428,10 @@
status = "okay";
};

&optee {
status = "okay";
};

&pwr_regulators {
vdd-supply = <&vdd>;
vdd_3v3_usbfs-supply = <&vdd_usb>;
Expand Down
9 changes: 9 additions & 0 deletions arch/arm/boot/dts/st/stm32mp15xx-dhcor-som.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
reg = <0x38000000 0x10000>;
no-map;
};

optee_memory: optee@fe000000 {
reg = <0xfe000000 0x2000000>;
no-map;
};
};
};

Expand Down Expand Up @@ -234,6 +239,10 @@
status = "okay";
};

&optee {
status = "okay";
};

&pwr_regulators {
vdd-supply = <&vdd>;
vdd_3v3_usbfs-supply = <&vdd_usb>;
Expand Down
32 changes: 23 additions & 9 deletions arch/arm64/boot/dts/arm/foundation-v8.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@

aliases {
serial0 = &v2m_serial0;
serial1 = &v2m_serial1;
serial2 = &v2m_serial2;
serial3 = &v2m_serial3;
};

ftpm {
compatible = "microsoft,ftpm";
};

cpus {
#address-cells = <2>;
#size-cells = <0>;
Expand Down Expand Up @@ -71,6 +74,17 @@
<0x00000008 0x80000000 0 0x80000000>;
};

reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;

optee@0x83000000 {
reg = <0x00000000 0x83000000 0 0x01000000>;
no-map;
};
};

timer {
compatible = "arm,armv8-timer";
interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
Expand Down Expand Up @@ -205,14 +219,6 @@
clock-names = "uartclk", "apb_pclk";
};

v2m_serial1: serial@a0000 {
compatible = "arm,pl011", "arm,primecell";
reg = <0x0a0000 0x1000>;
interrupts = <6>;
clocks = <&v2m_clk24mhz>, <&v2m_clk24mhz>;
clock-names = "uartclk", "apb_pclk";
};

v2m_serial2: serial@b0000 {
compatible = "arm,pl011", "arm,primecell";
reg = <0x0b0000 0x1000>;
Expand All @@ -236,4 +242,12 @@
};
};
};

firmware {
optee {
compatible = "linaro,optee-tz";
method = "smc";
};
};

};
12 changes: 12 additions & 0 deletions arch/arm64/boot/dts/arm/fvp-base-revc.dts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@
reg = <0x00000000 0x18000000 0 0x00800000>;
no-map;
};

optee@83000000 {
reg = <0x00000000 0x83000000 0 0x01000000>;
no-map;
};
};

gic: interrupt-controller@2f000000 {
Expand Down Expand Up @@ -320,4 +325,11 @@
<0 0 44 &gic 0 0 GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>,
<0 0 46 &gic 0 0 GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>;
};

firmware {
optee {
compatible = "linaro,optee-tz";
method = "smc";
};
};
};
19 changes: 19 additions & 0 deletions arch/arm64/boot/dts/arm/juno-base.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,18 @@
<0x00000008 0x80000000 0x1 0x80000000>;
};

reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;

/* Shared memory between secure and non-secure world */
optee@0xfee00000 {
reg = <0x00000000 0xfee00000 0 0x00200000>;
no-map;
};
};

bus@8000000 {
#interrupt-cells = <1>;
interrupt-map-mask = <0 0 15>;
Expand Down Expand Up @@ -993,4 +1005,11 @@
interrupt-map-mask = <0 0>;
interrupt-map = <0 0 &gic 0 GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>;
};

firmware {
optee {
compatible = "linaro,optee-tz";
method = "smc";
};
};
};
8 changes: 8 additions & 0 deletions arch/arm64/boot/dts/hisilicon/hi3798cv200-poplar.dts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

/dts-v1/;
/memreserve/ 0x00000000 0x04080000;

#include <dt-bindings/gpio/gpio.h>
#include "hi3798cv200.dtsi"
Expand Down Expand Up @@ -70,6 +71,13 @@
gpio = <&gpio6 7 0>;
enable-active-high;
};

firmware {
optee {
compatible = "linaro,optee-tz";
method = "smc";
};
};
};

&ehci {
Expand Down
7 changes: 7 additions & 0 deletions arch/arm64/boot/dts/mediatek/mt8173-evb.dts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@
gpio = <&pio 9 GPIO_ACTIVE_HIGH>;
enable-active-high;
};

firmware {
optee {
compatible = "linaro,optee-tz";
method = "smc";
};
};
};

&mfg_async {
Expand Down
9 changes: 0 additions & 9 deletions arch/arm64/boot/dts/mediatek/mt8173.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -525,15 +525,6 @@
reg = <0 0x10007000 0 0x100>;
};

timer: timer@10008000 {
compatible = "mediatek,mt8173-timer",
"mediatek,mt6577-timer";
reg = <0 0x10008000 0 0x1000>;
interrupts = <GIC_SPI 144 IRQ_TYPE_LEVEL_LOW>;
clocks = <&infracfg CLK_INFRA_CLK_13M>,
<&topckgen CLK_TOP_RTC_SEL>;
};

pwrap: pwrap@1000d000 {
compatible = "mediatek,mt8173-pwrap";
reg = <0 0x1000d000 0 0x1000>;
Expand Down
20 changes: 19 additions & 1 deletion arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,24 @@
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <1400000>;
};

firmware {
optee {
compatible = "linaro,optee-tz";
method = "smc";
};
};

reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;

optee@30000000 {
reg = <0x0 0x30000000 0x0 0x2400000>;
no-map;
};
};
};

&cpu_l0 {
Expand Down Expand Up @@ -766,7 +784,7 @@
};

&usbdrd_dwc3_0 {
status = "okay";
status = "disabled";
dr_mode = "host";
};

Expand Down
38 changes: 38 additions & 0 deletions drivers/tee/tee_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/cred.h>
#include <linux/fs.h>
#include <linux/idr.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/tee_core.h>
Expand Down Expand Up @@ -222,6 +223,11 @@ int tee_session_calc_client_uuid(uuid_t *uuid, u32 connection_method,
* For TEEC_LOGIN_GROUP:
* gid=<gid>
*
* For TEEC_LOGIN_APPLICATION:
* path=<command line path>
*
* For TEEC_LOGIN_USER_APPLICATION:
* uid=<uid>,path=<command line path>
*/

name = kzalloc(TEE_UUID_NS_NAME_SIZE, GFP_KERNEL);
Expand Down Expand Up @@ -254,6 +260,38 @@ int tee_session_calc_client_uuid(uuid_t *uuid, u32 connection_method,
}
break;

case TEE_IOCTL_LOGIN_APPLICATION:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the comment block above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

{
char path[PATH_MAX];
if (get_cmdline(current, path, sizeof(path)) >= sizeof(path)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How accurate is this when taking chroot and different techniques into account?

rc = -E2BIG;
goto out_free_name;
}
name_len = snprintf(name, TEE_UUID_NS_NAME_SIZE, "path=%s",
path);
if (name_len >= TEE_UUID_NS_NAME_SIZE) {
rc = -E2BIG;
goto out_free_name;
}
}
break;

case TEE_IOCTL_LOGIN_USER_APPLICATION:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the comment block above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

{
char path[PATH_MAX];
if (get_cmdline(current, path, sizeof(path)) >= sizeof(path)) {
rc = -E2BIG;
goto out_free_name;
}
name_len = snprintf(name, TEE_UUID_NS_NAME_SIZE, "uid=%x,path=%s",
current_euid().val, path);
if (name_len >= TEE_UUID_NS_NAME_SIZE) {
rc = -E2BIG;
goto out_free_name;
}
}
break;

default:
rc = -EINVAL;
goto out_free_name;
Expand Down