2014-01-09 05:00:29

by Naveen Krishna Chatradhi

[permalink] [raw]
Subject: [PATCH 6/6 v2] crypto:s5p-sss: validate iv before memcpy

This patch adds code to validate "iv" buffer before trying to
memcpy the contents

Signed-off-by: Naveen Krishna Chatradhi <[email protected]>
---
Changes since v1:
None

drivers/crypto/s5p-sss.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c
index 7c31a5f..220f123 100644
--- a/drivers/crypto/s5p-sss.c
+++ b/drivers/crypto/s5p-sss.c
@@ -398,8 +398,9 @@ static void s5p_set_aes(struct s5p_aes_dev *dev,
struct samsung_aes_varient *var = dev->varient;
void __iomem *keystart;

- memcpy(dev->ioaddr + SSS_REG_AES_IV_DATA
- (var->aes_offset, 0), iv, 0x10);
+ if (iv)
+ memcpy(dev->ioaddr + SSS_REG_AES_IV_DATA
+ (var->aes_offset, 0), iv, 0x10);

if (keylen == AES_KEYSIZE_256)
keystart = dev->ioaddr +
--
1.7.9.5


2014-01-10 11:45:11

by Naveen Krishna Chatradhi

[permalink] [raw]
Subject: [PATCH 7/8 v3] crypto:s5p-sss: validate iv before memcpy

This patch adds code to validate "iv" buffer before trying to
memcpy the contents

Signed-off-by: Naveen Krishna Chatradhi <[email protected]>
---
Changes since v2:
None

drivers/crypto/s5p-sss.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c
index f274f5f..7058bb6 100644
--- a/drivers/crypto/s5p-sss.c
+++ b/drivers/crypto/s5p-sss.c
@@ -381,8 +381,9 @@ static void s5p_set_aes(struct s5p_aes_dev *dev,
struct samsung_aes_variant *var = dev->variant;
void __iomem *keystart;

- memcpy(dev->ioaddr + SSS_REG_AES_IV_DATA
- (var->aes_offset, 0), iv, 0x10);
+ if (iv)
+ memcpy(dev->ioaddr + SSS_REG_AES_IV_DATA
+ (var->aes_offset, 0), iv, 0x10);

if (keylen == AES_KEYSIZE_256)
keystart = dev->ioaddr +
--
1.7.9.5

2014-01-10 16:03:21

by Tomasz Figa

[permalink] [raw]
Subject: Re: [PATCH 7/8 v3] crypto:s5p-sss: validate iv before memcpy

Hi Naveen,

On 10.01.2014 12:45, Naveen Krishna Chatradhi wrote:
> This patch adds code to validate "iv" buffer before trying to
> memcpy the contents
>
> Signed-off-by: Naveen Krishna Chatradhi <[email protected]>
> ---
> Changes since v2:
> None
>
> drivers/crypto/s5p-sss.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c
> index f274f5f..7058bb6 100644
> --- a/drivers/crypto/s5p-sss.c
> +++ b/drivers/crypto/s5p-sss.c
> @@ -381,8 +381,9 @@ static void s5p_set_aes(struct s5p_aes_dev *dev,
> struct samsung_aes_variant *var = dev->variant;
> void __iomem *keystart;
>
> - memcpy(dev->ioaddr + SSS_REG_AES_IV_DATA
> - (var->aes_offset, 0), iv, 0x10);
> + if (iv)
> + memcpy(dev->ioaddr + SSS_REG_AES_IV_DATA
> + (var->aes_offset, 0), iv, 0x10);

In what conditions can the iv end up being NULL?

Best regards,
Tomasz

2014-01-15 06:45:40

by Naveen Krishna Ch

[permalink] [raw]
Subject: Re: [PATCH 7/8 v3] crypto:s5p-sss: validate iv before memcpy

Hello Tomasz,

On 10 January 2014 21:33, Tomasz Figa <[email protected]> wrote:
> Hi Naveen,
>
>
> On 10.01.2014 12:45, Naveen Krishna Chatradhi wrote:
>>
>> This patch adds code to validate "iv" buffer before trying to
>> memcpy the contents
>>
>> Signed-off-by: Naveen Krishna Chatradhi <[email protected]>
>> ---
>> Changes since v2:
>> None
>>
>> drivers/crypto/s5p-sss.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c
>> index f274f5f..7058bb6 100644
>> --- a/drivers/crypto/s5p-sss.c
>> +++ b/drivers/crypto/s5p-sss.c
>> @@ -381,8 +381,9 @@ static void s5p_set_aes(struct s5p_aes_dev *dev,
>> struct samsung_aes_variant *var = dev->variant;
>> void __iomem *keystart;
>>
>> - memcpy(dev->ioaddr + SSS_REG_AES_IV_DATA
>> - (var->aes_offset, 0), iv, 0x10);
>> + if (iv)
>> + memcpy(dev->ioaddr + SSS_REG_AES_IV_DATA
>> + (var->aes_offset, 0), iv, 0x10);
>
>
> In what conditions can the iv end up being NULL?
req->info is the initialization vector in our case, which comes from user space.
Its good to have a check to avoid any crashes.

Also AES ECB mode does not use IV.
>
> Best regards,
> Tomasz



--
Shine bright,
(: Nav :)

2014-01-15 09:16:50

by Naveen Krishna Chatradhi

[permalink] [raw]
Subject: [PATCH 6/8 v4] ARM: dts: exynos5250/5420: add dt node for sss module

This patch adds the device tree node for SSS module
found on Exynos5420 and Exynos5250

Signed-off-by: Naveen Krishna Chatradhi <[email protected]>
Reviewed-by: Tomasz Figa <[email protected]>
TO: <[email protected]>
CC: Kukjin Kim <[email protected]>
CC: <[email protected]>
---
Changes since v3:
1. Modified the SSS clock ID as per dt-bindings for Exynos5250 in
samsung-clk.git tree.

arch/arm/boot/dts/exynos5250.dtsi | 8 ++++++++
arch/arm/boot/dts/exynos5420.dtsi | 10 ++++++++++
2 files changed, 18 insertions(+)

diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index c341e55..1d249df 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -704,4 +704,12 @@
io-channel-ranges;
status = "disabled";
};
+
+ sss@10830000 {
+ compatible = "samsung,exynos4210-secss";
+ reg = <0x10830000 0x10000>;
+ interrupts = <0 112 0>;
+ clocks = <&clock 348>;
+ clock-names = "secss";
+ };
};
diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi
index 11dd202..56a3f3e 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -652,4 +652,14 @@
clocks = <&clock 319>, <&clock 318>;
clock-names = "tmu_apbif", "tmu_triminfo_apbif";
};
+
+ sss@10830000 {
+ compatible = "samsung,exynos4210-secss";
+ reg = <0x10830000 0x10000>;
+ interrupts = <0 112 0>;
+ clocks = <&clock 471>;
+ clock-names = "secss";
+ samsung,power-domain = <&g2d_pd>;
+ };
+
};
--
1.7.9.5

