Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp932145imm; Wed, 23 May 2018 07:43:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZolhw0YT7dN/TySSvgH4w24BSuxISq6Y6Dzt+AYoDNLDy8TFMLhSLevGsuCamQC8R/N6T8o X-Received: by 2002:a62:f80c:: with SMTP id d12-v6mr3209171pfh.159.1527086635242; Wed, 23 May 2018 07:43:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527086635; cv=none; d=google.com; s=arc-20160816; b=p1r0mw0a7RW0AaxNuw5vA/BTSJ6FXkzCp1tzMAURi6G9BrtrJbSB85/ig0Ce2tpOH4 j7gwClu06K8l9VA0yRvDn8GaUIMaQoASHm8nuGVaDymMcKBTt52JDEKBYZcTzanPmgOd bpzyG38cxQ5tk0hH+FL66rhfdC7aD2P+0K2wx5Be8kh8e6J8u2rCbHcO+madTEaoNt6K cvOLktH/ovGxrfodMITBTr0G0sGQxblz49LSAIEu3cpfsYcy+mhrNzIAYmh4YahizhyX CG9HVoK8qy1HfGJzx1PoqE/jzspu1/WnrUyDYs+1h5w2NPVBTUYAF6MO2meL6l97LUhx 0WEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:cc:to:from:subject :arc-authentication-results; bh=bAAl4Y1ZA0/vFYgFF8GKsK+8SBPuopfrTMzowS91DBg=; b=YwndXdrOc7BF7vgvLzcHOoiqJsJ7VvSz8vSden53R1omeD4VGsAl6frfLQXlFzMg3+ 6n4b+Wv8E5joFvNMXMphRx8/rq2VSU6OUp+4fwAhWTe4opj+OvexLT4pfxh98NF3NK7C pMjZ1An44ZwS9HBLJ8OmNDEMRF6zHzNWL8U2aa0FYTCZmIkzcyGkVREkMCxSq3y/VL2b sAd2MlCpeQtYpLDEfPgtPreaSENniHmsNKKiIPkYsas8ociU/U3Q3dRA8WBQaZydiQ1m 97C7BTJWoHwQNmT0kOHXGru3Ur0HIzIKMAcK8Wp7TWWGzOi6/XLS93vOivvT07wLblD8 wDuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f8-v6si15330856pgr.139.2018.05.23.07.43.39; Wed, 23 May 2018 07:43:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933293AbeEWOmw (ORCPT + 99 others); Wed, 23 May 2018 10:42:52 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44866 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933149AbeEWOmt (ORCPT ); Wed, 23 May 2018 10:42:49 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4NEfpie079631 for ; Wed, 23 May 2018 10:42:49 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2j5852f503-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 23 May 2018 10:42:48 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 23 May 2018 15:42:47 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 23 May 2018 15:42:44 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4NEgiSr65798348; Wed, 23 May 2018 14:42:44 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D2944A4053; Wed, 23 May 2018 15:34:04 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0B4E9A4059; Wed, 23 May 2018 15:34:04 +0100 (BST) Received: from dhcp-9-2-60-181.watson.ibm.com (unknown [9.2.60.181]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 23 May 2018 15:34:03 +0100 (BST) Subject: Re: [PATCH 25/33] ima: use match_string() helper From: Mimi Zohar To: Yisheng Xie , linux-kernel@vger.kernel.org Cc: Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org Date: Wed, 23 May 2018 10:42:43 -0400 In-Reply-To: <1526903890-35761-26-git-send-email-xieyisheng1@huawei.com> References: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> <1526903890-35761-26-git-send-email-xieyisheng1@huawei.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.5 (3.20.5-1.fc24) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 18052314-0012-0000-0000-000005D9CD31 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18052314-0013-0000-0000-00001957182F Message-Id: <1527086563.4168.0.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-23_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805230149 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2018-05-21 at 19:58 +0800, Yisheng Xie wrote: > match_string() returns the index of an array for a matching string, > which can be used intead of open coded variant. > > 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 Reviewed-by: Mimi Zohar > --- > 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;