From patchwork Thu Jan 3 00:02:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 10746713 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 9B7606C5 for ; Thu, 3 Jan 2019 00:02:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BE8B27E71 for ; Thu, 3 Jan 2019 00:02:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 804D928396; Thu, 3 Jan 2019 00:02:34 +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 1360527E71 for ; Thu, 3 Jan 2019 00:02:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726941AbfACACd (ORCPT ); Wed, 2 Jan 2019 19:02:33 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:45272 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725871AbfACACd (ORCPT ); Wed, 2 Jan 2019 19:02:33 -0500 Received: by mail-pl1-f193.google.com with SMTP id a14so15111770plm.12 for ; Wed, 02 Jan 2019 16:02:32 -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=KNywLRoSIC3WF7SFL6cHozalavq2mS2jb+SaSoSvo1o=; b=hNevkkvgZ/miT3VrcbK5BnJVSimrGMO9Ws0uC/sdp4owNsipySa2R49Imb+9CFaL4J Qn6F+ObcHEGAKOV/f6mm38tG1wuPgf8iQIcyfHwS0AebeuQK6FW99HIL4rp8Z0FGHcbv 8hvrNmdEdj/32Saikd4e11SlJppurRgeBj/lQ= 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=KNywLRoSIC3WF7SFL6cHozalavq2mS2jb+SaSoSvo1o=; b=L3viFuEH+n9YWBbOTjdvQTA2tv/AG5vBRgyx0D+V0SZtYa44BB4GgEUtfYUV4Rk0uK NsgpGPpPLT2dv69EcRgIA4EqyGzoVck5ypT/mOxZNowvaWmXfG1cJbgp47pH3125lwio 5Eq8c/n+uA5Zah8kUwE+rGzVr6IDY3W+w6hktLSamAaqtm3ndk6mzPG8tvgV41W2jC9U r3oZvvtExSC3VRObGO4lk+vlQiet9mvnirMlXBfY0PuceB9kxm/Z+O2hNvLN1N1llmoA dVunToFOPRJw7QfKz/7bH3CjuZfThfPWKnupOHT2031fkXTSjdyAKwhIbBITnk3/riry 2HVw== X-Gm-Message-State: AJcUukdTNkZrEN9SfLO67FFUXxZkFzZzY8hp69Llrp3tgIvGyzFcW7Q7 OAzEgJTpFBiAwHfJoliox6Cu8Q== X-Google-Smtp-Source: ALg8bN6f+0wpHiiK7okfMe6+oyWBTpT1+WsT8C6wxdVmnB86H1s570wbuGa27VR1YaIGw/8CZ13nug== X-Received: by 2002:a17:902:4624:: with SMTP id o33mr44299497pld.289.1546473752652; Wed, 02 Jan 2019 16:02:32 -0800 (PST) Received: from evgreen2.mtv.corp.google.com ([2620:15c:202:201:ffda:7716:9afc:1301]) by smtp.gmail.com with ESMTPSA id u6sm60291199pgr.79.2019.01.02.16.02.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Jan 2019 16:02:31 -0800 (PST) From: Evan Green To: Andy Gross Cc: Bjorn Andersson , Brian Norris , Ben Chan , Evan Green , linux-arm-msm@vger.kernel.org, David Brown , linux-kernel@vger.kernel.org Subject: [PATCH v3 1/2] soc: qcom: rmtfs-mem: Add class to enable uevents Date: Wed, 2 Jan 2019 16:02:12 -0800 Message-Id: <20190103000213.230652-2-evgreen@chromium.org> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20190103000213.230652-1-evgreen@chromium.org> References: <20190103000213.230652-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 Reviewed-by: Brian Norris Reviewed-by: Bjorn Andersson --- Changes in v3: - Removed spurious whitespace changes (Brian, Bjorn) Changes in v2: - Moved class registration/deregistration into init/exit routines (Brian) drivers/soc/qcom/rmtfs_mem.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c index 97bb5989aa211..b2fa8fc8016c0 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, @@ -199,6 +204,7 @@ 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); @@ -277,32 +283,42 @@ static struct platform_driver qcom_rmtfs_mem_driver = { }, }; -static int qcom_rmtfs_mem_init(void) +static int __init qcom_rmtfs_mem_init(void) { int ret; + ret = class_register(&rmtfs_class); + if (ret) + return ret; + ret = alloc_chrdev_region(&qcom_rmtfs_mem_major, 0, QCOM_RMTFS_MEM_DEV_MAX, "qcom_rmtfs_mem"); if (ret < 0) { pr_err("qcom_rmtfs_mem: failed to allocate char dev region\n"); - return ret; + goto unregister_class; } ret = platform_driver_register(&qcom_rmtfs_mem_driver); if (ret < 0) { pr_err("qcom_rmtfs_mem: failed to register rmtfs_mem driver\n"); - unregister_chrdev_region(qcom_rmtfs_mem_major, - QCOM_RMTFS_MEM_DEV_MAX); + goto unregister_chrdev; } + return 0; + +unregister_chrdev: + unregister_chrdev_region(qcom_rmtfs_mem_major, QCOM_RMTFS_MEM_DEV_MAX); +unregister_class: + class_unregister(&rmtfs_class); return ret; } module_init(qcom_rmtfs_mem_init); -static void qcom_rmtfs_mem_exit(void) +static void __exit qcom_rmtfs_mem_exit(void) { platform_driver_unregister(&qcom_rmtfs_mem_driver); unregister_chrdev_region(qcom_rmtfs_mem_major, QCOM_RMTFS_MEM_DEV_MAX); + class_unregister(&rmtfs_class); } module_exit(qcom_rmtfs_mem_exit); From patchwork Thu Jan 3 00:02:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 10746715 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 107B591E for ; Thu, 3 Jan 2019 00:02:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F299E27E71 for ; Thu, 3 Jan 2019 00:02:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E59A428396; Thu, 3 Jan 2019 00:02:39 +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 94A8B27E71 for ; Thu, 3 Jan 2019 00:02:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727291AbfACACi (ORCPT ); Wed, 2 Jan 2019 19:02:38 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:43749 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726906AbfACACi (ORCPT ); Wed, 2 Jan 2019 19:02:38 -0500 Received: by mail-pl1-f196.google.com with SMTP id gn14so15143078plb.10 for ; Wed, 02 Jan 2019 16:02:37 -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=qvGpSFvsCqzZseERB3T3u2tb8jVF4wW/MgWIXQNMIVk=; b=UvuWE7JYujcbQg8Q6cQ1/RLkl5EezdI3Of1cQv21SLRpaQxyOLVMjlVYQOFYGhPIAr DVejTCjSEoZ7vIWMJQMxjP6Avft1ZPFnqQo1gADfBoQ71vIfXZ62BiNvPx5XNhuAnP45 HlNbC4ZC9Du1Pisi5RKUN8wo2pS489xBgvpJU= 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=qvGpSFvsCqzZseERB3T3u2tb8jVF4wW/MgWIXQNMIVk=; b=nf9hYwCAsJ9U7cAeOAKYzi4fL7l/hWkS8RWTrbnN7BOpnY8UxB2uF18dkof8gYSCyj 3I4/T67TMPzbtbg9uKJJcDjfWooWgB0G2kUXGcfYiuImKEqICVQYfcM6l+QicDgWiqff g0agO7gdMJ39Y7qOh/BaRH2UqGBKZMjGHCgdYtS86unYyGHufGdGBrZ9r35IvgV7N6/r q3aQEpVTBZCpqTDTP17Obc/kb7cNsHP6Li7pCRpIe02LWVcsE9xkmeDPizH0xGcQza8a xzZT5oA6MCtr0dMZroyVgiVkzKvrvzCt5B7KXq03RV1w/WzEFtfD8xoqkSvG+C+QtIsZ or6g== X-Gm-Message-State: AJcUukdTaGoqOjRuNr21cKjxVtboJACcTZ5VPcAu0OdoCOhJTZHAUkGX 2+8D+exisWM0qKrUoJbHp94AVQ== X-Google-Smtp-Source: ALg8bN7mdBxCjdkX0G2u8OuINYxJcWasDEVQsvDwhnr3+YYhZLN9P2Tlv7je2kX3McLmLxdoarwoTA== X-Received: by 2002:a17:902:f20b:: with SMTP id gn11mr43437149plb.274.1546473757673; Wed, 02 Jan 2019 16:02:37 -0800 (PST) Received: from evgreen2.mtv.corp.google.com ([2620:15c:202:201:ffda:7716:9afc:1301]) by smtp.gmail.com with ESMTPSA id u6sm60291199pgr.79.2019.01.02.16.02.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Jan 2019 16:02:37 -0800 (PST) From: Evan Green To: Andy Gross Cc: Bjorn Andersson , Brian Norris , Ben Chan , Evan Green , linux-arm-msm@vger.kernel.org, David Brown , linux-kernel@vger.kernel.org Subject: [PATCH v3 2/2] soc: qcom: rmtfs-mem: Make sysfs attributes world-readable Date: Wed, 2 Jan 2019 16:02:13 -0800 Message-Id: <20190103000213.230652-3-evgreen@chromium.org> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20190103000213.230652-1-evgreen@chromium.org> References: <20190103000213.230652-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 Reviewed-by: Bjorn Andersson --- Changes in v3: None Changes in v2: None 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 b2fa8fc8016c0..7200d762a9510 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,