lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160411115614.GA2175@nanopsycho.orion>
Date:	Mon, 11 Apr 2016 13:56:14 +0200
From:	Jiri Pirko <jiri@...nulli.us>
To:	Taku Izumi <izumi.taku@...fujitsu.com>
Cc:	davem@...emloft.net, netdev@...r.kernel.org
Subject: Re: [PATCH net-next 02/11] fjes: Add setting/getting register value
 feature via ioctl

Mon, Apr 11, 2016 at 10:10:04AM CEST, izumi.taku@...fujitsu.com wrote:
>This patch introduces setting/getting register value feature
>via ioctl. This feature is useful for debugging.
>
>Signed-off-by: Taku Izumi <izumi.taku@...fujitsu.com>
>---
> drivers/net/fjes/fjes_ioctl.h |  7 +++++++
> drivers/net/fjes/fjes_main.c  | 39 +++++++++++++++++++++++++++++++++++++++
> 2 files changed, 46 insertions(+)
>
>diff --git a/drivers/net/fjes/fjes_ioctl.h b/drivers/net/fjes/fjes_ioctl.h
>index 35adfda..61619f7 100644
>--- a/drivers/net/fjes/fjes_ioctl.h
>+++ b/drivers/net/fjes/fjes_ioctl.h
>@@ -25,6 +25,8 @@
> #define FJES_IOCTL_TRACE_START		(SIOCDEVPRIVATE + 1)
> #define FJES_IOCTL_TRACE_STOP		(SIOCDEVPRIVATE + 2)
> #define FJES_IOCTL_TRACE_GETCFG		(SIOCDEVPRIVATE + 3)
>+#define FJES_IOCTL_DEV_GETREG		(SIOCDEVPRIVATE + 4)
>+#define FJES_IOCTL_DEV_SETREG		(SIOCDEVPRIVATE + 5)


This patch certainly looks wrong to me. Exposing read and mainly write
access to registers using ioctl? I don't think so...




> 
> struct fjes_ioctl_trace_start_req_val {
> 	u32	mode;
>@@ -70,6 +72,11 @@ struct fjes_ioctl_trace_param {
> 	union fjes_ioctl_trace_res_val	res;
> };
> 
>+struct fjes_ioctl_dev_reg_param {
>+	u32	offset;
>+	u32	val;
>+};
>+
> #define FJES_IOCTL_TRACE_START_ERR_NORMAL		(0x0000)
> #define FJES_IOCTL_TRACE_START_ERR_BUSY			(0x0001)
> #define FJES_IOCTL_TRACE_START_ERR_PARAM		(0x0100)
>diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
>index bc6e31d..40cf65d 100644
>--- a/drivers/net/fjes/fjes_main.c
>+++ b/drivers/net/fjes/fjes_main.c
>@@ -977,6 +977,40 @@ static int fjes_ioctl_trace_getcfg(struct net_device *netdev, struct ifreq *rq)
> 	return 0;
> }
> 
>+static int fjes_ioctl_reg_read(struct net_device *netdev, struct ifreq *rq)
>+{
>+	struct fjes_adapter *adapter = netdev_priv(netdev);
>+	struct fjes_ioctl_dev_reg_param reg;
>+	struct fjes_hw *hw = &adapter->hw;
>+
>+	if (copy_from_user(&reg, rq->ifr_data, sizeof(reg)))
>+		return -EFAULT;
>+
>+	reg.val = rd32(reg.offset);
>+
>+	if (copy_to_user(rq->ifr_data, &reg, sizeof(reg)))
>+		return -EFAULT;
>+
>+	return 0;
>+}
>+
>+static int fjes_ioctl_reg_write(struct net_device *netdev, struct ifreq *rq)
>+{
>+	struct fjes_adapter *adapter = netdev_priv(netdev);
>+	struct fjes_ioctl_dev_reg_param reg;
>+	struct fjes_hw *hw = &adapter->hw;
>+
>+	if (copy_from_user(&reg, rq->ifr_data, sizeof(reg)))
>+		return -EFAULT;
>+
>+	wr32(reg.offset, reg.val);
>+
>+	if (copy_to_user(rq->ifr_data, &reg, sizeof(reg)))
>+		return -EFAULT;
>+
>+	return 0;
>+}
>+
> static int fjes_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
> {
> 	switch (cmd) {
>@@ -986,7 +1020,12 @@ static int fjes_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
> 		return fjes_ioctl_trace_stop(netdev, rq);
> 	case FJES_IOCTL_TRACE_GETCFG:
> 		return fjes_ioctl_trace_getcfg(netdev, rq);
>+	case FJES_IOCTL_DEV_GETREG:
>+		return fjes_ioctl_reg_read(netdev, rq);
>+	case FJES_IOCTL_DEV_SETREG:
>+		return fjes_ioctl_reg_write(netdev, rq);
> 	default:
>+
> 		return -EOPNOTSUPP;
> 	}
> }
>-- 
>2.4.3
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