static inline int xfrm_mark_get() broken
Subsystems (3)
Hi,
experimenting with the new XFRM_MARK feature of the 2.6.34 kernel I found out that the extraction of the mark mask might accidentally work on 64 bit platforms but on 32 bit platforms the function is awfully broken. The rather trivial patch attached to this mail fixes the problem. Otherwise the XFRM_MARK feature seems quite promising!
Best regards
Andreas
======================================================================
Andreas Steffen e-mail: [email protected]
Institute for Internet Technologies and Applications
Hochschule fuer Technik Rapperswil phone: +41 55 222 42 68
CH-8640 Rapperswil (Switzerland) mobile: +41 76 340 25 56
===========================================================[ITA-HSR]==
include/net/xfrm.h renamed from include/net/xfrm.h.ori +1 -1
@@ -1587,7 +1587,7 @@static inline int xfrm_mark_get (struct nlattr **attrs,struct xfrm_mark *m) {if (attrs[XFRMA_MARK ]) -memcpy (m,nla_data (attrs[XFRMA_MARK ]),sizeof (m)); +memcpy (m,nla_data (attrs[XFRMA_MARK ]),sizeof (struct xfrm_mark ));else m->v = m->m =0 ;
Quoted 22 lines · Andreas Steffen
Hi,
experimenting with the new
XFRM_MARKfeature of the 2.6.34 kernel I found out that the extraction of the mark mask might accidentally work on 64 bit platforms but on 32 bit platforms the function is awfully broken. The rather trivial patch attached to this mail fixes the problem. Otherwise theXFRM_MARKfeature seems quite promising!Best regards
Andreas
======================================================================
Andreas Steffen e-mail: [email protected]
Institute for Internet Technologies and Applications
Hochschule fuer Technik Rapperswil phone: +41 55 222 42 68
CH-8640 Rapperswil (Switzerland) mobile: +41 76 340 25 56
===========================================================[ITA-HSR]==
include/net/xfrm.h line 1590
Quoted 5 lines
include/net/xfrm.h renamed from include/net/xfrm.h.ori +1
-1@@ -1587,7 +1587,7 @@static inline int xfrm_mark_get (struct nlattr **attrs,struct xfrm_mark *m) {if (attrs[XFRMA_MARK ]) -memcpy (m,nla_data (attrs[XFRMA_MARK ]),sizeof (m)); +memcpy (m,nla_data (attrs[XFRMA_MARK ]),sizeof (struct xfrm_mark ));
This fix looks correct to me, but
I believe that sizeof(*m) is the preferred style.
Quoted 3 lines
include/net/xfrm.h renamed from include/net/xfrm.h.ori +0
-0else m->v = m->m =0 ;
Hello Simon,
actually I don't care how this bug is going to be fixed, but with sizeof(struct xfrm_mark) I'm dead certain that both the mark value and mask are being copied. Actually in the next inline function right below sizeof(struct xfrm_mark) is used, too:
static inline int xfrm_mark_put(struct sk_buff *skb, struct xfrm_mark *m)
{
if (m->m | m->v)
NLA_PUT(skb, XFRMA_MARK, sizeof(struct xfrm_mark), m);
return 0;Regards
Andreas
Quoted 20 lines · Simon Horman
Quoted 18 lines · Andreas Steffen
Hi,
experimenting with the new
XFRM_MARKfeature of the 2.6.34 kernel I found out that the extraction of the mark mask might accidentally work on 64 bit platforms but on 32 bit platforms the function is awfully broken. The rather trivial patch attached to this mail fixes the problem. Otherwise theXFRM_MARKfeature seems quite promising!Best regards
Andreas
======================================================================
Andreas Steffen e-mail: [email protected]
Institute for Internet Technologies and Applications
Hochschule fuer Technik Rapperswil phone: +41 55 222 42 68
CH-8640 Rapperswil (Switzerland) mobile: +41 76 340 25 56
===========================================================[ITA-HSR]==
Quoted 14 lines
include/net/xfrm.h line 1590
Quoted 8 lines
include/net/xfrm.h renamed from include/net/xfrm.h.ori +1
-1@@ -1587,7 +1587,7 @@static inline int xfrm_mark_get (struct nlattr **attrs,struct xfrm_mark *m) {if (attrs[XFRMA_MARK ]) -memcpy (m,nla_data (attrs[XFRMA_MARK ]),sizeof (m)); +memcpy (m,nla_data (attrs[XFRMA_MARK ]),sizeof (struct xfrm_mark ));This fix looks correct to me, but
I believe thatsizeof(*m)is the preferred style.Quoted 2 lines
include/net/xfrm.h renamed from include/net/xfrm.h.ori +0
-0else m->v = m->m =0 ;
======================================================================
Andreas Steffen e-mail: [email protected]
Institute for Internet Technologies and Applications
Hochschule fuer Technik Rapperswil phone: +41 55 222 42 68
CH-8640 Rapperswil (Switzerland) mobile: +41 76 340 25 56
===========================================================[ITA-HSR]==
Quoted 7 lines · Andreas Steffen
Hello Simon,
actually I don't care how this bug is going to be fixed, but with
sizeof(struct xfrm_mark)I'm dead certain that both the mark value and mask are being copied. Actually in the next inline function right belowsizeof(struct xfrm_mark)is used, too:
Quoted 5 lines
static inline int
xfrm_mark_put(struct sk_buff *skb, struct xfrm_mark *m){ if (m->m | m->v) NLA_PUT(skb, XFRMA_MARK, sizeof(struct xfrm_mark), m); return 0;
In that case I withdraw my suggestion.