Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8240890imu; Fri, 28 Dec 2018 13:29:31 -0800 (PST) X-Google-Smtp-Source: ALg8bN6gu8pSEz04cJEvpLOBm+OON+uVypwhO3u/0z/iDQIe8gDvGY2KB78Fmm+29BW22S4HoTsp X-Received: by 2002:a17:902:a411:: with SMTP id p17mr28742072plq.292.1546032571872; Fri, 28 Dec 2018 13:29:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546032571; cv=none; d=google.com; s=arc-20160816; b=wviG5NIvglFf5pSBBVjoGj82eP4NnmmZOahGbildLMXQPTSgQWmWFkialaiMXfKkF2 njFjOngptkAKYtImtEO7mkBsn1XChdDsVx+xf/Rn+ueMU7MbwbOg+arAdgL99aGHTblr Ua5JlZBY8uxSRP1fYeCZLLNMBfMPTvVfOHvjiK8sZ/y+++K7UGgQw/VRK2pnGdW6LNdK 19DUN9t5BGNBFLVLk8d1H1O2tsV53WWp1KPh9VFKUm4GBXcOoNV0vnJtfnanonLGwhh1 KPVg6sjc7WOgzcuDn+KaEkv21av9oa2rX+tuFVl+jbvyj/mP6PWQzk9R5FbjVEl18uZk BzyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KJXizuaYmoZDcozxO3V/LFfqgDCr6MJOc4z3AaO1KjU=; b=cyE4W01nYJBRuWYMchD6PnP7t/ifhfLD+lZn+ngxJ++4vK32D9XUBh36fJKAAYF4FD MtbTfuyTOTJtQAhTreRlHuT9dANe7WnzJSHvpHv0b2BeHq08wcOGcQAVPgNYAiuV6tUE /J1DnIvcYiHy/Eqhxgo2J3IRjqAhTCcoas/DM8Ux3FU/Zlk1Qqe21ANAA0f2XyV7d6eA NFYDNjdfyJTNksWnAtE7+5WXbH+dfq+RXU1kNKwoMyy2W8ej9L7lpvzVpCG71aArCxwp IyZ0CegV/ZCb8KKkNGvFyarCNMl+ZXIYcVlPanwU5U9nKWbR3nFHgVaFiymjubEIztDE SXjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Nle9OVIy; 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 e25si24591653pgv.486.2018.12.28.13.29.16; Fri, 28 Dec 2018 13:29:31 -0800 (PST) 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=@kernel.org header.s=default header.b=Nle9OVIy; 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 S1732392AbeL1Lx4 (ORCPT + 99 others); Fri, 28 Dec 2018 06:53:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:53726 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732370AbeL1Lxv (ORCPT ); Fri, 28 Dec 2018 06:53:51 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 892D9218F0; Fri, 28 Dec 2018 11:53:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545998030; bh=plkO8wSSGLEOB4xCOSgrayPclYFMJRLggZ8fSA+4AUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nle9OVIyNBjtunvixfQtjzwm42HYgFlKnJLPBDL993vBghIoeiOVVuKfpmpuoh50W dnqdu16lKMTWIElSoOdhQtUXyuMycPhqZWb8Tjqo00gJ7G3HqcQOhMJWsUZKI1Bwu0 JOAmhpet5OtCYqJ/eFFALsI7vm7XV3SPNNL5Ro+c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Dexuan Cui , Sasha Levin Subject: [PATCH 4.19 24/46] Drivers: hv: vmbus: Return -EINVAL for the sys files for unopened channels Date: Fri, 28 Dec 2018 12:52:18 +0100 Message-Id: <20181228113126.175718919@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20181228113124.971620049@linuxfoundation.org> References: <20181228113124.971620049@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dexuan Cui commit fc96df16a1ce80cbb3c316ab7d4dc8cd5c2852ce upstream. Before 98f4c651762c, we returned zeros for unopened channels. With 98f4c651762c, we started to return random on-stack values. We'd better return -EINVAL instead. Fixes: 98f4c651762c ("hv: move ringbuffer bus attributes to dev_groups") Cc: stable@vger.kernel.org Cc: K. Y. Srinivasan Cc: Haiyang Zhang Cc: Stephen Hemminger Signed-off-by: Dexuan Cui Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/hv/vmbus_drv.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -316,6 +316,8 @@ static ssize_t out_intr_mask_show(struct if (!hv_dev->channel) return -ENODEV; + if (hv_dev->channel->state != CHANNEL_OPENED_STATE) + return -EINVAL; hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound); return sprintf(buf, "%d\n", outbound.current_interrupt_mask); } @@ -329,6 +331,8 @@ static ssize_t out_read_index_show(struc if (!hv_dev->channel) return -ENODEV; + if (hv_dev->channel->state != CHANNEL_OPENED_STATE) + return -EINVAL; hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound); return sprintf(buf, "%d\n", outbound.current_read_index); } @@ -343,6 +347,8 @@ static ssize_t out_write_index_show(stru if (!hv_dev->channel) return -ENODEV; + if (hv_dev->channel->state != CHANNEL_OPENED_STATE) + return -EINVAL; hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound); return sprintf(buf, "%d\n", outbound.current_write_index); } @@ -357,6 +363,8 @@ static ssize_t out_read_bytes_avail_show if (!hv_dev->channel) return -ENODEV; + if (hv_dev->channel->state != CHANNEL_OPENED_STATE) + return -EINVAL; hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound); return sprintf(buf, "%d\n", outbound.bytes_avail_toread); } @@ -371,6 +379,8 @@ static ssize_t out_write_bytes_avail_sho if (!hv_dev->channel) return -ENODEV; + if (hv_dev->channel->state != CHANNEL_OPENED_STATE) + return -EINVAL; hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound); return sprintf(buf, "%d\n", outbound.bytes_avail_towrite); } @@ -384,6 +394,8 @@ static ssize_t in_intr_mask_show(struct if (!hv_dev->channel) return -ENODEV; + if (hv_dev->channel->state != CHANNEL_OPENED_STATE) + return -EINVAL; hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound); return sprintf(buf, "%d\n", inbound.current_interrupt_mask); } @@ -397,6 +409,8 @@ static ssize_t in_read_index_show(struct if (!hv_dev->channel) return -ENODEV; + if (hv_dev->channel->state != CHANNEL_OPENED_STATE) + return -EINVAL; hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound); return sprintf(buf, "%d\n", inbound.current_read_index); } @@ -410,6 +424,8 @@ static ssize_t in_write_index_show(struc if (!hv_dev->channel) return -ENODEV; + if (hv_dev->channel->state != CHANNEL_OPENED_STATE) + return -EINVAL; hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound); return sprintf(buf, "%d\n", inbound.current_write_index); } @@ -424,6 +440,8 @@ static ssize_t in_read_bytes_avail_show( if (!hv_dev->channel) return -ENODEV; + if (hv_dev->channel->state != CHANNEL_OPENED_STATE) + return -EINVAL; hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound); return sprintf(buf, "%d\n", inbound.bytes_avail_toread); } @@ -438,6 +456,8 @@ static ssize_t in_write_bytes_avail_show if (!hv_dev->channel) return -ENODEV; + if (hv_dev->channel->state != CHANNEL_OPENED_STATE) + return -EINVAL; hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound); return sprintf(buf, "%d\n", inbound.bytes_avail_towrite); }