Re: [PATCH v2 0/2] support sign module with SM2-with-SM3 algorithm

2021-04-06 Thread Tianjia Zhang
ping. Thanks, Tianjia On 3/24/21 8:15 PM, Tianjia Zhang wrote: The kernel module signature supports the option to use the SM3 secure hash (OSCCA GM/T 0004-2012 SM3). SM2 and SM3 always appear in pairs. The former is used for signing and the latter is used for hash calculation. To sign

Re: [PATCH] crypto: sm3 - use the more precise type u32 instead of unsigned int

2021-04-06 Thread Tianjia Zhang
On 3/26/21 5:38 PM, Gilad Ben-Yossef wrote: Hi, Thank you for the patch! On Fri, Mar 26, 2021 at 5:21 AM Tianjia Zhang wrote: In the process of calculating the hash, use the more accurate type 'u32' instead of the original 'unsigned int' to avoid ambiguity. I don't think there is any

[PATCH] crypto: sm3 - use the more precise type u32 instead of unsigned int

2021-03-25 Thread Tianjia Zhang
In the process of calculating the hash, use the more accurate type 'u32' instead of the original 'unsigned int' to avoid ambiguity. Signed-off-by: Tianjia Zhang --- crypto/sm3_generic.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crypto/sm3_generic.c b

[PATCH v2 2/2] init/Kconfig: support sign module with SM2-with-SM3 algorithm

2021-03-24 Thread Tianjia Zhang
cert.pem test.ko test.ko.signed At this point, we should built the CA certificate into the kernel, and then we can load the SM2-with-SM3 signed module normally. Signed-off-by: Tianjia Zhang --- Documentation/admin-guide/module-signing.rst | 5 +++-- init/Kconfig

[PATCH v2 0/2] support sign module with SM2-with-SM3 algorithm

2021-03-24 Thread Tianjia Zhang
rithm sign-file sm3 private.pem cert.pem test.ko test.ko.signed At this point, we should built the CA certificate into the kernel, and then we can load the SM2-with-SM3 signed module normally. --- v2 change: - split one patch into twos. - richer commit log. Tianjia Zhang (2): pkcs7: make parse

[PATCH v2 1/2] pkcs7: make parser enable SM2 and SM3 algorithms combination

2021-03-24 Thread Tianjia Zhang
Support parsing the message signature of the SM2 and SM3 algorithm combination. This group of algorithms has been well supported. One of the main users is module signature verification. Signed-off-by: Tianjia Zhang --- crypto/asymmetric_keys/pkcs7_parser.c | 7 +++ 1 file changed, 7

[tip: x86/sgx] selftests/sgx: Use getauxval() to simplify test code

2021-03-24 Thread tip-bot2 for Tianjia Zhang
The following commit has been merged into the x86/sgx branch of tip: Commit-ID: f33dece70e11ce82a09cb1ea2d7c32347b82c67e Gitweb: https://git.kernel.org/tip/f33dece70e11ce82a09cb1ea2d7c32347b82c67e Author:Tianjia Zhang AuthorDate:Sun, 14 Mar 2021 19:16:21 +08:00 Committer

Re: [PATCH] init/Kconfig: Support sign module with SM3 hash algorithm

2021-03-24 Thread Tianjia Zhang
Hi, On 3/24/21 6:14 AM, Ard Biesheuvel wrote: On Tue, 23 Mar 2021 at 09:36, Tianjia Zhang wrote: The kernel module signature supports the option to use the SM3 secure hash (OSCCA GM/T 0004-2012 SM3). Signed-off-by: Tianjia Zhang A secure hash is not the same as a signature. Looking

Re: [PATCH] init/Kconfig: Support sign module with SM3 hash algorithm

2021-03-24 Thread Tianjia Zhang
Hi, On 3/24/21 12:43 AM, Randy Dunlap wrote: On 3/23/21 1:35 AM, Tianjia Zhang wrote: The kernel module signature supports the option to use the SM3 secure hash (OSCCA GM/T 0004-2012 SM3). Signed-off-by: Tianjia Zhang --- Documentation/admin-guide/module-signing.rst | 5 +++-- crypto

Re: [PATCH v6] selftests/x86: Use getauxval() to simplify the code in sgx

2021-03-24 Thread Tianjia Zhang
Hi, On 3/24/21 2:51 AM, Borislav Petkov wrote: On Tue, Mar 23, 2021 at 11:08:25AM +0800, Tianjia Zhang wrote: Take time to look at this. A "please" wouldn't hurt. I'm very sorry that my mistake caused your hurt. Please take time to look at this, which tree this should be pick

[PATCH] init/Kconfig: Support sign module with SM3 hash algorithm

2021-03-23 Thread Tianjia Zhang
The kernel module signature supports the option to use the SM3 secure hash (OSCCA GM/T 0004-2012 SM3). Signed-off-by: Tianjia Zhang --- Documentation/admin-guide/module-signing.rst | 5 +++-- crypto/asymmetric_keys/pkcs7_parser.c| 7 +++ init/Kconfig

Re: [PATCH v6] selftests/x86: Use getauxval() to simplify the code in sgx

2021-03-22 Thread Tianjia Zhang
Hi, On 3/15/21 9:02 PM, Jarkko Sakkinen wrote: On Sun, Mar 14, 2021 at 07:16:21PM +0800, Tianjia Zhang wrote: Simplify the sgx code implemntation by using library function getauxval() instead of a custom function to get the base address of vDSO. Signed-off-by: Tianjia Zhang Reviewed

[PATCH] sign-file: Fix confusing error messages

