Skip to contentSkip to conversation

netfilter: nfnetlink: make OOM conditions fatal

PATCH New Florian Westphal 1 participant 1 message Jun 16

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 netfilter: nfnetlink: make OOM conditions fatal

Batch support design attempts to process the entire batch, even after a call has returned an error. The advantage is that userspace gets all errors in one go.

The disadvantages are:
1. ->call() needs to cope with bad-state-due-to-previous-error
2. One error can trigger a cascade of followup errors which can obfuscate the real problem.

Make -ENOMEM fatal, if we cannot allocate some object there is a high chance we're going to report followup errors that are nonsensical from userspace point of view.

Fixes 0628b123c96d ("netfilter: nfnetlink: add batch support and use it from nf_tables")

---
Not strictly required, but I think it makes sense to stop the batch early, as-is we might produce many silly followup errors.

 net/netfilter/nfnetlink.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/netfilter/nfnetlink.c +7 -0
index 47f3ed441f64..a1d480e4789c 100644
@@ -531,6 +531,13 @@ static void nfnetlink_rcv_batch(struct sk_buff *skb, struct nlmsghdr *nlh,
 				status |= NFNL_BATCH_REPLAY;
 				goto done;
 			}
+
+			/* No point in further processing; followup errors can
+			 * be bogus (e.g. -ENOENT because object that next
+			 * rule/element wants could not be inserted).
+			 */
+			if (err == -ENOMEM)
+				goto ack;
 		}
 ack:
 		if (nlh->nlmsg_flags & NLM_F_ACK || err) {
Signature · 1 line
2.53.0