From patchwork Mon Mar 28 15:10:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 8679721 Return-Path: X-Original-To: patchwork-selinux@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1E0949F36E for ; Mon, 28 Mar 2016 15:15:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1D62020220 for ; Mon, 28 Mar 2016 15:15:37 +0000 (UTC) Received: from emvm-gh1-uea09.nsa.gov (unknown [63.239.67.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 25FEC201F4 for ; Mon, 28 Mar 2016 15:15:36 +0000 (UTC) X-TM-IMSS-Message-ID: <2cbd73750001aeca@nsa.gov> Received: from tarius.tycho.ncsc.mil ([144.51.242.1]) by nsa.gov ([10.208.42.194]) with ESMTP (TREND IMSS SMTP Service 7.1) id 2cbd73750001aeca ; Mon, 28 Mar 2016 11:11:24 -0400 Received: from prometheus.infosec.tycho.ncsc.mil (prometheus [192.168.25.40]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u2SFApto001572; Mon, 28 Mar 2016 11:11:04 -0400 Received: from tarius.tycho.ncsc.mil (tarius.infosec.tycho.ncsc.mil [144.51.242.1]) by prometheus.infosec.tycho.ncsc.mil (8.15.2/8.15.2) with ESMTP id u2SFAkB7113580 for ; Mon, 28 Mar 2016 11:10:46 -0400 Received: from goalie.tycho.ncsc.mil (goalie [144.51.242.250]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u2SFAjpg001565 for ; Mon, 28 Mar 2016 11:10:46 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1BlBQDdSPlWkxy3hNFcGQEBAQGELTSKIp4sjX+CFoQNhg2BbgEBAQEBARIBAQEBCQsJCSGFGlYwBQImAkkXEognr2mQBwEBCAIBHXyFIoF7hlODMoJWBZdhlz2FUgJEjkeCdoFtIDABhzyBPQEBAQ X-IPAS-Result: A1BlBQDdSPlWkxy3hNFcGQEBAQGELTSKIp4sjX+CFoQNhg2BbgEBAQEBARIBAQEBCQsJCSGFGlYwBQImAkkXEognr2mQBwEBCAIBHXyFIoF7hlODMoJWBZdhlz2FUgJEjkeCdoFtIDABhzyBPQEBAQ X-IronPort-AV: E=Sophos;i="5.24,407,1454994000"; d="scan'208";a="5329882" Received: from emvm-gh1-uea09.nsa.gov ([10.208.42.194]) by goalie.tycho.ncsc.mil with ESMTP; 28 Mar 2016 11:10:41 -0400 X-TM-IMSS-Message-ID: <2cbc23c00001ae4e@nsa.gov> Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by nsa.gov ([10.208.42.194]) with ESMTP (TREND IMSS SMTP Service 7.1; TLSv1/SSLv3 ADH-AES256-SHA (256/256)) id 2cbc23c00001ae4e ; Mon, 28 Mar 2016 11:09:58 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 38FE2C049E1A; Mon, 28 Mar 2016 15:10:39 +0000 (UTC) Received: from [127.0.0.1] (unused [10.10.51.4] (may be forged)) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2SFAcvk005152; Mon, 28 Mar 2016 11:10:38 -0400 Subject: [PATCH] netlabel: fix a problem with netlbl_secattr_catmap_setrng() From: Paul Moore To: netdev@vger.kernel.org, selinux@tycho.nsa.gov Date: Mon, 28 Mar 2016 11:10:38 -0400 Message-ID: <145917783800.9565.7759086668991534988.stgit@localhost> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-TM-AS-MML: disable X-BeenThere: selinux@tycho.nsa.gov X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: Cc: Janak Desai Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RDNS_NONE, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Janak Desai We try to be clever and set large chunks of the bitmap at once, when possible; unfortunately we weren't very clever when we wrote the code and messed up the if-conditional. Fix this bug and restore proper operation. Signed-off-by: Janak Desai Signed-off-by: Paul Moore --- net/netlabel/netlabel_kapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c index 28cddc8..1325776 100644 --- a/net/netlabel/netlabel_kapi.c +++ b/net/netlabel/netlabel_kapi.c @@ -677,7 +677,7 @@ int netlbl_catmap_setrng(struct netlbl_lsm_catmap **catmap, u32 spot = start; while (rc == 0 && spot <= end) { - if (((spot & (BITS_PER_LONG - 1)) != 0) && + if (((spot & (BITS_PER_LONG - 1)) == 0) && ((end - spot) > BITS_PER_LONG)) { rc = netlbl_catmap_setlong(catmap, spot,