2021-03-22 Thread Tianjia Zhang
message will appear: sign-file: CMS_add1_signer: Success errx() ignores errno and does not cause such issue. Signed-off-by: Tianjia Zhang --- scripts/sign-file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/sign-file.c b/scripts/sign-file.c index fbd34b8e8f57

[PATCH v6] selftests/x86: Use getauxval() to simplify the code in sgx

2021-03-14 Thread Tianjia Zhang
Simplify the sgx code implemntation by using library function getauxval() instead of a custom function to get the base address of vDSO. Signed-off-by: Tianjia Zhang Reviewed-by: Jarkko Sakkinen Acked-by: Shuah Khan --- tools/testing/selftests/sgx/main.c | 24 1 file

Re: [PATCH] selftests/sgx: fix EINIT failure dueto SGX_INVALID_SIGNATURE

2021-03-10 Thread Tianjia Zhang
-0800, Andy Lutomirski wrote: On Mon, Mar 1, 2021 at 9:06 PM Tianjia Zhang wrote: On 3/1/21 5:54 PM, Jarkko Sakkinen wrote: On Mon, Mar 01, 2021 at 01:18:36PM +0800, Tianjia Zhang wrote: q2 is not always 384-byte length. Sometimes it only has 383-byte. What does determine

Re: [PATCH v9 2/9] x509: Detect sm2 keys by their parameters OID

2021-03-07 Thread Tianjia Zhang
Hi, On 3/5/21 11:04 PM, Stefan Berger wrote: On 3/5/21 2:37 AM, Tianjia Zhang wrote: Hi, On 3/4/21 7:46 AM, Stefan Berger wrote: Tianjia,     can you say whether SM2 support works for you before and after applying this patch? I cannot verify it with an sm2 key I have created using

Re: [PATCH v10 5/9] x509: Detect sm2 keys by their parameters OID

2021-03-04 Thread Tianjia Zhang
-off-by: Stefan Berger Reviewed-by: Tianjia Zhang --- crypto/asymmetric_keys/x509_cert_parser.c | 12 +++- include/linux/oid_registry.h | 1 + lib/oid_registry.c| 13 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/crypto

Re: [PATCH v9 2/9] x509: Detect sm2 keys by their parameters OID

2021-03-04 Thread Tianjia Zhang
Ll9J0dquxgCktp9DrTAPBgNVHRMBAf8EBTADAQH/MAoG CCqBHM9VAYN1A0cAMEQCIAvLWIfGFq85u/vVMLc5H1D/DnrNS0VhSkQA4daRO4tc AiABbeWENcQZDZLWTuqG9P2KDPOoNqV/QV/+0XjMAVblhg== -END CERTIFICATE- If you can, please add: Tested-by: Tianjia Zhang good luck! Tianjia

Re: [PATCH] selftests/sgx: fix EINIT failure dueto SGX_INVALID_SIGNATURE

2021-03-03 Thread Tianjia Zhang
On 3/2/21 8:51 PM, Jarkko Sakkinen wrote: Nit: "due to" Start with capital letter "Fix" Will do in the next patch. On Tue, Mar 02, 2021 at 01:06:52PM +0800, Tianjia Zhang wrote: On 3/1/21 5:54 PM, Jarkko Sakkinen wrote: On Mon, Mar 01, 2021 at 01:18:36PM +0800,

Re: [PATCH] selftests/sgx: fix EINIT failure dueto SGX_INVALID_SIGNATURE

2021-03-03 Thread Tianjia Zhang
On 3/2/21 1:54 PM, Andy Lutomirski wrote: On Mon, Mar 1, 2021 at 9:06 PM Tianjia Zhang wrote: On 3/1/21 5:54 PM, Jarkko Sakkinen wrote: On Mon, Mar 01, 2021 at 01:18:36PM +0800, Tianjia Zhang wrote: q2 is not always 384-byte length. Sometimes it only has 383-byte. What does determine

Re: [PATCH] selftests/sgx: fix EINIT failure dueto SGX_INVALID_SIGNATURE

2021-03-02 Thread Tianjia Zhang
On 3/1/21 5:54 PM, Jarkko Sakkinen wrote: On Mon, Mar 01, 2021 at 01:18:36PM +0800, Tianjia Zhang wrote: q2 is not always 384-byte length. Sometimes it only has 383-byte. What does determine this? In this case, the valid portion of q2 is reordered reversely for little endian order

[PATCH] selftests/sgx: fix EINIT failure dueto SGX_INVALID_SIGNATURE

2021-02-28 Thread Tianjia Zhang
q2 is not always 384-byte length. Sometimes it only has 383-byte. In this case, the valid portion of q2 is reordered reversely for little endian order, and the remaining portion is filled with zero. Signed-off-by: Tianjia Zhang --- tools/testing/selftests/sgx/sigstruct.c | 41

Re: [PATCH v5 3/3] x86/sgx: Remove redundant if conditions in sgx_encl_create

2021-02-24 Thread Tianjia Zhang
On 2/16/21 4:29 PM, Jarkko Sakkinen wrote: On Tue, Feb 16, 2021 at 11:31:33AM +0800, Tianjia Zhang wrote: In this scenario, there is no case where va_page is NULL, and the error has been checked. The if-condition statement here is redundant, so remove the condition detection. Signed-off

[PATCH v5 2/3] x86/sgx: Allows ioctl PROVISION to execute before CREATE

