From patchwork Thu Sep 5 23:29:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pablo Neira Ayuso X-Patchwork-Id: 13793099 X-Patchwork-Delegate: kuba@kernel.org Received: from mail.netfilter.org (mail.netfilter.org [217.70.188.207]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D78651BBBD8; Thu, 5 Sep 2024 23:29:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.188.207 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725578981; cv=none; b=EbdwHiM4sI1WD2UVpcSTTKLpOYJWf/vtvPpOporHALHFjC7DiquICvTJd1DfEr02Bs0pk2ZTCgj6/iZ4gKa3ZFV/3m436UPWQiGCsru6ZprVnrEuPTeZpINwUXVq/tAWg6/9mzuVyzPY96Nz3ozG3/3F7fkoUPumEz2+rIiXgCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725578981; c=relaxed/simple; bh=fOKBt1w9by9miooypLvtND+8xkAyW+mHfa0RhEZFiOM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XrAiitX22HRsnw1QoCmjaQA+m4uGYu1wmkhl+loqw9KxpR0y0FF7EGyhICEBznYJ5oZPLn4syY0uli06j0FLqcVo5xnP0cXTi1EoYsRGsqcZ3MAFCtY/PiHy4NwFX5M0CFiiAztoM0ufnSjXeecQ6hSk+MiVDjAumhejw82rFEk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; arc=none smtp.client-ip=217.70.188.207 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netfilter.org From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Cc: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, fw@strlen.de Subject: [PATCH net-next 10/16] netfilter: nf_tables: reject expiration higher than timeout Date: Fri, 6 Sep 2024 01:29:14 +0200 Message-Id: <20240905232920.5481-11-pablo@netfilter.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240905232920.5481-1-pablo@netfilter.org> References: <20240905232920.5481-1-pablo@netfilter.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Report ERANGE to userspace if user specifies an expiration larger than the timeout. Fixes: 8e1102d5a159 ("netfilter: nf_tables: support timeouts larger than 23 days") Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nf_tables_api.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index da75bc1de466..6c0c6f8a08a8 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -6930,6 +6930,9 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set, &expiration); if (err) return err; + + if (expiration > timeout) + return -ERANGE; } if (nla[NFTA_SET_ELEM_EXPR]) {