Return-Path: Received: from mail-wi0-f172.google.com ([209.85.212.172]:36782 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753063AbbHTIwa (ORCPT ); Thu, 20 Aug 2015 04:52:30 -0400 Received: by wicja10 with SMTP id ja10so139403987wic.1 for ; Thu, 20 Aug 2015 01:52:29 -0700 (PDT) Subject: Re: [PATCH 1/3] IB/uverbs: reject invalid or unknown opcodes To: Christoph Hellwig , Doug Ledford , Sean Hefty , Hal Rosenstock , Eli Cohen References: <1440002254-795-1-git-send-email-hch@lst.de> <1440002254-795-2-git-send-email-hch@lst.de> Cc: linux-rdma@vger.kernel.org, stable@vger.kernel.org From: Sagi Grimberg Message-ID: <55D59553.4080306@dev.mellanox.co.il> Date: Thu, 20 Aug 2015 11:52:35 +0300 MIME-Version: 1.0 In-Reply-To: <1440002254-795-2-git-send-email-hch@lst.de> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org List-ID: On 8/19/2015 7:37 PM, Christoph Hellwig wrote: > We have many WR opcodes that are only supported in kernel space > and/or require optional information to be copied into the WR > structure. Reject all those not explicitly handled so that we > can't pass invalid information to drivers. > > Cc: stable@vger.kernel.org > Signed-off-by: Christoph Hellwig > --- > drivers/infiniband/core/uverbs_cmd.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c > index a15318a..f9f3921 100644 > --- a/drivers/infiniband/core/uverbs_cmd.c > +++ b/drivers/infiniband/core/uverbs_cmd.c > @@ -2372,6 +2372,12 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, > next->send_flags = user_wr->send_flags; > > if (is_ud) { > + if (next->opcode != IB_WR_SEND && > + next->opcode != IB_WR_SEND_WITH_IMM) { > + ret = -EINVAL; > + goto out_put; > + } > + > next->wr.ud.ah = idr_read_ah(user_wr->wr.ud.ah, > file->ucontext); > if (!next->wr.ud.ah) { > @@ -2413,7 +2419,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, > next->wr.atomic.rkey = user_wr->wr.atomic.rkey; > break; > default: > - break; > + ret = -EINVAL; > + goto out_put; > } > } > > Reviewed-by: Sagi Grimberg Haggai, can you also have a look?