Received: by 10.192.165.148 with SMTP id m20csp563416imm; Wed, 25 Apr 2018 04:19:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx49cOwlL4+CF+YRP/xOTPMn5IqL9KHKETTERqZA7KLq7oDmcEZ/1j/dfegPqPkr5GRvrKvDx X-Received: by 10.98.214.218 with SMTP id a87mr23288640pfl.200.1524655191680; Wed, 25 Apr 2018 04:19:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524655191; cv=none; d=google.com; s=arc-20160816; b=H+YtWpK7FdC+flM2YTkcpy+ny8d8RNDE6hO52idr1/5nNtStYgovDVOGY8zC6p/gL0 FRsbCDz4TEK5PYgQgcTcJsiKMmNAUbAaAJu6qWeiaLe52Sgtb23ZcYP7YJBIgiP33m73 JXIppC6lJAYd5FmdHRU1KrnCfUDXnZZ5Dtqi1Uukw/ik45nPP/FBmHrusCuX4cDuABcm vhTyTIwA+kNv+WzY2jpGkQBHjSo5xjCzSjlTc7QbBHp2A8rJIuFNcELQ3JBzEhZ8J1tS 1pA1pp7RoGD9A5VAAYC65+//nnW0s9LzFCh/yit6RcZNYG1Oh91FpPY4M3BV8nOQ5XXe ht2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=wWxHnoMAU5Eny5uRAKOAXf0SqQsU1ro4JBqAI79FGVg=; b=tktxhpqpXWC8EJox2lAHnIXlZgiCjoVru2pESZJyMa0mGQMlw6LTg4FTa8Gv31/zpl 8iZE8oo4ztJ8o9xdZNDtsjJUm4kWOR0XuOOA3LWN+uSZK+lXgaXi9tdbjuTHJFlTPca5 9kWfv5ru2evX7Ooj2jyrGcMkaN1xTgB0B+PCiyKp5XfTht0lIO1ZujC4zqB0ZpdBc7yP SzU1traTVXlUGIIssahBp0Ak1wXCBz5X4fQ2VzF73FtX1Md/tvql8qXARzSVJ4rtqJBO M59aaAHOEKvxRdAVT518HXtV8bUZpYy30LIWO98Pu/wSn6RGaY1eqqcDFGA5OzGkoqhh fOIg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t11si13249932pgn.337.2018.04.25.04.19.37; Wed, 25 Apr 2018 04:19:51 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753453AbeDYLSX (ORCPT + 99 others); Wed, 25 Apr 2018 07:18:23 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:52104 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753768AbeDYKkV (ORCPT ); Wed, 25 Apr 2018 06:40:21 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C77A436; Wed, 25 Apr 2018 10:40:20 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ming Lei , Eryu Guan , Jens Axboe , Sasha Levin Subject: [PATCH 4.14 082/183] blk-mq-debugfs: dont allow write on attributes with seq_operations set Date: Wed, 25 Apr 2018 12:35:02 +0200 Message-Id: <20180425103245.800521498@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- block/blk-mq-debugfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -704,7 +704,11 @@ static ssize_t blk_mq_debugfs_write(stru const struct blk_mq_debugfs_attr *attr = m->private; void *data = d_inode(file->f_path.dentry->d_parent)->i_private; - if (!attr->write) + /* + * Attributes that only implement .seq_ops are read-only and 'attr' is + * the same with 'data' in this case. + */ + if (attr == data || !attr->write) return -EPERM; return attr->write(data, buf, count, ppos);