netfilter: nfnetlink: skip error delivery on batch in case of ENOMEM
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 7 Jun 2023 22:19:12 +0000 (00:19 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 8 Jun 2023 02:00:02 +0000 (04:00 +0200)
If caller reports ENOMEM, then stop iterating over the batch and send a
single netlink message to userspace to report OOM.

Fixes: cbb8125eb40b ("netfilter: nfnetlink: deliver netlink errors on batch completion")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nfnetlink.c

index ae71464..c9fbe0f 100644 (file)
@@ -533,7 +533,8 @@ ack:
                         * processed, this avoids that the same error is
                         * reported several times when replaying the batch.
                         */
-                       if (nfnl_err_add(&err_list, nlh, err, &extack) < 0) {
+                       if (err == -ENOMEM ||
+                           nfnl_err_add(&err_list, nlh, err, &extack) < 0) {
                                /* We failed to enqueue an error, reset the
                                 * list of errors and send OOM to userspace
                                 * pointing to the batch header.