Received: by 10.213.65.68 with SMTP id h4csp2123933imn; Sun, 8 Apr 2018 20:17:50 -0700 (PDT) X-Google-Smtp-Source: AIpwx48EloJ/U2O2tKxyfV7kVvXzwwJGEhUDXqRkaQBh/cU2niIiA12MNms1XlfPABPFgYG2eYiU X-Received: by 2002:a17:902:8685:: with SMTP id g5-v6mr1560163plo.46.1523243869972; Sun, 08 Apr 2018 20:17:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243869; cv=none; d=google.com; s=arc-20160816; b=AbRClINXvP3437QQ+M4tmFbBavFux/N6IvOoBIaF2Iit3WGpriN6V1DHvVQiHDY42K oRy+Rb/LcWzwTyY3Vj84UzLcNo797kdpgJmi2XUjRsjZArVP1IE1Xc0+tEUPiDtg7kql /XTSDK0jFoBt8CRLNrKuh8z/0FmXAn4EvxhrskGLRhayqsIOMcXt1E3w1npCOtWBL2Ft MZ2bNUtIak+eCzF2O9OEjrvg44XKXDhed/4B5F9hnB/+9x40rz2KvZfDkm6GK1wO3mwk l9+QjXjrymo49B9fjIrNymC3N4VxVZI3cT6uUiCy9RAk+GACPFfbQ206gSztaxkzWDiE aoRQ== 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=sV6TC5PYIL1uVqXPPVeNWjO/VrTu2KXUMo57A6YdYp8=; b=SKMQugMUMoNM2lzbRycB12a0L/52T422uGAh3DVw6M/VBDGlhWTHCTaJdTVhSSb6aZ /bXWamgfNjq1+JQ0hidmzRjZFkL0e5x1MqvEpuf8yAzfdGdG2FTATZNDT5RJZqIUDFM5 Dk5fNF+itgcCBagC+VAxwO5RTRg1zY7kBej06Ju/Iz4luftbUlWTMmLMN5R0MYTL8c4g HnmKlwYKn8K+HUxgpImwls+5YxqwMlbnSncvA/s+v4GZjs1wtiMTigrMAfMVBryDdcBA G6vB8akKXMkCcYluNNkUFnuOBkibbU1eFKegnfkpi5jRrGumzeyl21OhUi3jNrYsHUMW KXqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=WVhr9ml9; 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 m1si10533544pgm.413.2018.04.08.20.17.12; Sun, 08 Apr 2018 20:17:49 -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=WVhr9ml9; 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 S1751978AbeDIDN4 (ORCPT + 99 others); Sun, 8 Apr 2018 23:13:56 -0400 Received: from mail-by2nam03on0115.outbound.protection.outlook.com ([104.47.42.115]:29467 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754941AbeDIAXu (ORCPT ); Sun, 8 Apr 2018 20:23:50 -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=sV6TC5PYIL1uVqXPPVeNWjO/VrTu2KXUMo57A6YdYp8=; b=WVhr9ml9e7Agj0HfHFSt66C2dL4pnB9IOyZibPJIMENZIAF24gvJ6F2/l3HzpkSx83J9qToioKSQnhYXR6LMDEtJM+gW2ChoqPLDs1Sh/Xe9xYvlPOhuP1X9JrCuuUmiB2qOJd16qeGHwW6lF7DCbFDzHTjxOhrskUgChL+Z38o= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1080.namprd21.prod.outlook.com (52.132.130.14) 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:23:46 +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:23:45 +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.14 070/161] blk-mq-debugfs: don't allow write on attributes with seq_operations set Thread-Topic: [PATCH AUTOSEL for 4.14 070/161] blk-mq-debugfs: don't allow write on attributes with seq_operations set Thread-Index: AQHTz5iYRpWuT6cNrUyhI31Gj/wmfw== Date: Mon, 9 Apr 2018 00:20:43 +0000 Message-ID: <20180409001936.162706-70-alexander.levin@microsoft.com> References: <20180409001936.162706-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001936.162706-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;DM5PR2101MB1080;7:cDgwPmFH0QHsQjGqUPPY0XxfhAaI6W7rMTuqcrNzcXVmdjcN7DOiiwgTIqHzkWfqAZZDxGy/zsV1IX+BegkP1KllEnKv+5C7cfFtaEQSheM961nPkrI5XF9Li9iK6cJ8vpx9stGGCwSHfZw7c4G1ChMLYm9f0v2aWh6Omwydj/SS4hal8SljnZgiBIggR3+l+xoKlomv8CYbdv0zYEiVJASbGUoVuDBoorniCFKfaoeNVoyrNyKapKrFUuX0E7Qj;20:GJZ/X/QK0rVIQXMqhhec6/eDL6Kt53XpwKZHRAgwYiZZUdOaAvFE1JBaPCgwC9k0Swj3Y6IuWssQKNKX90LF5k3DNHgOHt8KCPP0m0vJ6e8XIWn7vEer2zuhBRuh4lzex6HCaH0sA44fnWFQ9HM1H7kzruehJSiI1CiNYAbglmI= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 9bdba955-bc0c-4bfd-0849-08d59db0285c x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1080; x-ms-traffictypediagnostic: DM5PR2101MB1080: 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)(10201501046)(93006095)(93001095)(3002001)(3231221)(944501327)(52105095)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB1080;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1080; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(346002)(396003)(39380400002)(366004)(39860400002)(199004)(189003)(2501003)(5250100002)(8936002)(10090500001)(5660300001)(3660700001)(446003)(107886003)(14454004)(36756003)(6436002)(476003)(3280700002)(2616005)(11346002)(4326008)(53936002)(6512007)(22452003)(305945005)(10290500003)(316002)(102836004)(2906002)(6116002)(66066001)(6506007)(3846002)(7736002)(486006)(54906003)(110136005)(186003)(72206003)(26005)(1076002)(105586002)(2900100001)(6486002)(97736004)(478600001)(81156014)(81166006)(86612001)(8676002)(106356001)(99286004)(86362001)(575784001)(76176011)(59450400001)(68736007)(25786009)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1080;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: DlmAjYG2XkshmLLavRYRcYZkTFlKB8Wy25NdrBExYAfiavZ76D8Z6nf0OooQrqm20J7RYVMzWuoGRCeqFL3jY7v049nOrZA2SnAXSF1WkiGO2rWjHxsow3oLCsPnRxtTGtEcPReBTooZ0ZmdI2UfK5EhFmzJBHOoRIOvHApKeUOIvEj1FeRnLOKQHTB/ptX7Da2M+dyaGjujk6y9OwBQZ11E36YrBbgOfeOeWuTf2QPVcR8StSWKGWEW3U564goaJA12XS1pBhcXhrooMiU37HioDCBAkfrggHSPKDBUmrAibmqzeLPGMkPzcdpZRluk3A14knEhmHkUjvKVMzcASeVfjGP3P7eDD8F1Ke2/6ScQ9ZEVbCg/q88FuqM++VGziY/FPrPoq7RyKbNWWe8VQbVXQ37Yq791zoVTGdyPR7k= 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: 9bdba955-bc0c-4bfd-0849-08d59db0285c X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:20:43.2066 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1080 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 de294d775acf..d95439154556 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -704,7 +704,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