From patchwork Wed Jul 25 10:40:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 1236211 X-Patchwork-Delegate: alexne@voltaire.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 726893FDFB for ; Wed, 25 Jul 2012 10:40:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756139Ab2GYKkJ (ORCPT ); Wed, 25 Jul 2012 06:40:09 -0400 Received: from mail-qa0-f53.google.com ([209.85.216.53]:40386 "EHLO mail-qa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755686Ab2GYKkI (ORCPT ); Wed, 25 Jul 2012 06:40:08 -0400 Received: by qaas11 with SMTP id s11so382652qaa.19 for ; Wed, 25 Jul 2012 03:40:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-forwarded-message-id:content-type :content-transfer-encoding:x-gm-message-state; bh=vd43/XENqQDrPvnFe66qE6hx7uO7cki7D13DKKkoYxY=; b=KhOt9BQUhZhsaiEJF4WQEZiRD2nXdM/P2Jk77FSuzAXEUoC3sep4tdVt1esJTAo1gr 2cVPX0tXNIhHQ5j1I8iHo48+M9B4m8upL5njDm8NjXP3Araa//h+XHksn0qdNiuYhO8s PhHDidpfdLX6tgFT/LWC/NeGGim6OcuobVMkFjI5BUY49p5DtPADbyEKsZJaEOeHl+un XrY00gx3NPzpQrhSmmigh82Fr6XTJiq+JKHuoh9QdLr4mFEYxdshUtgP3MwFzPseMfEN oSFcEpLf+uFbowIiJdm4jdzSl94fWF4nIOP2EZznZo60EUUDhyGBnveqfJ2fG4k2BQoK OmxQ== Received: by 10.229.137.148 with SMTP id w20mr10982381qct.24.1343212807826; Wed, 25 Jul 2012 03:40:07 -0700 (PDT) Received: from [192.168.1.102] (c-71-192-10-85.hsd1.ma.comcast.net. [71.192.10.85]) by mx.google.com with ESMTPS id g10sm9222811qae.12.2012.07.25.03.40.06 (version=SSLv3 cipher=OTHER); Wed, 25 Jul 2012 03:40:07 -0700 (PDT) Message-ID: <500FCD06.9090602@dev.mellanox.co.il> Date: Wed, 25 Jul 2012 06:40:06 -0400 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: Alex Netes CC: "linux-rdma (linux-rdma@vger.kernel.org)" Subject: [PATCHv3] opensm/osm_sa_informinfo.c: Add trusted support for InformInfo/InformInfoRecord References: <4FC635A6.5070804@dev.mellanox.co.il> In-Reply-To: <4FC635A6.5070804@dev.mellanox.co.il> X-Forwarded-Message-Id: <4FC635A6.5070804@dev.mellanox.co.il> X-Gm-Message-State: ALoCoQkB6YpkjczkMsJmBLyY66XYw6PX+xjLyLWHGI+VbuYIOhpASpTO67e3ji8wB40adIkZmPan Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org per C15-0.2-1.16 Compile tested only Signed-off-by: Hal Rosenstock --- Changes since v2: Removed error number change (now in separate patch) Change since v1: Rebased against latest upstream master -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/opensm/osm_sa_informinfo.c b/opensm/osm_sa_informinfo.c index e3f6ffa..772a293 100644 --- a/opensm/osm_sa_informinfo.c +++ b/opensm/osm_sa_informinfo.c @@ -74,6 +74,7 @@ typedef struct osm_iir_search_ctxt { ib_net16_t subscriber_enum; osm_sa_t *sa; osm_physp_t *p_req_physp; + ib_net64_t sm_key; } osm_iir_search_ctxt_t; /********************************************************************** @@ -291,6 +292,16 @@ static void sa_inform_info_rec_by_comp_mask(IN osm_sa_t * sa, memcpy(&p_rec_item->rec, &p_infr->inform_record, sizeof(ib_inform_info_record_t)); + + /* + * Per C15-0.2-1.16, InformInfoRecords shall always be + * provided with the QPN set to 0, except for the case + * of a trusted request, in which case the actual + * subscriber QPN shall be returned. + */ + if (p_ctxt->sm_key == 0) + ib_inform_info_set_qpn(&p_rec_item->rec.inform_info, 0); + cl_qlist_insert_tail(p_ctxt->p_list, &p_rec_item->list_item); Exit: @@ -349,6 +360,7 @@ static void infr_rcv_process_get_method(osm_sa_t * sa, IN osm_madw_t * p_madw) context.subscriber_enum = p_rcvd_rec->subscriber_enum; context.sa = sa; context.p_req_physp = p_req_physp; + context.sm_key = p_rcvd_mad->sm_key; OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Query Subscriber GID:%s(%02X) Enum:0x%X(%02X)\n", @@ -448,6 +460,24 @@ static void infr_rcv_process_set_method(osm_sa_t * sa, IN osm_madw_t * p_madw) } /* + * Per C15-0.2-1.16, SubnAdmSet(InformInfo) subscriptions for + * SM security traps shall be provided only if they come from a + * trusted source. + */ + if ((p_sa_mad->sm_key == 0) && p_recvd_inform_info->is_generic && + ((cl_ntoh16(p_recvd_inform_info->g_or_v.generic.trap_num) >= 256) && + (cl_ntoh16(p_recvd_inform_info->g_or_v.generic.trap_num) <= 259))) { + cl_plock_release(sa->p_lock); + + OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 430B " + "Request for security trap from non-trusted requester: " + "Given SM_Key:0x%016" PRIx64 "\n", + cl_ntoh64(p_sa_mad->sm_key)); + osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID); + goto Exit; + } + + /* * MODIFICATIONS DONE ON INCOMING REQUEST: * * QPN: