Skip to content

Commit 9db6c14

Browse files
jsmart-ghmartinkpetersen
authored andcommitted
scsi: lpfc: Remove bg debugfs buffers
Capturing and downloading dif command data and dif data was done a dozen years ago and no longer being used. Also creates a potential security hole. Remove the debugfs buffer for dif debugging. Signed-off-by: Dick Kennedy <[email protected]> Signed-off-by: James Smart <[email protected]> CC: KyleMahlkuch <[email protected]> CC: Hannes Reinecke <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 7f9989b commit 9db6c14

File tree

5 files changed

+0
-295
lines changed

5 files changed

+0
-295
lines changed

drivers/scsi/lpfc/lpfc.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,8 +1038,6 @@ struct lpfc_hba {
10381038
struct dentry *debug_hbqinfo;
10391039
struct dentry *debug_dumpHostSlim;
10401040
struct dentry *debug_dumpHBASlim;
1041-
struct dentry *debug_dumpData; /* BlockGuard BPL */
1042-
struct dentry *debug_dumpDif; /* BlockGuard BPL */
10431041
struct dentry *debug_InjErrLBA; /* LBA to inject errors at */
10441042
struct dentry *debug_InjErrNPortID; /* NPortID to inject errors at */
10451043
struct dentry *debug_InjErrWWPN; /* WWPN to inject errors at */

drivers/scsi/lpfc/lpfc_crtn.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -433,16 +433,6 @@ int lpfc_sli4_get_allocated_extnts(struct lpfc_hba *, uint16_t,
433433
int lpfc_sli4_get_avail_extnt_rsrc(struct lpfc_hba *, uint16_t,
434434
uint16_t *, uint16_t *);
435435

436-
/* externs BlockGuard */
437-
extern char *_dump_buf_data;
438-
extern unsigned long _dump_buf_data_order;
439-
extern char *_dump_buf_dif;
440-
extern unsigned long _dump_buf_dif_order;
441-
extern spinlock_t _dump_buf_lock;
442-
extern int _dump_buf_done;
443-
extern spinlock_t pgcnt_lock;
444-
extern unsigned int pgcnt;
445-
446436
/* Interface exported by fabric iocb scheduler */
447437
void lpfc_fabric_abort_nport(struct lpfc_nodelist *);
448438
void lpfc_fabric_abort_hba(struct lpfc_hba *);

drivers/scsi/lpfc/lpfc_debugfs.c

Lines changed: 0 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,89 +2162,6 @@ lpfc_debugfs_dumpHostSlim_open(struct inode *inode, struct file *file)
21622162
return rc;
21632163
}
21642164

2165-
static int
2166-
lpfc_debugfs_dumpData_open(struct inode *inode, struct file *file)
2167-
{
2168-
struct lpfc_debug *debug;
2169-
int rc = -ENOMEM;
2170-
2171-
if (!_dump_buf_data)
2172-
return -EBUSY;
2173-
2174-
debug = kmalloc(sizeof(*debug), GFP_KERNEL);
2175-
if (!debug)
2176-
goto out;
2177-
2178-
/* Round to page boundary */
2179-
pr_err("9059 BLKGRD: %s: _dump_buf_data=0x%p\n",
2180-
__func__, _dump_buf_data);
2181-
debug->buffer = _dump_buf_data;
2182-
if (!debug->buffer) {
2183-
kfree(debug);
2184-
goto out;
2185-
}
2186-
2187-
debug->len = (1 << _dump_buf_data_order) << PAGE_SHIFT;
2188-
file->private_data = debug;
2189-
2190-
rc = 0;
2191-
out:
2192-
return rc;
2193-
}
2194-
2195-
static int
2196-
lpfc_debugfs_dumpDif_open(struct inode *inode, struct file *file)
2197-
{
2198-
struct lpfc_debug *debug;
2199-
int rc = -ENOMEM;
2200-
2201-
if (!_dump_buf_dif)
2202-
return -EBUSY;
2203-
2204-
debug = kmalloc(sizeof(*debug), GFP_KERNEL);
2205-
if (!debug)
2206-
goto out;
2207-
2208-
/* Round to page boundary */
2209-
pr_err("9060 BLKGRD: %s: _dump_buf_dif=x%px file=%pD\n",
2210-
__func__, _dump_buf_dif, file);
2211-
debug->buffer = _dump_buf_dif;
2212-
if (!debug->buffer) {
2213-
kfree(debug);
2214-
goto out;
2215-
}
2216-
2217-
debug->len = (1 << _dump_buf_dif_order) << PAGE_SHIFT;
2218-
file->private_data = debug;
2219-
2220-
rc = 0;
2221-
out:
2222-
return rc;
2223-
}
2224-
2225-
static ssize_t
2226-
lpfc_debugfs_dumpDataDif_write(struct file *file, const char __user *buf,
2227-
size_t nbytes, loff_t *ppos)
2228-
{
2229-
/*
2230-
* The Data/DIF buffers only save one failing IO
2231-
* The write op is used as a reset mechanism after an IO has
2232-
* already been saved to the next one can be saved
2233-
*/
2234-
spin_lock(&_dump_buf_lock);
2235-
2236-
memset((void *)_dump_buf_data, 0,
2237-
((1 << PAGE_SHIFT) << _dump_buf_data_order));
2238-
memset((void *)_dump_buf_dif, 0,
2239-
((1 << PAGE_SHIFT) << _dump_buf_dif_order));
2240-
2241-
_dump_buf_done = 0;
2242-
2243-
spin_unlock(&_dump_buf_lock);
2244-
2245-
return nbytes;
2246-
}
2247-
22482165
static ssize_t
22492166
lpfc_debugfs_dif_err_read(struct file *file, char __user *buf,
22502167
size_t nbytes, loff_t *ppos)
@@ -2457,17 +2374,6 @@ lpfc_debugfs_release(struct inode *inode, struct file *file)
24572374
return 0;
24582375
}
24592376

