From patchwork Thu Nov 3 10:54:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jos=C3=A9_Bollo?= X-Patchwork-Id: 9410715 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 CD4886022E for ; Thu, 3 Nov 2016 10:55:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB6BC2A9C0 for ; Thu, 3 Nov 2016 10:55:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFD642A9C2; Thu, 3 Nov 2016 10:55:28 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 9A0D02A9C0 for ; Thu, 3 Nov 2016 10:55:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753415AbcKCKz0 (ORCPT ); Thu, 3 Nov 2016 06:55:26 -0400 Received: from edna.lautre.net ([80.67.160.88]:44721 "EHLO edna.lautre.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752544AbcKCKz0 (ORCPT ); Thu, 3 Nov 2016 06:55:26 -0400 Received: from localhost (localhost [127.0.0.1]) by edna.lautre.net (Postfix) with ESMTP id AB4BE109044 for ; Thu, 3 Nov 2016 11:55:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=nonadev.net; s=alternc; t=1478170521; bh=riNiz2w8XZvoLBn7w3GdhZtdb6mthJqn3W9p2dJ7S9g=; h=From:To:Cc:Subject:Date; b=lov3JSeToOEUyj99gCofgwFdYiRQbulqcyyE2RRpiODRFDOCiIr5yg39E19d+jDf8 E8xkwEY0WA+mFWbZQT4c3JVuHrnrgHMOQPeqngtUdGOiJKNYQ/agaL2SX1Crijygx5 n6UhcXNss3VsgZ/RtECNUXe8KfyeHyLoiYuEJIeE= X-Virus-Scanned: Debian amavisd-new at edna.lautre.net Received: from edna.lautre.net ([127.0.0.1]) by localhost (edna.admin.lautre.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YNxiw61WRsYn for ; Thu, 3 Nov 2016 11:55:16 +0100 (CET) Received: from d-jobol.iot.bzh (por56-1-78-229-206-229.fbx.proxad.net [78.229.206.229]) by edna.lautre.net (Postfix) with ESMTPA id 1CE7D109022; Thu, 3 Nov 2016 11:55:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=nonadev.net; s=alternc; t=1478170516; bh=riNiz2w8XZvoLBn7w3GdhZtdb6mthJqn3W9p2dJ7S9g=; h=From:To:Cc:Subject:Date; b=OYuYcuPNKO+7ozadUr5DJGoXD+wVXxVajDZIPmW9JDjBE/K+Pq/EQ6h0JkFMBcYTe YynXi4O3LkZqznTp+hpW/zrc2AHD0E8vYeJOG6jrql9DahROCWaz8SuOSF+57dDC1b i4rspVWYjhNHXIULgCH/PsCFmhXQmVKeEaZojUV8= From: jobol@nonadev.net To: linux-security-module@vger.kernel.org, casey@schaufler-ca.com, jooseong.lee@samsung.com Cc: kd0228.kim@samsung.com, dh79.pyun@samsung.com, jobol@iot.bzh, stephane.desneux@iot.bzh Subject: [PATCH] Smack: Assign smack_known_web label for kernel thread's Date: Thu, 3 Nov 2016 11:54:39 +0100 Message-Id: <1478170479-22841-1-git-send-email-jobol@nonadev.net> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: jooseong lee Assign smack_known_web label for kernel thread's socket in the sk_alloc_security hook Creating struct sock by sk_alloc function in various kernel subsystems like bluetooth dosen't call smack_socket_post_create(). In such case, received sock label is the floor('_') label and makes access deny. Signed-off-by: jooseong lee --- security/smack/smack_lsm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 1cb0602..e73460d 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -2337,8 +2337,16 @@ static int smack_sk_alloc_security(struct sock *sk, int family, gfp_t gfp_flags) if (ssp == NULL) return -ENOMEM; - ssp->smk_in = skp; - ssp->smk_out = skp; + /* + * Sockets created by kernel threads receive web label. + */ + if (unlikely(current->flags & PF_KTHREAD)) { + ssp->smk_in = &smack_known_web; + ssp->smk_out = &smack_known_web; + } else { + ssp->smk_in = skp; + ssp->smk_out = skp; + } ssp->smk_packet = NULL; sk->sk_security = ssp;