From nobody Fri Sep 5 20:24:37 2025 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 410F3C32772 for ; Tue, 23 Aug 2022 11:54:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358711AbiHWLyg (ORCPT ); Tue, 23 Aug 2022 07:54:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358976AbiHWLv0 (ORCPT ); Tue, 23 Aug 2022 07:51:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADCE3D3985; Tue, 23 Aug 2022 02:32:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 309AFB81C95; Tue, 23 Aug 2022 09:32:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77B62C433D6; Tue, 23 Aug 2022 09:32:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661247130; bh=g50zDTVcQS08LAu01kQ31YSa+m5euRa8lzIjKbTqsww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QUKm3LaJwmiZd0ujsoA38NYH+lKBDLAjd/+TW3YPwiiBuhSIOu4chR0I2CYDuTQAY SkLCGmnJFAnAyeFwF531r4SXAPg79hnwwa75nR/4+R4X5cPUVWx3TkFs7yw7ptkN9F uX35pGjKZ66Py4ImzVxTDEbcflioYkcu3XMm2UEA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Rix , John Johansen Subject: [PATCH 5.4 297/389] apparmor: fix aa_label_asxprint return check Date: Tue, 23 Aug 2022 10:26:15 +0200 Message-Id: <20220823080127.964405043@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080115.331990024@linuxfoundation.org> References: <20220823080115.331990024@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Tom Rix commit 3e2a3a0830a2090e766d0d887d52c67de2a6f323 upstream. Clang static analysis reports this issue label.c:1802:3: warning: 2nd function call argument is an uninitialized value pr_info("%s", str); ^~~~~~~~~~~~~~~~~~ str is set from a successful call to aa_label_asxprint(&str, ...) On failure a negative value is returned, not a -1. So change the check. Fixes: f1bd904175e8 ("apparmor: add the base fns() for domain labels") Signed-off-by: Tom Rix Signed-off-by: John Johansen Signed-off-by: Greg Kroah-Hartman --- security/apparmor/label.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/security/apparmor/label.c +++ b/security/apparmor/label.c @@ -1750,7 +1750,7 @@ void aa_label_xaudit(struct audit_buffer if (!use_label_hname(ns, label, flags) || display_mode(ns, label, flags)) { len =3D aa_label_asxprint(&name, ns, label, flags, gfp); - if (len =3D=3D -1) { + if (len < 0) { AA_DEBUG("label print error"); return; } @@ -1778,7 +1778,7 @@ void aa_label_seq_xprint(struct seq_file int len; =20 len =3D aa_label_asxprint(&str, ns, label, flags, gfp); - if (len =3D=3D -1) { + if (len < 0) { AA_DEBUG("label print error"); return; } @@ -1801,7 +1801,7 @@ void aa_label_xprintk(struct aa_ns *ns, int len; =20 len =3D aa_label_asxprint(&str, ns, label, flags, gfp); - if (len =3D=3D -1) { + if (len < 0) { AA_DEBUG("label print error"); return; }