2460-
static int
2461-
lpfc_debugfs_dumpDataDif_release(struct inode *inode, struct file *file)
2462-
{
2463-
struct lpfc_debug *debug = file->private_data;
2464-
2465-
debug->buffer = NULL;
2466-
kfree(debug);
2467-
2468-
return 0;
2469-
}
2470-
24712377
/**
24722378
* lpfc_debugfs_multixripools_write - Clear multi-XRI pools statistics
24732379
* @file: The file pointer to read from.
@@ -5448,26 +5354,6 @@ static const struct file_operations lpfc_debugfs_op_cpucheck = {
54485354
.release = lpfc_debugfs_release,
54495355
};
54505356

5451-
#undef lpfc_debugfs_op_dumpData
5452-
static const struct file_operations lpfc_debugfs_op_dumpData = {
5453-
.owner = THIS_MODULE,
5454-
.open = lpfc_debugfs_dumpData_open,
5455-
.llseek = lpfc_debugfs_lseek,
5456-
.read = lpfc_debugfs_read,
5457-
.write = lpfc_debugfs_dumpDataDif_write,
5458-
.release = lpfc_debugfs_dumpDataDif_release,
5459-
};
5460-
5461-
#undef lpfc_debugfs_op_dumpDif
5462-
static const struct file_operations lpfc_debugfs_op_dumpDif = {
5463-
.owner = THIS_MODULE,
5464-
.open = lpfc_debugfs_dumpDif_open,
5465-
.llseek = lpfc_debugfs_lseek,
5466-
.read = lpfc_debugfs_read,
5467-
.write = lpfc_debugfs_dumpDataDif_write,
5468-
.release = lpfc_debugfs_dumpDataDif_release,
5469-
};
5470-
54715357
#undef lpfc_debugfs_op_dif_err
54725358
static const struct file_operations lpfc_debugfs_op_dif_err = {
54735359
.owner = THIS_MODULE,
@@ -5864,20 +5750,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
58645750
} else
58655751
phba->debug_dumpHostSlim = NULL;
58665752

5867-
/* Setup dumpData */
5868-
snprintf(name, sizeof(name), "dumpData");
5869-
phba->debug_dumpData =
5870-
debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
5871-
phba->hba_debugfs_root,
5872-
phba, &lpfc_debugfs_op_dumpData);
5873-
5874-
/* Setup dumpDif */
5875-
snprintf(name, sizeof(name), "dumpDif");
5876-
phba->debug_dumpDif =
5877-
debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
5878-
phba->hba_debugfs_root,
5879-
phba, &lpfc_debugfs_op_dumpDif);
5880-
58815753
/* Setup DIF Error Injections */
58825754
snprintf(name, sizeof(name), "InjErrLBA");
58835755
phba->debug_InjErrLBA =
@@ -6255,12 +6127,6 @@ lpfc_debugfs_terminate(struct lpfc_vport *vport)
62556127
debugfs_remove(phba->debug_dumpHostSlim); /* HostSlim */
62566128
phba->debug_dumpHostSlim = NULL;
62576129

6258-
debugfs_remove(phba->debug_dumpData); /* dumpData */
6259-
phba->debug_dumpData = NULL;
6260-
6261-
debugfs_remove(phba->debug_dumpDif); /* dumpDif */
6262-
phba->debug_dumpDif = NULL;
6263-
62646130
debugfs_remove(phba->debug_InjErrLBA); /* InjErrLBA */
62656131
phba->debug_InjErrLBA = NULL;
62666132

