Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp707661imm; Thu, 31 May 2018 08:04:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKICgiqDTzNW8Z2voadnOcS+5V9TK75E7j1iG7NlkBodgeZ3kssQCnG6jkTrG0McVelIzWvE X-Received: by 2002:a17:902:981:: with SMTP id 1-v6mr7345847pln.11.1527779053850; Thu, 31 May 2018 08:04:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527779053; cv=none; d=google.com; s=arc-20160816; b=BU+rlffejoChraD9QxP6IBL07dKUPq3jdDUTnau69rhDwy5iZ2D1FHdnyTVBkoYDtX xVVTxNSQN4eaSAkrzkJIqVJKVBjk5LGEExs/xJW0zTYwUjHtw2MDrRKT6asJb80xDfzd E8D3/IcTCDDWf2y0EwdCmN6v2qZW78yghYkJRL5Rk/3a7SOW6BxFJS9Jgmy6h6pzjvxr YFQkTZ6abmx6onH0T53jbaamtya39DNlyxVpX791ycu+effLh1LFPUrvhqEo1KlJROzF FSorktGw2aKVC9Tq2979QOy478gxjg4Si2sWZTkaU/sB2KycKhuDmEhxX7VSwJJYjTFs Yy0g== 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=Jkb56M/hPpr8WGvO0GG+7jqF/mBifdwpQPgr0Cfs5Vc=; b=o2ZH4o8xTiLbNCWjNTHuxZbFAs/LahIdkA59iVIXypjduVUTSjE2vWjEcnQwWmp2JD /Mr8Qx562PsXXsHB7sWTFtEeWZSoZTisyATvgUP2DRo3ySxEPN6a6fQIwY3MuOxBdGnh 0Xt4QH9f/TqcapzaTSDYF7V02Z6IJoOamXy7Uu0xvLI6zNuauWoqQrtOQcL9KkZh4ivb 0MRfYSjSHB0DR7g9vCPBNU0rKwwBqCSdK+oWinKU/0sbDmR+LhsXkZ7WQgoFTrt3GLYW S5bkogap0s/tx2bujDRIeCxM5xjwqxbLiDYoWIR307elUozBDLgH5jfw25F1n2sZ2sxV lARg== 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 b39-v6si36933104plb.456.2018.05.31.08.03.58; Thu, 31 May 2018 08:04:13 -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 S1755507AbeEaPDB (ORCPT + 99 others); Thu, 31 May 2018 11:03:01 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51060 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755163AbeEaPC7 (ORCPT ); Thu, 31 May 2018 11:02:59 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4VEx5Jp047852 for ; Thu, 31 May 2018 11:02:58 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jahdf644v-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 31 May 2018 11:02:58 -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 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 31 May 2018 16:02:51 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4VF2oc918087946 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 31 May 2018 15:02:50 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 87EFA4C05C; Thu, 31 May 2018 15:54:19 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6A07B4C05E; Thu, 31 May 2018 15:54:18 +0100 (BST) Received: from localhost.localdomain (unknown [9.80.85.240]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 31 May 2018 15:54:18 +0100 (BST) 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" 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: 18053115-0008-0000-0000-000002426993 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18053115-0009-0000-0000-000021A81751 Message-Id: <1527778958.3427.16.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-31_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1805310169 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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@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;