Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753356AbbHaN7J (ORCPT ); Mon, 31 Aug 2015 09:59:09 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:43088 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753325AbbHaN7F (ORCPT ); Mon, 31 Aug 2015 09:59:05 -0400 X-AuditID: cbfec7f5-f794b6d000001495-94-55e45da5dd3d Message-id: <1441029540.2335.2.camel@samsung.com> Subject: Re: [PATCH] security: smack: Add support automatic Smack labeling From: Lukasz Pawelczyk To: jonghwa3.lee@samsung.com, Casey Schaufler , linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org Cc: james.l.morris@oracle.com, serge@hallyn.com, sangbae90.lee@samsung.com, inki.dae@samsung.com Date: Mon, 31 Aug 2015 15:59:00 +0200 In-reply-to: <55E3F0A2.2070102@samsung.com> References: <1440640704-21730-1-git-send-email-jonghwa3.lee@samsung.com> <1440640704-21730-2-git-send-email-jonghwa3.lee@samsung.com> <55E09B2E.3040805@schaufler-ca.com> <55E3F0A2.2070102@samsung.com> Content-type: text/plain; charset=UTF-8 X-Mailer: Evolution 3.16.5 (3.16.5-1.fc22) MIME-version: 1.0 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHLMWRmVeSWpSXmKPExsVy+t/xy7pLY5+EGuw6qmVxb9svNotJ9yew WPQ9DrLoPPuE2eLyrjlsFh96HrFZHP90kMXi/IVz7A4cHtd2R3p8fHqLxaNvyypGj6P7F7F5 fN4kF8AaxWWTkpqTWZZapG+XwJUx7dZipoJzfBWTe8QbGNdxdzFycEgImEi0vU7tYuQEMsUk Ltxbz9bFyMUhJLCUUWLR45dMEM5nRon/HffZQap4BQwlnrZfYwWxhQW8JFY9uQAWZxMwkPh+ YS8zSIOIQC+jxMk5k5lBEswCSRLT9nxhArFZBFQldny6ywZicwpoS8w7OosVYsMZRok3Gx8z QTSoS0yat4gZ4jwtia1ruCAWC0r8mHyPBaJEXmLzmrfMExgFZiHpmIWkbBaSsgWMzKsYRVNL kwuKk9JzjfSKE3OLS/PS9ZLzczcxQkL96w7GpcesDjEKcDAq8fB+6HocKsSaWFZcmXuIUYKD WUmEl9/wSagQb0piZVVqUX58UWlOavEhRmkOFiVx3pm73ocICaQnlqRmp6YWpBbBZJk4OKUa GFkuluackTmtYtIkfuXhyyNrJy0MEpjfuG/Gb9Vw2fBvUR21137zro6cebp/Y84klbBYgdVT K9PY14d79sldY/+rLL5PafOTBW+nGtmaN91Q4lD+u8yq0/mvZ7mO+st004ur1TVWvA06q5Fo frpwRtWuW5uvhmZvuHPp6PtDyZdvuevM+lWXdVaJpTgj0VCLuag4EQB1fLy9cQIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2057 Lines: 63 On pon, 2015-08-31 at 15:13 +0900, jonghwa3.lee@samsung.com wrote: > A rule is defined for a process, 'process A', in smack rule table. > > ... > Process A device::A arwx- > ... > > The object 'device::A' will be used to a device node that 'process A' > will access. > However when the target device node is created it's labeled with > default label > which is inherited from any of filesystem, ancestor, or creating > process. > Let's say the default object label for devtmpfs is '_' which allows > only read and > write access. So we need the specific labeling by the authorized > process as like > udevd for the devtmpfs. > > In normal, smack label and access control follow the sequences, > > 1. Kernel module driver loaded > 2. New device node is created (/dev/aaa , '_') > 3. Udevd gets uevent and appies udev rule (/dev/aaa, 'device::A') > 4. 'Process A' accesses the device node ('Process A' ---> > 'device::A', MAY_WRITE) > 5. Access is permitted. > > However, when labeling isn't done in proper time, result will be > different, > > 1. Kernel module driver loaded > 2. New device node is created (/dev/aaa , '_') > 3. 'Process A' accesses the device node ('Process A' ---> '_', > MAY_WRITE) > 4. Access is prohibited > > Can this situation be handled in current Smack subsystem? > If so, could you give me an idea how to handle it. This doesn't seem to be a Smack problem. This isn't even a kernel problem. It's userspace race. You should wait for a proper udev event that notifies after all udev rules are applied. I think there are 2 udev events. One that notifies that a device has been added. Second that notifies where all the rules for the device has been applied. You need to use the second one. -- Lukasz Pawelczyk Samsung R&D Institute Poland Samsung Electronics -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/