From patchwork Mon Feb 4 18:38:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaroslav Kysela X-Patchwork-Id: 10796355 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9B15746 for ; Mon, 4 Feb 2019 18:39:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 986222AC93 for ; Mon, 4 Feb 2019 18:39:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C80C2B4AE; Mon, 4 Feb 2019 18:39:11 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D45D92AC93 for ; Mon, 4 Feb 2019 18:39:10 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 19CD026745C; Mon, 4 Feb 2019 19:39:09 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id D904726746F; Mon, 4 Feb 2019 19:39:06 +0100 (CET) Received: from mail1.perex.cz (mail1.perex.cz [77.48.224.245]) by alsa0.perex.cz (Postfix) with ESMTP id 371F6267459 for ; Mon, 4 Feb 2019 19:39:05 +0100 (CET) Received: from mail1.perex.cz (localhost [127.0.0.1]) by smtp1.perex.cz (Perex's E-mail Delivery System) with ESMTP id E6BA5A003F; Mon, 4 Feb 2019 19:39:04 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.perex.cz E6BA5A003F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=perex.cz; s=default; t=1549305544; bh=ChzlDRJL/5yxGBcVfodGWwyYNbzgUypHw+YU3xMQjWg=; h=From:To:Cc:Subject:Date:From; b=I9bRRFsV5qGtaKvaWpod7Pv3mq5k2LgWUyq+3XuH0JjYcgGkP2EJQ8sqfbwj1L+zy xDEbHs+26x4IPKGq2QWj/pBpM08wLMez765fPYV0ll/VR+s2LNiYCfMSqYxTN33kfy Q4kU1EGXT22I96WwmNM/SlWAjxBL5F7RyCd5AdfM= Received: from p50.perex-int.cz (unknown [192.168.100.94]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: perex) by mail1.perex.cz (Perex's E-mail Delivery System) with ESMTPSA; Mon, 4 Feb 2019 19:38:56 +0100 (CET) From: Jaroslav Kysela To: ALSA development Date: Mon, 4 Feb 2019 19:38:14 +0100 Message-Id: <20190204183817.975-1-perex@perex.cz> X-Mailer: git-send-email 2.13.6 Cc: Baolin Wang , Takashi Iwai , Phil Burk , Zach Riggle , Mark Brown , Leo Yan Subject: [alsa-devel] [PATCH v6 0/3] ALSA: pcm: anonymous dup implementation X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP This patchset contains the anonymous dup implementation with permissions checking for the ALSA's PCM interface in kernel to enable the restricted DMA sound buffer sharing for the restricted tasks. The code was tested through qemu and it seems to be pretty stable. The initial tinyalsa implementation can be found here: https://github.com/perexg/tinyalsa/commits/anondup The filtering might be refined. It depends on the real requirements. Perhaps, we may create more ioctl groups. Any comments are more than welcome. v2 of the patches: - change clone parameter to subdevice number for the pcm attach - change SNDRV_PCM_PERM_MAX to SNDRV_PCM_PERM_MASK - the tinyalsa implementation was a little updated (restructured) v3 of the patches: - group integer declarations in snd_pcm_anonymous_dup() - replaced substream->pcm with pcm in snd_pcm_anonymous_dup() - added SNDRV_PCM_PERM_RW check for read/write/readv/writev syscalls v4 of the patches: - more simple restriction control (only two modes - full/buffer) - the tinyalsa implementation follows this change v5 of the patches: - merge pcm_..._mmap_allowed fcns to the snd_pcm_mmap_... fcns v6: - add proper open_mutex protection for snd_pcm_open_file() Cc: Phil Burk Cc: Zach Riggle Cc: Mark Brown Cc: Leo Yan Cc: Baolin Wang Jaroslav Kysela (3): ALSA: pcm: implement the anonymous dup (inode file descriptor) ALSA: pcm: merge pcm_..._mmap_allowed fcns to the snd_pcm_mmap_... fcns ALSA: pcm: implement the mmap buffer mode for the anonymous dup include/sound/pcm.h | 10 +-- include/uapi/sound/asound.h | 6 +- sound/core/oss/pcm_oss.c | 2 +- sound/core/pcm.c | 13 ++-- sound/core/pcm_compat.c | 1 + sound/core/pcm_native.c | 154 +++++++++++++++++++++++++++++++++----------- 6 files changed, 133 insertions(+), 53 deletions(-) Reviewed-by: Mark Brown