Received: by 10.213.65.68 with SMTP id h4csp2114044imn; Sun, 8 Apr 2018 20:04:11 -0700 (PDT) X-Google-Smtp-Source: AIpwx48AGpFgzt8SxSdEYgDGg1va7X8SP7ThVEv7qfo4op1iyfumaVlPrUxfUmJPEbkfRgqDyMy9 X-Received: by 2002:a17:902:52a4:: with SMTP id a33-v6mr29952449pli.371.1523243051341; Sun, 08 Apr 2018 20:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243051; cv=none; d=google.com; s=arc-20160816; b=ei/HxvuHnHeTjhn+D3LosCw4OiA8Xy9ltmEWFghOv1OqLDtYhbmTu9AT7NIZC7caLb vCKclpKRqDM4isIr0GH002D9ccobN2DGpT1cEOWn6PzxJqsa/RbI8t5FTuO0CCWsKEAo pzcbQOO3CXt3LqJyFPizG7SnWXbbRke//6HxoImLFdD+sadaYAJIct2JDCjperC2kIMv T/9ZMwVLZEdPsNlBR5dcdyajLi6lmH+gkE2RHM4tU9KqCbG60n5Kxzj6JWOeWivZyfjE 6JKsJLW5zZzaSq097uIazZngdzw3WTp0HK/isq1Ua3hcClrnEuKumhS5heTVbQO3RBvc vIjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=e/ycNec9WR78R6m2BR7mOkHDCtpJ9ibZhqF/dABRlEw=; b=w3rRZxTKwPrMJZ7mqoMKJ2EFlvSYsMEcOCM5b+v8kbEYGw1GOn3N9NA1Hkzn9QxP07 v0sxh1KY0N8/Ff2V4+BUtcBbYgkv8KC18+AKSW7NufE+K2YaOR9tK3CrV3Hs9DMzICa1 8XlQXsbhAxcWon+6sI9kjlpkcqQmOGqYfb/OumIMWPHG/YEfuEf00Gu73iYMksYiMeYa YWDJ6yAqLIhIQqzuGV4L26XvTzm+0waUd7L/4JOIKbjETIM/Owwn1J3+s3DFt6GoXZPM hL947vvoW0rCuScLi9vv/Kj7GkDXUD+TTOhLtkNhUmc7+AZ4dwijb0Rvtmc774911Q0r UUxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=KcKxNHE3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n20si10844299pgc.508.2018.04.08.20.03.34; Sun, 08 Apr 2018 20:04:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=KcKxNHE3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756450AbeDIAcM (ORCPT + 99 others); Sun, 8 Apr 2018 20:32:12 -0400 Received: from mail-sn1nam01on0103.outbound.protection.outlook.com ([104.47.32.103]:45281 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756399AbeDIAcF (ORCPT ); Sun, 8 Apr 2018 20:32:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=e/ycNec9WR78R6m2BR7mOkHDCtpJ9ibZhqF/dABRlEw=; b=KcKxNHE3uUBOBTemxzPb14vG9VHTgqeEeIGyTzUKQyj1tplZlg3o+07jQooAN2ZOrO1zJTrTW3utKeDPD8bOlGSxwfWLXHi3D6Ap1TZH+00yqDSiodI0SyeG/qhAnC26LRMUM/g2qkoL8Y77chaCUsUDDouWkl9yIVHWdqjTTpQ= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0870.namprd21.prod.outlook.com (10.167.110.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:32:03 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:32:03 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Tonghao Zhang , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 193/293] datapath: Avoid using stack larger than 1024. Thread-Topic: [PATCH AUTOSEL for 4.9 193/293] datapath: Avoid using stack larger than 1024. Thread-Index: AQHTz5lAVgk+Bjjoc0a99Wq/wyO3+g== Date: Mon, 9 Apr 2018 00:25:25 +0000 Message-ID: <20180409002239.163177-193-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0870;7:4odaGhUN8gUHzCkxYRfn2TaioL1RbPistvfCTrAYPyr+GlHcVCY6RuJLlJYX5lq9k9MMs5+9XOUjpTpnBpTK/o9k997f/K/W08umtZEftTy0M9LZuU6789C2go0nbiUAhUkj/NxXS6m876RY4ZdsMT70Cb+Ur3Z4z71MPV59ztGM4SVvBzlIuFwcG+VvhYcezOqad8Y6t/1Aq8XScvYdzFlxRChPTKHE3euSlnnYUX1k6T5tQ+f6H6rUH0g3PhxA;20:b5t2yjP6ISAY4HcN+u0XItthRCiLFuuZ23lnyPcBNLHdtl6hHJENLBBNDXsvSse5cKNDOiIOops22QjSFbogQ+Zbt6fm1e+RPoduidMVlwALo2V1BfoyMjLW8OEVxs6gj5+74RTCqNFxHK9Y709zJ0nBv84kHGFODHBZB/8dDw8= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 9e5b63e7-0f04-4084-9723-08d59db150fa x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0870; x-ms-traffictypediagnostic: DM5PR2101MB0870: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(85827821059158); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(3231221)(944501327)(52105095)(93006095)(93001095)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB0870;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0870; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(366004)(396003)(39380400002)(376002)(199004)(189003)(53936002)(2906002)(6512007)(102836004)(2616005)(76176011)(14454004)(446003)(10090500001)(11346002)(476003)(39060400002)(486006)(107886003)(59450400001)(2900100001)(97736004)(66066001)(6506007)(6436002)(106356001)(99286004)(105586002)(3660700001)(6116002)(86612001)(3280700002)(6666003)(2501003)(10290500003)(26005)(8676002)(8936002)(478600001)(68736007)(5250100002)(5660300001)(316002)(4326008)(72206003)(186003)(110136005)(6486002)(7736002)(25786009)(3846002)(86362001)(36756003)(22452003)(81156014)(81166006)(305945005)(54906003)(1076002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0870;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: TrC8bClFJdX5kzBWKrqCQR7hO4Gr/ndzhv4zlfB4h0ikkJwQJXwf1yP+fAS+LSvpgHnhv7PH812kCIG/npIWpoDlHGfXEiVGFqIkoJxJwbP3SCWnLymrGvXMUq+GTeyiq1zDUyWShMsaPdCoC1fuNIyQR0DKDoPw00u4WhE7Gzcd2ZW8pe6RB+iEjy8rr8hwdGe7uGsodi7vLQhkDZoLivbio5ZHBHHi4wzZ8/ykPbQPS/x/vHONfSv+2XJYJUjxo80ExytKBqIYss+IDgkagq2qniCFIC5/Wmjp6SNN6vkRlPqqpWQC/yTMQMmjiIeaUBBwixiWeZJ3sVivEZl2+LXiDcOz7jgM1hcyxvhrQ2XJon9aDesgsKvYfefonmtnYSHo+7vWKHs9GjEyYOxmSAoAxeL2wp4bVAVIyIZyJ8Q= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9e5b63e7-0f04-4084-9723-08d59db150fa X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:25:25.2064 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0870 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tonghao Zhang [ Upstream commit 9cc9a5cb176ccb4f2cda5ac34da5a659926f125f ] When compiling OvS-master on 4.4.0-81 kernel, there is a warning: CC [M] /root/ovs/datapath/linux/datapath.o /root/ovs/datapath/linux/datapath.c: In function 'ovs_flow_cmd_set': /root/ovs/datapath/linux/datapath.c:1221:1: warning: the frame size of 1040 bytes is larger than 1024 bytes [-Wframe-larger-than=3D] This patch factors out match-init and action-copy to avoid "Wframe-larger-than=3D1024" warning. Because mask is only used to get actions, we new a function to save some stack space. Signed-off-by: Tonghao Zhang Acked-by: Pravin B Shelar Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/openvswitch/datapath.c | 81 +++++++++++++++++++++++++++++++++---------= ---- 1 file changed, 58 insertions(+), 23 deletions(-) diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index 453f806afe6e..0f594140c5ff 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c @@ -1105,6 +1105,58 @@ static struct sw_flow_actions *get_flow_actions(stru= ct net *net, return acts; } =20 +/* Factor out match-init and action-copy to avoid + * "Wframe-larger-than=3D1024" warning. Because mask is only + * used to get actions, we new a function to save some + * stack space. + * + * If there are not key and action attrs, we return 0 + * directly. In the case, the caller will also not use the + * match as before. If there is action attr, we try to get + * actions and save them to *acts. Before returning from + * the function, we reset the match->mask pointer. Because + * we should not to return match object with dangling reference + * to mask. + * */ +static int ovs_nla_init_match_and_action(struct net *net, + struct sw_flow_match *match, + struct sw_flow_key *key, + struct nlattr **a, + struct sw_flow_actions **acts, + bool log) +{ + struct sw_flow_mask mask; + int error =3D 0; + + if (a[OVS_FLOW_ATTR_KEY]) { + ovs_match_init(match, key, true, &mask); + error =3D ovs_nla_get_match(net, match, a[OVS_FLOW_ATTR_KEY], + a[OVS_FLOW_ATTR_MASK], log); + if (error) + goto error; + } + + if (a[OVS_FLOW_ATTR_ACTIONS]) { + if (!a[OVS_FLOW_ATTR_KEY]) { + OVS_NLERR(log, + "Flow key attribute not present in set flow."); + return -EINVAL; + } + + *acts =3D get_flow_actions(net, a[OVS_FLOW_ATTR_ACTIONS], key, + &mask, log); + if (IS_ERR(*acts)) { + error =3D PTR_ERR(*acts); + goto error; + } + } + + /* On success, error is 0. */ +error: + match->mask =3D NULL; + return error; +} + static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info) { struct net *net =3D sock_net(skb->sk); @@ -1112,7 +1164,6 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, stru= ct genl_info *info) struct ovs_header *ovs_header =3D info->userhdr; struct sw_flow_key key; struct sw_flow *flow; - struct sw_flow_mask mask; struct sk_buff *reply =3D NULL; struct datapath *dp; struct sw_flow_actions *old_acts =3D NULL, *acts =3D NULL; @@ -1124,34 +1175,18 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, st= ruct genl_info *info) bool ufid_present; =20 ufid_present =3D ovs_nla_get_ufid(&sfid, a[OVS_FLOW_ATTR_UFID], log); - if (a[OVS_FLOW_ATTR_KEY]) { - ovs_match_init(&match, &key, true, &mask); - error =3D ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY], - a[OVS_FLOW_ATTR_MASK], log); - } else if (!ufid_present) { + if (!a[OVS_FLOW_ATTR_KEY] && !ufid_present) { OVS_NLERR(log, "Flow set message rejected, Key attribute missing."); - error =3D -EINVAL; + return -EINVAL; } + + error =3D ovs_nla_init_match_and_action(net, &match, &key, a, + &acts, log); if (error) goto error; =20 - /* Validate actions. */ - if (a[OVS_FLOW_ATTR_ACTIONS]) { - if (!a[OVS_FLOW_ATTR_KEY]) { - OVS_NLERR(log, - "Flow key attribute not present in set flow."); - error =3D -EINVAL; - goto error; - } - - acts =3D get_flow_actions(net, a[OVS_FLOW_ATTR_ACTIONS], &key, - &mask, log); - if (IS_ERR(acts)) { - error =3D PTR_ERR(acts); - goto error; - } - + if (acts) { /* Can allocate before locking if have acts. */ reply =3D ovs_flow_cmd_alloc_info(acts, &sfid, info, false, ufid_flags); --=20 2.15.1