lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1322496298.2292.76.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC>
Date:	Mon, 28 Nov 2011 17:04:58 +0100
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	Joe Perches <joe@...ches.com>
Cc:	David Miller <davem@...emloft.net>,
	netdev <netdev@...r.kernel.org>,
	Michał Mirosław <mirq-linux@...e.qmqm.pl>
Subject: Re: [PATCH net-next] tcp: tcp_sendmsg() wrong access to
 sk_route_caps

Le lundi 28 novembre 2011 à 02:46 -0800, Joe Perches a écrit :
> On Mon, 2011-11-28 at 11:27 +0100, Eric Dumazet wrote:
> > Now sk_route_caps is u64, its dangerous to use an integer to store
> > result of an AND operator. It wont work if NETIF_F_SG is moved on the
> > upper part of u64.
> 
> trivial comment below.

Well, not trivial at all ;)

> 
> > diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> []
> > @@ -917,9 +917,9 @@ int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
> >  	struct iovec *iov;
> >  	struct tcp_sock *tp = tcp_sk(sk);
> >  	struct sk_buff *skb;
> > -	int iovlen, flags;
> > +	int iovlen, flags, err, copied;
> >  	int mss_now, size_goal;
> > -	int sg, err, copied;
> > +	bool sg;
> >  	long timeo;
> >  
> >  	lock_sock(sk);
> > @@ -946,7 +946,7 @@ int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
> >  	if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))
> >  		goto out_err;
> >  
> > -	sg = sk->sk_route_caps & NETIF_F_SG;
> > +	sg = !!(sk->sk_route_caps & NETIF_F_SG);
> 
> As sg is now bool, using !! is unnecessary.
> 
> A commit was done recently to remove one.
> 3ad9b358e03fd9dbf6705721490c811b666b0fe2
> 

Hmm... I find it dangerous and error prone. Obviously not at the time we
commit such changes, but later, because a future reader might be fooled.

Using !!(expr) is pretty clear about the potential problem, and
generates no extra code if a bool is used for the target.



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