From patchwork Fri Aug 17 03:12:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yu Chao X-Patchwork-Id: 10568407 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 9882014BD for ; Fri, 17 Aug 2018 03:12:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 853252B176 for ; Fri, 17 Aug 2018 03:12:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 795902B1C4; Fri, 17 Aug 2018 03:12:47 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID 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 8AE3D2B176 for ; Fri, 17 Aug 2018 03:12:46 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 7FE75267814; Fri, 17 Aug 2018 05:12:42 +0200 (CEST) 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 BDDF3267817; Fri, 17 Aug 2018 05:12:39 +0200 (CEST) Received: from mail-pl0-f66.google.com (mail-pl0-f66.google.com [209.85.160.66]) by alsa0.perex.cz (Postfix) with ESMTP id F0FFF267812 for ; Fri, 17 Aug 2018 05:12:35 +0200 (CEST) Received: by mail-pl0-f66.google.com with SMTP id e11-v6so3047900plb.3 for ; Thu, 16 Aug 2018 20:12:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=h3pp3YOJIB+u+cn1mK3sONRoWo7bPok5z38q+IRcL4M=; b=aqnQ0IcpqpeCnLCG6oGyCUQKJwfipOhYYj9YAgs7to6g4h9LRlZ/DVbLR21oyNIOPs Ywqczokp1tXP1gaHUVZ03bXW/8UKgPvG4WbFLzRKCcW0z6sJhng4tj4F0jVvznIcwJan Y8cOaFVAaHNxkZudNGNPvYjklrvROdvqTIIzo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=h3pp3YOJIB+u+cn1mK3sONRoWo7bPok5z38q+IRcL4M=; b=Ioo+tjW/gu0i6iEZFrX97blZ7UNGQJ3HkrrHKrLulghtrnb3UV/+RX4B/of3WrM8gN gkClJEsM+SVh9rc884dh7EaUXvgdPzcgcmDioQSD8/vMWADTZEjgMdCek6b+xP9bWO9g vtL9+0NDYo68t4fkGkqQGKbIMcV7moadwejcA0TRhUcSZ+EfHoQgLbv/wcmM+vMHKW13 zqmoiRGcUZQ64gzQ1F5ZSXfDjOYlaNnWLXxf/gJilytZHsnFAbAhWIyEY4GASAXRYRKv /c5/Itbh/aV43+pl3sh9qXD9/hVRSB1QdQYJ4BsXXfo0Yd9KAXzKKb8P50dTNWbb8og3 Wumw== X-Gm-Message-State: AOUpUlH0bybSolzWFy28keoWvnEoSQHv6Xk/qx6IkrpivvQsq81qBDtM sr2mLtIr2tGG23rhvdCgV49DDp1PK7g= X-Google-Smtp-Source: AA+uWPxoTSC2xmiPF0e0Q3COCt+zO4wtbZuiE/ek+6/05gQ/I+kCwvGJX7+VpqLzk+XthLow8VkSBA== X-Received: by 2002:a17:902:8486:: with SMTP id c6-v6mr31899759plo.105.1534475553359; Thu, 16 Aug 2018 20:12:33 -0700 (PDT) Received: from hychaoz840.tpe.corp.google.com ([2401:fa00:1:10:c303:3d7e:c8f2:7f84]) by smtp.gmail.com with ESMTPSA id h4-v6sm622785pgp.13.2018.08.16.20.12.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Aug 2018 20:12:32 -0700 (PDT) From: Hsin-Yu Chao To: alsa-devel@alsa-project.org Date: Fri, 17 Aug 2018 11:12:27 +0800 Message-Id: <20180817031227.187676-1-hychao@chromium.org> X-Mailer: git-send-email 2.16.4 Cc: vinod.koul@intel.com, dgreid@chromium.org, Hsin-Yu Chao Subject: [alsa-devel] [PATCH v2] control_hw: Fix issue when applying seccomp policy 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 When seccomp policy is applied to filter ioctl syscall with SNDRV_CTL_IOCTL_TLV_COMMAND, SNDRV_CTL_IOCTL_TLV_READ and SNDRV_CTL_IOCTL_TLV_WRITE in whiltelist, alsa-lib still breaks in at snd_ctl_hw_elem_tlv(). The problem behind is because ioctl() takes unsigned long cmd argument, and the signed bit of local int variable could cause 0xff bytes appended after casted to unsigned long. In kernel, seccomp data struct takes 64 bits argument to check against seccomp rules, these unexpected 0xff bytes could make the rule check fail. Fix the problem by passing unsigned int to ioctl. Signed-off-by: Hsin-Yu Chao --- src/control/control_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/control/control_hw.c b/src/control/control_hw.c index 68eca522..b54d65f2 100644 --- a/src/control/control_hw.c +++ b/src/control/control_hw.c @@ -215,7 +215,7 @@ static int snd_ctl_hw_elem_tlv(snd_ctl_t *handle, int op_flag, unsigned int numid, unsigned int *tlv, unsigned int tlv_size) { - int inum; + unsigned int inum; snd_ctl_hw_t *hw = handle->private_data; struct snd_ctl_tlv *xtlv;