Skip to contentSkip to conversation

System crash in tcp_fragment()

DISCUSSION David S. Miller 2 participants 2 messages May 21, 2002 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

From: [email protected]
Date: Tue, 21 May 2002 04:41:39 +0400 (MSD)

+Two similar problems arise. An example code snippet:
+

   +       struct this_needs_locking tux[NR_CPUS];
   +       tux[smp_processor_id()] = some_value;
   +       /* task is preempted here... */
   +       something = tux[smp_processor_id()];

If you are not going to break all the kernel just make sure that tasks preempted in the kernel do not migrate. That's all, simple & stupid.

Such rule does not even make this piece of code legal. Consider:

task1:cpu0: x = counters[smp_processor_id()];
cpu0: PREEMPT
task2:cpu0: x = counters[smp_processor_id()];
task2:cpu0: counters[smp_processor_id()] = x + 1;
cpu0: PREEMPT
task1:cpu0: counters[smp_processor_id()] = x + 1;
full garbage

But it does bring up important point, preemption people need to fully audit entire networking.

It is totally broken by preemption the more I think about it.

At the very beginning, all the SNMP counter bumping tricks will totally fail with preemption enabled.

#3 lore raw
In reply to a message not in the archive

Hello!

Quoted 5 lines
Quoted 4 lines

if [ "$CONFIG_SMP" = "n" ]; then
bool 'Preemptible Kernel' CONFIG_PREEMPT
fi

That is not a fix! It is dodging the issue. ;)

It is the only real fix, if you are going to follow this instruction:

+RULE #1: Per-CPU data structures need explicit protection +
+
+Two similar problems arise. An example code snippet:
+

+       struct this_needs_locking tux[NR_CPUS];
+       tux[smp_processor_id()] = some_value;
+       /* task is preempted here... */
+       something = tux[smp_processor_id()];

+
+First, since the data is per-CPU, it may not have explicit SMP locking, but +require it otherwise. Second, when a preempted task is finally rescheduled, +the previous value of smp_processor_id may not equal the current. You must +protect these situations by disabling preemption around them.

If you are not going to break all the kernel just make sure that tasks preempted in the kernel do not migrate. That's all, simple & stupid.

Alexey