Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp803022pxv; Wed, 14 Jul 2021 16:17:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrTup53VvDddokk177l1epXqmU7sT63p6gfIiXIpziM+9rorXNYCg/yjHcJ5oRxfJnxWCR X-Received: by 2002:a17:906:f9c5:: with SMTP id lj5mr706658ejb.482.1626304628572; Wed, 14 Jul 2021 16:17:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626304628; cv=none; d=google.com; s=arc-20160816; b=D6OU8O14V3eDz3uydcHsnch2wxEzYitekcSwM8aMJCcm2sBkdOZAOkab/JtgLbpFIE mRReUiSjXFPytVIA7OEQ0I8WoBEGZjkzIIq/5jszY9FBv4mOfEixZ1/vGZ+tGJ6HBoKh XPi23RQojP792b8bYyH9nmpMzFg8af+iz/9OLsxCqkCP/89voMpLcluMQ13IBeCRnb3i DIVkj8D60FVOka0Ar7a1hlVWBQzvLQk8R/HPHbJd7n0+q1eqLRE5k2YEiJES5kx5U9V7 k0bq71/EZKElclFmZ446JuOi0bfDoY5fz0IytK8BnDb4KgM9Jh4T8E1hxr94p/GpNk0U b9Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=/ecMCBD0DRX8i6ceCMBbDcAoHrM9zIxqgKO1lRrTFgA=; b=H7ytPLQrgBSG6kSC0OUPsxm1kkK9NtNAYzQyHD4omZvuQqi/9RXvOU+PsTg2DJp/mT KdA/hUl+T7iUg2216qndWGoceOn+BazcA0cByF+raTSmJ9NFgt8TEnvQJVki8fXOtMRM 3ntzFZS8qguT2ZYAT5yz6yEGYCE4gCPalmCpVRO2s125p1GErWq5wtKwOH9A+sApKzRV 0AyO0elvchacuugFPoPL1PGNr/coksxRufGG4wQTnYjPcU6ZGObopS8TCjVqeXY/RXlb eeCy9oR936bsvSSoNse6LqxpHrh2rv5FfUbZ1ggh0bfCkjZOntUg/6FgPVVbJYpjbBma U3+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZU1rg2kx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s10si4284175edr.36.2021.07.14.16.16.45; Wed, 14 Jul 2021 16:17:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZU1rg2kx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236013AbhGNVr4 (ORCPT + 99 others); Wed, 14 Jul 2021 17:47:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235956AbhGNVrz (ORCPT ); Wed, 14 Jul 2021 17:47:55 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C7D9C06175F; Wed, 14 Jul 2021 14:45:03 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id q10so3206440pfj.12; Wed, 14 Jul 2021 14:45:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=/ecMCBD0DRX8i6ceCMBbDcAoHrM9zIxqgKO1lRrTFgA=; b=ZU1rg2kxF1xhpB09DWxWH4ZRjGXZTX9WF60dLpoChO4lv7ueN8II8Rohp5s90/BTRe 8a5l2kCFNXFmCY/eD1S7M9HhUknYtZNpSBpfQ1qfAhh0yQKHtfUxl8h0ojNACKkvY0bz J1YnxNKCaYzIzEXgEeYA79d2sONF4bQtGwIjil4PeQDj7aHhhjXhAdsyBXJG4sGIP5TT bPUdfZVLoCf5s3OuKPh2KQvJDm/fdyHT8jIuU1lyS6HMYvHxcS7KWFGBenCpK7KXDuDi t+VbQwLsgKkExDC3PD3pv4KLRSJYBVoDaX2DjoSj07tBkqcLnuIbQGX1dmjh6h4RTBEC +eeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=/ecMCBD0DRX8i6ceCMBbDcAoHrM9zIxqgKO1lRrTFgA=; b=Nnnesi9AUps0lp2aZOEDMGhp5NQrNykvMTrJUg54qQWmGSd+ooP4iVtlV/4g7NB+DM 9XNTBI27yAvSIVyIkQ/nXGrkBY6Fhl0Y0R00D3+2P4TZIgdlqZXC4uRD3ZvUMWtOO5wC MNhzC+mb2Kb1s4a24UqvXWC/ZXpB6KYUnJZR2kHTOoqizAc7W17suM23d+Tsejz8J7iG kHgVZbWVXyH8azEZJlzM5+ylyxH2yztPodMWZHfpZgJ65bIvqaL4udyv1lbH8UKsdFfg U7fCPxeoJXsN07gBjuayO5hF+YmA3RVuoF0JOTlqwsWXvZFCNTYs/tX5ktd3FcEyCboM t0sQ== X-Gm-Message-State: AOAM533LxLSp/fKvXpEdJIyGXjBE7biq4DOlckXBzv2P9JGC69CZ0KBN T+8JL0/3g7z9TZgYAPf3S25KnNQlCx3cIE0iL0A= X-Received: by 2002:aa7:81d8:0:b029:308:1d33:a5fa with SMTP id c24-20020aa781d80000b02903081d33a5famr51074pfn.55.1626299103098; Wed, 14 Jul 2021 14:45:03 -0700 (PDT) MIME-Version: 1.0 References: <20210712234434.GA29205@raspberrypi> In-Reply-To: From: Austin Kim Date: Thu, 15 Jul 2021 06:44:52 +0900 Message-ID: Subject: Re: [PATCH] LSM: add NULL check for kcalloc() To: James Morris Cc: "Serge E. Hallyn" , Kees Cook , linux-security-module , Linux Kernel Mailing List , =?UTF-8?B?6rmA64+Z7ZiE?= , kernel-team@lge.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2021=EB=85=84 7=EC=9B=94 15=EC=9D=BC (=EB=AA=A9) =EC=98=A4=EC=A0=84 4:12, J= ames Morris =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > On Tue, 13 Jul 2021, Austin Kim wrote: > > > From: Austin Kim > > > > kcalloc() may return NULL when memory allocation fails. > > So it is necessary to add NULL check after the call to kcalloc() is mad= e. > > > > Signed-off-by: Austin Kim > > --- > > security/security.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/security/security.c b/security/security.c > > index 09533cbb7221..f885c9e9bc35 100644 > > --- a/security/security.c > > +++ b/security/security.c > > @@ -321,6 +321,8 @@ static void __init ordered_lsm_init(void) > > > > ordered_lsms =3D kcalloc(LSM_COUNT + 1, sizeof(*ordered_lsms), > > GFP_KERNEL); > > + if (ordered_lsms) > > + return; > > Your logic is reversed here. I feel very sorry for my terrible mistake. 'if (ordered_lsms)' should have been 'if (!ordered_lsms)'. Let me resend patch(v2) soon. Thanks, Austin Kim > > Should this also be a kernel panic? > > > > > if (chosen_lsm_order) { > > if (chosen_major_lsm) { > > -- > > 2.20.1 > > > > -- > James Morris > >