From patchwork Wed Sep 11 15:10:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Or Gerlitz X-Patchwork-Id: 2873031 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 38302BF43F for ; Wed, 11 Sep 2013 15:10:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 94E962037D for ; Wed, 11 Sep 2013 15:10:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AE46120372 for ; Wed, 11 Sep 2013 15:10:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754093Ab3IKPKU (ORCPT ); Wed, 11 Sep 2013 11:10:20 -0400 Received: from eu1sys200aog123.obsmtp.com ([207.126.144.155]:50972 "EHLO eu1sys200aog123.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754078Ab3IKPKT (ORCPT ); Wed, 11 Sep 2013 11:10:19 -0400 Received: from mtrcas01.mtl.com ([193.47.165.214]) (using TLSv1) by eu1sys200aob123.postini.com ([207.126.147.11]) with SMTP ID DSNKUjCH0C7VJYFO/zLajjq2KsvveCPx/m9V@postini.com; Wed, 11 Sep 2013 15:10:19 UTC Received: from [10.223.8.25] (10.222.66.109) by mtrcas01.mtl.com (10.222.66.11) with Microsoft SMTP Server (TLS) id 14.3.123.3; Wed, 11 Sep 2013 18:10:06 +0300 Message-ID: <523087CE.4080007@mellanox.com> Date: Wed, 11 Sep 2013 18:10:06 +0300 From: Or Gerlitz User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: Yann Droneaud CC: Matan Barak , Roland Dreier , , Hadar Har-Zion , , , Subject: Re: [PATCH V4 for-next 3/4] IB/core: Export ib_create/destroy_flow through uverbs References: <1377694075-29287-1-git-send-email-matanb@mellanox.com> <1377694075-29287-4-git-send-email-matanb@mellanox.com> <1378908269.2258.31.camel@localhost.localdomain> In-Reply-To: <1378908269.2258.31.camel@localhost.localdomain> X-Originating-IP: [10.222.66.109] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 11/09/2013 17:04, Yann Droneaud wrote: [...] >> + int i; >> + int kern_attr_size; >> + >> + if (out_len < sizeof(resp)) >> + return -ENOSPC; >> + >> + if (copy_from_user(&cmd, buf, sizeof(cmd))) >> + return -EFAULT; >> + >> + if (cmd.comp_mask) >> + return -EINVAL; >> + >> + if ((cmd.flow_attr.type == IB_FLOW_ATTR_SNIFFER && >> + !capable(CAP_NET_ADMIN)) || !capable(CAP_NET_RAW)) >> + return -EPERM; >> + >> + if (cmd.flow_attr.num_of_specs < 0 || > num_of_specs is unsigned ... sure, will send fix that eliminates this redundant check > >> + cmd.flow_attr.num_of_specs > IB_FLOW_SPEC_SUPPORT_LAYERS) >> + return -EINVAL; >> + >> + kern_attr_size = cmd.flow_attr.size - sizeof(cmd) - >> + sizeof(struct ib_uverbs_cmd_hdr_ex); >> + > Please, no under/overflow. Check that cmd.flow_attr.size is bigger than > sizeof(cmd) + sizeof(struct ib_uverbs_cmd_hdr_ex) before computing kern_attr_size. We've got feedback on this code from Sean and Roland and Matan Barak from our team addressed it to the bit. Matan is OOO for couple of days, plus we're having few holidays here. This way or another (accepting the comments and sending fixes or arguing with you over the list), all your feedback will be addressed before 3.12-rc2 is out, thanks for looking over this! > >> + if (cmd.flow_attr.size < 0 || cmd.flow_attr.size > in_len || > just like num_of_specs, it's unsigned ! ditto here, will fix. [...] >> + struct ib_kern_spec_ipv4 ipv4; >> + struct ib_kern_spec_tcp_udp tcp_udp; >> + }; >> +}; >> + > [Aside note: no IPv6 spec ?] indeed, but note that the way the specs are defines allow for adding future spec types w.o breaking anything, its done in TLV (Type-Length-Value) manner, see the change log of the IB core main patch for flow steering 319a441 IB/core: Add receive flow steering support Or. --- 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/include/uapi/rdma/ib_user_verbs.h b/include/uapi/rdma/ib_user_verbs.h index 61535aa..0b233c5 100644 --- a/include/uapi/rdma/ib_user_verbs.h +++ b/include/uapi/rdma/ib_user_verbs.h @@ -86,7 +86,9 @@ enum { >> +struct ib_kern_spec { >> + union { >> + struct { >> + __u32 type; >> + __u16 size; >> + __u16 reserved; >> + }; >> + struct ib_kern_spec_eth eth;