2014-01-15 09:17:18

by Naveen Krishna Chatradhi

[permalink] [raw]
Subject: [PATCH 7/8 v4] crypto:s5p-sss: validate iv before memcpy

This patch adds code to validate "iv" buffer before trying to
memcpy the contents

Signed-off-by: Naveen Krishna Chatradhi <[email protected]>
---
Changes since v3:
None

drivers/crypto/s5p-sss.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c
index 69130b2..f7c66c7 100644
--- a/drivers/crypto/s5p-sss.c
+++ b/drivers/crypto/s5p-sss.c
@@ -380,7 +380,8 @@ static void s5p_set_aes(struct s5p_aes_dev *dev,
{
void __iomem *keystart;

- memcpy(dev->aes_ioaddr + SSS_REG_AES_IV_DATA (0), iv, 0x10);
+ if (iv)
+ memcpy(dev->aes_ioaddr + SSS_REG_AES_IV_DATA (0), iv, 0x10);

if (keylen == AES_KEYSIZE_256)
keystart = dev->aes_ioaddr + SSS_REG_AES_KEY_DATA(0);
--
1.7.9.5

2014-01-23 10:19:24

by Naveen Krishna Ch

[permalink] [raw]
Subject: Re: [PATCH 7/8 v4] crypto:s5p-sss: validate iv before memcpy

Hello All,

On 15 January 2014 14:47, Naveen Krishna Chatradhi
<[email protected]> wrote:
> This patch adds code to validate "iv" buffer before trying to
> memcpy the contents
>
> Signed-off-by: Naveen Krishna Chatradhi <[email protected]>
> ---
> Changes since v3:
> None
>
> drivers/crypto/s5p-sss.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c
> index 69130b2..f7c66c7 100644
> --- a/drivers/crypto/s5p-sss.c
> +++ b/drivers/crypto/s5p-sss.c
> @@ -380,7 +380,8 @@ static void s5p_set_aes(struct s5p_aes_dev *dev,
> {
> void __iomem *keystart;
>
> - memcpy(dev->aes_ioaddr + SSS_REG_AES_IV_DATA (0), iv, 0x10);
> + if (iv)
> + memcpy(dev->aes_ioaddr + SSS_REG_AES_IV_DATA (0), iv, 0x10);
>
> if (keylen == AES_KEYSIZE_256)
> keystart = dev->aes_ioaddr + SSS_REG_AES_KEY_DATA(0);
> --
> 1.7.9.5
Any update on this patch, Please
>



--
Shine bright,
(: Nav :)

2014-01-23 10:19:37

by Naveen Krishna Ch

[permalink] [raw]
Subject: Re: [PATCH 6/8 v4] ARM: dts: exynos5250/5420: add dt node for sss module

Hello All,

On 15 January 2014 14:46, Naveen Krishna Chatradhi
<[email protected]> wrote:
> This patch adds the device tree node for SSS module
> found on Exynos5420 and Exynos5250
>
> Signed-off-by: Naveen Krishna Chatradhi <[email protected]>
> Reviewed-by: Tomasz Figa <[email protected]>
> TO: <[email protected]>
> CC: Kukjin Kim <[email protected]>
> CC: <[email protected]>
> ---
> Changes since v3:
> 1. Modified the SSS clock ID as per dt-bindings for Exynos5250 in
> samsung-clk.git tree.
>
> arch/arm/boot/dts/exynos5250.dtsi | 8 ++++++++
> arch/arm/boot/dts/exynos5420.dtsi | 10 ++++++++++
> 2 files changed, 18 insertions(+)
>
> diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
> index c341e55..1d249df 100644
> --- a/arch/arm/boot/dts/exynos5250.dtsi
> +++ b/arch/arm/boot/dts/exynos5250.dtsi
> @@ -704,4 +704,12 @@
> io-channel-ranges;
> status = "disabled";
> };
> +
> + sss@10830000 {
> + compatible = "samsung,exynos4210-secss";
> + reg = <0x10830000 0x10000>;
> + interrupts = <0 112 0>;
> + clocks = <&clock 348>;
> + clock-names = "secss";
> + };
> };
> diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi
> index 11dd202..56a3f3e 100644
> --- a/arch/arm/boot/dts/exynos5420.dtsi
> +++ b/arch/arm/boot/dts/exynos5420.dtsi
> @@ -652,4 +652,14 @@
> clocks = <&clock 319>, <&clock 318>;
> clock-names = "tmu_apbif", "tmu_triminfo_apbif";
> };
> +
> + sss@10830000 {
> + compatible = "samsung,exynos4210-secss";
> + reg = <0x10830000 0x10000>;
> + interrupts = <0 112 0>;
> + clocks = <&clock 471>;
> + clock-names = "secss";
> + samsung,power-domain = <&g2d_pd>;
> + };
> +
> };
> --
> 1.7.9.5
Any update on this patch, Please
>



