Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp755338iog; Mon, 13 Jun 2022 12:13:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v4la5qIy06HIsQFMPF9Dec7jQcv5bre/rUaNhTLmPtm1Kbx4LHgH3oLkQZSZpz8GQDh3lF X-Received: by 2002:a17:902:e888:b0:163:f3e5:b379 with SMTP id w8-20020a170902e88800b00163f3e5b379mr623399plg.62.1655147596348; Mon, 13 Jun 2022 12:13:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655147596; cv=none; d=google.com; s=arc-20160816; b=eszDomTxG7WlI2Bw63ccgp9EQfw1ATQfZmwsZFErPw8OzgTAS2i/86NcMzljrkWKUT CbQlTBeLLDHijedEqbNUlQrK+tObASuGQ2c502N5Cw6z9FZqapxcOQjhPGkny3DDO1s5 JMESQm7bzKalDzu+ecNWSDtlIvMQlb2RmCQ0EN5RaZICQzTGy12/yyaXfxJLkpnu9M1l 3vypdwgfVbYoIF5Eo6sVZ1Gce+/t/DPX/BsF86IC4zImBfj9A3IWCGYm+w4eOmZp2KdC PaZ9moYsKLHc65qTA16zsIwdPnHzJrSgI0wHQjOeZ5/rz3ZMIu07txqMSSsHj8vEPpnR Ia2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=0SgoT7OQEOKIkib3oIGruLdZdvQGYAiUQ4MXiAUTnPI=; b=wkQLdiMfgu1idCkJlAuGcLvgpvGCT8jhip1XmItfhAaXFatSAuPclfImNpX9ONuuqV jk+AOoL4tabmF6qxc5sh+GPrMrLm/aQST3bQN9CDfVB4+4Zs1dp1vaJKytafMoKo9Ibz HnJDapWJUznHZR0KrZW5uykdRNdqRLNIt3JQdST2g8rnsFs70Ht12CT5rEDl2rL+A6EI CimP1WnYGQOxY3PfcG3JsihnzGYB50oPwGAr9txyF8f/rjl2SvjxKnBRfAxCCukS++LP 3xMlpZJosZopiwl1UcUYzuxirBxvv2N8ileiTSP37Q14ZPW8HKrUjClvmWe5JA06QfS1 ga/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=FXke69Jq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z10-20020a170902834a00b0016641a8abcfsi8827826pln.549.2022.06.13.12.13.04; Mon, 13 Jun 2022 12:13:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=FXke69Jq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245259AbiFMSed (ORCPT + 99 others); Mon, 13 Jun 2022 14:34:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245179AbiFMSeG (ORCPT ); Mon, 13 Jun 2022 14:34:06 -0400 Received: from sonic304-27.consmr.mail.ne1.yahoo.com (sonic304-27.consmr.mail.ne1.yahoo.com [66.163.191.153]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2E04C9651 for ; Mon, 13 Jun 2022 07:53:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1655132021; bh=0SgoT7OQEOKIkib3oIGruLdZdvQGYAiUQ4MXiAUTnPI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From:Subject:Reply-To; b=FXke69JqlRRNJrFFWvEOaPCujhPRK221IP9c3YDlGwPEBRdFzJZzFtjHPUmW1k4q+b7iMdili2lrpgJj+l4qie8Wkqyb1eP36fWrIdUAQb51SG+unKpw/p30eIEJoDi3uoSan+LUESE7hNGLwJLoEWNjwKyYq54CMvxYa9nfrX4mBujcERvRSlnPDXDko0Q5vVyUe/p92IDzW4sZ3cMivBx6DWqKFsCG2jILkSBO7N5BPHm2VgZTriYrOPOrK9tLghcWARHBIQkGtOMgRXi7SUm3zHAXKpD/5QUGtjVsnKpcX//uqeQUughn6WMR+OJmNQtwC/dmiCeIomrKh/k+Jw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1655132021; bh=grY/OEdyoXdDjlfXN0/WNt7lg26XYsq3xUM46loWHYq=; h=X-Sonic-MF:Date:Subject:To:From:From:Subject; b=TXf93jjHQtF0SYfWaqpCmU+mfcET2+RuDUTrRJwdRV9TCx1YMk2pcbcK/y2ZbO0Z6+23EBR5NzHIMTZVqXB7AJQabf1dCGzkRc6EoFxsIjz5J7sfhb1o/4lEkP0Og9UQR5MaljnZHylHgN+qVlpW5ADFIbSDfGeEkbP/vMx1F2W+HQAmzZnQltqmPJXgG57ONDL18qZptZ3UVUkHYEBDO3q+78jnhqrCi2cWlUnEfWNO/JQAAfyP5YEB+yn/MFQAHBxvbimq6r1fr7h+vGss4sA5gIbLfKH6RAPsNKACkaslNMzobmTDV6bhq2CUiwgbKN41K+H3fb/lJoAQJt/4Nw== X-YMail-OSG: CBD8m6sVM1mWWJAJktVvFXOdXPIh01AqOykUKU6tjLybFlu0MbXn8siUQnJPdK5 pJkRlW9z8kTyajt73IQ.H9kO7TFfFYeVEWc2CagvVFNTngALaInQWI_7BRHuHUYAvAJ1M7s1uVah lV35hC.5gp95I1TBStohgbUNkUy_NFhTcnAJYXNAVHaKss2REl5Yvj6rlAnJE8p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L.TWzrSWZiRvk- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.ne1.yahoo.com with HTTP; Mon, 13 Jun 2022 14:53:41 +0000 Received: by hermes--canary-production-bf1-856dbf94db-lkxdg (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 1de6620996886a81d03d658fd9893895; Mon, 13 Jun 2022 14:53:39 +0000 (UTC) Message-ID: <88718d10-4435-f5a8-9123-afc73257e0ca@schaufler-ca.com> Date: Mon, 13 Jun 2022 07:53:36 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH] smackfs: check for allocation failure of kmalloc() Content-Language: en-US To: Li Qiong , James Morris , "Serge E . Hallyn" Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, yuzhe@nfschina.com, renyu@nfschina.com, Casey Schaufler References: <20220613062202.29194-1-liqiong@nfschina.com> From: Casey Schaufler In-Reply-To: <20220613062202.29194-1-liqiong@nfschina.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailer: WebService/1.1.20280 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/12/2022 11:22 PM, Li Qiong wrote: > As the possible failure of the kmalloc(), it should be better > to check it and print a warning message. The allocation is done with __GFP_NOFAIL, which assures it will not fail. > > Signed-off-by: Li Qiong > --- > security/smack/smackfs.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c > index 4b58526450d4..0d11ba3cb4cd 100644 > --- a/security/smack/smackfs.c > +++ b/security/smack/smackfs.c > @@ -695,6 +695,11 @@ static void smk_cipso_doi(void) > __func__, __LINE__, rc); > > doip = kmalloc(sizeof(struct cipso_v4_doi), GFP_KERNEL | __GFP_NOFAIL); > + if (unlikely(!doip)) { > + printk(KERN_WARNING "%s:%d failed to allocate a memory for doip\n", > + __func__, __LINE__); > + return; > + } > doip->map.std = NULL; > doip->doi = smk_cipso_doi_value; > doip->type = CIPSO_V4_MAP_PASS;