From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:63880 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755163AbeEaPC5 (ORCPT ); Thu, 31 May 2018 11:02:57 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4VExmJ0012792 for ; Thu, 31 May 2018 11:02:57 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jaj6w3ed8-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 31 May 2018 11:02:56 -0400 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 31 May 2018 16:02:55 +0100 Subject: Re: [PATCH v2 13/21] ima: use match_string() helper From: Mimi Zohar To: Yisheng Xie , linux-kernel@vger.kernel.org Cc: andy.shevchenko@gmail.com, Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org Date: Thu, 31 May 2018 11:02:38 -0400 In-Reply-To: <1527765086-19873-14-git-send-email-xieyisheng1@huawei.com> References: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> <1527765086-19873-14-git-send-email-xieyisheng1@huawei.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Message-Id: <1527778958.3427.16.camel@linux.vnet.ibm.com> Sender: linux-integrity-owner@vger.kernel.org List-ID: On Thu, 2018-05-31 at 19:11 +0800, Yisheng Xie wrote: > match_string() returns the index of an array for a matching string, > which can be used instead of open coded variant. > > Reviewed-by: Mimi Zohar > Reviewed-by: Andy Shevchenko > Cc: Mimi Zohar > Cc: Dmitry Kasatkin > Cc: James Morris > Cc: "Serge E. Hallyn" > Cc: linux-integrity@vger.kernel.org > Cc: linux-security-module@vger.kernel.org > Signed-off-by: Yisheng Xie In the future, the patch's author Signed-off-by is always first. Thanks, this patch is now queued in the next-integrity branch. Mimi > --- > v2: > - add Reviewed-by tag. > > security/integrity/ima/ima_main.c | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) > > diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c > index 74d0bd7..f807093 100644 > --- a/security/integrity/ima/ima_main.c > +++ b/security/integrity/ima/ima_main.c > @@ -61,14 +61,11 @@ static int __init hash_setup(char *str) > goto out; > } > > - for (i = 0; i < HASH_ALGO__LAST; i++) { > - if (strcmp(str, hash_algo_name[i]) == 0) { > - ima_hash_algo = i; > - break; > - } > - } > - if (i == HASH_ALGO__LAST) > + i = match_string(hash_algo_name, HASH_ALGO__LAST, str); > + if (i < 0) > return 1; > + > + ima_hash_algo = i; > out: > hash_setup_done = 1; > return 1; From mboxrd@z Thu Jan 1 00:00:00 1970 From: zohar@linux.vnet.ibm.com (Mimi Zohar) Date: Thu, 31 May 2018 11:02:38 -0400 Subject: [PATCH v2 13/21] ima: use match_string() helper In-Reply-To: <1527765086-19873-14-git-send-email-xieyisheng1@huawei.com> References: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> <1527765086-19873-14-git-send-email-xieyisheng1@huawei.com> Message-ID: <1527778958.3427.16.camel@linux.vnet.ibm.com> To: linux-security-module@vger.kernel.org List-Id: linux-security-module.vger.kernel.org On Thu, 2018-05-31 at 19:11 +0800, Yisheng Xie wrote: > match_string() returns the index of an array for a matching string, > which can be used instead of open coded variant. > > Reviewed-by: Mimi Zohar > Reviewed-by: Andy Shevchenko > Cc: Mimi Zohar > Cc: Dmitry Kasatkin > Cc: James Morris > Cc: "Serge E. Hallyn" > Cc: linux-integrity at vger.kernel.org > Cc: linux-security-module at vger.kernel.org > Signed-off-by: Yisheng Xie In the future, the patch's author Signed-off-by is always first. Thanks, this patch is now queued in the next-integrity branch. Mimi > --- > v2: > - add Reviewed-by tag. > > security/integrity/ima/ima_main.c | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) > > diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c > index 74d0bd7..f807093 100644 > --- a/security/integrity/ima/ima_main.c > +++ b/security/integrity/ima/ima_main.c > @@ -61,14 +61,11 @@ static int __init hash_setup(char *str) > goto out; > } > > - for (i = 0; i < HASH_ALGO__LAST; i++) { > - if (strcmp(str, hash_algo_name[i]) == 0) { > - ima_hash_algo = i; > - break; > - } > - } > - if (i == HASH_ALGO__LAST) > + i = match_string(hash_algo_name, HASH_ALGO__LAST, str); > + if (i < 0) > return 1; > + > + ima_hash_algo = i; > out: > hash_setup_done = 1; > return 1; -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html