Received: by 10.213.65.68 with SMTP id h4csp2151041imn; Sun, 8 Apr 2018 21:01:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/SmZscifD1aLHETlay9f9iMkbzD47XMKEk8uPmEoUlUjVnrIsRdtwS5V5u6TNsJUVCi4W/ X-Received: by 2002:a17:902:144:: with SMTP id 62-v6mr37452349plb.202.1523246518350; Sun, 08 Apr 2018 21:01:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523246518; cv=none; d=google.com; s=arc-20160816; b=VfvuwdGl1MT4IFXz+DT/SpP+mB3SCEGC/dlXQ5EfgpmEH0ePtcLMCkx0mT4barYLBc uKjn0jBCvYIRxZyuqFJ/jCgE3ssys0VKZDjfDk+sCfxV99ehCdz2XY54cSq6jZjh74Hu UomzWEcZxQiyAau6iSZv1bb3AP/3n8jCmyplbZDTao6l0vRTzMPvPNJAVLr8Az9a0kv1 4V0KPDs0qS6mH7QOn3nunT7b+0Cs/pmcEp0lDhNGSAwbxeG9rqTDt9iM4uVX7vCEp/5C M3EZqHKm/qJMM2X6GWhLH1EI/qwz6ZNo4y8h5u/+yxQwX2jjtHAHd/kc3bQAQmqKnZU/ 6tjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=jxX0CcdG6P6dpr3NzEAnDzvk4pjayEDc3M12Q/+6mhw=; b=ZLDuv+0g9kulgbu6USaAflylRjYE5+hjUcZi2mLP5EmSPqbyLwwF1V/ERdfy3mOaXH SwFJTqZ8nSAtrEy3h21tX1iUDUxeyDc2Pl78ez1SakJYsRdGvzXINbm1TG9M4oDYCSWP IDBVmT3Fhwek8wQjywjtN4WcMNIBroz97wV3QmjJ0HrmfBQgU2ChQ747klfj2paZgy9n KxTgiFuHpxxuskzndWqM+AH6A0AiZoV2LRaY27hyAb9+sxUQWDi/4gScxsCe898/o5XO zQ4EYOdavrHc5FDC7WR/S6BwRNr+ZegTSoiTvbs1Bv4Pt8WaQZPwy8jkMy6fakIioCL4 uuRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=jNG2S2c9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 97-v6si13774297plb.383.2018.04.08.21.01.21; Sun, 08 Apr 2018 21:01:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=jNG2S2c9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754484AbeDID4R (ORCPT + 99 others); Sun, 8 Apr 2018 23:56:17 -0400 Received: from mail-by2nam01on0126.outbound.protection.outlook.com ([104.47.34.126]:59343 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753778AbeDIASs (ORCPT ); Sun, 8 Apr 2018 20:18:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=jxX0CcdG6P6dpr3NzEAnDzvk4pjayEDc3M12Q/+6mhw=; b=jNG2S2c9ZEAHdC26i8Li618HCO7jRfLn4oTOiGdEMA+/pW9xeE7BY7ecTJ9i2N9rq8JmMQkCZPFmH3pM+Fj6kKylVzbDPdBLIPNh6S9GBDh3JCkxZPLqyRWJ2subjkCLvQJtjT3aEu4oGbkEfZ6OPftqTaBlInrYdjsdawu5cb0= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1128.namprd21.prod.outlook.com (52.132.133.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:18:40 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:18:40 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Eryu Guan , Ming Lei , Jens Axboe , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 084/189] blk-mq-debugfs: don't allow write on attributes with seq_operations set Thread-Topic: [PATCH AUTOSEL for 4.15 084/189] blk-mq-debugfs: don't allow write on attributes with seq_operations set Thread-Index: AQHTz5gykjFfMh+GGUiXOF+6xTfgsA== Date: Mon, 9 Apr 2018 00:17:51 +0000 Message-ID: <20180409001637.162453-84-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1128;7:qSf76zbajB2J8tEjC9BlWmYzJE8B+KQPGpa4R6m+Uk2YFvM72A7Z/p7MFntqWz5vj1uKP0fjKKjJ6gZa1mfGhIXXxgpPEnHKGf43v5CHiUDdl+W6gLkJCFFwQfkvVClVte+O/H/ghviWabHH8v3KhiQhU7zKBKCmCQZi6ys5Ijhv64eRgSJWTY57UEYZiiqVVb+EGWHHsUwOGVz0dgnVFKM9AWzhIdr8U2RpCWZwC7UjwdYCLw6mgJfSALC7xnUR;20:gSQZPqm7bj4DapYsQzj7qLqCEKDxRu8tUl2yaqafmOtVNyFyjvTT67sVnmo2flHKyF1TWOFs0xo8jijjBafm07ilrodbilR+l+2q37qOPdAfV1cXlKle5LZpJlhZBMuBD60a/BbMriahiXrPL26E0qg/zCDxkg/Wd010T9yYdQQ= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 499fca3a-4961-4017-b248-08d59daf725e x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1128; x-ms-traffictypediagnostic: DM5PR2101MB1128: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1128;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1128; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(396003)(376002)(366004)(39380400002)(199004)(189003)(66066001)(86362001)(59450400001)(3660700001)(3280700002)(2900100001)(25786009)(36756003)(6506007)(76176011)(2906002)(6486002)(86612001)(99286004)(102836004)(1076002)(7736002)(575784001)(97736004)(2616005)(446003)(486006)(11346002)(476003)(26005)(305945005)(6666003)(6512007)(4326008)(107886003)(478600001)(6436002)(5660300001)(10290500003)(5250100002)(22452003)(316002)(105586002)(186003)(8676002)(110136005)(54906003)(72206003)(53936002)(2501003)(68736007)(14454004)(6116002)(8936002)(3846002)(81156014)(10090500001)(106356001)(81166006)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1128;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: ZTQ8qqY+rl8vYNc6CDBjXtoKofWSCg6CWukm+z7t8vG+/Inb9ZqLdFc4cPFkR+TD2PZbBxLYxmUBCUmd19oFhicE99ks5Oz4VkCrSLmI0vGHxOYSp85Mr6accbzfJWdRMJydFs2VHxtmjzohXluwMzH+6+OVRHN52Z7UtsXTGcfAM/dqO+39KIuui66ZfbxcdwzCMxe31GjErsTye0Rtx4N0HNE/q4hc+HEHbrfu4mgAg0sfotYM8zTgZblA66VO2Vlqyq5fWw+I+GPpVkt3vO3npH9Gl47w1G69C3ZmT90/bfXpI3jQDkTaa+WbTa7Tssne182A8OQ35WRBS/QN+of6batEnAdFeWr4hfZr7l7mexRerV3S/KSYsc+1rjrIFvSPIB55Oqezxri1P18XkKG+TBR4/iCXIB/LmCx2Lgs= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 499fca3a-4961-4017-b248-08d59daf725e X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:17:51.7419 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1128 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eryu Guan [ Upstream commit 6b136a24b05c81a24e0b648a4bd938bcd0c4f69e ] Attributes that only implement .seq_ops are read-only, any write to them should be rejected. But currently kernel would crash when writing to such debugfs entries, e.g. chmod +w /sys/kernel/debug/block//requeue_list echo 0 > /sys/kernel/debug/block//requeue_list chmod -w /sys/kernel/debug/block//requeue_list Fix it by returning -EPERM in blk_mq_debugfs_write() when writing to such attributes. Cc: Ming Lei Signed-off-by: Eryu Guan Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-mq-debugfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index b56a4f35720d..54bd8c31b822 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -703,7 +703,11 @@ static ssize_t blk_mq_debugfs_write(struct file *file,= const char __user *buf, const struct blk_mq_debugfs_attr *attr =3D m->private; void *data =3D d_inode(file->f_path.dentry->d_parent)->i_private; =20 - if (!attr->write) + /* + * Attributes that only implement .seq_ops are read-only and 'attr' is + * the same with 'data' in this case. + */ + if (attr =3D=3D data || !attr->write) return -EPERM; =20 return attr->write(data, buf, count, ppos); --=20 2.15.1