Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3829977ybb; Mon, 6 Apr 2020 17:02:39 -0700 (PDT) X-Google-Smtp-Source: APiQypKGLkBidQiXXnzZ3g7y1xYbJqVBmwAXSyw4cj2CwoQjgTGUg7FvNu0V1435O1i+NCZrjXAQ X-Received: by 2002:a9d:6a05:: with SMTP id g5mr1426822otn.116.1586217759184; Mon, 06 Apr 2020 17:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586217759; cv=none; d=google.com; s=arc-20160816; b=xF/L3p1VwA1FOibd5kX9RQHJC7gSSiQCqowG0BzuTnOZocPxMgenrSTB4rfsza0bdW TgHGjTqliADovG3EAOsyJeTUlkrt1JhdMkWuevDqIVu/J8JO5FznHuoKX8WydlK24jjj HII9BcQ64YoVN9xzymGJwO4Xd4iLHo5a8ne99Y2VtMM/nnwRX2nMzaIH3dqa1GW/43yO 3SSs529NyKGV/U0/n/4PiTYQlT+F2ssOLevt4Qf3SCRMNeOGdk6cSLVYJ0MkMqLg0qNt Ep4NjbQ7XRRHTqK2dAbYVCIIXpv5u84xPjje5vZ2FYb/gVUn7dw5OwLvTCqOxVxmkJP1 eEsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6QGtppbX0D4HXfhLkDIUFMNF53MhdwcX1nXRx1Ica00=; b=0NtimOVIzWlVudtdEuQcjgJ3KG84HFasobIW3hzGWlSu+bJFp6Ea4jqxfE2XGHxY87 fCYTyNyt/XxOZj8MR5o40zBjtDyohfUhKoLycKfHGmqJRXwyTctEx6X0TsWuZjKZLdsk ZbWTDVypf/1fHF0EJZeOaMu0ikXM8v/rb6+6JBjhyHEIEAdxS33DVvry5AC91wa4CNgv 7Sh4SlJ5tT2gFmvr9apWnP3B0atY+P37liUkNGw+/OwuAen2CVQQvWwYrZDaXSuHHezT 0AYJFRdArlt4CWZUn5RKnLaSSEuOTRU/7HSUs+OojmNcpmstz0Fnwd7MhjSeEdzek29T dqjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QoHxiqRg; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v62si560735ooc.18.2020.04.06.17.02.27; Mon, 06 Apr 2020 17:02:39 -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=@kernel.org header.s=default header.b=QoHxiqRg; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727208AbgDGABi (ORCPT + 99 others); Mon, 6 Apr 2020 20:01:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:34714 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726965AbgDGABe (ORCPT ); Mon, 6 Apr 2020 20:01:34 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 519CE208E4; Tue, 7 Apr 2020 00:01:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586217693; bh=nSZIgXpFCKsSZKb4dKx/zHl30eiBHp5c5LbK7nJDkxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QoHxiqRgFLjnQDIWxntGWeLiEr6aFAvi5OvnazrebtGst/hOzL3ry5UtQa/xdXTQu HrYROmZDH/J5UuB+KjtKdE2afGXh2XwLYxEjAyImuJwqtyRCJQJjsYw2o7/x/GPzWz F/p6BQRWLtW94mZTNtnG8e1TXD7/93PNR4Zfk9Ks= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pablo Neira Ayuso , Phil Sutter , Stefano Brivio , Sasha Levin , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.5 27/35] netfilter: nf_tables: Allow set back-ends to report partial overlaps on insertion Date: Mon, 6 Apr 2020 20:00:49 -0400 Message-Id: <20200407000058.16423-27-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200407000058.16423-1-sashal@kernel.org> References: <20200407000058.16423-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pablo Neira Ayuso [ Upstream commit 8c2d45b2b65ca1f215244be1c600236e83f9815f ] Currently, the -EEXIST return code of ->insert() callbacks is ambiguous: it might indicate that a given element (including intervals) already exists as such, or that the new element would clash with existing ones. If identical elements already exist, the front-end is ignoring this without returning error, in case NLM_F_EXCL is not set. However, if the new element can't be inserted due an overlap, we should report this to the user. To this purpose, allow set back-ends to return -ENOTEMPTY on collision with existing elements, translate that to -EEXIST, and return that to userspace, no matter if NLM_F_EXCL was set. Reported-by: Phil Sutter Signed-off-by: Stefano Brivio Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nf_tables_api.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 11a2a7b5312ee..a9f6bace16245 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -4957,6 +4957,11 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set, err = -EBUSY; else if (!(nlmsg_flags & NLM_F_EXCL)) err = 0; + } else if (err == -ENOTEMPTY) { + /* ENOTEMPTY reports overlapping between this element + * and an existing one. + */ + err = -EEXIST; } goto err5; } -- 2.20.1