Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1109263imm; Wed, 13 Jun 2018 13:31:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIA8OVWlpU4NLgPXZvu/yegpilHIvDvKiRr6lkwgi3Hl38ct8WIng02egIFQ7cfgNuIFJqh X-Received: by 2002:a17:902:a416:: with SMTP id p22-v6mr6715209plq.228.1528921900082; Wed, 13 Jun 2018 13:31:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528921900; cv=none; d=google.com; s=arc-20160816; b=wSqVDKrSJkRSxrMJ5CoRrP60kHN5u2SHyhl7+H+nr3Z6sjfywMqfY3QBLA1XmScZmd D3GKtClIE3A62WYdHMyB2xZaQR55W7X8aGAtdyl0TK1hn9Zzrb99szYKSEFra0H65O7r 2uglE9n1LwabaEoapSnWSQBqAANrE8b+onBccAD9Bjo7zEi7grnfvvlagrPeeFaj6uN3 eB2sxTBVM2IGdAUYb+GwLAFYYrxsExxBUQfpmZt90OYqdxOWp+SeS3woopCll+Xm0CJN LSLBSq+S5d/jfh4DZtgb7ig303fYAUe2Vp+dkHVXl8dZjkmidbJnLqSVrf0fYJqdXpI4 cMNg== 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=nQ8EmLUK+NU40OrwS8eo65REj5tc5LgOlgu8fJGHzMA=; b=TOw0E43ESk+ufYDZC9zwzPhUIldyuaCDb+wekF+siEnOVrhNq3uudrMIuJw1Zv2SJU gGiSaLcAZJhxspYt/Wvs0b9T1+CkeiyyD8yogqmVzFC5N62V9r5+wvQ6GKown3XIRZs3 kEpdP9fG1fQGV+2+2rCeKkGDnH6QDppdcUK+tCpwQ/URa/AgCZ8YUZhlx+AK5fxIOEIV A4sfK5lcbUf38mxMIH3iw8zAAkDDAH4lZtiHw1hRO09O+RFob51c40snecfJgzKBgSsi HxOWiHstsGLhEkOcyA1rnuWWumGMKozZ4M3omL3q89ivDP59HGiSNkPJSjIFm4p6d+ht g4AQ== 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 s136-v6si3678953pfc.222.2018.06.13.13.31.25; Wed, 13 Jun 2018 13:31:40 -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 S935461AbeFMUaj (ORCPT + 99 others); Wed, 13 Jun 2018 16:30:39 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:49630 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754517AbeFMUai (ORCPT ); Wed, 13 Jun 2018 16:30:38 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5DKTGVl088511 for ; Wed, 13 Jun 2018 16:30:38 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jk6kd1v2a-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 13 Jun 2018 16:30:37 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 13 Jun 2018 21:30:35 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 13 Jun 2018 21:30:33 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5DKUWG828770524 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 13 Jun 2018 20:30:32 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CA89352043; Wed, 13 Jun 2018 20:19:59 +0100 (BST) Received: from dhcp-9-2-55-142.watson.ibm.com (unknown [9.2.55.142]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id DEF235203F; Wed, 13 Jun 2018 20:19:58 +0100 (BST) Subject: Re: [PATCH] integrity: add error handling for kmem_cache_create From: Mimi Zohar To: Zhouyang Jia Cc: James Morris , "Serge E. Hallyn" , Matthew Garrett , Jeff Layton , Thiago Jung Bauermann , Dmitry Kasatkin , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 13 Jun 2018 16:30:30 -0400 In-Reply-To: <1528777625-40502-1-git-send-email-jiazhouyang09@gmail.com> References: <1528777625-40502-1-git-send-email-jiazhouyang09@gmail.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: 8bit X-TM-AS-GCONF: 00 x-cbid: 18061320-0016-0000-0000-000001DB6F9D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18061320-0017-0000-0000-0000322EAD89 Message-Id: <1528921830.3282.7.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-06-13_08:,, 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=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-1806130217 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-06-12 at 12:27 +0800, Zhouyang Jia wrote: > When kmem_cache_create fails, the lack of error-handling code may > cause unexpected results. > > This patch adds error-handling code after calling kmem_cache_create. The slab is being create during __init.  Under what circumstances do you expect the allocation to fail?  Have you tested what happens if it fails with/without at least an IMA measurement policy? Mimi    > > Signed-off-by: Zhouyang Jia > --- > security/integrity/iint.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/security/integrity/iint.c b/security/integrity/iint.c > index 149faa8..c074fd8 100644 > --- a/security/integrity/iint.c > +++ b/security/integrity/iint.c > @@ -172,6 +172,9 @@ static int __init integrity_iintcache_init(void) > iint_cache = > kmem_cache_create("iint_cache", sizeof(struct integrity_iint_cache), > 0, SLAB_PANIC, init_once); > + if (!iint_cache) > + return -ENOMEM; > + > return 0; > } > security_initcall(integrity_iintcache_init);