Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3038971pxb; Fri, 8 Oct 2021 23:32:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwebKs2aE62Mzp/XyDtZIxjuk9m10Gab8dRMYqMjZQbsX02tu2mA1iIaU1bjPPwjl3EkyTU X-Received: by 2002:a17:90a:ab90:: with SMTP id n16mr16121719pjq.157.1633761133683; Fri, 08 Oct 2021 23:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633761133; cv=none; d=google.com; s=arc-20160816; b=dYi7pvA61MXgAeTZyesM7HkcqcigvYBwqa9KVP4DLYVdXxy/MRSXFJMSKu7Zdrhx93 /sMEtdrFYrmwbT6YCbUlEZPZaiZRfQqHwVepEi/DqQ0jA1imNiRHVjCH19JnFcLaLjWB 8+8a17y+I5ZNRywovNaob5DHTHwcAsksnlEgYvsmlfOcR4Gvac19xIYFt7A+eY3F0X3K IbeSisyIun7rHn2HX3BepON+iWu4QfiR2R1rygZYQaghLkFptciV/Z4o27L4Z0jq4msB O6VxDt7fb8hwCOUt6eNwGBEOOBSx3NRsRvxdfAZyKGZM+ATnCpNZKu26AsutFpHEmSHD qwQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=p5ouH7WU9a1DvMZsR1hQEdO0a8L+S/jjP6A/nkwsxh8=; b=dySbaXRIXxWT3e1Q57QwDfb1GnLphASxv6JRnFcM/G50ooira2sPufofC058K2ZLTV OWU3iPetgkjlPpvpOQehpft1KCs4Bj7MkSfGfkjZcK5Yt0Ak6d8MQbYvo4ZYVZC3raN0 pm7pVGWK3uQdJrAEMc33cQ0TLxFhAYs9VpEoB9JjsJQL42aKXD1xnUaGBiGPzXZGPs+n BqoSZoOljwgd5rKCCPeF0jHXPrhGGlP82Z6scx5CUgZjpvkcv9jpisbWEWo8MCImiR+/ xEewJZj1MBBGbeIytTwfKQHp8Cu8E05BmaE3sWR2BnJGBsp2Ns+wXtdmMtuZDxCfSqOA e6Rg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a2si2145617pls.44.2021.10.08.23.31.52; Fri, 08 Oct 2021 23:32:13 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232701AbhJIGas (ORCPT + 99 others); Sat, 9 Oct 2021 02:30:48 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:23357 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229538AbhJIGar (ORCPT ); Sat, 9 Oct 2021 02:30:47 -0400 Received: from dggeme762-chm.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4HRFQJ0Wl2zYdZv; Sat, 9 Oct 2021 14:24:24 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.44) by dggeme762-chm.china.huawei.com (10.3.19.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.8; Sat, 9 Oct 2021 14:28:48 +0800 From: Gaosheng Cui To: , CC: , , , Subject: [PATCH -next] integrity: return early if audit_log_start return NULL Date: Sat, 9 Oct 2021 14:30:53 +0800 Message-ID: <20211009063053.187953-1-cuigaosheng1@huawei.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.174.44] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggeme762-chm.china.huawei.com (10.3.19.108) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org audit_log_start() may return NULL in below cases: - when audit is not initialized. - when audit backlog limit exceeds. After the call to audit_log_start() is made and then possible NULL audit buffer argument is passed to audit_log_*() functions, audit_log_*() functions return immediately in case of a NULL audit buffer argument. It is not necessary for audit_log_*() functions to be called with NULL audit buffer argument, so return early when audit_log_start() returns NULL. Signed-off-by: Gaosheng Cui --- security/integrity/integrity_audit.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/security/integrity/integrity_audit.c b/security/integrity/integrity_audit.c index 29220056207f..fbc032185d72 100644 --- a/security/integrity/integrity_audit.c +++ b/security/integrity/integrity_audit.c @@ -45,6 +45,8 @@ void integrity_audit_message(int audit_msgno, struct inode *inode, return; ab = audit_log_start(audit_context(), GFP_KERNEL, audit_msgno); + if (unlikely(!ab)) + return; audit_log_format(ab, "pid=%d uid=%u auid=%u ses=%u", task_pid_nr(current), from_kuid(&init_user_ns, current_uid()), -- 2.30.0