Re: [PATCH nf-next] netfilter: nf_tables: support updating userdata for nft_table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quan Tian <tianquan23@xxxxxxxxx> wrote:
> -				if (!(trans->ctx.table->flags & __NFT_TABLE_F_UPDATE)) {
> -					nft_trans_destroy(trans);
> -					break;
> +				if (trans->ctx.table->flags & __NFT_TABLE_F_UPDATE) {
> +					if (trans->ctx.table->flags & NFT_TABLE_F_DORMANT)
> +						nf_tables_table_disable(net, trans->ctx.table);
> +					trans->ctx.table->flags &= ~__NFT_TABLE_F_UPDATE;
>  				}
> -				if (trans->ctx.table->flags & NFT_TABLE_F_DORMANT)
> -					nf_tables_table_disable(net, trans->ctx.table);
> -
> -				trans->ctx.table->flags &= ~__NFT_TABLE_F_UPDATE;
> +				kfree(trans->ctx.table->udata);

This kfree() needs to happen in nft_commit_release().

Otherwise netlink dumps (which run without a lock) results in
use-after-free.

Second issue is that ->udata and ->udlen would have to be
updated atomically so that async dump doesn't observe old/new
pointer with a larger udlen.

I suggest a preparation patch that replaces

   u16  udlen;
   u8   *udata;

in struct nft_table with

	struct nlattr *udata;

so its enough to swap() ctx.table->udata with nft_trans_table_udata(),
then kfree() the old udata from nft_commit_release().

At _release time we can be sure no other cpu is referencing the old
udata.




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux