Message ID | 20231107213647.1405493-3-avadhut.naik@amd.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp530028vqo; Tue, 7 Nov 2023 13:38:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IFOHQ18k5//SnHr5rJ+hnnNAnQFhbOwzn+ye9JvVEfCZbUCg0hTCcwetmTMTAekCqISE0Ar X-Received: by 2002:a05:6a21:3e01:b0:180:23d2:b5e5 with SMTP id bk1-20020a056a213e0100b0018023d2b5e5mr264902pzc.60.1699393098146; Tue, 07 Nov 2023 13:38:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699393098; cv=pass; d=google.com; s=arc-20160816; b=Xgn5ddeDWzyLuQc2FsMUne34GZQ+Mjvenk9QbBOIwb+SNsBBvn3N/3AGeodLGItjX5 60kQEZzgvmqY2s5XMqlahfmIJ9t/4Jwwd9Sq7II21oEvtM/Q6Jw3ras1Rz9IrSdcy8iz QtEnvJD1N0rJVS3SYpdBeJOy/i0bqcgPBw30boYD1Bf64Pev05iJz9JiMQ5kXy0DU6mu 8lnXY46VqOAWUhtHVtQtxbOK6VoiuVIHk09lIjz4wwmUY2/Fn/z71/RebCZKyh0Y735Z uTX4S24S5Qk9qPDBgByXzZ1HhhAySnZzsarw6FXgaDSLlYSdmhAlgrj+UQqPKVd2fefl wQrg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xzTktEFdcwv/5VgXiTNBHKocFlFlxVO5ZUECMKyR/GA=; fh=nPCLbHLCBrSrCsrWolipsWkS15d8m+LirVQf+srZKkY=; b=eZ4PlNrA+QTTI5LhpyZ+Eb2w8mxKeHTei2w8VGiGZ37DXWlvWr3WhXzcCYxJhcQfL+ hbhd+ltkRoslzdorAZ+JhqY6yqslvAPrDvfR7gfxasnb8VjVwecpL2ipYOZAya81hONp IAdSIh5D1c5yB9OHFtbk7dBKJD/HDZ3c67+EBAIIlAllHp3h8Qp9J5y2Ys+dMo1QglFu TWorQJd+4QLHERaX1gwDzPa3r7ud6wA7EKwgqKysNa+iCxrLEkAmT8X/qq14Us795B2m yXtPUWpiH+InPY5IM6tPjdq1+4tzXT8bZt2WZnQ3BDGaQQ24HJmAxMSu8DGJW0MlEQki 9g/Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=U1gW+cxU; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id d15-20020a056a0024cf00b0069023e4bca8si11877240pfv.214.2023.11.07.13.38.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 13:38:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=U1gW+cxU; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id B74F281C0CB1; Tue, 7 Nov 2023 13:38:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235311AbjKGVhp (ORCPT <rfc822;lhua1029@gmail.com> + 32 others); Tue, 7 Nov 2023 16:37:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235345AbjKGVhh (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 7 Nov 2023 16:37:37 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2088.outbound.protection.outlook.com [40.107.94.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D62AC1700; Tue, 7 Nov 2023 13:37:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TgWA5iLuJh3x9I1Jpn8/D40X/wU/QSFozcJKeOJM/SkYBVTnA56gWBudzheI5bnUcU3ITf4pNVuqPilScWf5fGDZ56L44PQpwctIXQuy8SPutmNiCLQ1/x2uD8d0VXvq+rzFvr0J96c/I5O1rjbcqY/aL+lCI+R0jJcqKRGFQIsqehf8W7kE7uy9ZubnXJVd4GgfvlfX88yYgL0jisN4mtju5QrC+QsQtw3J9DXKLcf10FUT5CV8Bub+iCous1ahcdCiGVx6hIWmYBIpVsCm0cZjYEQAjnfGFiB7fJsu0zV7ILgcqRFHoxy8sCnF5O1zI0GcBhHU9Qbyga3T5ko9mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xzTktEFdcwv/5VgXiTNBHKocFlFlxVO5ZUECMKyR/GA=; b=lrUI/wjV0t/HvVnb0FYm5CK3IpX7GVy+iWXqPc7JncKibXTlMMJKtQZImVUT8AeGMNl1QLKoyIuDbVWZVU+f8kQVNLYviptwPQ996pn341LR0VEsSzjRojJt7+gzyqFS9aO9HjZUmsrtiiureshkS8i/HwHkqD5z7TDWBSLcx9fvJdCbA8ZP8TQumH3BeHVijfvAfVsEnOFSDsDu/hWXVIl9HJJ+59fUoL1AdxVsBMc+Eh8KWiFAEdApb4rqZhlHFj0oUNw3brWb2L8JjES07DgnkBazr/3/oFXV7q1t3pD/Au8LXEYcGUX33IR9EKqqplvkX8LkBJo5Bx17aCqe7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xzTktEFdcwv/5VgXiTNBHKocFlFlxVO5ZUECMKyR/GA=; b=U1gW+cxUUQnEzV8AkV6Wef9TJkwK0SvhwBz8PUcR+IHeSA5rsIzbF+IlgpXDX2WGOxleAsNdEBbC6bWkJ7aXkJadeUu3lah8NwMvPJHbJMIXOcyHAqFNPUzHqN2WJS1iptaPZQhnEZOK6hP+MtZJJ2+m6c4nEFRV0XwC/kYo4xE= Received: from SN4PR0501CA0034.namprd05.prod.outlook.com (2603:10b6:803:40::47) by DS7PR12MB5720.namprd12.prod.outlook.com (2603:10b6:8:73::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Tue, 7 Nov 2023 21:37:30 +0000 Received: from SA2PEPF000015C6.namprd03.prod.outlook.com (2603:10b6:803:40:cafe::c2) by SN4PR0501CA0034.outlook.office365.com (2603:10b6:803:40::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.17 via Frontend Transport; Tue, 7 Nov 2023 21:37:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF000015C6.mail.protection.outlook.com (10.167.241.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6977.16 via Frontend Transport; Tue, 7 Nov 2023 21:37:30 +0000 Received: from titanite-d354host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Tue, 7 Nov 2023 15:37:28 -0600 From: Avadhut Naik <avadhut.naik@amd.com> To: <linux-acpi@vger.kernel.org> CC: <rafael@kernel.org>, <lenb@kernel.org>, <james.morse@arm.com>, <tony.luck@intel.com>, <bp@alien8.de>, <gregkh@linuxfoundation.org>, <linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <alexey.kardashevskiy@amd.com>, <yazen.ghannam@amd.com>, <avadnaik@amd.com> Subject: [RESEND v5 2/4] fs: debugfs: Add write functionality to debugfs blobs Date: Tue, 7 Nov 2023 15:36:45 -0600 Message-ID: <20231107213647.1405493-3-avadhut.naik@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231107213647.1405493-1-avadhut.naik@amd.com> References: <20231107213647.1405493-1-avadhut.naik@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015C6:EE_|DS7PR12MB5720:EE_ X-MS-Office365-Filtering-Correlation-Id: 46245511-c702-4e41-65bd-08dbdfd9be9a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e2VgscXowLA+BKuOHz/2Swm3dd5PmMC8z9N4hRoyP3oHniaghV7zh59aAEzHFLht/UMxYLkiYuQLbYKxl07w7LhgCzzIfJ+GLHVEGkUK7updSR2/uCQLPO3+wP8fQHXUerCLpkHjQrBqu24MjSvr+8eFXStI+EdHia9dHwAeW66Rbvgh4r7mZQkXf5jBI8pxSNa7seMO5WlnDNKhQewNPZr/V1NV61t1Lx/QtM+B8iSZNgMvYwi/lGvcs4O9/5fmEK4iRN8lHa4EF5XZ/v6A88MYASLoj/4UZsbblmm0VZon6Q9h7uhZyrXkOZf30uyXcEWzJ0DvFD0z+3ql4SEi8Y3kQkbJVstUvBIzph+V2NzlFpZfyI2cHzTYHtajlp6sajy4vdjwLZgNaiueJ+jcQEzDEcPb0n0Ru37AFcHHCUM8VqDetC4xTbg9B+sXJdPhs3zZ9lfjDkt57/JxjKubls2w55Lyw6FNYzNy40DAv6Sx2/ASAEzOPNH+EgzZ3UoStMIVw1KES/4pQjnsCqB6YONR9jRWfv+rAdsQSHPCg5MrrEfNERXk9k6DOmouAoaQMHNRi8HracAPBdARonKlPVrWdkZ2oZt3bDQq6St1LWtTJoifB0orBxSPZGpIGMkSBKyOZSpzdAw8IASugdklHUYnbtRhhnwOZmLibvGlbIfRPtjBKL+UXXm+BqQVW3ZWhmycuYrJBV3ci/OQFkLe5WhRHPNYs0GBWK6h3qByTImrWN8ULvDYcY3j1oxW6RJtTwBTzsCugKl6s19q5Qt8cw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(346002)(136003)(39860400002)(376002)(396003)(230922051799003)(186009)(82310400011)(1800799009)(64100799003)(451199024)(40470700004)(46966006)(36840700001)(6666004)(478600001)(70206006)(1076003)(54906003)(7696005)(426003)(336012)(26005)(2616005)(6916009)(41300700001)(8676002)(8936002)(4326008)(316002)(5660300002)(70586007)(44832011)(2906002)(36860700001)(36756003)(82740400003)(86362001)(47076005)(81166007)(83380400001)(356005)(40480700001)(16526019)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 21:37:30.1275 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 46245511-c702-4e41-65bd-08dbdfd9be9a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF000015C6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5720 Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 07 Nov 2023 13:38:08 -0800 (PST) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781942817171134847 X-GMAIL-MSGID: 1781942817171134847 |
Series |
Add support for Vendor Defined Error Types in Einj Module
|
|
Commit Message
Avadhut Naik
Nov. 7, 2023, 9:36 p.m. UTC
From: Avadhut Naik <Avadhut.Naik@amd.com> Currently, debugfs_create_blob() creates read-only debugfs binary blob files. In some cases, however, userspace tools need to write variable length data structures into predetermined memory addresses. An example is when injecting Vendor-defined error types through the einj module. In such cases, the functionality to write to these blob files in debugfs would be desired since the mapping aspect can be handled within the modules with userspace tools only needing to write into the blob files. Implement a write callback to enable writing to these blob files in debugfs. Signed-off-by: Avadhut Naik <Avadhut.Naik@amd.com> Reviewed-by: Alexey Kardashevskiy <aik@amd.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- fs/debugfs/file.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)
Comments
> @@ -1042,7 +1060,7 @@ struct dentry *debugfs_create_blob(const char *name, umode_t mode, > struct dentry *parent, > struct debugfs_blob_wrapper *blob) > { > - return debugfs_create_file_unsafe(name, mode & 0444, parent, blob, &fops_blob); > + return debugfs_create_file_unsafe(name, mode, parent, blob, &fops_blob); > } The minimalist change here would be to s/0444/0666/ That would just allow callers to ask for writeable files without letting them add execute permission, or exotic modes like setuid etc. -Tony
Hi, On 11/7/2023 16:28, Luck, Tony wrote: >> @@ -1042,7 +1060,7 @@ struct dentry *debugfs_create_blob(const char *name, umode_t mode, >> struct dentry *parent, >> struct debugfs_blob_wrapper *blob) >> { >> - return debugfs_create_file_unsafe(name, mode & 0444, parent, blob, &fops_blob); >> + return debugfs_create_file_unsafe(name, mode, parent, blob, &fops_blob); >> } > > The minimalist change here would be to s/0444/0666/ > > That would just allow callers to ask for writeable files without letting them > add execute permission, or exotic modes like setuid etc. > Noted. Thanks for the clarification. Will change to something like below: return debugfs_create_file_unsafe(name, mode & 0666, parent, blob, &fops_blob); > -Tony
Hi Tony, On 11/7/2023 16:28, Luck, Tony wrote: >> @@ -1042,7 +1060,7 @@ struct dentry *debugfs_create_blob(const char *name, umode_t mode, >> struct dentry *parent, >> struct debugfs_blob_wrapper *blob) >> { >> - return debugfs_create_file_unsafe(name, mode & 0444, parent, blob, &fops_blob); >> + return debugfs_create_file_unsafe(name, mode, parent, blob, &fops_blob); >> } > > The minimalist change here would be to s/0444/0666/ > Just realized that s/0444/0644/ might be an even more minimalist change since you anyways, I think, need to be root for error injection through einj. Does that sound good? In any case, using 0666 will result in the below checkpatch warning: [root avadnaik-linux]# ./scripts/checkpatch.pl --strict -g HEAD WARNING: Exporting world writable files is usually an error. Consider more restrictive permissions. #84: FILE: fs/debugfs/file.c:1063: + return debugfs_create_file_unsafe(name, mode & 0666, parent, blob, &fops_blob); total: 0 errors, 1 warnings, 0 checks, 54 lines checked Would you be okay with s/0444/0644/? - return debugfs_create_file_unsafe(name, mode & 0444, parent, blob, &fops_blob); + return debugfs_create_file_unsafe(name, mode & 0644, parent, blob, &fops_blob); > That would just allow callers to ask for writeable files without letting them > add execute permission, or exotic modes like setuid etc. > > -Tony
> > The minimalist change here would be to s/0444/0666/ > > > Just realized that s/0444/0644/ might be an even more minimalist change since you anyways, > I think, need to be root for error injection through einj. Does that sound good? You need write access. I don't think you need to be root. E.g. a validation system might set up an "einj" group and "chmod" all these files to 0664. But that's nitpicking. > > In any case, using 0666 will result in the below checkpatch warning: > > [root avadnaik-linux]# ./scripts/checkpatch.pl --strict -g HEAD > WARNING: Exporting world writable files is usually an error. Consider more restrictive permissions. > #84: FILE: fs/debugfs/file.c:1063: > + return debugfs_create_file_unsafe(name, mode & 0666, parent, blob, &fops_blob); > > total: 0 errors, 1 warnings, 0 checks, 54 lines checked The warning is dubious. This code isn't necessarily exporting a world writeable file. But it does allow a caller of this routine to do that. > > Would you be okay with s/0444/0644/? > - return debugfs_create_file_unsafe(name, mode & 0444, parent, blob, &fops_blob); > + return debugfs_create_file_unsafe(name, mode & 0644, parent, blob, &fops_blob); Yes. This is fine (better). Make sure to mention in the commit comment that this allows callers to create files writeable by owner. -Tony
On 11/16/2023 12:44, Luck, Tony wrote: >>> The minimalist change here would be to s/0444/0666/ >>> >> Just realized that s/0444/0644/ might be an even more minimalist change since you anyways, >> I think, need to be root for error injection through einj. Does that sound good? > > You need write access. I don't think you need to be root. E.g. a validation system might > set up an "einj" group and "chmod" all these files to 0664. But that's nitpicking. > >> >> In any case, using 0666 will result in the below checkpatch warning: >> >> [root avadnaik-linux]# ./scripts/checkpatch.pl --strict -g HEAD >> WARNING: Exporting world writable files is usually an error. Consider more restrictive permissions. >> #84: FILE: fs/debugfs/file.c:1063: >> + return debugfs_create_file_unsafe(name, mode & 0666, parent, blob, &fops_blob); >> >> total: 0 errors, 1 warnings, 0 checks, 54 lines checked > > The warning is dubious. This code isn't necessarily exporting a world writeable file. But > it does allow a caller of this routine to do that. > >> >> Would you be okay with s/0444/0644/? > >> - return debugfs_create_file_unsafe(name, mode & 0444, parent, blob, &fops_blob); >> + return debugfs_create_file_unsafe(name, mode & 0644, parent, blob, &fops_blob); > > > Yes. This is fine (better). Make sure to mention in the commit comment that this allows > callers to create files writeable by owner. > Will do. Thanks for the confirmation! > -Tony > >
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index c45e8c2d62e1..dde1f5f30fb3 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -1008,17 +1008,35 @@ static ssize_t read_file_blob(struct file *file, char __user *user_buf, return r; } +static ssize_t write_file_blob(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct debugfs_blob_wrapper *blob = file->private_data; + struct dentry *dentry = F_DENTRY(file); + ssize_t r; + + r = debugfs_file_get(dentry); + if (unlikely(r)) + return r; + r = simple_write_to_buffer(blob->data, blob->size, ppos, user_buf, + count); + + debugfs_file_put(dentry); + return r; +} + static const struct file_operations fops_blob = { .read = read_file_blob, + .write = write_file_blob, .open = simple_open, .llseek = default_llseek, }; /** - * debugfs_create_blob - create a debugfs file that is used to read a binary blob + * debugfs_create_blob - create a debugfs file that is used to read and write + * a binary blob * @name: a pointer to a string containing the name of the file to create. - * @mode: the read permission that the file should have (other permissions are - * masked out) + * @mode: the permission that the file should have * @parent: a pointer to the parent dentry for this file. This should be a * directory dentry if set. If this parameter is %NULL, then the * file will be created in the root of the debugfs filesystem. @@ -1027,7 +1045,7 @@ static const struct file_operations fops_blob = { * * This function creates a file in debugfs with the given name that exports * @blob->data as a binary blob. If the @mode variable is so set it can be - * read from. Writing is not supported. + * read from and written to. * * This function will return a pointer to a dentry if it succeeds. This * pointer must be passed to the debugfs_remove() function when the file is @@ -1042,7 +1060,7 @@ struct dentry *debugfs_create_blob(const char *name, umode_t mode, struct dentry *parent, struct debugfs_blob_wrapper *blob) { - return debugfs_create_file_unsafe(name, mode & 0444, parent, blob, &fops_blob); + return debugfs_create_file_unsafe(name, mode, parent, blob, &fops_blob); } EXPORT_SYMBOL_GPL(debugfs_create_blob);