Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1411280 > unrolled thread

[PATCH] ethtool: fix a kernel infoleak in ethtool_get_pauseparam

Started byKangjie Lu <kangjielu@gmail.com>
First post2016-06-01 16:40 +0200
Last post2016-06-01 19:20 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] ethtool: fix a kernel infoleak in ethtool_get_pauseparam Kangjie Lu <kangjielu@gmail.com> - 2016-06-01 16:40 +0200
    Re: [PATCH] ethtool: fix a kernel infoleak in ethtool_get_pauseparam Edward Cree <ecree@solarflare.com> - 2016-06-01 17:10 +0200
    Re: [PATCH] ethtool: fix a kernel infoleak in ethtool_get_pauseparam Ben Hutchings <ben@decadent.org.uk> - 2016-06-01 19:20 +0200

#1411280 — [PATCH] ethtool: fix a kernel infoleak in ethtool_get_pauseparam

FromKangjie Lu <kangjielu@gmail.com>
Date2016-06-01 16:40 +0200
Subject[PATCH] ethtool: fix a kernel infoleak in ethtool_get_pauseparam
Message-ID<rFfto-17P-13@gated-at.bofh.it>
The field autoneg of pauseparam is not initialized in some
implementations of get_pauseparam(), but the whole object is
copied to userland.

Signed-off-by: Kangjie Lu <kjlu@gatech.edu>
---
 net/core/ethtool.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index f426c5a..84544bd 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1723,7 +1723,10 @@ static noinline_for_stack int ethtool_set_channels(struct net_device *dev,
 
 static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr)
 {
-	struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM };
+	struct ethtool_pauseparam pauseparam;
+
+	memset(&pauseparam, 0, sizeof(pauseparam));
+	pauseparam.cmd = ETHTOOL_GPAUSEPARAM;
 
 	if (!dev->ethtool_ops->get_pauseparam)
 		return -EOPNOTSUPP;
-- 
1.9.1

[toc] | [next] | [standalone]


#1411309

FromEdward Cree <ecree@solarflare.com>
Date2016-06-01 17:10 +0200
Message-ID<rFfWq-1wV-29@gated-at.bofh.it>
In reply to#1411280
On 01/06/16 15:39, Kangjie Lu wrote:
> The field autoneg of pauseparam is not initialized in some
> implementations of get_pauseparam(), but the whole object is
> copied to userland.
>
> Signed-off-by: Kangjie Lu <kjlu@gatech.edu>
> ---
>  net/core/ethtool.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/net/core/ethtool.c b/net/core/ethtool.c
> index f426c5a..84544bd 100644
> --- a/net/core/ethtool.c
> +++ b/net/core/ethtool.c
> @@ -1723,7 +1723,10 @@ static noinline_for_stack int ethtool_set_channels(struct net_device *dev,
>  
>  static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr)
>  {
> -	struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM };
AIUI an incomplete compound initialiser will fill all unspecified fields
with zeroes of the appropriate type.  So this patch is unnecessary.

Per C99, §6.7.8.21:
> If there are fewer initializers in a brace-enclosed list than there are elements or members of an aggregate [...] the remainder of the aggregate shall be initialized implicitly the same as objects that have static storage duration.

-Ed

> +	struct ethtool_pauseparam pauseparam;
> +
> +	memset(&pauseparam, 0, sizeof(pauseparam));
> +	pauseparam.cmd = ETHTOOL_GPAUSEPARAM;
>  
>  	if (!dev->ethtool_ops->get_pauseparam)
>  		return -EOPNOTSUPP;

[toc] | [prev] | [next] | [standalone]


#1411414

FromBen Hutchings <ben@decadent.org.uk>
Date2016-06-01 19:20 +0200
Message-ID<rFhYd-2Pw-9@gated-at.bofh.it>
In reply to#1411280

[Multipart message — attachments visible in raw view] — view raw

On Wed, 2016-06-01 at 16:39 +0200, Kangjie Lu wrote:
> The field autoneg of pauseparam is not initialized in some
> implementations of get_pauseparam(),

Nonsense.  The current implementation initialises all fields.  (If
there was padding in the structure, this change would be needed to
guarantee that the padding was initialised.  But there isn't.)

Ben.

>  but the whole object is
> copied to userland.
> 
> Signed-off-by: Kangjie Lu <kjlu@gatech.edu>
> ---
>  net/core/ethtool.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/net/core/ethtool.c b/net/core/ethtool.c
> index f426c5a..84544bd 100644
> --- a/net/core/ethtool.c
> +++ b/net/core/ethtool.c
> @@ -1723,7 +1723,10 @@ static noinline_for_stack int
> ethtool_set_channels(struct net_device *dev,
>  
>  static int ethtool_get_pauseparam(struct net_device *dev, void
> __user *useraddr)
>  {
> -	struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM
> };
> +	struct ethtool_pauseparam pauseparam;
> +
> +	memset(&pauseparam, 0, sizeof(pauseparam));
> +	pauseparam.cmd = ETHTOOL_GPAUSEPARAM;
>  
>  	if (!dev->ethtool_ops->get_pauseparam)
>  		return -EOPNOTSUPP;
-- 
Ben Hutchings
To err is human; to really foul things up requires a computer.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web