From patchwork Tue Jun 20 20:46:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9800241 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C1EF860329 for ; Tue, 20 Jun 2017 20:47:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2DCE27DCD for ; Tue, 20 Jun 2017 20:47:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7146283AF; Tue, 20 Jun 2017 20:47:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E18EB27DCD for ; Tue, 20 Jun 2017 20:47:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751639AbdFTUrc (ORCPT ); Tue, 20 Jun 2017 16:47:32 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:57371 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751041AbdFTUrb (ORCPT ); Tue, 20 Jun 2017 16:47:31 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue004 [212.227.15.129]) with ESMTPA (Nemesis) id 0Md090-1d6RP40s1i-00IDVy; Tue, 20 Jun 2017 22:47:24 +0200 From: Arnd Bergmann To: John Johansen Cc: Arnd Bergmann , James Morris , "Serge E. Hallyn" , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] apparmor: add braces around optional statement Date: Tue, 20 Jun 2017 22:46:19 +0200 Message-Id: <20170620204722.910610-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:SRfAlKnFl5snvcyYtuGbvLIvVv7yLl+pzuUo2ACf3g56tDwis4z 6OffE+u75i8YNLltKuQf7Os/IjxLs+viqn1i+tKZRUsOO3mEotWDAiMiqFNQGyNJ+xCnnyz VVlMSJ1AoKebbTFJPQBRZ+ER7GISKUEDjm1vsCRWCKJFJ3Q5ye4gPXD0sBmZFLpFCOGXc/s Gndj4VhBzr3vvUx05mPZQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:wvMi7dv1jDM=:tY0dwiJ0yQZgdfp8yl9ziy ausQYwm0yn6IwXArWDbO8HYPmMsDsFqeg+WsZUY7yieZ2OyBBeE0KR9NJBU7Zo5f8AAQPTlI2 WKvpG/IFrNbi0+fpDGHXsMs7XXqly03JsqbfNqqaxbFgtM9qD4zEnDjBN0q6AZDxdfEpMkrBw v1pUlfsG2XN/m5+Cmdf2FTVba9dNAHLj3KX2/RE0SemeFUoFYko7qqiY27GbLhexs9c+1Se+Z UN9pcWIClGfn3VmrgEi3DXRV0nEhQJwSeKhX2yErMHdk9Gv/c12jjo3QTJpqG/gZ+wfqfhk0g 736C2EJP/zrCEGwT6ufrsjV+SImJ52t588jjU93tTQvXU47YaN3GwL8j5UXQXC1yyGxLjYAYw 5P984KnuaHj+7Us9hmfwPtArO6+OLrU9RBk7dnauK7YDX7ba2R0ArdBxtTu4L2DpaUrILYITk VAm9cSXMQWzSt5vCn5FqtUAKA4tsgMOHGOndtq1Hdj3UmUUSmIrxlc+pKlT0zWiOQb50Z21UG JRq9bafNKwtOJy4ZpywEC+bmU57eVHaPjqlrTGR9Dgm4dIqWQRyyVLAbrFhz17Qo8YgsTfAod j2M0te7UdLpd2v01ZzBXIrQUWoPVvwzEDDQzI7lRK95sjplG1htySo+D9n+n/bRnAHDD3DWQM vhEuaTnsOUZSlNsEy6LVZBJyefaxn/xtyde00cAzycL7kRdlbn4DMqUvV7F5Axm+LOaI= Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP We get a warning when AA_BUG() compiles to an nothing: security/apparmor/label.c: In function '__label_update': security/apparmor/label.c:2055:3: error: suggest braces around empty body in an 'else' statement [-Werror=empty-body] There are two things we can do about this: - add the missing braces in the call site, which also brings the code in line with the regular Linux coding style - redefine the macro so it is not empty but instead uses no_printk() in AA_BUG_FMT() to perform format checking. Both seem like good ideas, so this does both at once. Fixes: f1bd904175e8 ("apparmor: add the base fns() for domain labels") Signed-off-by: Arnd Bergmann Acked-by: Serge Hallyn Acked-by: John Johansen --- v2: actually include the second part of the patch --- security/apparmor/include/lib.h | 2 +- security/apparmor/label.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/security/apparmor/include/lib.h b/security/apparmor/include/lib.h index 436b3a722357..cbfb71c1ec88 100644 --- a/security/apparmor/include/lib.h +++ b/security/apparmor/include/lib.h @@ -50,7 +50,7 @@ #define AA_BUG_FMT(X, fmt, args...) \ WARN((X), "AppArmor WARN %s: (" #X "): " fmt, __func__, ##args) #else -#define AA_BUG_FMT(X, fmt, args...) +#define AA_BUG_FMT(X, fmt, args...) no_printk("%s" fmt, __func__, ##args) #endif #define AA_ERROR(fmt, args...) \ diff --git a/security/apparmor/label.c b/security/apparmor/label.c index e052eaba1cf6..f8e08d94a8a6 100644 --- a/security/apparmor/label.c +++ b/security/apparmor/label.c @@ -2051,8 +2051,9 @@ static struct aa_label *__label_update(struct aa_label *label) write_lock_irqsave(&ls->lock, flags); goto remove; } - } else + } else { AA_BUG(labels_ns(label) != labels_ns(new)); + } tmp = __label_insert(labels_set(label), new, true); remove: