From nobody Tue Nov 26 17:22:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; arc=fail (BodyHash is different from the expected one) Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568046606785289.899461582199; Mon, 9 Sep 2019 09:30:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 747DD8980FE; Mon, 9 Sep 2019 16:30:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CA1165C1D8; Mon, 9 Sep 2019 16:30:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C113F180B536; Mon, 9 Sep 2019 16:30:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x89GTxK7028132 for ; Mon, 9 Sep 2019 12:29:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 42E54196AE; Mon, 9 Sep 2019 16:29:59 +0000 (UTC) Received: from mx1.redhat.com (ext-mx26.extmail.prod.ext.phx2.redhat.com [10.5.110.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3CFEB19C78 for ; Mon, 9 Sep 2019 16:29:56 +0000 (UTC) Received: from m9a0003g.houston.softwaregrp.com (m9a0003g.houston.softwaregrp.com [15.124.64.68]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 17CDB8980FE for ; Mon, 9 Sep 2019 16:29:55 +0000 (UTC) Received: FROM m9a0003g.houston.softwaregrp.com (15.121.0.191) BY m9a0003g.houston.softwaregrp.com WITH ESMTP FOR libvir-list@redhat.com; Mon, 9 Sep 2019 16:29:09 +0000 Received: from M4W0335.microfocus.com (2002:f78:1193::f78:1193) by M9W0068.microfocus.com (2002:f79:bf::f79:bf) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 9 Sep 2019 16:26:44 +0000 Received: from NAM05-CO1-obe.outbound.protection.outlook.com (15.124.8.13) by M4W0335.microfocus.com (15.120.17.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10 via Frontend Transport; Mon, 9 Sep 2019 16:26:44 +0000 Received: from BY5PR18MB3315.namprd18.prod.outlook.com (10.255.139.204) by BY5PR18MB3236.namprd18.prod.outlook.com (10.255.136.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2241.20; Mon, 9 Sep 2019 16:26:37 +0000 Received: from BY5PR18MB3315.namprd18.prod.outlook.com ([fe80::59be:6d5e:12a4:f03c]) by BY5PR18MB3315.namprd18.prod.outlook.com ([fe80::59be:6d5e:12a4:f03c%7]) with mapi id 15.20.2241.018; Mon, 9 Sep 2019 16:26:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ehVBIuO5i5HYO4Ab/nJO5Cos8opAym5Wlm1GrWx1YJLZ7TOUewgLrjf5GZUf0vMoq4pGx7GquETAT8y/eD3uHVcziX0PzuOPR9C0QbsNghSqAjfUsx2iK0MLjRcPM2yLK1KfEtwyzYdqaRVlL8fb8L0yUVSBD/e3mo/Cegoh9JK+0UDyr0/MeG/Y7QcgksTsPRlnNKz1WtjGWyaBgY2x9o0mWw5UFPTCgZ3JVoB6kE0hq5DSlb4ETGPTXkzdAu+ymx0FKQ+RL60uYbHYCBnxDrRHd/IyF8at8hptGtePmaj8M/0YCJenJagMiLNR8KAD1RGKQxtt0Xq4/yNGzgrn4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FoWZMU+2xpIBG67hXvHjcOVHhAH/O8TgwKj71TkywwY=; b=VfJ4v/2FGMyScwh/sY9UajMyU89uFbjQ3K9Motx2q7YLUp59IUc5qHVdyMWjmKrdPD7yK16KwZi9/PlzY0sZXkpon/az7ipa/J5YEHfeugL3Asr3+Kz+3eC0JmJVbDokdLDNBwbJ1/L+2mejbYbzdkf7nNHtI4L90ItBvxrYMOeRjN1HJKM7jE25QUAjwqg6uZunJ3gIpURsSRdABSbwaPYmP5R/qDgRSl9nlqcJAtdpQ7QQc+wkIuItQTQLTKqKHyxfkuDy9ulQEh2nbmSdLpXCd1/YJkEQQqNQ/lcxAaNFzekGU3xXZYJT/cMXQAwpHJzqCpC/Ug7MEnmobB3NOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none From: Jim Fehlig To: "libvir-list@redhat.com" Thread-Topic: [PATCH] apparmor: avoid copying empty profile name Thread-Index: AQHVZytaXPvLf1xLWUmi18j4gXRjWQ== Date: Mon, 9 Sep 2019 16:26:37 +0000 Message-ID: <20190909162620.12249-1-jfehlig@suse.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BY5PR03CA0014.namprd03.prod.outlook.com (2603:10b6:a03:1e0::24) To BY5PR18MB3315.namprd18.prod.outlook.com (2603:10b6:a03:196::12) authentication-results: spf=none (sender IP is ) smtp.mailfrom=jfehlig@suse.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [2620:113:8044:4009:ffff:ffff:ffff:e5a1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6eab52f8-ca2b-44dd-106c-08d735427c98 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600166)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:BY5PR18MB3236; x-ms-traffictypediagnostic: BY5PR18MB3236: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:269; x-forefront-prvs: 01559F388D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(346002)(376002)(39860400002)(136003)(366004)(396003)(199004)(189003)(2906002)(86362001)(8936002)(6436002)(99286004)(46003)(81166006)(8676002)(81156014)(66946007)(2351001)(256004)(52116002)(107886003)(71200400001)(486006)(5660300002)(4326008)(71190400001)(6916009)(66476007)(66556008)(64756008)(66446008)(2616005)(476003)(25786009)(5640700003)(386003)(6506007)(53936002)(36756003)(14444005)(1076003)(50226002)(316002)(2501003)(6512007)(6486002)(14454004)(186003)(305945005)(7736002)(6116002)(102836004)(478600001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY5PR18MB3236; H:BY5PR18MB3315.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; received-spf: None (protection.outlook.com: suse.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 3RKMO/e8MzZIqZaOrhnGnC3tOfLC/X6IvjHjjqSIoYyOIy8q/9waHeHQDev8t9O5DU/jSdaJJ/wl3KXgRsPZ8Gd42cIz/R4aQmQEMdScCjsRjwL5JlRETysUt9bsM8ga38R6L5xrFMCD+LWjb1z7xWtV0TLKng0eTWQSep8LePKypuZP0ccT1ftPisJjBoOSiSl1vwigMK0JsV78XQt359sGHCb20k76H/uA7fL6dUCyY+d1AJWgzFYFGlrYaqnUPlIjNlsppZQ+Gb+1NT8ttxIdPfhCQfOxkhzXGsX9i+66WGKyXCcX9q2lZwnPXW2hSCrfb3lQM+OLRgJ5ibNMVuVt9ejI6qma/yq7jKiJovgrvDPUF+uHxVGkKoPjY8gX44bl1qZxe5qhnLfkMcZR1luEB9ZyJqtKlUc4R9CPCCk= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 6eab52f8-ca2b-44dd-106c-08d735427c98 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Sep 2019 16:26:37.2747 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 856b813c-16e5-49a5-85ec-6f081e13b527 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: OxuaRVvmo+P/KKRknpoQuUbWcwBJtbZVqLCJed/YW7M5rLhiyx2/JMyTuEVepti5r0ajRa4MUsGyqr40IEC4Xw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR18MB3236 X-OriginatorOrg: suse.com X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.67]); Mon, 09 Sep 2019 16:29:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.67]); Mon, 09 Sep 2019 16:29:56 +0000 (UTC) for IP:'15.124.64.68' DOMAIN:'m9a0003g.houston.softwaregrp.com' HELO:'m9a0003g.houston.softwaregrp.com' FROM:'jfehlig@suse.com' RCPT:'' X-RedHat-Spam-Score: 0.001 (RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY) 15.124.64.68 m9a0003g.houston.softwaregrp.com 15.124.64.68 m9a0003g.houston.softwaregrp.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.67 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id x89GTxK7028132 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] apparmor: avoid copying empty profile name X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.67]); Mon, 09 Sep 2019 16:30:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" AppArmorGetSecurityProcessLabel copies the VM's profile name to the label member of virSecurityLabel struct. If the profile is not loaded, the name is set empty before calling virStrcpy to copy it. However, virStrcpy will fail if src is empty (0 length), causing AppArmorGetSecurityProcessLabel to needlessly fail. Simple operations that report security driver information will subsequently fail virsh dominfo test Id: 248 Name: test ... Security model: apparmor Security DOI: 0 error: internal error: error copying profile name Avoid copying an empty profile name when the profile is not loaded. Signed-off-by: Jim Fehlig Reviewed-by: Michal Privoznik --- src/security/security_apparmor.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/security/security_apparmor.c b/src/security/security_appar= mor.c index 6d16b15c65..77eee9410c 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -525,14 +525,13 @@ AppArmorGetSecurityProcessLabel(virSecurityManagerPtr= mgr ATTRIBUTE_UNUSED, "%s", _("error getting profile status")); goto cleanup; } else if (status =3D=3D -1) { - profile_name[0] =3D '\0'; - } - - if (virStrcpy(sec->label, profile_name, - VIR_SECURITY_LABEL_BUFLEN) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("error copying profile name")); - goto cleanup; + sec->label[0] =3D '\0'; + } else { + if (virStrcpy(sec->label, profile_name, VIR_SECURITY_LABEL_BUFLEN)= < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("error copying profile name")); + goto cleanup; + } } =20 sec->enforcing =3D status =3D=3D 1; --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list