From patchwork Thu Jan 27 01:59:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaoke Wang X-Patchwork-Id: 12726099 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09E7EC433EF for ; Thu, 27 Jan 2022 02:14:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232935AbiA0COd (ORCPT ); Wed, 26 Jan 2022 21:14:33 -0500 Received: from out162-62-57-64.mail.qq.com ([162.62.57.64]:49195 "EHLO out162-62-57-64.mail.qq.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232881AbiA0COb (ORCPT ); Wed, 26 Jan 2022 21:14:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1643249668; bh=f2+hKX7ZjpgXeWickBv9h0zklArTVddDzY2IvRqIHbA=; h=From:To:Cc:Subject:Date; b=KFBlfWSyQzjjiXFMmm1xwmq5u9uyKAxBcSOBYAJ8kirGC3rdzxmXFvbyrSlsKRWvZ gzZJuYgxuQI4zzUiL16WGpqVScgOOFazEFUYgmhtCmbbFZxV+uvmVpSvQO/wgQ6Yhg KnzTJiCj96D04Sy0MhlEvaiKlFV237V6Y//qAZfg= X-QQ-FEAT: oHWrrGTW1dDsFGnIWaujQqI6HtP+N16t X-QQ-SSF: 00000000000000F000000000000000Z X-QQ-XMAILINFO: OBvbJS/7aDyUH4zGt5t0a2JXRNroDbyKmBypMIgcvPnIsSvLP62QehXLRIY/E5 JwD+KidU6kmNqCcTW0ijaiD56SiCrZQFbcUFGyQNlNcn10iX7n30N4aPcCGMLSOxQ/IpnkeznE1va XmFWDkmHAWt+3KUUYZPe94J4bfmXxCeudXBNGUp5AYUyORz30GfaGcUmZP++evvtY4ytfQJCRCrj/ DL3zvhTY1piqOhnzeCzBaQWrmrtHxsKC2gKzKPuqaMLdhjw7nU5gp8A3130InztI4BwjtjQeFi/IM iWXRSUppJ7cPM8LbwqPb9pA/PPITeKGBU5Ohpjl7IITLnG0KBbBP22f9BFbJ89TXGB5239HupU/h3 xGOrRVuRBtX8KOcd6o5iOXi0QWmvdVA3ReO0YcYgpmMvIqkddVuUbAhoDhY7ZjuuUjY5YkEorHj7M wS+LI9sKZnITvlkxuuYh80LKXMDTADvo34R3Wk2VJNK7R2zr8d5LAIWNBVW0rpvU6rRJmbA5g0/ZS g4PEa4tkVIvQHVmVFoSEmbsogAUgu2xHLiMosnbxQE2AUys1jWKxmgII3IWQXSPgkP3qNvdnUa25i /r9aRE9U3WZj+gR1wYbZCo+xsLJMHmluLBdWZz6ZYLP8/MzqYnCDEhNYSeCWSeLCQHF8PCIwzI9V7 4i6P0AMAcyylEBEYMIgG9dxTzWSz/OhD5PKr5a4zDviNmJf+2vLp8affzeT0gTF8REQNrQg+szmO+ espU81WQzOw94bUmnhkTlIIvg31wppp6MxxGxh+XOVUtYdVWhMm5hdZaqJ+rI5b03gSc0KfuSuYHD +tA7xaWy7eA/uCDP0SAnRwGEgCHQLtalYJVZreTKw2JafsF7gSGaUs8= X-HAS-ATTACH: no X-QQ-BUSINESS-ORIGIN: 2 X-Originating-IP: 39.149.171.117 X-QQ-STYLE: X-QQ-mid: webmail813t1643248745t8210637 From: " =?iso-8859-1?q?Xiaoke_Wang?= " To: " =?iso-8859-1?q?Mimi_Zohar?= " Cc: " =?iso-8859-1?q?paul?= " , " =?iso-8859-1?q?jmorri?= =?iso-8859-1?q?s?= " , " =?iso-8859-1?q?serge?= " , " =?iso-8859-1?q?linux-integ?= =?iso-8859-1?q?rity?= " , " =?iso-8859-1?q?linux-security-module?= " , " =?iso-8859-1?q?linux-kernel?= " Subject: [PATCH v4] integrity: check the return value of audit_log_start() Mime-Version: 1.0 Date: Thu, 27 Jan 2022 09:59:05 +0800 X-Priority: 3 Message-ID: X-QQ-MIME: TCMime 1.0 by Tencent X-Mailer: QQMail 2.x X-QQ-Mailer: QQMail 2.x Precedence: bulk List-ID: From: Xiaoke Wang audit_log_start() returns audit_buffer pointer on success or NULL on error, so it is better to check the return value of it. Signed-off-by: Xiaoke Wang Reviewed-by: Paul Moore --- Changelogs: V3 -> V4: update the mail list. V2 -> V3: add the Reviewed-by tag. V1 -> V2: simplify the patch. 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 2922005..0ec5e4c 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 (!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()),