From patchwork Thu Jul 21 20:24:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 9242497 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 16C90602F0 for ; Thu, 21 Jul 2016 20:28:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 086C527BF7 for ; Thu, 21 Jul 2016 20:28:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0A9827DE0; Thu, 21 Jul 2016 20:28:15 +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=-2.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from emsm-gh1-uea11.nsa.gov (emsm-gh1-uea11.nsa.gov [8.44.101.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AEB8227D85 for ; Thu, 21 Jul 2016 20:28:14 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.28,401,1464652800"; d="scan'208";a="17851688" IronPort-PHdr: =?us-ascii?q?9a23=3A6+taBBdE4eQZy7Y+oqs29lYqlGMj4u6mDksu8pMi?= =?us-ascii?q?zoh2WeGdxc6yYx7h7PlgxGXEQZ/co6odzbGH6+a9BCdZvc3JmUtBWaQEbwUCh8?= =?us-ascii?q?QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYsExnyfTB4?= =?us-ascii?q?Ov7yUtaLyZ/mj6bvptaKP14ArQH+SIs6FA+xowTVu5teqqpZAYF19CH0pGBVcf?= =?us-ascii?q?9d32JiKAHbtR/94sCt4MwrqHwI6LoJvvRNWqTifqk+UacQTHF/azh0t/DxsVH/?= =?us-ascii?q?aSfHpj5FCiRF2iZPVgzG6RWyCpPwtDbq8+lwwi+XOeXoQr0uHzev9aFmTFnvki?= =?us-ascii?q?hRZBAj92SCqMtwiupgvA+luw43l4zTYIfTL+Zjer/PVdcbQ2NbWYBWTSMXUdD0?= =?us-ascii?q?VJcGE+dUZbUQlIL6vVZb6ELnXQQ=3D?= X-IPAS-Result: =?us-ascii?q?A2EkAQCqL5FX/wHyM5BdHAEBgyGBUrl7BU8hhzVMAQEBAQE?= =?us-ascii?q?BAgJiJ4IyBAESAQdJAQEBAQEBAQEBTAINXwIBAwECDxUTBgEBDCALAQIDCQEBF?= =?us-ascii?q?ykICAMBLQMBBQELEQYICwUYBAGIDqIjgTI+MYpUhSoBAQWBAYgFAQEIAQEBARs?= =?us-ascii?q?IEIQPgguIXxEBhXePBoleR4FfjQwCiUIlhVFIjhowgQ9UgX4NHIFsToZIgTUBA?= =?us-ascii?q?QE?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea11.nsa.gov with ESMTP; 21 Jul 2016 20:28:12 +0000 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 u6LKP8B5017672; Thu, 21 Jul 2016 16:25:22 -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 u6LKOZYX005221 for ; Thu, 21 Jul 2016 16:24:35 -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 u6LKOYis017525 for ; Thu, 21 Jul 2016 16:24:34 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1A8AACELpFXhq3AVdFdHAEBhHO2T4MsBVmGGgKBMEwBAQEBAQETAQEBCAsLCSGFDAIBAxIVGQEBNwEPUTQBBQEcBhMiiA6iI4EyPjGKVIUqAQEFgQGIBgEBAQEBAQEDAQEBAQEaCBCED4ILi1YLgwePBoleR4FfjQwCiUKFdkiOGjCBD4JSDRELgWxOh30BAQE X-IPAS-Result: A1A8AACELpFXhq3AVdFdHAEBhHO2T4MsBVmGGgKBMEwBAQEBAQETAQEBCAsLCSGFDAIBAxIVGQEBNwEPUTQBBQEcBhMiiA6iI4EyPjGKVIUqAQEFgQGIBgEBAQEBAQEDAQEBAQEaCBCED4ILi1YLgwePBoleR4FfjQwCiUKFdkiOGjCBD4JSDRELgWxOh30BAQE X-IronPort-AV: E=Sophos;i="5.28,401,1464667200"; d="scan'208";a="5595874" Received: from emsm-gh1-uea11.corp.nsa.gov (HELO emsm-gh1-uea11.nsa.gov) ([10.208.41.37]) by goalie.tycho.ncsc.mil with ESMTP; 21 Jul 2016 16:24:33 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3AAx7NfxQ2JeIGi1fjp9Aazmijk9psv+yvbD5Q0YIu?= =?us-ascii?q?jvd0So/mwa64YxeN2/xhgRfzUJnB7Loc0qyN4vimBDFLuM3Y+Fk5M7V0Hycfjs?= =?us-ascii?q?sXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aJBzzOEJP?= =?us-ascii?q?K/jvHcaK1oLshrj0psCYOl4RzBOGIppKZC2sqgvQssREyaBDEY0WjiXzn31TZu?= =?us-ascii?q?5NznlpL1/A1zz158O34YIxu38I46Fp34d6XK77Z6U1S6BDRHRjajhtpZ6jiR6W?= =?us-ascii?q?SQiK4jNIVmQQjwoNAAXf6hz+don+vzG8tedn3iSee8rsQuZndy6l6vJJTx/uwB?= =?us-ascii?q?wbKjol4imDiMtwiuRAvA+luw5Xx4/SaZuScv1kcfWOLpshWWNdU5MJBGR6CYSm?= =?us-ascii?q?Yt5KVrJZMA=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0GTAACELpFXhq3AVdFdHAEBhHO2T4MsB?= =?us-ascii?q?VmGGgKBMEwBAQEBAQECAg8BAQEICwsJIS+CMgQBEgEHSQEBAQEBAQEBAUwCDV8?= =?us-ascii?q?CAQMSFRkBATcBD1E0AQUBHAYTIogOoiOBMj4xilSFKgEBBYEBiAYBAQEBAQEBA?= =?us-ascii?q?wEBAQEBGggQhA+CC4tWC4MHjwaJXkeBX40MAolChXZIjhowgQ+CUg0RC4FsTod?= =?us-ascii?q?9AQEB?= X-IPAS-Result: =?us-ascii?q?A0GTAACELpFXhq3AVdFdHAEBhHO2T4MsBVmGGgKBMEwBAQE?= =?us-ascii?q?BAQECAg8BAQEICwsJIS+CMgQBEgEHSQEBAQEBAQEBAUwCDV8CAQMSFRkBATcBD?= =?us-ascii?q?1E0AQUBHAYTIogOoiOBMj4xilSFKgEBBYEBiAYBAQEBAQEBAwEBAQEBGggQhA+?= =?us-ascii?q?CC4tWC4MHjwaJXkeBX40MAolChXZIjhowgQ+CUg0RC4FsTod9AQEB?= X-IronPort-AV: E=Sophos;i="5.28,401,1464652800"; d="scan'208";a="17851577" Received: from mail-pf0-f173.google.com ([209.85.192.173]) by emsm-gh1-uea11.nsa.gov with ESMTP/TLS/AES128-GCM-SHA256; 21 Jul 2016 20:24:32 +0000 Received: by mail-pf0-f173.google.com with SMTP id x72so33565657pfd.2 for ; Thu, 21 Jul 2016 13:24:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qR/7b9+VNQ/zIAirhXO7am7AxVNdZ+kT++nquZQhazg=; b=aWhNyx3hVLb08HY3oN6wkcEUuAuOX2CVgwCIBBcX2daWyQau177QcNTWRAVhpaXKmV OofozlytkNsmCGYQJAfLybfhLjcc4pFU89yHK3sl9o/HtmkI4rffJY7anJzwm7vOyPzr svoSx+/G9CeGMZrWVWBl+yxW6+d5nlDB2/+yU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qR/7b9+VNQ/zIAirhXO7am7AxVNdZ+kT++nquZQhazg=; b=SGtJodpcBWXuTPer53EXslTxoyNVwEgjJvcGf3mZHN4NFDQlA71lrvNL4/S7FOzsCt W9NM0h6/+Z4fOtKH/MY4gOQiOwgsiNV2CvUyiFjcW0AMynx0nenZZIwBS3e+miR7IYS4 sEmDiKjxgcPSpHThtKnwGbLxjacokPrsKKMTzHAmmUjOzc3w491JhxnKz0C+Yy9nlMNN 1jORvXKL8W/Cxu7rYHgy2QOQviaa016e+fN0JIX1p1/9cXBeeS5bp+QIwl+69fhiBXpF 6//1701d9xYtTZYyB927pcC/iwplmuor4tfzJZpU38cKqgEHHgehmc5FvgbxdygtS02C Ymdg== X-Gm-Message-State: AEkooutAVxIAZdchqMIIlHyi8fNaOetNCgEyDHkzYcbemx+yORmldrqj9BcRdKx5f6VB4Es9 X-Received: by 10.98.102.221 with SMTP id s90mr209572pfj.69.1469132672030; Thu, 21 Jul 2016 13:24:32 -0700 (PDT) Received: from localhost.localdomain (c-73-67-244-238.hsd1.or.comcast.net. [73.67.244.238]) by smtp.gmail.com with ESMTPSA id d185sm14277920pfd.80.2016.07.21.13.24.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jul 2016 13:24:31 -0700 (PDT) From: John Stultz To: lkml Subject: [PATCH 2/2 v4] proc: Add LSM hook checks to /proc//timerslack_ns Date: Thu, 21 Jul 2016 13:24:27 -0700 Message-Id: <1469132667-17377-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469132667-17377-1-git-send-email-john.stultz@linaro.org> References: <1469132667-17377-1-git-send-email-john.stultz@linaro.org> X-Mailman-Approved-At: Thu, 21 Jul 2016 16:25:06 -0400 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: Elliott Hughes , Kees Cook , linux-security-module@vger.kernel.org, Android Kernel Team , Rom Lemarchand , Oren Laadan , Ruchi Kandoi , Dmitry Shmidt , John Stultz , selinux@tycho.nsa.gov, Colin Cross , Andrew Morton , Todd Kjos , Arjan van de Ven , Thomas Gleixner MIME-Version: 1.0 Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-Virus-Scanned: ClamAV using ClamSMTP As requested, this patch checks the existing LSM hooks task_getscheduler/task_setscheduler when reading or modifying the task's timerslack value. Previous versions added new get/settimerslack LSM hooks, but since they checked the same PROCESS__SET/GETSCHED values as existing hooks, it was suggested we just use the existing ones. Cc: Kees Cook Cc: "Serge E. Hallyn" Cc: Andrew Morton Cc: Thomas Gleixner CC: Arjan van de Ven Cc: Oren Laadan Cc: Ruchi Kandoi Cc: Rom Lemarchand Cc: Todd Kjos Cc: Colin Cross Cc: Nick Kralevich Cc: Dmitry Shmidt Cc: Elliott Hughes Cc: James Morris Cc: Android Kernel Team Cc: linux-security-module@vger.kernel.org Cc: selinux@tycho.nsa.gov Signed-off-by: John Stultz Acked-by: Paul Moore --- v2: * Initial swing at adding settimerslack LSM hook v3: * Fix current/p switchup bug noted by NickK * Add gettimerslack hook suggested by NickK v4: * Dropped adding get/settimerslack LSM hooks, and just reuse the get/setscheduler ones. fs/proc/base.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/proc/base.c b/fs/proc/base.c index c94abae..02f8389 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2286,6 +2286,12 @@ static ssize_t timerslack_ns_write(struct file *file, const char __user *buf, goto out; } + err = security_task_setscheduler(p); + if (err) { + count = err; + goto out; + } + task_lock(p); if (slack_ns == 0) p->timer_slack_ns = p->default_timer_slack_ns; @@ -2314,6 +2320,10 @@ static int timerslack_ns_show(struct seq_file *m, void *v) goto out; } + err = security_task_getscheduler(p); + if (err) + goto out; + task_lock(p); seq_printf(m, "%llu\n", p->timer_slack_ns); task_unlock(p);