From patchwork Tue Dec 18 00:08:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 10734557 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 30F4714E5 for ; Tue, 18 Dec 2018 00:09:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21B5029BE7 for ; Tue, 18 Dec 2018 00:09:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15FE629BF1; Tue, 18 Dec 2018 00:09: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 A6AC829BE7 for ; Tue, 18 Dec 2018 00:09:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726538AbeLRAJN (ORCPT ); Mon, 17 Dec 2018 19:09:13 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:42612 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726308AbeLRAJE (ORCPT ); Mon, 17 Dec 2018 19:09:04 -0500 Received: by mail-pf1-f196.google.com with SMTP id 64so7168368pfr.9 for ; Mon, 17 Dec 2018 16:09:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nKA343VWfqT0i6llLCv/qR9rGyeHc6kj4MhGFMqq5pQ=; b=nIkEvDVT0DKbehtvUeKxjag7iF8MH/Lq9uKi66Gmu2QH3j5Wr2QhofqaIJ3zrihtj1 AW8CGeFJELP6CSTObw+J/o3z+tj8DHOuOpB54bUgX4JP/RAmoudFVPiuHqd6ybegLScq ta67mJ4C92Wgn8b+uy/JinVpRJMUS7wxbfc3Y= 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:in-reply-to :references; bh=nKA343VWfqT0i6llLCv/qR9rGyeHc6kj4MhGFMqq5pQ=; b=SMDCknCrPwqRv54Pu1sDNKMQNjrrh3fM+BGNJaD2S9u61ld20D27r3SBnU8xhYovzI k2woZZrCkiTW8jXnFUpqDTh7a/DaYv28XxJFsvEyFUZrmre3nUIwFkhVPYX6iC0brt3x HaoBVjLDRwuGyVKuNqUlzuvSRgXQgQ4N0PgmNH127TieiPv2Bmef7i2iTTsdKve6+9KP lvJRCzL4uqXnfQYR2hg81aLmFcjU0n9G/6CgL7VApAikBM2jg8Kt8l4FA2pzPBaTNf+i P/UWiKUzx/tbr86q6HMBx3BG1+2qlRBV19Hgi86SmeCQZhkuQGuaIs45TKD8ky5yUVes Xyig== X-Gm-Message-State: AA+aEWa8imgxCppAfMqWvFl1SLGpHaqU5Hsc1FGVNql+oHDcCQDadw2g Tfr3Jvuogdr8omHXrntkQa9q+Q== X-Google-Smtp-Source: AFSGD/V9R2ngeQ/UVOD9iyHh71lEuLWY6Eq71OW1YqMguCSTiKdVXN/ZxQ8HA+sjfWr5mvInAsaH2g== X-Received: by 2002:a62:5716:: with SMTP id l22mr15114407pfb.16.1545091743883; Mon, 17 Dec 2018 16:09:03 -0800 (PST) Received: from evgreen2.mtv.corp.google.com ([2620:15c:202:201:ffda:7716:9afc:1301]) by smtp.gmail.com with ESMTPSA id m65sm21734424pfg.180.2018.12.17.16.09.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Dec 2018 16:09:03 -0800 (PST) From: Evan Green To: Andy Gross , Bjorn Andersson Cc: Brian Norris , Ben Chan , Evan Green , linux-arm-msm@vger.kernel.org, David Brown , linux-kernel@vger.kernel.org Subject: [PATCH v1 1/2] soc: qcom: rmtfs-mem: Add class to enable uevents Date: Mon, 17 Dec 2018 16:08:33 -0800 Message-Id: <20181218000834.201748-2-evgreen@chromium.org> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20181218000834.201748-1-evgreen@chromium.org> References: <20181218000834.201748-1-evgreen@chromium.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the qcom_rmtfs_memN devices are entirely invisible to the udev world. Add a class to the rmtfs device so that uevents fire when the device is added. Signed-off-by: Evan Green --- drivers/soc/qcom/rmtfs_mem.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c index 97bb5989aa211..0bf800ee2a978 100644 --- a/drivers/soc/qcom/rmtfs_mem.c +++ b/drivers/soc/qcom/rmtfs_mem.c @@ -132,6 +132,11 @@ static int qcom_rmtfs_mem_release(struct inode *inode, struct file *filp) return 0; } +static struct class rmtfs_class = { + .owner = THIS_MODULE, + .name = "rmtfs", +}; + static const struct file_operations qcom_rmtfs_mem_fops = { .owner = THIS_MODULE, .open = qcom_rmtfs_mem_open, @@ -173,9 +178,15 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev) } + ret = class_register(&rmtfs_class); + if (ret) + return ret; + rmtfs_mem = kzalloc(sizeof(*rmtfs_mem), GFP_KERNEL); - if (!rmtfs_mem) - return -ENOMEM; + if (!rmtfs_mem) { + ret = -ENOMEM; + goto unregister_class; + } rmtfs_mem->addr = rmem->base; rmtfs_mem->client_id = client_id; @@ -199,8 +210,8 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev) dev_set_name(&rmtfs_mem->dev, "qcom_rmtfs_mem%d", client_id); rmtfs_mem->dev.id = client_id; + rmtfs_mem->dev.class = &rmtfs_class; rmtfs_mem->dev.devt = MKDEV(MAJOR(qcom_rmtfs_mem_major), client_id); - ret = cdev_device_add(&rmtfs_mem->cdev, &rmtfs_mem->dev); if (ret) { dev_err(&pdev->dev, "failed to add cdev: %d\n", ret); @@ -235,11 +246,13 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev) return 0; + remove_cdev: cdev_device_del(&rmtfs_mem->cdev, &rmtfs_mem->dev); put_device: put_device(&rmtfs_mem->dev); - +unregister_class: + class_unregister(&rmtfs_class); return ret; } @@ -258,7 +271,7 @@ static int qcom_rmtfs_mem_remove(struct platform_device *pdev) cdev_device_del(&rmtfs_mem->cdev, &rmtfs_mem->dev); put_device(&rmtfs_mem->dev); - + class_unregister(&rmtfs_class); return 0; } From patchwork Tue Dec 18 00:08:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 10734555 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 0D6066C2 for ; Tue, 18 Dec 2018 00:09:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F174929BE7 for ; Tue, 18 Dec 2018 00:09:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E591B29BF1; Tue, 18 Dec 2018 00:09:12 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 9877229BE7 for ; Tue, 18 Dec 2018 00:09:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726502AbeLRAJJ (ORCPT ); Mon, 17 Dec 2018 19:09:09 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:44378 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726455AbeLRAJI (ORCPT ); Mon, 17 Dec 2018 19:09:08 -0500 Received: by mail-pl1-f196.google.com with SMTP id e11so6252278plt.11 for ; Mon, 17 Dec 2018 16:09:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CS3SSpVEoM1vQfMSMjWaDpR3zqnEl7pcEwBAFTqfrTg=; b=GPIOEmkULv0u3soaT0ebmmE/N7cgdEYFBVgtrTs2MG+IAkvWzh4Pbxqjkn01Nxzk97 WwgX1ZbLTF/b3sy2sS6g2asTdJKx3Ca2lCQCrMc+yH/rkbkTs48pUu8Eo3TzrYO7W8r9 0gGxvbOK10iCDQm90HKPNwtVndkIlxEf8/WW0= 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:in-reply-to :references; bh=CS3SSpVEoM1vQfMSMjWaDpR3zqnEl7pcEwBAFTqfrTg=; b=AHcSJGl180SQ1Jp33FywHTn5F3aVRqKnYdXQHbnICUirCqJCcJgCCWwvtA5ytxM3H/ Fsqd+ga4mIVnwNv9wbeCJwpY6ErBABU1d63hp+NLclXIZ87tla9lHQGwzvDhLpO121vm jA/dNXJwVUxxWC5HgyFzhSJdKS/eyeeIQwAvc5Ffps+Ck3vhaXdb1tutL/VZ4FIxnwze ul6O1/0PQ+iXdbbDNcqJzXQKTo2iLYf9ZT7TLYp/t9X6adudNB9ISP8FKGNQhTqRC6DT 0vKE/QYf0forGSIdWCF+undhIyDoC1s96yk/dvxUxsvFfbYV2umtrkYRbuIlVnUwPrRw TCaw== X-Gm-Message-State: AA+aEWYwp2s2flveip2EJlfiuW3CPCv42ze7haCzGsvjPMmULcz/elFg jjzDbyI8tHSK55l8+Xt6TBRjNg== X-Google-Smtp-Source: AFSGD/XIQyKORhz9aSBPljWI4z0N+86LPw71SOkmnmGzbWsi8qz5OMu0cGlmcpFpJyO9PCQGv/BEcQ== X-Received: by 2002:a17:902:1126:: with SMTP id d35mr13514187pla.1.1545091747813; Mon, 17 Dec 2018 16:09:07 -0800 (PST) Received: from evgreen2.mtv.corp.google.com ([2620:15c:202:201:ffda:7716:9afc:1301]) by smtp.gmail.com with ESMTPSA id m65sm21734424pfg.180.2018.12.17.16.09.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Dec 2018 16:09:07 -0800 (PST) From: Evan Green To: Andy Gross , Bjorn Andersson Cc: Brian Norris , Ben Chan , Evan Green , linux-arm-msm@vger.kernel.org, David Brown , linux-kernel@vger.kernel.org Subject: [PATCH v1 2/2] soc: qcom: rmtfs-mem: Make sysfs attributes world-readable Date: Mon, 17 Dec 2018 16:08:34 -0800 Message-Id: <20181218000834.201748-3-evgreen@chromium.org> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20181218000834.201748-1-evgreen@chromium.org> References: <20181218000834.201748-1-evgreen@chromium.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to run an rmtfs daemon as an unprivileged user, that user would need access to the phys_addr and size sysfs attributes. Sharing these attributes with unprivileged users doesn't really leak anything sensitive, since if you have access to physical memory, the jig is up anyway. Make those attributes readable by all. Signed-off-by: Evan Green Reviewed-by: Brian Norris --- drivers/soc/qcom/rmtfs_mem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c index 0bf800ee2a978..4eeb9f02e7889 100644 --- a/drivers/soc/qcom/rmtfs_mem.c +++ b/drivers/soc/qcom/rmtfs_mem.c @@ -45,9 +45,9 @@ static ssize_t qcom_rmtfs_mem_show(struct device *dev, struct device_attribute *attr, char *buf); -static DEVICE_ATTR(phys_addr, 0400, qcom_rmtfs_mem_show, NULL); -static DEVICE_ATTR(size, 0400, qcom_rmtfs_mem_show, NULL); -static DEVICE_ATTR(client_id, 0400, qcom_rmtfs_mem_show, NULL); +static DEVICE_ATTR(phys_addr, 0444, qcom_rmtfs_mem_show, NULL); +static DEVICE_ATTR(size, 0444, qcom_rmtfs_mem_show, NULL); +static DEVICE_ATTR(client_id, 0444, qcom_rmtfs_mem_show, NULL); static ssize_t qcom_rmtfs_mem_show(struct device *dev, struct device_attribute *attr,