hfi1/rdmavt: For 4.8 rc
Subsystems (3)
cover hfi1/rdmavt: For 4.8 rc
Doug,
Here are four patches that we'd like to get into the rc cycle.
These apply on top of the last set of patches Ira sent (including the v2 of [1]).
[1] http://marc.info/?l=linux-rdma&m=147116491910005&w=2
Patches can also be viewed in my repo at:
https://github.com/ddalessa/kernel/tree/for-4.8
---
Easwar Hariharan (1):
IB/hfi1: Return invalid field for non-QSFP CableInfo queries
Ira Weiny (1):
IB/hfi1: Fix mm_struct use after free
Mike Marciniszyn (1):
IB/rdmvat: Fix double vfree() in rvt_create_qp() error path
Mitko Haralanov (1):
IB/hfi1: Improve J_KEY generation
drivers/infiniband/hw/hfi1/file_ops.c | 2 ++ drivers/infiniband/hw/hfi1/hfi.h | 19 ++++++++++++++++++- drivers/infiniband/hw/hfi1/mad.c | 5 +++++ drivers/infiniband/sw/rdmavt/qp.c | 3 ++- 4 files changed, 27 insertions(+), 2 deletions(-)
--
-Denny
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20160816202133.24004.31487.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org
PATCH 1/4 IB/hfi1: Return invalid field for non-QSFP CableInfo queries
From: Easwar Hariharan <[email protected]>
The driver does not check if the CableInfo query is supported for the port type. Return early if CableInfo is not supported for the port type, making compliance with the specification explicit and preventing lower level code from potentially doing the wrong thing if the query is not supported for the hardware implementation.
--- drivers/infiniband/hw/hfi1/mad.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/infiniband/hw/hfi1/mad.c +5 -0
@@ -1819,6 +1819,11 @@ static int __subn_get_opa_cable_info(struct opa_smp *smp, u32 am, u8 *data,u32 len =OPA_AM_CI_LEN (am) +1 ;int ret; +if (dd->pport->port_type !=PORT_TYPE_QSFP ) { + smp->status |=IB_SMP_INVALID_FIELD ; +return reply ((struct ib_mad_hdr *)smp); + } +#define __CI_PAGE_SIZE BIT(7)/* 128 bytes */ #define __CI_PAGE_MASK ~(__CI_PAGE_SIZE - 1)#define __CI_PAGE_NUM (a) ((a) & __CI_PAGE_MASK)
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/4 IB/hfi1: Improve J_KEY generation
In reply to a message not in the archiveFrom: Mitko Haralanov <[email protected]>
Previously, J_KEY generation was based on the lower 16 bits of the user's UID. While this works, it was not good enough as a non-root user could collide with a root user given a sufficiently large UID.
This patch attempt to improve the J_KEY generation by using the following algorithm:
The 16 bit J_KEY space is partitioned into 3 separate spaces reserved for different user classes:
* all users with administtor privileges (including 'root') will use J_KEYs in the range of 0 to 31,
* all kernel protocols, which use KDETH packets will use J_KEYs in the range of 32 to 63, and
* all other users will use J_KEYs in the range of 64 to
65535.
The above separation is aimed at preventing different user levels from sending packets to each other and, additionally, separate kernel protocols from all other types of users. The later is meant to prevent the potential corruption of kernel memory by any other type of user.
--- drivers/infiniband/hw/hfi1/hfi.h | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-)
drivers/infiniband/hw/hfi1/hfi.h +18 -1
@@ -1272,9 +1272,26 @@ static inline int hdr2sc(struct hfi1_message_header *hdr, u64 rhf) ((!!(rhf_dc_info (rhf))) <<4 ); } +#define HFI1_JKEY_WIDTH 16 +#define HFI1_JKEY_MASK (BIT(16) - 1) +#define HFI1_ADMIN_JKEY_RANGE 32 + +/* +* J_KEYs are split and allocated in the following groups: +* 0 - 31 - users with administrator privileges +* 32 - 63 - kernel protocols using KDETH packets +* 64 - 65535 - all other users using KDETH packets +*/ static inline u16 generate_jkey (kuid_t uid) { -return from_kuid (current_user_ns (), uid) &0xffff ; +u16 jkey =from_kuid (current_user_ns (), uid) &HFI1_JKEY_MASK ; + +if (capable (CAP_SYS_ADMIN )) + jkey &=HFI1_ADMIN_JKEY_RANGE -1 ; +else if (jkey <64 ) + jkey |=BIT (HFI1_JKEY_WIDTH -1 ); + +return jkey; }/*
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/4 IB/rdmvat: Fix double vfree() in rvt_create_qp() error path
In reply to a message not in the archiveFrom: Mike Marciniszyn <[email protected]>
The unwind logic for creating a user QP has a double vfree of the non-shared receive queue when handling a "too many qps" failure.
The code unwinds the mmmap info by decrementing a reference count which will call rvt_release_mmap_info() which in turn does the vfree() of the r_rq.wq. The unwind code then does the same free.
Fix by guarding the vfree() with the same test that is done in close and only do the vfree() if qp->ip is NULL.
--- drivers/infiniband/sw/rdmavt/qp.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/infiniband/sw/rdmavt/qp.c +2 -1
@@ -873,7 +873,8 @@ bail_qpn:free_qpn (&rdi->qp_dev->qpn_table, qp->ibqp.qp_num); bail_rq_wq: -vfree (qp->r_rq.wq); +if (!qp->ip) +vfree (qp->r_rq.wq); bail_driver_priv: rdi->driver_f.qp_priv_free (rdi, qp);
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 4/4 IB/hfi1: Fix mm_struct use after free
In reply to a message not in the archiveFrom: Ira Weiny <[email protected]>
Testing with CONFIG_SLUB_DEBUG_ON=y resulted in the kernel panic below.
This is the result of the mm_struct sometimes being free'd prior to hfi1_file_close being called.
This was due to the combination of 2 reasons:
1) hfi1_file_close is deferred in process exit and it therefore may not be called synchronously with process exit.
2) exit_mm is called prior to exit_files in do_exit. Normally this is ok however, our kernel bypass code requires us to have access to the mm_struct for house keeping both at "normal" close time as well as at process exit.
Therefore, the fix is to simply keep a reference to the mm_struct until we are done with it.
[ 3006.340150] general protection fault: 0000 [#1] SMP [ 3006.346469] Modules linked in: hfi1 rdmavt rpcrdma ib_isert iscsi_target_mod
ib_iser libiscsi scsi_transport_iscsi ib_srpt target_core_mod
ib_srp scsi_transport_srp ib_ipoib rdma_ucm ib_ucm ib_uverbs ib_umad rdma_cm ib_cm iw_cm dm_mirror dm_region_hash dm_log dm_mod snd_hda_code c_realtek iTCO_wdt snd_hda_codec_generic iTCO_vendor_support sb_edac edac_core x86_pkg_temp_thermal intel_powerclamp coretemp kvm irqbypass c rct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel lrw snd_hda_intel gf128mul snd_hda_codec glue_helper snd_hda_core ablk_helper sn d_hwdep cryptd snd_seq snd_seq_device snd_pcm snd_timer snd soundcore pcspkr shpchp mei_me sg lpc_ich mei i2c_i801 mfd_core ioatdma ipmi_devi ntf wmi ipmi_si ipmi_msghandler acpi_cpufreq nfsd auth_rpcgss nfs_acl lockd grace sunrpc ip_tables ext4 jbd2 mbcache mlx4_en ib_core sr_mod s d_mod cdrom crc32c_intel mgag200 drm_kms_helper syscopyarea sysfillrect igb sysimgblt fb_sys_fops ptp mlx4_core ttm isci pps_core ahci drm li bsas libahci dca firewire_ohci i2c_algo_bit scsi_transport_sas firewire_core crc_itu_t i2c_core libata [last unloaded: mlx4_ib]
[ 3006.461759] CPU: 16 PID: 11624 Comm: mpi_stress Not tainted 4.7.0-rc5+ #1 [ 3006.469915] Hardware name: Intel Corporation W2600CR ........../W2600CR, BIOS SE5C600.86B.01.08.0003.022620131521 02/26/2013 [ 3006.483027] task: ffff8804102f0040 ti: ffff8804102f8000 task.ti: ffff8804102f8000 [ 3006.491971] RIP: 0010:[<ffffffff810f0383>] [<ffffffff810f0383>] __lock_acquire+0xb3/0x19e0 [ 3006.501905] RSP: 0018:ffff8804102fb908 EFLAGS: 00010002 [ 3006.508447] RAX: 6b6b6b6b6b6b6b6b RBX: 0000000000000001 RCX: 0000000000000000 [ 3006.517012] RDX: 0000000000000001 RSI: 0000000000000000 RDI: ffff880410b56a40 [ 3006.525569] RBP: ffff8804102fb9b0 R08: 0000000000000001 R09: 0000000000000000 [ 3006.534119] R10: ffff8804102f0040 R11: 0000000000000000 R12: 0000000000000000 [ 3006.542664] R13: ffff880410b56a40 R14: 0000000000000000 R15: 0000000000000000 [ 3006.551203] FS: 00007ff478c08700(0000) GS:ffff88042e200000(0000) knlGS:0000000000000000 [ 3006.560814] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 3006.567806] CR2: 00007f667f5109e0 CR3: 0000000001c06000 CR4: 00000000000406e0 [ 3006.576352] Stack: [ 3006.579157] ffffffff8124b819 ffffffffffffffff 0000000000000000 ffff8804102fb940 [ 3006.588072] 0000000000000002 0000000000000000 ffff8804102f0040 0000000000000007 [ 3006.596971] 0000000000000006 ffff8803cad6f000 0000000000000000 ffff8804102f0040 [ 3006.605878] Call Trace: [ 3006.609220] [<ffffffff8124b819>] ? uncharge_batch+0x109/0x250 [ 3006.616382] [<ffffffff810f2313>] lock_acquire+0xd3/0x220 [ 3006.623056] [<ffffffffa0a30bfc>] ? hfi1_release_user_pages+0x7c/0xa0 [hfi1] [ 3006.631593] [<ffffffff81775579>] down_write+0x49/0x80 [ 3006.638022] [<ffffffffa0a30bfc>] ? hfi1_release_user_pages+0x7c/0xa0 [hfi1] [ 3006.646569] [<ffffffffa0a30bfc>] hfi1_release_user_pages+0x7c/0xa0 [hfi1] [ 3006.654898] [<ffffffffa0a2efb6>] cacheless_tid_rb_remove+0x106/0x330 [hfi1] [ 3006.663417] [<ffffffff810efd36>] ? mark_held_locks+0x66/0x90 [ 3006.670498] [<ffffffff817771f6>] ? _raw_spin_unlock_irqrestore+0x36/0x60 [ 3006.678741] [<ffffffffa0a2f1ee>] tid_rb_remove+0xe/0x10 [hfi1] [ 3006.686010] [<ffffffffa0a0c5d5>] hfi1_mmu_rb_unregister+0xc5/0x100 [hfi1] [ 3006.694387] [<ffffffffa0a2fcb9>] hfi1_user_exp_rcv_free+0x39/0x120 [hfi1] [ 3006.702732] [<ffffffffa09fc6ea>] hfi1_file_close+0x17a/0x330 [hfi1] [ 3006.710489] [<ffffffff81263e9a>] __fput+0xfa/0x230 [ 3006.716595] [<ffffffff8126400e>] ____fput+0xe/0x10 [ 3006.722696] [<ffffffff810b95c6>] task_work_run+0x86/0xc0 [ 3006.729379] [<ffffffff81099933>] do_exit+0x323/0xc40 [ 3006.735672] [<ffffffff8109a2dc>] do_group_exit+0x4c/0xc0 [ 3006.742371] [<ffffffff810a7f55>] get_signal+0x345/0x940 [ 3006.748958] [<ffffffff810340c7>] do_signal+0x37/0x700 [ 3006.755328] [<ffffffff8127872a>] ? poll_select_set_timeout+0x5a/0x90 [ 3006.763146] [<ffffffff811609cb>] ? __audit_syscall_exit+0x1db/0x260 [ 3006.770853] [<ffffffff8110f3e3>] ? rcu_read_lock_sched_held+0x93/0xa0 [ 3006.778765] [<ffffffff812347a4>] ? kfree+0x1e4/0x2a0 [ 3006.784986] [<ffffffff8108e75a>] ? exit_to_usermode_loop+0x33/0xac [ 3006.792551] [<ffffffff8108e785>] exit_to_usermode_loop+0x5e/0xac [ 3006.799907] [<ffffffff81003dca>] do_syscall_64+0x12a/0x190 [ 3006.806664] [<ffffffff81777a7f>] entry_SYSCALL64_slow_path+0x25/0x25 [ 3006.814396] Code: 24 08 44 89 44 24 10 89 4c 24 18 e8 a8 d8 ff ff 48 85 c0 8b 4c 24 18 44 8b 44 24 10 44 8b 4c 24 08 4c 8b 14 24 0f 84 30 08 00 00 <f0> ff 80 98 01 00 00 8b 3d 48 ad be 01 45 8b a2 90 0b 00 00 85 [ 3006.837158] RIP [<ffffffff810f0383>] __lock_acquire+0xb3/0x19e0 [ 3006.844401] RSP <ffff8804102fb908> [ 3006.851170] ---[ end trace b7b9f21cf06c27df ]--- [ 3006.927420] Kernel panic - not syncing: Fatal exception [ 3006.933954] Kernel Offset: disabled [ 3006.940961] ---[ end Kernel panic - not syncing: Fatal exception [ 3006.948249] ------------[ cut here ]------------
--- drivers/infiniband/hw/hfi1/file_ops.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/infiniband/hw/hfi1/file_ops.c +2 -0
@@ -183,6 +183,7 @@ static int hfi1_file_open(struct inode *inode, struct file *fp)if (fd) { fd->rec_cpu_num =-1 ;/* no cpu affinity by default */ fd->mm = current->mm; +atomic_inc (&fd->mm->mm_count); } fp->private_data = fd;
@@ -779,6 +780,7 @@ static int hfi1_file_close(struct inode *inode, struct file *fp)mutex_unlock (&hfi1_mutex);hfi1_free_ctxtdata (dd, uctxt); done: +mmdrop (fdata->mm);kobject_put (&dd->kobj);kfree (fdata);return 0 ;
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 27 lines · Dennis Dalessandro
Doug,
Here are four patches that we'd like to get into the rc cycle.
These apply on top of the last set of patches Ira sent (including the v2 of [1]).
[1] http://marc.info/?l=linux-rdma&m=147116491910005&w=2
Patches can also be viewed in my repo at:
https://github.com/ddalessa/kernel/tree/for-4.8---
Easwar Hariharan (1):
IB/hfi1: Return invalid field for non-QSFP CableInfo queriesIra Weiny (1):
IB/hfi1: Fixmm_structuse after freeMike Marciniszyn (1):
IB/rdmvat: Fix doublevfree()inrvt_create_qp()error pathMitko Haralanov (1):
IB/hfi1: ImproveJ_KEYgeneration
Quoted 9 lines
drivers/infiniband/hw/hfi1/file_ops.c | 2 ++ drivers/infiniband/hw/hfi1/hfi.h | 19 ++++++++++++++++++- drivers/infiniband/hw/hfi1/mad.c | 5 +++++ drivers/infiniband/sw/rdmavt/qp.c | 3 ++- 4 files changed, 27 insertions(+), 2 deletions(-)--
-Denny
Series applied, thanks.
Signature · 2 lines
Doug Ledford <[email protected]> GPG Key ID: 0E572FDD