ixgbe: add bounds check for debugfs register access
Subsystems (2)
PATCH 1/1 ixgbe: add bounds check for debugfs register access
Add bounds check for debugfs read and write register access.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c +4 -2
@@ -103,7 +103,8 @@ static ssize_t ixgbe_dbg_reg_ops_write(struct file *filp,u32 reg, value;int cnt; cnt =sscanf (&ixgbe_dbg_reg_ops_buf[5 ],"%x %x" , ®, &value); -if (cnt ==2 ) { +/* check format and bounds check register access */ +if (cnt ==2 && reg <=IXGBE_HFDR ) {IXGBE_WRITE_REG (&adapter->hw, reg, value); value =IXGBE_READ_REG (&adapter->hw, reg);e_dev_info ("write: 0x%08x = 0x%08x\n" , reg, value);
@@ -114,7 +115,8 @@ static ssize_t ixgbe_dbg_reg_ops_write(struct file *filp,u32 reg, value;int cnt; cnt =sscanf (&ixgbe_dbg_reg_ops_buf[4 ],"%x" , ®); -if (cnt ==1 ) { +/* check format and bounds check register access */ +if (cnt ==1 && reg <=IXGBE_HFDR ) { value =IXGBE_READ_REG (&adapter->hw, reg);e_dev_info ("read 0x%08x = 0x%08x\n" , reg, value); }else {
Signature · 1 line
2.7.4
PATCH 1/1 ixgbe: add bounds check for debugfs register access
Quoted 22 lines · Paul Greenwalt
Add bounds check for debugfs read and write register access.
Signed-off-by Paul Greenwalt <[email protected]>--- drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c +2
-1@@ -103,7 +103,8 @@ static ssize_t ixgbe_dbg_reg_ops_write(struct file *filp,u32 reg, value;int cnt; cnt =sscanf (&ixgbe_dbg_reg_ops_buf[5 ],"%x %x" , ®, &value); -if (cnt ==2 ) { +/* check format and bounds check register access */ +if (cnt ==2 && reg <=IXGBE_HFDR ) {IXGBE_WRITE_REG (&adapter->hw, reg, value); value =IXGBE_READ_REG (&adapter->hw, reg);e_dev_info ("write: 0x%08x = 0x%08x\n" , reg, value);
drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c static ssize_t ixgbe_dbg_reg_ops_write(struct file *filp, · line 122
Quoted 9 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c +2
-1@@ -114,7 +115,8 @@ static ssize_t ixgbe_dbg_reg_ops_write(struct file *filp,u32 reg, value;int cnt; cnt =sscanf (&ixgbe_dbg_reg_ops_buf[4 ],"%x" , ®); -if (cnt ==1 ) { +/* check format and bounds check register access */ +if (cnt ==1 && reg <=IXGBE_HFDR ) { value =IXGBE_READ_REG (&adapter->hw, reg);e_dev_info ("read 0x%08x = 0x%08x\n" , reg, value); }else {
Not to be snarky, but there is actually for this there is an easier fix. Just remove the ability to write registers from debugfs. Stuff like this isn't supposed to be in debugfs. It isn't a configuration interface. That is the feedback you will probably get from the community anyway on this patch.
- Alex
Tantilov
PATCH 1/1 ixgbe: add bounds check for debugfs register access
Quoted 46 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alexander Duyck
Sent: Tuesday, October 24, 2017 9:05 AM
To: Greenwalt, Paul <[email protected]>
Cc: intel-wired-lan <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH] ixgbe: add bounds check for debugfs register accessReview
Quoted 8 lines · Paul Greenwalt
Add bounds check for debugfs read and write register access.
Signed-off-by Paul Greenwalt <[email protected]>--- drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.cdrivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c static ssize_t ixgbe_dbg_reg_ops_write(struct file
Quoted 4 lines
index 5e2c1e3..4fcd980 100644
drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c +0
-0@@ -103,7 +103,8 @@ static ssize_t ixgbe_dbg_reg_ops_write(struct file*filp,
drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c static ssize_t ixgbe_dbg_reg_ops_write(struct file *filp,
Quoted 3 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c +0
-0u32 reg, value;int cnt; cnt = sscanf(&ixgbe_dbg_reg_ops_buf[5], "%x %x", ®,&value);
drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c static ssize_t ixgbe_dbg_reg_ops_write(struct file *filp,
Quoted 6 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c +2
-1-if (cnt ==2 ) { +/* check format and bounds check register access */ +if (cnt ==2 && reg <=IXGBE_HFDR ) {IXGBE_WRITE_REG (&adapter->hw, reg, value); value =IXGBE_READ_REG (&adapter->hw, reg); e_dev_info("write: 0x%08x = 0x%08x\n", reg,value);
drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c static ssize_t ixgbe_dbg_reg_ops_write(struct file
Quoted 1 line
drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c +0
-0@@ -114,7 +115,8 @@ static ssize_t ixgbe_dbg_reg_ops_write(struct file*filp,
drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c static ssize_t ixgbe_dbg_reg_ops_write(struct file *filp,
Quoted 8 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c +2
-1u32 reg, value;int cnt; cnt =sscanf (&ixgbe_dbg_reg_ops_buf[4 ],"%x" , ®); -if (cnt ==1 ) { +/* check format and bounds check register access */ +if (cnt ==1 && reg <=IXGBE_HFDR ) { value =IXGBE_READ_REG (&adapter->hw, reg); e_dev_info("read 0x%08x = 0x%08x\n", reg,
Quoted 8 lines
value);
drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c static ssize_t ixgbe_dbg_reg_ops_write(struct file *filp, · line 122
Quoted 1 line
drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c +0
-0}else {Not to be snarky, but there is actually for this there is an easier fix. Just remove the ability to write registers from debugfs. Stuff like this isn't supposed to be in debugfs. It isn't a configuration interface. That is the feedback you will probably get from the community anyway on this patch.
I'd also be in favor we can remove this code altogether. Both reading and writing of the registers can be done from user space.
Thanks,
Emil
Bowers
PATCH 1/1 ixgbe: add bounds check for debugfs register access
In reply to Paul GreenwaltQuoted 8 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Paul Greenwalt
Sent: Monday, October 23, 2017 8:21 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH] ixgbe: add bounds check for debugfs register access
Quoted 6 lines
Add bounds check for debugfs read and write register access.
Signed-off-by Paul Greenwalt <[email protected]>--- drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)