--
Shine bright,
(: Nav :)

2014-01-24 15:36:53

by Tomasz Figa

[permalink] [raw]
Subject: Re: [PATCH 6/8 v4] ARM: dts: exynos5250/5420: add dt node for sss module

Hi Naveen,

On 15.01.2014 10:16, Naveen Krishna Chatradhi wrote:
> This patch adds the device tree node for SSS module
> found on Exynos5420 and Exynos5250
>
> Signed-off-by: Naveen Krishna Chatradhi <[email protected]>
> Reviewed-by: Tomasz Figa <[email protected]>
> TO: <[email protected]>
> CC: Kukjin Kim <[email protected]>
> CC: <[email protected]>
> ---
> Changes since v3:
> 1. Modified the SSS clock ID as per dt-bindings for Exynos5250 in
> samsung-clk.git tree.
>
> arch/arm/boot/dts/exynos5250.dtsi | 8 ++++++++
> arch/arm/boot/dts/exynos5420.dtsi | 10 ++++++++++
> 2 files changed, 18 insertions(+)

Reviewed-by: Tomasz Figa <[email protected]>

Best regards,
Tomasz

2014-01-24 15:53:14

by Tomasz Figa

[permalink] [raw]
Subject: Re: [PATCH 7/8 v4] crypto:s5p-sss: validate iv before memcpy

