From patchwork Wed Jul 13 07:32:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Georget X-Patchwork-Id: 9227021 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 B91E46088F for ; Wed, 13 Jul 2016 07:33:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACC232766D for ; Wed, 13 Jul 2016 07:33:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A16D327F8E; Wed, 13 Jul 2016 07:33:26 +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 3F77A27C38 for ; Wed, 13 Jul 2016 07:33:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750961AbcGMHdX (ORCPT ); Wed, 13 Jul 2016 03:33:23 -0400 Received: from lgeorget.eu ([178.170.116.192]:59864 "EHLO lgeorget.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751278AbcGMHdX (ORCPT ); Wed, 13 Jul 2016 03:33:23 -0400 Received: from localhost (unknown [193.54.192.15]) by lgeorget.eu (Postfix) with ESMTPSA id 9756E6BE68; Wed, 13 Jul 2016 09:33:11 +0200 (CEST) From: Laurent Georget To: James Morris , LSM Cc: Paul Moore , Laurent Georget Subject: [PATCH 2/2] Add LSM hooks for mq_timedsend and mq_timedreceive Date: Wed, 13 Jul 2016 09:32:51 +0200 Message-Id: <309c3eb6dac783590b66e39e66d7f85f1ba66a20.1468394884.git.laurent.georget@supelec.fr> X-Mailer: git-send-email 2.9.0 In-Reply-To: References: In-Reply-To: References: Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Laurent Georget --- include/linux/security.h | 16 ++++++++++++++++ ipc/mqueue.c | 9 +++++++++ 2 files changed, 25 insertions(+) diff --git a/include/linux/security.h b/include/linux/security.h index c3e2109..8f4d5c5 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -338,6 +338,10 @@ int security_msg_queue_msgsnd(struct msg_queue *msq, struct msg_msg *msg, int msqflg); int security_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg, struct task_struct *target, long type, int mode); +int security_mq_timedsend(struct file *mq, size_t msg_len, + unsigned long msg_prio, struct timespec *ts); +int security_mq_timedreceive(struct file *mq, size_t msg_len, + struct timespec *ts); int security_shm_alloc(struct shmid_kernel *shp); void security_shm_free(struct shmid_kernel *shp); int security_shm_associate(struct shmid_kernel *shp, int shmflg); @@ -1018,6 +1022,18 @@ static inline int security_msg_queue_msgrcv(struct msg_queue *msq, return 0; } +static inline int security_mq_timedsend(struct file *mq, size_t msg_len, + unsigned long msg_prio, + struct timespec *ts) +{ + return 0; +} +static inline int security_mq_timedreceive(struct file *mq, size_t msg_len, + struct timespec *ts) +{ + return 0; +} + static inline int security_shm_alloc(struct shmid_kernel *shp) { return 0; diff --git a/ipc/mqueue.c b/ipc/mqueue.c index ade739f..da8ec3a 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -1002,6 +1002,11 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr, goto out_fput; } + ret = security_mq_timedsend(f.file, msg_len, msg_prio, + timeout ? &ts : NULL); + if (ret) + goto out_fput; + if (unlikely(msg_len > info->attr.mq_msgsize)) { ret = -EMSGSIZE; goto out_fput; @@ -1118,6 +1123,10 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr, goto out_fput; } + ret = security_mq_timedreceive(f.file, msg_len, timeout ? &ts : NULL); + if (ret) + goto out_fput; + /* checks if buffer is big enough */ if (unlikely(msg_len < info->attr.mq_msgsize)) { ret = -EMSGSIZE;