drivers/scsi/lpfc/lpfc_init.c

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@
6666
#include "lpfc_version.h"
6767
#include "lpfc_ids.h"
6868

69-
char *_dump_buf_data;
70-
unsigned long _dump_buf_data_order;
71-
char *_dump_buf_dif;
72-
unsigned long _dump_buf_dif_order;
73-
spinlock_t _dump_buf_lock;
74-
7569
/* Used when mapping IRQ vectors in a driver centric manner */
7670
static uint32_t lpfc_present_cpu;
7771

@@ -7617,7 +7611,6 @@ lpfc_setup_bg(struct lpfc_hba *phba, struct Scsi_Host *shost)
76177611
uint32_t old_mask;
76187612
uint32_t old_guard;
76197613

7620-
int pagecnt = 10;
76217614
if (phba->cfg_prot_mask && phba->cfg_prot_guard) {
76227615
lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
76237616
"1478 Registering BlockGuard with the "
@@ -7654,56 +7647,6 @@ lpfc_setup_bg(struct lpfc_hba *phba, struct Scsi_Host *shost)
76547647
"layer, Bad protection parameters: %d %d\n",
76557648
old_mask, old_guard);
76567649
}
7657-
7658-
if (!_dump_buf_data) {
7659-
while (pagecnt) {
7660-
spin_lock_init(&_dump_buf_lock);
7661-
_dump_buf_data =
7662-
(char *) __get_free_pages(GFP_KERNEL, pagecnt);
7663-
if (_dump_buf_data) {
7664-
lpfc_printf_log(phba, KERN_ERR, LOG_BG,
7665-
"9043 BLKGRD: allocated %d pages for "
7666-
"_dump_buf_data at x%px\n",
7667-
(1 << pagecnt), _dump_buf_data);
7668-
_dump_buf_data_order = pagecnt;
7669-
memset(_dump_buf_data, 0,
7670-
((1 << PAGE_SHIFT) << pagecnt));
7671-
break;
7672-
} else
7673-
--pagecnt;
7674-
}
7675-
if (!_dump_buf_data_order)
7676-
lpfc_printf_log(phba, KERN_ERR, LOG_BG,
7677-
"9044 BLKGRD: ERROR unable to allocate "
7678-
"memory for hexdump\n");
7679-
} else
7680-
lpfc_printf_log(phba, KERN_ERR, LOG_BG,
7681-
"9045 BLKGRD: already allocated _dump_buf_data=x%px"
7682-
"\n", _dump_buf_data);
7683-
if (!_dump_buf_dif) {
7684-
while (pagecnt) {
7685-
_dump_buf_dif =
7686-
(char *) __get_free_pages(GFP_KERNEL, pagecnt);
7687-
if (_dump_buf_dif) {
7688-
lpfc_printf_log(phba, KERN_ERR, LOG_BG,
7689-
"9046 BLKGRD: allocated %d pages for "
7690-
"_dump_buf_dif at x%px\n",
7691-
(1 << pagecnt), _dump_buf_dif);
7692-
_dump_buf_dif_order = pagecnt;
7693-
memset(_dump_buf_dif, 0,
7694-
((1 << PAGE_SHIFT) << pagecnt));
7695-
break;
7696-
} else
7697-
--pagecnt;
7698-
}
7699-
if (!_dump_buf_dif_order)
7700-
lpfc_printf_log(phba, KERN_ERR, LOG_BG,
7701-
"9047 BLKGRD: ERROR unable to allocate "
7702-
"memory for hexdump\n");
7703-
} else
7704-
lpfc_printf_log(phba, KERN_ERR, LOG_BG,
7705-
"9048 BLKGRD: already allocated _dump_buf_dif=x%px\n",
7706-
_dump_buf_dif);
77077650
}
77087651

