Received: by 10.223.185.116 with SMTP id b49csp5460850wrg; Wed, 7 Mar 2018 12:08:54 -0800 (PST) X-Google-Smtp-Source: AG47ELsXnEwmLFwnROl6cawN9VBWcltArhzesMcG2XFPTndIJxKUo/PKLG2GlrKVTsEylvNtzaLX X-Received: by 10.98.76.26 with SMTP id z26mr24036465pfa.220.1520453334776; Wed, 07 Mar 2018 12:08:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520453334; cv=none; d=google.com; s=arc-20160816; b=F4+LcDSWyrovLudDSeBLT4mimfBuw7RyUTXTXET6+lmnRwn/QfOvA5WYo0TtrnIcK9 GG2WNRSpRm5WQDwFWlb9YzeItnhY2uJ3JVbKFGMRakXrA0btyFyP5rb4eZDFuJT6lnRh M6HPeLUSIqUeHy6MDYcNbbdq6azSjafYYI/QCTqZ0o3Fqj+dTe2wUSKpaoPJHYysQL8w 9cGRNFNLFcFBKwiKBKYm/VGfTraEHD3mnUItAfp2MY7vUxM0UuTlTkvB0C2LreHS/ZQH a9KRg5RYMt8cXc6yjPqZqgvn84KkJg+//MNzFr25sO7EE1YK9ZwDzoea28hYL6cfUAdZ ka9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=cKlGJHY75vTyquG2u9MefodLJfcXT+1YsCVEM6gUeo0=; b=lxn4OlrouhWZ9o1kt2Q5WLoh9ubsziMAAI1idL5o/2bAGPmS+lYLBUKoqAyPU50vrl TJAZJdc3Kbc49KYjB/HVFBoZ0upgihGkz2W745QMXnDZLgfgkbaibjGQhCIFM6RK0z3X l6sAZ8Y+DEyI9LwqjqmJBOKb/ZdeDUaq2ab9oVJo5+doCN487DyBz3hXYD34HFRirgz5 x+Dt6ZAecMSdXe5X+OwxRJpxar/NPf4izx329jUluMKw7Lag1B3t077a9GLVRNO4uPTZ n35G6izzSCJBID5/j7JIhsgIyLJAqaBzcwys16mbxFK7EQNZzA5KDmX4YZhLhWgqZXMs uUhQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 32-v6si13593992pls.319.2018.03.07.12.08.40; Wed, 07 Mar 2018 12:08:54 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965417AbeCGTp4 (ORCPT + 99 others); Wed, 7 Mar 2018 14:45:56 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:44330 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965404AbeCGTpu (ORCPT ); Wed, 7 Mar 2018 14:45:50 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 41EA0F0B; Wed, 7 Mar 2018 19:45:50 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roman Kapl , Jiri Pirko , Cong Wang , "David S. Miller" Subject: [PATCH 4.14 043/110] net: sched: report if filter is too large to dump Date: Wed, 7 Mar 2018 11:38:26 -0800 Message-Id: <20180307191045.241327158@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180307191039.748351103@linuxfoundation.org> References: <20180307191039.748351103@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Roman Kapl [ Upstream commit 5ae437ad5a2ed573b1ebb04e0afa70b8869f88dd ] So far, if the filter was too large to fit in the allocated skb, the kernel did not return any error and stopped dumping. Modify the dumper so that it returns -EMSGSIZE when a filter fails to dump and it is the first filter in the skb. If we are not first, we will get a next chance with more room. I understand this is pretty near to being an API change, but the original design (silent truncation) can be considered a bug. Note: The error case can happen pretty easily if you create a filter with 32 actions and have 4kb pages. Also recent versions of iproute try to be clever with their buffer allocation size, which in turn leads to Signed-off-by: Roman Kapl Acked-by: Jiri Pirko Acked-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sched/cls_api.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -871,13 +871,18 @@ static int tc_dump_tfilter(struct sk_buf if (tca[TCA_CHAIN] && nla_get_u32(tca[TCA_CHAIN]) != chain->index) continue; - if (!tcf_chain_dump(chain, skb, cb, index_start, &index)) + if (!tcf_chain_dump(chain, skb, cb, index_start, &index)) { + err = -EMSGSIZE; break; + } } cb->args[0] = index; out: + /* If we did no progress, the error (EMSGSIZE) is real */ + if (skb->len == 0 && err) + return err; return skb->len; }