From patchwork Wed May 23 02:27:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khalid Elmously X-Patchwork-Id: 918703 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40rGgR1xm1z9s2S; Wed, 23 May 2018 12:29:39 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fLJWt-00037t-9L; Wed, 23 May 2018 02:29:31 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fLJWq-000362-TE for kernel-team@lists.ubuntu.com; Wed, 23 May 2018 02:29:28 +0000 Received: from mail-io0-f198.google.com ([209.85.223.198]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fLJWq-0007sI-IE for kernel-team@lists.ubuntu.com; Wed, 23 May 2018 02:29:28 +0000 Received: by mail-io0-f198.google.com with SMTP id l4-v6so16739373iog.9 for ; Tue, 22 May 2018 19:29:28 -0700 (PDT) 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=lKa0Fz5rGUD2zcEe2GVbMUiPdYU+l5D2YGDZFhata2I=; b=a97AkajKa+h4vz0/3odPnhn4GEnsoL2OiN+mKUctToJmL/EmENdltQXaTFsBPLqlbj tuNCn9Har2qqBHR0cQq+2lTWG8WJbFSz1hUbOe9dD9IylYJ2dk0qtF1SGWNtbmWtjuid 6Hgk/VpSUYEiLs/q8Td5AZDgBh0C+R661ww16VzQ20T+aa97RZNIOX3sfqUkhfPuzYVO AjC0X0FbMtYKKUsYtQwTYRMLGQaoR/KGWFXZQunM5c3IL+fHty7QmruqrE7O5465iM3d RZVaQEjzC9uR7KEfh8tXCULxDfwMibFIOmj21cimkAF5hBgSYYDkrlVMyPRFWHZubKGZ X5Mg== X-Gm-Message-State: ALKqPwfLcjK96qiy0039iS+5EoetLZlFJXcQvgmx1hF1K092OGr52yQS 6lJs8n/u6dNgNv7oAg4uA5wAf7f8Usq4/VZrfQKwSiFFcA8E6quskJr3KKkkQWyanDnWlj6ZXxR VgkFtw/BY5b3PzS2ZPH4PBm7W8qKbZRfKAJcKgyDIJw== X-Received: by 2002:a24:ac23:: with SMTP id s35-v6mr3530165ite.104.1527042567242; Tue, 22 May 2018 19:29:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKVAv1IP9nNG1BFKCroBfhGOtZX3kso0d8whYnLBdsgtKZHODugK/s7Gqg+D1THsurxBYrPkw== X-Received: by 2002:a24:ac23:: with SMTP id s35-v6mr3530156ite.104.1527042567076; Tue, 22 May 2018 19:29:27 -0700 (PDT) Received: from kbuntu.fuzzbuzz.org (198-84-180-15.cpe.teksavvy.com. [198.84.180.15]) by smtp.gmail.com with ESMTPSA id m16-v6sm9428605iob.69.2018.05.22.19.29.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 19:29:25 -0700 (PDT) From: Khalid Elmously To: kernel-team@lists.ubuntu.com Subject: [CVE-2017-18232][A][PATCH 07/11] scsi: libsas: make the event threshold configurable Date: Tue, 22 May 2018 22:27:55 -0400 Message-Id: <20180523022759.22556-8-khalid.elmously@canonical.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180523022759.22556-1-khalid.elmously@canonical.com> References: <20180523022759.22556-1-khalid.elmously@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jason Yan CVE-2017-18232 Add a sysfs attr that LLDD can configure it for every host. We made an example in hisi_sas. Other LLDDs using libsas can implement it if they want. Suggested-by: Hannes Reinecke Signed-off-by: Jason Yan CC: John Garry CC: Johannes Thumshirn CC: Ewan Milne CC: Christoph Hellwig CC: Tomas Henzl CC: Dan Williams Acked-by: John Garry #for hisi_sas part Reviewed-by: Hannes Reinecke Signed-off-by: Martin K. Petersen (cherry-picked from 8eea9dd84e450e5262643823691108f2a208a2ac ) Signed-off-by: Khalid Elmously --- drivers/scsi/hisi_sas/hisi_sas_main.c | 6 ++++++ drivers/scsi/libsas/sas_init.c | 31 +++++++++++++++++++++++++++ include/scsi/libsas.h | 1 + 3 files changed, 38 insertions(+) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 2bdd039a3d51..ce699a76dd4d 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -1554,6 +1554,11 @@ EXPORT_SYMBOL_GPL(hisi_sas_kill_tasklets); struct scsi_transport_template *hisi_sas_stt; EXPORT_SYMBOL_GPL(hisi_sas_stt); +struct device_attribute *host_attrs[] = { + &dev_attr_phy_event_threshold, + NULL, +}; + static struct scsi_host_template _hisi_sas_sht = { .module = THIS_MODULE, .name = DRV_NAME, @@ -1573,6 +1578,7 @@ static struct scsi_host_template _hisi_sas_sht = { .eh_bus_reset_handler = sas_eh_bus_reset_handler, .target_destroy = sas_target_destroy, .ioctl = sas_ioctl, + .shost_attrs = host_attrs, }; struct scsi_host_template *hisi_sas_sht = &_hisi_sas_sht; EXPORT_SYMBOL_GPL(hisi_sas_sht); diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c index 1957716dbcf6..811128eb0283 100644 --- a/drivers/scsi/libsas/sas_init.c +++ b/drivers/scsi/libsas/sas_init.c @@ -537,6 +537,37 @@ static struct sas_function_template sft = { .smp_handler = sas_smp_handler, }; +static inline ssize_t phy_event_threshold_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); + + return scnprintf(buf, PAGE_SIZE, "%u\n", sha->event_thres); +} + +static inline ssize_t phy_event_threshold_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); + + sha->event_thres = simple_strtol(buf, NULL, 10); + + /* threshold cannot be set too small */ + if (sha->event_thres < 32) + sha->event_thres = 32; + + return count; +} + +DEVICE_ATTR(phy_event_threshold, + S_IRUGO|S_IWUSR, + phy_event_threshold_show, + phy_event_threshold_store); +EXPORT_SYMBOL_GPL(dev_attr_phy_event_threshold); + struct scsi_transport_template * sas_domain_attach_transport(struct sas_domain_function_template *dft) { diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index a301569a1a7d..0698768cb383 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -680,6 +680,7 @@ extern int sas_bios_param(struct scsi_device *, sector_t capacity, int *hsc); extern struct scsi_transport_template * sas_domain_attach_transport(struct sas_domain_function_template *); +extern struct device_attribute dev_attr_phy_event_threshold; int sas_discover_root_expander(struct domain_device *);