From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [PATCH net] packet: fix bitfield update race Date: Tue, 24 Apr 2018 13:17:54 -0400 (EDT) Message-ID: <20180424.131754.1266434549335457413.davem@davemloft.net> References: <20180423213703.241054-1-willemdebruijn.kernel@gmail.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, byoungyoung@purdue.edu, threeearcat@gmail.com, xiyou.wangcong@gmail.com, herbert@gondor.apana.org.au, willemb@google.com To: willemdebruijn.kernel@gmail.com Return-path: Received: from shards.monkeyblade.net ([184.105.139.130]:37494 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750826AbeDXRR4 (ORCPT ); Tue, 24 Apr 2018 13:17:56 -0400 In-Reply-To: <20180423213703.241054-1-willemdebruijn.kernel@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Willem de Bruijn Date: Mon, 23 Apr 2018 17:37:03 -0400 > From: Willem de Bruijn > > Updates to the bitfields in struct packet_sock are not atomic. > Serialize these read-modify-write cycles. > > Move po->running into a separate variable. Its writes are protected by > po->bind_lock (except for one startup case at packet_create). Also > replace a textual precondition warning with lockdep annotation. > > All others are set only in packet_setsockopt. Serialize these > updates by holding the socket lock. Analogous to other field updates, > also hold the lock when testing whether a ring is active (pg_vec). > > Fixes: 8dc419447415 ("[PACKET]: Add optional checksum computation for recvmsg") > Reported-by: DaeRyong Jeong > Reported-by: Byoungyoung Lee > Signed-off-by: Willem de Bruijn Looks good, applied and queued up for -stable. Thanks for fixing this Willem.