On 15.01.2014 10:17, Naveen Krishna Chatradhi wrote:
> This patch adds code to validate "iv" buffer before trying to
> memcpy the contents
>
> Signed-off-by: Naveen Krishna Chatradhi <[email protected]>
> ---
> Changes since v3:
> None
>
> drivers/crypto/s5p-sss.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Tomasz Figa <[email protected]>

Best regards,
Tomasz

2014-01-29 09:25:44

by Naveen Krishna Chatradhi

[permalink] [raw]
Subject: [PATCH 7/9 v5] crypto:s5p-sss: validate iv before memcpy

This patch adds code to validate "iv" buffer before trying to
memcpy the contents

Signed-off-by: Naveen Krishna Chatradhi <[email protected]>
Reviewed-by: Tomasz Figa <[email protected]>
---
Changes since v4:
None

Changes since v3:
None

drivers/crypto/s5p-sss.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c
index da1c8943..a890273 100644
--- a/drivers/crypto/s5p-sss.c
+++ b/drivers/crypto/s5p-sss.c
@@ -380,7 +380,8 @@ static void s5p_set_aes(struct s5p_aes_dev *dev,
{
void __iomem *keystart;

- memcpy(dev->aes_ioaddr + SSS_REG_AES_IV_DATA (0), iv, 0x10);
+ if (iv)
+ memcpy(dev->aes_ioaddr + SSS_REG_AES_IV_DATA (0), iv, 0x10);

if (keylen == AES_KEYSIZE_256)
keystart = dev->aes_ioaddr + SSS_REG_AES_KEY_DATA(0);
--
1.7.9.5

2014-01-29 09:31:26

by Naveen Krishna Chatradhi

[permalink] [raw]
Subject: [PATCH 6/9 v5] ARM: dts: exynos5250/5420: add dt node for sss module

This patch adds the device tree node for SSS module
found on Exynos5420 and Exynos5250

Signed-off-by: Naveen Krishna Chatradhi <[email protected]>
Reviewed-by: Tomasz Figa <[email protected]>
TO: <[email protected]>
CC: Kukjin Kim <[email protected]>
CC: <[email protected]>
---
Changes since v4:
None
Changes since v3:
1. Modified the SSS clock ID as per dt-bindings for Exynos5250 in
samsung-clk.git tree.

arch/arm/boot/dts/exynos5250.dtsi | 8 ++++++++
arch/arm/boot/dts/exynos5420.dtsi | 10 ++++++++++
2 files changed, 18 insertions(+)

diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index c341e55..1d249df 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -704,4 +704,12 @@
io-channel-ranges;
status = "disabled";
};
+
+ sss@10830000 {
+ compatible = "samsung,exynos4210-secss";
+ reg = <0x10830000 0x10000>;
+ interrupts = <0 112 0>;
+ clocks = <&clock 348>;
+ clock-names = "secss";
+ };
};
diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi
index 11dd202..56a3f3e 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -652,4 +652,14 @@
clocks = <&clock 319>, <&clock 318>;
clock-names = "tmu_apbif", "tmu_triminfo_apbif";
};
+
+ sss@10830000 {
+ compatible = "samsung,exynos4210-secss";
+ reg = <0x10830000 0x10000>;
+ interrupts = <0 112 0>;
+ clocks = <&clock 471>;
+ clock-names = "secss";
+ samsung,power-domain = <&g2d_pd>;
+ };
+
};
--
1.7.9.5

2014-02-07 05:25:47

by Naveen Krishna Chatradhi

[permalink] [raw]
Subject: [PATCH 7/9 v6] crypto:s5p-sss: validate iv before memcpy

This patch adds code to validate "iv" buffer before trying to
memcpy the contents

Signed-off-by: Naveen Krishna Chatradhi <[email protected]>
Reviewed-by: Tomasz Figa <[email protected]>
---
changes since v5:
None

drivers/crypto/s5p-sss.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c
index da1c8943..a890273 100644
--- a/drivers/crypto/s5p-sss.c
+++ b/drivers/crypto/s5p-sss.c
@@ -380,7 +380,8 @@ static void s5p_set_aes(struct s5p_aes_dev *dev,
{
void __iomem *keystart;

- memcpy(dev->aes_ioaddr + SSS_REG_AES_IV_DATA (0), iv, 0x10);
+ if (iv)
+ memcpy(dev->aes_ioaddr + SSS_REG_AES_IV_DATA (0), iv, 0x10);

if (keylen == AES_KEYSIZE_256)
keystart = dev->aes_ioaddr + SSS_REG_AES_KEY_DATA(0);
--
1.7.9.5