Re: xfrm_input() and ->seq oddities
From: Al Viro <viro@ZenIV.linux.org.uk>
Date: 2008-02-03 11:04:51
On Sun, Feb 03, 2008 at 02:05:16PM +1100, Herbert Xu wrote:
On Sun, Feb 03, 2008 at 12:37:19AM +0000, Al Viro wrote:quoted
This is still very odd... Where do you initialize ->seq.input? WhatIn xfrm_input.quoted
guarantees that async call of xfrm_input() will be always preceded by at least one non-async one?OK I admit it isn't pretty. But the encap_type argument is reused to indicate async resumption. That is, if we enter with encap_type < 0, it means that we're resuming a previous operation and seq.input has therefore been set by the previous xfrm_input call.
*Ouch* So what you are saying is * callers of xfrm_input_resume() are in callbacks that couldn't have been set other than from esp_input()/esp6_input() * these two could have only been called via ->type->input() * ->type->input() is called from xfrm_input(), immediately after having set ->seq.input, *or* from xfrm6_input_addr(). The former is safe. * xfrm6_input_addr() calls ->type->input() of object it gets from xfrm_state_lookup_byaddr(). The protocol number passed to the latter comes from xfrm6_input_addr() argument. * the protocol numbers given to xfrm6_input_addr() by its callers are IPPROTO_DSTOPTS and IPPROTO_ROUTING resp; ->input() instances in their xfrm_type do *not* set callbacks that could lead to xfrm_input_resume(), so we are safe. IMO that at least deserves a comment near xfrm_input()... doe