Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp680233imu; Fri, 11 Jan 2019 07:16:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN7V8JXbSeNhDlha3syjlTTJFrYpFiwNZsYMF3XHpYrmUkU4ZXek7gf4nIP8mfwu6xe+PBCh X-Received: by 2002:a65:43c5:: with SMTP id n5mr14098147pgp.250.1547219766442; Fri, 11 Jan 2019 07:16:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547219766; cv=none; d=google.com; s=arc-20160816; b=TOPf+iR0k/3WLG6EzIQgJzZfYhmhMII7WWTjaCT2wP+e7/yO5SMBXNoTEjHL8M4KZb s7hLXnrz+H8OGvJBc3AsZtpwUs5wp7X1LdqttF4421soUFjvPuLo4PcBExgkLFGm4sdP 6tASywjDyoxUKCbN/Kj4GZx20ds9BIp6vsUQs9T/IQvS6ZoDhUmag9a/kZndubJw3Pb9 ozxvX84Q8bEs3X46TwRIdEYTIXtNSBe6P0lvJcRlRhLgCD6ZhzqIZYgTFVtvOGDUuueD xUx6R5jhMXwI5u1O0upZRWXU3LA6v1W4H2zh8gVURiBxW9S5cb6rJo+I3gA+wmPg6sA6 avEg== 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=0pv/6XvNcaQ7Burj+7DBjprE2K3B0GISHb+FD9RlxcU=; b=b8Z6pgnaevVVBOsK4DqdT709OX0FUvMABARc75jeEV9sRIRFHHXHRs54rWYo4jSPq4 KPLGrGi5Yx+ea13gNWxlsrikooD9jX7GngxmsA80l8gVLgXbpVmS3Zq9G97F2q/8JE2Q JIes1QLgH1HrTUXMQUqVZqSmSdVAeuLO8jPOg+tqAGISfziAPj6eMT5ctZpuaQdXZs1m Jpz+aCBP2bQJD5LNz0nhhe3REwc2mMvi3Ckf7kCh6QQnP/mdUyhdMgyaPXX6JrdFo7AI FlvWB8YDCjTcW1T4xCfWwmfA0FQByMXs5bsTMwpokfh+InDjxUbDKjXdbwEtmS8/0ol7 vm2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sTYrr9uF; 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 q32si73024178pgm.410.2019.01.11.07.15.50; Fri, 11 Jan 2019 07:16:06 -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=sTYrr9uF; 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 S1733120AbfAKOOn (ORCPT + 99 others); Fri, 11 Jan 2019 09:14:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:58446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732147AbfAKOOm (ORCPT ); Fri, 11 Jan 2019 09:14:42 -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 980DC2177B; Fri, 11 Jan 2019 14:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547216081; bh=D28Gxzh+3/f0vNptvD9ENwoeO/HLQDCMcNx83HJmidI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sTYrr9uFAUcdCnyDxNZEyDkWNgz8EeE+DeW6c4GK2Y8yi9q21EIyMU/LvgkCBlG0v Nl2qf0DqKpqnN6WcOjHB/uWIQTUrt26vRLC2r4bloRgTyvWdq88o/2ciVvPFl1Q5V2 uO1kKSCqMAdtIlpErTzjqg/KAFIsPbgdlGwT+hRw= 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 3.18 06/47] Drivers: hv: vmbus: Return -EINVAL for the sys files for unopened channels Date: Fri, 11 Jan 2019 15:07:51 +0100 Message-Id: <20190111130956.960900276@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190111130956.170952125@linuxfoundation.org> References: <20190111130956.170952125@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 3.18-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 @@ -258,6 +258,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); } @@ -271,6 +273,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); } @@ -285,6 +289,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); } @@ -299,6 +305,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); } @@ -313,6 +321,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); } @@ -326,6 +336,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); } @@ -339,6 +351,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); } @@ -352,6 +366,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); } @@ -366,6 +382,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); } @@ -380,6 +398,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); }