From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [91.216.245.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93ABF49641 for ; Thu, 1 Aug 2024 12:13:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.216.245.30 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722514400; cv=none; b=oC/sA5PQe2ox9UZ1LpznjIUvmP+ttCQi8h7oMFovyduEMyPtlm2JNyKQ0+XvmXlxebNeuvqKTVMkLIUJ3iCt6iTbIRB07U0v9bvYOeCsSgJ0KeC8GSs0qrvJJRbYT5emHBHAvDWMO7N8B5jfz/VcNJHzYWEEZyF6SwMzPNAfLT4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722514400; c=relaxed/simple; bh=O8N+Zda9aWqgCfLdcELACsfdjnC5t/TgFd9q7n5G3bE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FL+WS7GGpggGEdiFwPqa5luN8pC5TgBDQxmCmX87IR3kK3m/rdE2ZLKVYzw1l9Q7975ESqhSGKFAGPBo23gfIL7AnNq4njqZg3BJKCVqG793l2eGa+wu/4wHw/ZHmCD1AfnxlEi2z3iZE4XEaXIpTOnz+wkydGA9lGjAFmJph3U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strlen.de; spf=pass smtp.mailfrom=strlen.de; arc=none smtp.client-ip=91.216.245.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strlen.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=strlen.de Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1sZUgA-00088d-Se; Thu, 01 Aug 2024 14:13:10 +0200 Date: Thu, 1 Aug 2024 14:13:10 +0200 From: Florian Westphal To: Christian Hopps Cc: devel@linux-ipsec.org, Steffen Klassert , netdev@vger.kernel.org, Christian Hopps Subject: Re: [PATCH ipsec-next v7 07/16] xfrm: iptfs: add new iptfs xfrm mode impl Message-ID: <20240801121310.GA10274@breakpoint.cc> References: <20240801080314.169715-1-chopps@chopps.org> <20240801080314.169715-8-chopps@chopps.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240801080314.169715-8-chopps@chopps.org> User-Agent: Mutt/1.10.1 (2018-07-13) Christian Hopps wrote: > +static int __iptfs_init_state(struct xfrm_state *x, > + struct xfrm_iptfs_data *xtfs) > +{ > + /* Modify type (esp) adjustment values */ > + > + if (x->props.family == AF_INET) > + x->props.header_len += sizeof(struct iphdr) + sizeof(struct ip_iptfs_hdr); > + else if (x->props.family == AF_INET6) > + x->props.header_len += sizeof(struct ipv6hdr) + sizeof(struct ip_iptfs_hdr); > + x->props.enc_hdr_len = sizeof(struct ip_iptfs_hdr); > + > + /* Always have a module reference if x->mode_data is set */ > + if (!try_module_get(x->mode_cbs->owner)) > + return -EINVAL; If the comment means that we already have a module owner ref taken before this try_module_get, then this should use __module_get and a mention where the first ref was taken. If not, then this needs an explanation as to what prevents another cpu to rmmod the owning module between the lookup in xfrm_init_state and the module reference in __iptfs_init_state. cpu0 cpu1 xfrm_init_state -> xfrm_get_mode_cbs rmmod -> __iptfs_init_state xfrm_iptfs_fini xfrm_unregister_mode_cbs release memory try_module_get -> UaF