netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* 16/32 bit issues at nfulnl_recv_config
@ 2006-05-18 23:20 Alexey Dobriyan
  2006-05-19  1:15 ` Patrick McHardy
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Dobriyan @ 2006-05-18 23:20 UTC (permalink / raw)
  To: netdev; +Cc: netfilter-devel

I'm talking about net/netfilter/nfnetlink_log.c::^nfulnl_recv_config
below. I'm totally confused and beer supply almost ended, so can someone else
also look at it...

Put your attention at line 905:

net/netfilter/nfnetlink_log.c:

   902		if (nfula[NFULA_CFG_FLAGS-1]) {
   903			u_int16_t flags =
   904				*(u_int16_t *)NFA_DATA(nfula[NFULA_CFG_FLAGS-1]);
   905			nfulnl_set_flags(inst, ntohl(flags));


1) Cast should be made to __be16, and history of fixing endian warning
   slightly above supports it.
2) Assuming __be16, ntohl(__be16) is whooops.
3) nfulnl_set_flags() wants something 16-bit wide as a second argument,
   so ntohling there is double whoops.
4) NFULNL_CFG_F_SEQ* defines fit into 16 bit and are host-endian;
   inst->flags is &'ed with host endian so it's probably host-endian and

   static int
   nfulnl_set_flags(struct nfulnl_instance *inst, u_int16_t flags)
   						  ^^^^^^^^^
						  this should be made __be16.
   {
	spin_lock_bh(&inst->lock);
	inst->flags = ntohs(flags);
	spin_unlock_bh(&inst->lock);
	return 0;
   }

   What to do with lines 903-905 if it is.

	Alexey "confused in Moscow" Dobriyan


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-05-19  1:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-18 23:20 16/32 bit issues at nfulnl_recv_config Alexey Dobriyan
2006-05-19  1:15 ` Patrick McHardy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).