2021-02-15 Thread Tianjia Zhang
the function sgx_create_enclave() has been moved to the function sgx_open(), this will allow users to perform ioctl PROVISION operations before ioctl CREATE, increase the flexibility of the API and reduce restrictions. Signed-off-by: Tianjia Zhang --- arch/x86/kernel/cpu/sgx/driver.c | 1 + arch/x86

[PATCH v5 0/3] Some optimizations related to sgx

2021-02-15 Thread Tianjia Zhang
changes: * Improvements suggested by review v3 changes: * split free_cnt count and spin lock optimization into two patches v2 changes: * review suggested changes Tianjia Zhang (3): selftests/x86: Use getauxval() to simplify the code in sgx x86/sgx: Allows ioctl PROVISION to execute

[PATCH v5 3/3] x86/sgx: Remove redundant if conditions in sgx_encl_create

2021-02-15 Thread Tianjia Zhang
In this scenario, there is no case where va_page is NULL, and the error has been checked. The if-condition statement here is redundant, so remove the condition detection. Signed-off-by: Tianjia Zhang Acked-by: Jarkko Sakkinen --- arch/x86/kernel/cpu/sgx/ioctl.c | 7 --- 1 file changed, 4

[PATCH v5 1/3] selftests/x86: Use getauxval() to simplify the code in sgx

2021-02-15 Thread Tianjia Zhang
Simplify the sgx code implemntation by using library function getauxval() instead of a custom function to get the base address of vDSO. Signed-off-by: Tianjia Zhang Reviewed-by: Jarkko Sakkinen Acked-by: Shuah Khan --- tools/testing/selftests/sgx/main.c | 24 1 file

Re: [PATCH v3 3/5] x86/sgx: Optimize the free_cnt count in sgx_epc_section

2021-02-15 Thread Tianjia Zhang
On 2/12/21 8:19 PM, Jarkko Sakkinen wrote: On Thu, Feb 11, 2021 at 02:04:12PM +0800, Tianjia Zhang wrote: Hi, Sorry for the late reply. On 1/28/21 1:40 AM, Jarkko Sakkinen wrote: I could bet some money that this does not bring any significant performance gain. Yes, this does not bring

Re: [PATCH v4 5/5] x86/sgx: Remove redundant if conditions in sgx_encl_create

2021-02-10 Thread Tianjia Zhang
On 2/3/21 6:04 AM, Jarkko Sakkinen wrote: On Mon, Feb 01, 2021 at 09:26:53PM +0800, Tianjia Zhang wrote: In this scenario, there is no case where va_page is NULL, and the error has been checked. The if condition statement here is if-condition, i.e. dash missing Will do in the next patch

Re: [PATCH v4 2/5] x86/sgx: Reduce the locking range in sgx_sanitize_section()

2021-02-10 Thread Tianjia Zhang
On 2/3/21 6:00 AM, Jarkko Sakkinen wrote: On Mon, Feb 01, 2021 at 09:26:50PM +0800, Tianjia Zhang wrote: The spin lock of sgx_epc_section only locks the page_list. The EREMOVE operation and init_laundry_list is not necessary in the protection range of the spin lock. This patch reduces

Re: [PATCH v4 4/5] x86/sgx: Allows ioctl PROVISION to execute before CREATE

2021-02-10 Thread Tianjia Zhang
On 2/3/21 5:57 AM, Jarkko Sakkinen wrote: On Mon, Feb 01, 2021 at 09:26:52PM +0800, Tianjia Zhang wrote: In the function sgx_create_enclave(), the direct assignment operation of attributes_mask determines that the ioctl PROVISION operation must be executed after the ioctl CREATE operation

Re: [PATCH v4 3/5] x86/sgx: Optimize the free_cnt count in sgx_epc_section

2021-02-10 Thread Tianjia Zhang
On 2/3/21 5:54 AM, Jarkko Sakkinen wrote: On Mon, Feb 01, 2021 at 09:26:51PM +0800, Tianjia Zhang wrote: 'section->free_cnt' represents the free page in sgx_epc_section, which is assigned once after initialization. In fact, just after the initialization is completed, the pa

Re: [PATCH v3 3/5] x86/sgx: Optimize the free_cnt count in sgx_epc_section

2021-02-10 Thread Tianjia Zhang
accurate. On Sun, Jan 24, 2021 at 02:29:05PM +0800, Tianjia Zhang wrote: `section->free_cnt` represents the free page in sgx_epc_section, which is assigned once after initialization. In fact, just after the initialization is completed, the pages are in the `init_laundry_list` list and can

[PATCH v4 0/5] Some optimizations related to sgx

2021-02-01 Thread Tianjia Zhang
lock optimization into two patches v2 changes: * review suggested changes Tianjia Zhang (5): selftests/x86: Use getauxval() to simplify the code in sgx x86/sgx: Reduce the locking range in sgx_sanitize_section() x86/sgx: Optimize the free_cnt count in sgx_epc_section x86/sgx: Allows

[PATCH v4 3/5] x86/sgx: Optimize the free_cnt count in sgx_epc_section

2021-02-01 Thread Tianjia Zhang
ection(), and then accumulates the count after the successful execution of EREMOVE. This seems to be more reasonable, free_cnt will also truly reflect the allocatable free pages in EPC. Sined-off-by: Tianjia Zhang Reviewed-by: Sean Christopherson --- arch/x86/kernel/cpu/sgx/main.c | 2 +- 1 file changed, 1 ins

[PATCH v4 2/5] x86/sgx: Reduce the locking range in sgx_sanitize_section()