77097652
/**
@@ -13511,19 +13454,6 @@ lpfc_exit(void)
1351113454
pci_unregister_driver(&lpfc_driver);
1351213455
fc_release_transport(lpfc_transport_template);
1351313456
fc_release_transport(lpfc_vport_transport_template);
13514-
if (_dump_buf_data) {
13515-
printk(KERN_ERR "9062 BLKGRD: freeing %lu pages for "
13516-
"_dump_buf_data at x%px\n",
13517-
(1L << _dump_buf_data_order), _dump_buf_data);
13518-
free_pages((unsigned long)_dump_buf_data, _dump_buf_data_order);
13519-
}
13520-
13521-
if (_dump_buf_dif) {
13522-
printk(KERN_ERR "9049 BLKGRD: freeing %lu pages for "
13523-
"_dump_buf_dif at x%px\n",
13524-
(1L << _dump_buf_dif_order), _dump_buf_dif);
13525-
free_pages((unsigned long)_dump_buf_dif, _dump_buf_dif_order);
13526-
}
1352713457
idr_destroy(&lpfc_hba_index);
1352813458
}
1352913459

drivers/scsi/lpfc/lpfc_scsi.c

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@
5353
#define LPFC_RESET_WAIT 2
5454
#define LPFC_ABORT_WAIT 2
5555

56-
int _dump_buf_done = 1;
57-
5856
static char *dif_op_str[] = {
5957
"PROT_NORMAL",
6058
"PROT_READ_INSERT",
@@ -89,63 +87,6 @@ lpfc_release_scsi_buf_s3(struct lpfc_hba *phba, struct lpfc_io_buf *psb);
8987
static int
9088
lpfc_prot_group_type(struct lpfc_hba *phba, struct scsi_cmnd *sc);
9189

92-
static void
93-
lpfc_debug_save_data(struct lpfc_hba *phba, struct scsi_cmnd *cmnd)
94-
{
95-
void *src, *dst;
96-
struct scatterlist *sgde = scsi_sglist(cmnd);
97-
98-
if (!_dump_buf_data) {
99-
lpfc_printf_log(phba, KERN_ERR, LOG_BG,
100-
"9050 BLKGRD: ERROR %s _dump_buf_data is NULL\n",
101-
__func__);
102-
return;
103-
}
104-
105-
106-
if (!sgde) {
107-
lpfc_printf_log(phba, KERN_ERR, LOG_BG,
108-
"9051 BLKGRD: ERROR: data scatterlist is null\n");
109-
return;
110-
}
111-
112-
dst = (void *) _dump_buf_data;
113-
while (sgde) {
114-
src = sg_virt(sgde);
115-
memcpy(dst, src, sgde->length);
116-
dst += sgde->length;
117-
sgde = sg_next(sgde);
118-
}
119-
}
120-
121-
static void
122-
lpfc_debug_save_dif(struct lpfc_hba *phba, struct scsi_cmnd *cmnd)
123-
{
124-
void *src, *dst;
125-
struct scatterlist *sgde = scsi_prot_sglist(cmnd);
126-
127-
if (!_dump_buf_dif) {
128-
lpfc_printf_log(phba, KERN_ERR, LOG_BG,
129-
"9052 BLKGRD: ERROR %s _dump_buf_data is NULL\n",
130-
__func__);
131-
return;
132-
}
133-
134-
if (!sgde) {
135-
lpfc_printf_log(phba, KERN_ERR, LOG_BG,
136-
"9053 BLKGRD: ERROR: prot scatterlist is null\n");
137-
return;
138-
}
139-
140-
dst = _dump_buf_dif;
141-
while (sgde) {
142-
src = sg_virt(sgde);
143-
memcpy(dst, src, sgde->length);
144-
dst += sgde->length;
145-
sgde = sg_next(sgde);
146-
}
147-
}
148-
14990
static inline unsigned
15091
lpfc_cmd_blksize(struct scsi_cmnd *sc)
15192
{
@@ -2962,26 +2903,6 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,
29622903
uint32_t bgstat = bgf->bgstat;
29632904
uint64_t failing_sector = 0;
29642905

2965-
spin_lock(&_dump_buf_lock);
2966-
if (!_dump_buf_done) {
2967-
lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9070 BLKGRD: Saving"
2968-
" Data for %u blocks to debugfs\n",
2969-
(cmd->cmnd[7] << 8 | cmd->cmnd[8]));
2970-
lpfc_debug_save_data(phba, cmd);
2971-
2972-
/* If we have a prot sgl, save the DIF buffer */
2973-
if (lpfc_prot_group_type(phba, cmd) ==
2974-
LPFC_PG_TYPE_DIF_BUF) {
2975-
lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9071 BLKGRD: "
2976-
"Saving DIF for %u blocks to debugfs\n",
2977-
(cmd->cmnd[7] << 8 | cmd->cmnd[8]));
2978-
lpfc_debug_save_dif(phba, cmd);
2979-
}
2980-
2981-
_dump_buf_done = 1;
2982-
}
2983-
spin_unlock(&_dump_buf_lock);
2984-
29852906
if (lpfc_bgs_get_invalid_prof(bgstat)) {
29862907
cmd->result = DID_ERROR << 16;
29872908
lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,

0 commit comments

Comments
 (0)