Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp743420iog; Mon, 13 Jun 2022 11:56:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEqDDAhONEKTrp8nrjS+Gy92aCX9yY5aZ5QLOawd7cmzyWhhvgPFjaj7JuGwL3astTCIS8 X-Received: by 2002:a63:f944:0:b0:3fd:4f29:67e9 with SMTP id q4-20020a63f944000000b003fd4f2967e9mr842093pgk.593.1655146613053; Mon, 13 Jun 2022 11:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655146613; cv=none; d=google.com; s=arc-20160816; b=s0H3oaxFMWD+sglVC7rAR3nkfnjUlbk+7xzMj98iAUvUjyEnpE+zjiftklJjx8GTaN awebUlQGkzqCMTGQ8J4T/lLw4NNBybV8Eqig/utGxlO4chRH+r5VaO36T7yn2W4b7Js4 16GWhkjBiYbriEczV1ttSU88BFk6dqd7K/5pXPDnwm3l0T03kzuWlyVtfh1qek0xqAHP Gf0T1K9yyywDehEkE9HP617EZStl98ggQfA/7OPnms3affUEmF2MpXOEJu95mZkruO0Q HuffaYon64xvBpGzrEdSH1sXoRmHZ6BoTTmum4UFIMLtKNPkGWYaN4cmYTecVw73vZlU v9BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:subject:from; bh=u8Yg2Sn0RBBdwNlTSv0GctmdUgS0s/BDB7B4xpo72rw=; b=ynnSwMfB6IJd3hTiWy46A8Ho7avHQTK5vtqmNQIumdp06LtakB91T9tBPjDnOSjA2c X2+/6E2fk3/tvLEm8VigMnDeiw2i2JL1mazq1EODAJzcpsLrj/P31Fd+N6jnknwkotGM bGBvbnNXwRBYrXtZ44pH+j8GvxS099MI1iAAjYRxDzdBYeYEL6Vo3TS4OngKZzf5VrKa 77Ec27pExhCElKFMbm7x7fpd1BsKNoQByhyIscnesa0hoqGcb03y0Z5uHblhbL5NIrUO 4B6oZvOmmj7awICtW82/4Qge1dE8DBo7+OEJ/11pz/HiAwFf5cMMFAIXVI9tDO3iie1L pBAw== ARC-Authentication-Results: i=1; mx.google.com; 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 x22-20020aa79576000000b005187a9a74cdsi9056461pfq.269.2022.06.13.11.56.41; Mon, 13 Jun 2022 11:56:53 -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; 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 S1343578AbiFMSjy (ORCPT + 99 others); Mon, 13 Jun 2022 14:39:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345661AbiFMSi4 (ORCPT ); Mon, 13 Jun 2022 14:38:56 -0400 Received: from mail.nfschina.com (unknown [IPv6:2400:dd01:100f:2:72e2:84ff:fe10:5f45]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4964F36305; Mon, 13 Jun 2022 08:33:21 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id DD35F1E80D53; Mon, 13 Jun 2022 23:32:06 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ph1dDZH7zWRn; Mon, 13 Jun 2022 23:32:04 +0800 (CST) Received: from [172.30.21.244] (unknown [180.167.10.98]) (Authenticated sender: liqiong@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id CB06C1E80D05; Mon, 13 Jun 2022 23:32:03 +0800 (CST) From: liqiong Subject: Re: [PATCH] smackfs: check for allocation failure of kmalloc() To: Casey Schaufler , James Morris , "Serge E . Hallyn" Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, yuzhe@nfschina.com, renyu@nfschina.com References: <20220613062202.29194-1-liqiong@nfschina.com> <88718d10-4435-f5a8-9123-afc73257e0ca@schaufler-ca.com> Message-ID: Date: Mon, 13 Jun 2022 23:33:16 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <88718d10-4435-f5a8-9123-afc73257e0ca@schaufler-ca.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RDNS_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 在 2022年06月13日 22:53, Casey Schaufler 写道: > 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. Thanks, my mistake. Drop this patch. > >> >> 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;