2021-02-01 Thread Tianjia Zhang
of the page_list. Suggested-by: Sean Christopherson Signed-off-by: Tianjia Zhang --- arch/x86/kernel/cpu/sgx/main.c | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c index c519fc5f6948..4465912174fd 100644 --- a/arch

[PATCH v4 4/5] x86/sgx: Allows ioctl PROVISION to execute before CREATE

2021-02-01 Thread Tianjia Zhang
the function sgx_create_enclave() has been moved to the function sgx_open(), this will allow users to perform ioctl PROVISION operations before ioctl CREATE, increase the flexibility of the API and reduce restrictions. Signed-off-by: Tianjia Zhang --- arch/x86/kernel/cpu/sgx/driver.c | 1 + arch/x86

[PATCH v4 1/5] selftests/x86: Use getauxval() to simplify the code in sgx

2021-02-01 Thread Tianjia Zhang
Simplify the sgx code implemntation by using library function getauxval() instead of a custom function to get the base address of vDSO. Signed-off-by: Tianjia Zhang --- tools/testing/selftests/sgx/main.c | 24 1 file changed, 4 insertions(+), 20 deletions(-) diff --git

[PATCH v4 5/5] x86/sgx: Remove redundant if conditions in sgx_encl_create

2021-02-01 Thread Tianjia Zhang
In this scenario, there is no case where va_page is NULL, and the error has been checked. The if condition statement here is redundant, so remove the condition detection. Signed-off-by: Tianjia Zhang --- arch/x86/kernel/cpu/sgx/ioctl.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions

Re: [PATCH v3 4/5] x86/sgx: Allows ioctl PROVISION to execute before CREATE

2021-02-01 Thread Tianjia Zhang
On 1/30/21 9:26 PM, Jarkko Sakkinen wrote: On Sun, Jan 24, 2021 at 02:29:06PM +0800, Tianjia Zhang wrote: In the function sgx_create_enclave(), the direct assignment operation of attributes_mask determines that the ioctl PROVISION operation must be executed after the ioctl CREATE operation

Re: [PATCH v3 5/5] x86/sgx: Remove redundant if conditions in sgx_encl_create

2021-02-01 Thread Tianjia Zhang
On 1/30/21 10:33 PM, Jarkko Sakkinen wrote: On Sun, Jan 24, 2021 at 02:29:07PM +0800, Tianjia Zhang wrote: In this scenario, there is no case where va_page is NULL, and the error has been checked. The if condition statement here is redundant, so remove the condition detection. Signed-off

Re: [PATCH v3 1/5] selftests/x86: Simplify the code to get vdso base address in sgx

2021-02-01 Thread Tianjia Zhang
use upper and lower case letter, e.g. vDSO instead of vdso. Reply-To: In-Reply-To: <20210124062907.88229-2-tianjia.zh...@linux.alibaba.com> On Sun, Jan 24, 2021 at 02:29:03PM +0800, Tianjia Zhang wrote: This patch uses the library function `getauxval(AT_SYSINFO_EHDR)` instead of the

Re: [PATCH v6 2/4] x509: Detect sm2 keys by their parameters OID

2021-02-01 Thread Tianjia Zhang
; + /* * sprint_OID - Print an Object Identifier into a buffer * @data: The encoded OID to print Great job, I'm just curious why we need to add a new function, this seems unnecessary, if possible, please add Reviewed-by: Tianjia Zhang Best regards, Tianjia

Re: [PATCH v6 4/4] ima: Support EC keys for signature verification

2021-02-01 Thread Tianjia Zhang
of keys, we change the selection of the encoding type to be driven by the key's signature scheme rather than by the hash type. Signed-off-by: Stefan Berger Reviewed-by: Vitaly Chikunov Cc: Mimi Zohar Cc: Dmitry Kasatkin Cc: linux-integr...@vger.kernel.org Cc: Vitaly Chikunov Cc: Tianjia Zhang Cc

Re: [PATCH] x86/sgx: Allows ioctl PROVISION to execute before CREATE

2021-01-23 Thread Tianjia Zhang
On 1/21/21 6:37 AM, Jarkko Sakkinen wrote: On Thu, Jan 21, 2021 at 12:34:49AM +0200, Jarkko Sakkinen wrote: On Wed, Jan 20, 2021 at 11:57:18AM +0800, Tianjia Zhang wrote: Hi, On 1/20/21 4:05 AM, Sean Christopherson wrote: On Mon, Jan 18, 2021, Tianjia Zhang wrote: In function

Re: [PATCH v2] x86/sgx: Remove redundant if conditions in sgx_encl_create

2021-01-23 Thread Tianjia Zhang
On 1/21/21 1:47 AM, Sean Christopherson wrote: On Wed, Jan 20, 2021, Tianjia Zhang wrote: In this scenario, there is no case where va_page is NULL, and the error has been checked. The if condition statement here is redundant, so remove the condition detection. Reported-by: Jia Zhang

[PATCH v3 4/5] x86/sgx: Allows ioctl PROVISION to execute before CREATE

2021-01-23 Thread Tianjia Zhang
the function sgx_create_enclave() has been moved to the function sgx_open() to avoid this restriction. Signed-off-by: Tianjia Zhang --- arch/x86/kernel/cpu/sgx/driver.c | 1 + arch/x86/kernel/cpu/sgx/ioctl.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu

[PATCH v3 0/5] Some optimizations related to sgx

2021-01-23 Thread Tianjia Zhang
: * review suggested changes Tianjia Zhang (5): selftests/x86: Simplify the code to get vdso base address in sgx x86/sgx: Optimize the locking range in sgx_sanitize_section() x86/sgx: Optimize the free_cnt count in sgx_epc_section x86/sgx: Allows ioctl PROVISION to execute before CREATE

[PATCH v3 2/5] x86/sgx: Optimize the locking range in sgx_sanitize_section()

2021-01-23 Thread Tianjia Zhang
of the page_list. Suggested-by: Sean Christopherson Signed-off-by: Tianjia Zhang --- arch/x86/kernel/cpu/sgx/main.c | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c index c519fc5f6948..4465912174fd 100644 --- a/arch

[PATCH v3 3/5] x86/sgx: Optimize the free_cnt count in sgx_epc_section

2021-01-23 Thread Tianjia Zhang
ection()`, and then accumulates the count after the successful execution of EREMOVE. This seems to be more reasonable, free_cnt will also truly reflect the allocatable free pages in EPC. Sined-off-by: Tianjia Zhang Reviewed-by: Sean Christopherson --- arch/x86/kernel/cpu/sgx/main.c | 2 +- 1 file chan

[PATCH v3 5/5] x86/sgx: Remove redundant if conditions in sgx_encl_create

2021-01-23 Thread Tianjia Zhang
In this scenario, there is no case where va_page is NULL, and the error has been checked. The if condition statement here is redundant, so remove the condition detection. Signed-off-by: Tianjia Zhang --- arch/x86/kernel/cpu/sgx/ioctl.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions

[PATCH v3 1/5] selftests/x86: Simplify the code to get vdso base address in sgx

2021-01-23 Thread Tianjia Zhang
This patch uses the library function `getauxval(AT_SYSINFO_EHDR)` instead of the custom function `vdso_get_base_addr` to obtain the base address of vDSO, which will simplify the code implementation. Signed-off-by: Tianjia Zhang --- tools/testing/selftests/sgx/main.c | 24

Re: [PATCH] tpm/tpm_tis: Fix variable reset during IRQ probing

2021-01-19 Thread Tianjia Zhang
On 1/15/21 5:23 PM, Jarkko Sakkinen wrote: On Thu, Jan 14, 2021 at 12:12:16PM +0800, Tianjia Zhang wrote: On 1/14/21 10:51 AM, Jarkko Sakkinen wrote: On Wed, Jan 13, 2021 at 08:00:21PM +0800, Tianjia Zhang wrote: In tpm_tis_core_init(), tpm2_probe() will be called first, this function

[PATCH v2] x86/sgx: Allows ioctl PROVISION to execute before CREATE

2021-01-19 Thread Tianjia Zhang
and more flexibly. Reported-by: Jia Zhang Suggested-by: Sean Christopherson Signed-off-by: Tianjia Zhang --- arch/x86/kernel/cpu/sgx/driver.c | 3 +++ arch/x86/kernel/cpu/sgx/ioctl.c | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/sgx/driver.c b/arch

Re: [PATCH] x86/sgx: Allows ioctl PROVISION to execute before CREATE

2021-01-19 Thread Tianjia Zhang
Hi, On 1/20/21 4:05 AM, Sean Christopherson wrote: On Mon, Jan 18, 2021, Tianjia Zhang wrote: In function sgx_encl_create(), the logic of directly assigning value to attributes_mask determines that the call to SGX_IOC_ENCLAVE_PROVISION must be after the command of SGX_IOC_ENCLAVE_CREATE

[PATCH v2] x86/sgx: Fix free_cnt counting logic in epc section

2021-01-19 Thread Tianjia Zhang
: Sean Christopherson Reviewed-by: Sean Christopherson Signed-off-by: Tianjia Zhang --- arch/x86/kernel/cpu/sgx/main.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c index c519fc5f6948..34a72a147983

[PATCH v2] x86/sgx: Remove redundant if conditions in sgx_encl_create

2021-01-19 Thread Tianjia Zhang
In this scenario, there is no case where va_page is NULL, and the error has been checked. The if condition statement here is redundant, so remove the condition detection. Reported-by: Jia Zhang Suggested-by: Sean Christopherson Signed-off-by: Tianjia Zhang --- arch/x86/kernel/cpu/sgx/ioctl.c

[PATCH] mm: Optimizing error condition detection in do_mprotect_pkey()

2021-01-18 Thread Tianjia Zhang
Obviously, the error variable detection of the if statement is for the mprotect callback function, so it is also put into the scope of calling callbck. Reported-by: Jia Zhang Signed-off-by: Tianjia Zhang --- mm/mprotect.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git

[PATCH] x86/sgx: Allows ioctl PROVISION to execute before CREATE

2021-01-18 Thread Tianjia Zhang
and more flexibly. Reported-by: Jia Zhang Signed-off-by: Tianjia Zhang --- arch/x86/kernel/cpu/sgx/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c index f45957c05f69..0ca3fc238bc2 100644 --- a/arch/x86

[PATCH] x86/sgx: Remove redundant if conditions in sgx_encl_create

2021-01-18 Thread Tianjia Zhang
In this scenario, there is no case where va_page is NULL, and the error has been checked. The if condition statement here is redundant, so remove the condition detection. Reported-by: Jia Zhang Signed-off-by: Tianjia Zhang --- arch/x86/kernel/cpu/sgx/ioctl.c | 5 ++--- 1 file changed, 2

[PATCH] x86/sgx: Fix free_cnt counting logic in epc section

2021-01-18 Thread Tianjia Zhang
eed to be reset by ksgxd. Reported-by: Jia Zhang Signed-off-by: Tianjia Zhang --- arch/x86/kernel/cpu/sgx/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c index c519fc5f6948..9e9a3cf7c00b 100644 --- a/arch/

[PATCH] selftests/x86: Simplify the code of getting vdso base address in sgx

2021-01-18 Thread Tianjia Zhang
The base address of vDSO can be obtained through the library function `getauxval()`, so use `getauxval(AT_SYSINFO_EHDR)` instead of a custom implementation to simplify the code. Reported-by: Jia Zhang Signed-off-by: Tianjia Zhang --- tools/testing/selftests/sgx/main.c | 24

Re: [PATCH] tpm/tpm_tis: Fix variable reset during IRQ probing

2021-01-13 Thread Tianjia Zhang
On 1/14/21 10:51 AM, Jarkko Sakkinen wrote: On Wed, Jan 13, 2021 at 08:00:21PM +0800, Tianjia Zhang wrote: In tpm_tis_core_init(), tpm2_probe() will be called first, this function will eventually call tpm_tis_send(), and then tpm_tis_probe_irq_single() will detect whether the interrupt

[PATCH] tpm/tpm_tis: Fix variable reset during IRQ probing

2021-01-13 Thread Tianjia Zhang
tch solves this issue by introducing a new variable, which is only used in interrupts, and irq_tested only marks whether the interrupt test has been completed. Signed-off-by: Tianjia Zhang --- drivers/char/tpm/tpm_tis_core.c | 8 drivers/char/tpm/tpm_tis_core.h | 1 + 2 files changed

Re: [PATCH] X.509: Fix crash caused by NULL pointer

2021-01-12 Thread Tianjia Zhang
On 1/7/21 6:58 PM, David Howells wrote: Tianjia Zhang wrote: On the following call path, `sig->pkey_algo` is not assigned in asymmetric_key_verify_signature(), which causes runtime crash in public_key_verify_signature(). keyctl_pkey_verify asymmetric_key_verify_signat

[PATCH] X.509: Fix crash caused by NULL pointer

2021-01-07 Thread Tianjia Zhang
ply check this situation and fixes the crash caused by NULL pointer. Fixes: 215525639631 ("X.509: support OSCCA SM2-with-SM3 certificate verification") Cc: sta...@vger.kernel.org # v5.10+ Reported-by: Tobias Markus Signed-off-by: Tianjia Zhang --- crypto/asymmetric_keys/public_key.c |

Re: [PATCH] crypto: ecrdsa - use subsys_initcall instead of module_init

2020-11-29 Thread Tianjia Zhang
On 11/30/20 10:24 AM, Herbert Xu wrote: On Mon, Nov 30, 2020 at 10:21:56AM +0800, Tianjia Zhang wrote: That is true only if there are non-generic implementations of the algorithms, which is not the case here. Please explain the real reason why this is needed. This is a generic algorithm

Re: [PATCH] crypto: ecrdsa - use subsys_initcall instead of module_init

2020-11-29 Thread Tianjia Zhang
Hi Herbert, On 10/15/20 8:05 PM, Herbert Xu wrote: On Thu, Oct 15, 2020 at 07:02:41PM +0800, Tianjia Zhang wrote: All templates and generic algorithms have been registered in subsys_initcall instead of module_init. The ecrdsa algorithm happened to be missed. Here is a fix

[PATCH] crypto: public_key: Remove redundant header file from public_key.h

2020-11-18 Thread Tianjia Zhang
The akcipher.h header file was originally introduced in SM2, and then the definition of SM2 was moved to the existing code. This header file is left and should be removed. Signed-off-by: Tianjia Zhang --- include/crypto/public_key.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include

[PATCH] crypto: ecrdsa - use subsys_initcall instead of module_init

2020-10-15 Thread Tianjia Zhang
All templates and generic algorithms have been registered in subsys_initcall instead of module_init. The ecrdsa algorithm happened to be missed. Here is a fix for it. Cc: Vitaly Chikunov Signed-off-by: Tianjia Zhang --- crypto/ecrdsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion

[PATCH] crypto: sm2 - remove unnecessary reset operations

2020-10-15 Thread Tianjia Zhang
This is an algorithm optimization. The reset operation when setting the public key is repeated and redundant, so remove it. At the same time, `sm2_ecc_os2ec()` is optimized to make the function more simpler and more in line with the Linux code style. Signed-off-by: Tianjia Zhang --- crypto/sm2

[PATCH] KVM: x86: filter guest NX capability for cpuid2

2020-10-05 Thread Tianjia Zhang
Original KVM_SET_CPUID has removed NX on non-NX hosts as it did before. but KVM_SET_CPUID2 does not. The two should be consistent. Signed-off-by: Tianjia Zhang --- arch/x86/kvm/cpuid.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index

[PATCH] ipmi_si: Fix wrong return value in try_smi_init()

2020-10-05 Thread Tianjia Zhang
On an error exit path, a negative error code should be returned instead of a positive return value. Fixes: 90b2d4f15ff7 ("ipmi_si: Remove hacks for adding a dummy platform devices") Cc: Corey Minyard Signed-off-by: Tianjia Zhang --- drivers/char/ipmi/ipmi_si_intf.c | 2 +- 1 file

[PATCH] X.509: fix error return value on the failed path

2020-10-05 Thread Tianjia Zhang
When memory allocation fails, an appropriate return value should be set. Fixes: 215525639631 ("X.509: support OSCCA SM2-with-SM3 certificate verification") Signed-off-by: Tianjia Zhang --- crypto/asymmetric_keys/public_key_sm2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletio

[tip: timers/urgent] clocksource/drivers/h8300_timer8: Fix wrong return value in h8300_8timer_init()

2020-09-27 Thread tip-bot2 for Tianjia Zhang
The following commit has been merged into the timers/urgent branch of tip: Commit-ID: 400d033f5a599120089b5f0c54d14d198499af5a Gitweb: https://git.kernel.org/tip/400d033f5a599120089b5f0c54d14d198499af5a Author:Tianjia Zhang AuthorDate:Sun, 02 Aug 2020 19:15:41 +08:00

Re: [PATCH] lib/mpi: Fix unused variable warnings

2020-09-25 Thread Tianjia Zhang
Hi Herbert, Thanks for your patch, The changes look good. I have tested this patch, so, Tested-by: Tianjia Zhang Best regards, Tianjia On 9/25/20 4:19 PM, Herbert Xu wrote: On Mon, Sep 21, 2020 at 12:20:55AM +0800, Tianjia Zhang wrote: Expand the mpi library based on libgcrypt, and the ECC

Re: [PATCH] lib/mpi: Fix unused variable warnings

2020-09-25 Thread Tianjia Zhang
Hi Herbert, Thanks for your patch, I will do a test later. By the way, did you add special compilation parameters? I compile normally without warnings in gcc 6.5 and 9.3. Best regards, Tianjia On 9/25/20 4:19 PM, Herbert Xu wrote: On Mon, Sep 21, 2020 at 12:20:55AM +0800, Tianjia Zhang

Re: [PATCH] mm/shmem.c: Fix the missing unaccount on the failed path

2020-09-21 Thread Tianjia Zhang
On 9/21/20 2:49 AM, Hugh Dickins wrote: On Mon, 21 Sep 2020, Tianjia Zhang wrote: In function __shmem_file_setup(), shmem_unacct_size() is forgotten on the failed path, so add it. Fixes: 93dec2da7b234 ("... and switch shmem_file_setup() to alloc_file_pseudo()") Cc: Al Viro

[PATCH] mm/shmem.c: Fix the missing unaccount on the failed path

2020-09-20 Thread Tianjia Zhang
In function __shmem_file_setup(), shmem_unacct_size() is forgotten on the failed path, so add it. Fixes: 93dec2da7b234 ("... and switch shmem_file_setup() to alloc_file_pseudo()") Cc: Al Viro Signed-off-by: Tianjia Zhang --- mm/shmem.c | 4 +++- 1 file changed, 3 insertions(+),

[PATCH v7 06/10] crypto: testmgr - Fix potential memory leak in test_akcipher_one()

2020-09-20 Thread Tianjia Zhang
When the 'key' allocation fails, the 'req' will not be released, which will cause memory leakage on this path. This patch adds a 'free_req' tag used to solve this problem, and two new err values are added to reflect the real reason of the error. Signed-off-by: Tianjia Zhang --- crypto/testmgr.c

[PATCH v7 09/10] X.509: support OSCCA SM2-with-SM3 certificate verification

2020-09-20 Thread Tianjia Zhang
and calculate ZA. Finally calculate the digest of the signature and complete the verification work. The calculation process of ZA is declared in specifications GM/T 0009-2012 and GM/T 0003.2-2012. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang Reviewed-by: Gilad Ben-Yossef --- crypto

[PATCH v7 05/10] crypto: testmgr - support test with different ciphertext per encryption

2020-09-20 Thread Tianjia Zhang
to achieve the test purpose. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- crypto/testmgr.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 23c27fc96394..cd002a030af5 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c

[PATCH v7 04/10] crypto: sm2 - introduce OSCCA SM2 asymmetric cipher algorithm

2020-09-20 Thread Tianjia Zhang
://tools.ietf.org/html/draft-shen-sm2-ecdsa-02 oscca: http://www.oscca.gov.cn/sca/xxgk/2010-12/17/content_1002386.shtml scctc: http://www.gmbz.org.cn/main/bzlb.html Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- crypto/Kconfig | 17 ++ crypto/Makefile | 8

[PATCH v7 02/10] lib/mpi: Extend the MPI library

2020-09-20 Thread Tianjia Zhang
Expand the mpi library based on libgcrypt, and the ECC algorithm of mpi based on libgcrypt requires these functions. Some other algorithms will be developed based on mpi ecc, such as SM2. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- include/linux/mpi.h| 87 +++ lib/mpi

[PATCH v7 07/10] crypto: sm2 - add SM2 test vectors to testmgr

2020-09-20 Thread Tianjia Zhang
Add testmgr test vectors for SM2 algorithm. These vectors come from `openssl pkeyutl -sign` and libgcrypt. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- crypto/testmgr.c | 6 + crypto/testmgr.h | 59 2 files changed, 65

[PATCH v7 08/10] X.509: support OSCCA certificate parse

2020-09-20 Thread Tianjia Zhang
the standard elliptic curve public key, and the sm2 algorithm signs the hash generated by sm3. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang Reviewed-by: Vitaly Chikunov --- crypto/asymmetric_keys/x509_cert_parser.c | 27 ++- include/linux/oid_registry.h | 6

[PATCH v7 01/10] crypto: sm3 - export crypto_sm3_final function

2020-09-20 Thread Tianjia Zhang
Both crypto_sm3_update and crypto_sm3_finup have been exported, exporting crypto_sm3_final, to avoid having to use crypto_sm3_finup(desc, NULL, 0, dgst) to calculate the hash in some cases. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- crypto/sm3_generic.c | 7 --- include

[PATCH v7 10/10] integrity: Asymmetric digsig supports SM2-with-SM3 algorithm

2020-09-20 Thread Tianjia Zhang
Asymmetric digsig supports SM2-with-SM3 algorithm combination, so that IMA can also verify SM2's signature data. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang Reviewed-by: Mimi Zohar Reviewed-by: Vitaly Chikunov --- security/integrity/digsig_asymmetric.c | 14 +++--- 1 file

[PATCH v7 00/10] crpyto: introduce OSCCA certificate and SM2 asymmetric algorithm

2020-09-20 Thread Tianjia Zhang
on mainline. v2 changes: 1. simplify the sm2 algorithm and only retain the verify function. 2. extract the sm2 certificate code into a separate file. Tianjia Zhang (10): crypto: sm3 - export crypto_sm3_final function lib/mpi: Extend the MPI library lib/mpi: Introduce ec implementation to MPI

[PATCH v7 03/10] lib/mpi: Introduce ec implementation to MPI library

2020-09-20 Thread Tianjia Zhang
The implementation of EC is introduced from libgcrypt as the basic algorithm of elliptic curve, which can be more perfectly integrated with MPI implementation. Some other algorithms will be developed based on mpi ecc, such as SM2. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang

Re: [PATCH v6 5/8] crypto: testmgr - support test with different ciphertext per encryption

2020-09-18 Thread Tianjia Zhang
On 9/18/20 2:47 PM, Herbert Xu wrote: On Thu, Sep 03, 2020 at 09:12:39PM +0800, Tianjia Zhang wrote: Some asymmetric algorithms will get different ciphertext after each encryption, such as SM2, and let testmgr support the testing of such algorithms. In struct akcipher_testvec, set c

Re: [PATCH] vhost-vdpa: fix memory leak in error path

2020-09-18 Thread Tianjia Zhang
LGTM. Reviewed-by: Tianjia Zhang Thanks. On 9/9/20 11:41 PM, Li Qiang wrote: Free the 'page_list' when the 'npages' is zero. Signed-off-by: Li Qiang --- drivers/vhost/vdpa.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost

Re: [PATCH v1] atomisp:pci/runtime/queue: modify the return error value

2020-09-16 Thread Tianjia Zhang
LGTM. Reviewed-by: Tianjia Zhang On 9/17/20 11:44 AM, Xiaoliang Pang wrote: modify the return error value is -EDOM Fixes: 2cac05dee6e30("drm/amd/powerplay: add the hw manager for vega12 (v4)") Cc: Evan Quan Signed-off-by: Xiaoliang Pang --- .../staging/media/atomisp/pci/runtime

Re: [PATCH v6 0/8] crpyto: introduce OSCCA certificate and SM2 asymmetric algorithm

2020-09-14 Thread Tianjia Zhang
Hi, On 9/11/20 12:24 PM, Herbert Xu wrote: On Thu, Sep 03, 2020 at 09:12:34PM +0800, Tianjia Zhang wrote: --- v6 changes: 1. remove mpi_sub_ui function from mpi library. 2. rebase on mainline. This series is still missing acks for patches 6-8. Without them it cannot proceed. Thanks

Re: [PATCH v6 7/8] X.509: support OSCCA sm2-with-sm3 certificate verification

2020-09-14 Thread Tianjia Zhang
Hi Gilad, On 9/13/20 3:12 PM, Gilad Ben-Yossef wrote: Hi, On Thu, Sep 3, 2020 at 4:13 PM Tianjia Zhang wrote: The digital certificate format based on SM2 crypto algorithm as specified in GM/T 0015-2012. It was published by State Encryption Management Bureau, China. The method

[PATCH v6 6/8] X.509: support OSCCA certificate parse

2020-09-03 Thread Tianjia Zhang
the standard elliptic curve public key, and the sm2 algorithm signs the hash generated by sm3. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- crypto/asymmetric_keys/x509_cert_parser.c | 14 +- include/linux/oid_registry.h | 6 ++ 2 files changed, 19 insertions

[PATCH v6 4/8] crypto: sm2 - introduce OSCCA SM2 asymmetric cipher algorithm

2020-09-03 Thread Tianjia Zhang
://tools.ietf.org/html/draft-shen-sm2-ecdsa-02 oscca: http://www.oscca.gov.cn/sca/xxgk/2010-12/17/content_1002386.shtml scctc: http://www.gmbz.org.cn/main/bzlb.html Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- crypto/Kconfig | 17 ++ crypto/Makefile | 8

[PATCH v6 7/8] X.509: support OSCCA sm2-with-sm3 certificate verification

2020-09-03 Thread Tianjia Zhang
and calculate ZA. Finally calculate the digest of the signature and complete the verification work. The calculation process of ZA is declared in specifications GM/T 0009-2012 and GM/T 0003.2-2012. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- crypto/asymmetric_keys/Makefile | 1

[PATCH v6 5/8] crypto: testmgr - support test with different ciphertext per encryption

2020-09-03 Thread Tianjia Zhang
to achieve the test purpose. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang --- crypto/testmgr.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 23c27fc96394..cd002a030af5 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c

[PATCH v6 0/8] crpyto: introduce OSCCA certificate and SM2 asymmetric algorithm

2020-09-03 Thread Tianjia Zhang
into a separate file. Tianjia Zhang (8): crypto: sm3 - export crypto_sm3_final function lib/mpi: Extend the MPI library lib/mpi: Introduce ec implementation to MPI library crypto: sm2 - introduce OSCCA SM2 asymmetric cipher algorithm crypto: testmgr - support test with different ciphertext per

  1   2   >