Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp12058196imu; Tue, 1 Jan 2019 13:08:48 -0800 (PST) X-Google-Smtp-Source: ALg8bN6861HBkf2p2CmvoxqAbjlZo0kqhdGOYLFBZV9ev4U5zML9nwj11LMQ8Q4Sb1kqNi6E+53Q X-Received: by 2002:a17:902:aa82:: with SMTP id d2mr41500608plr.153.1546376928843; Tue, 01 Jan 2019 13:08:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546376928; cv=none; d=google.com; s=arc-20160816; b=CCELNhA2JofWUuJlVRrz6qKR8wVLflbISz8qZ3eZWla1GTWRnNdYlng7bTybMsrs1w 99zQj/hpTxzyZ4b0ZmxKlXGpZkZ9ReEgAC0ZX1pRuF+k6sGCajywDJrl28PnXxSvDub/ ewUObQQRru8syPo/l6HZ2C6PIaTi94Pme6MwtVS51wGpnzJd8jJVrc0kmpGzQG8QtVqh KwpwzmW3ZG7CYpjh6kAd3liVkA98qQucWCdKLFEbsOx6kZvPCkDfNkNgmlBMDkXhsCpk +e5NqQWjmP8O4cSGy8hQcL7t4zNS3EcVL9wSLaBzDcdNJq6TK2YhZidB1jnqoiL9WINc brxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:from:subject:cc:to:message-id:date; bh=l+hPv5ISZPdugSKP/sVAik8QrDIxktWB6NJJgJYjWRc=; b=frfO5HiDfdA/r/oKoobH+vOWy0gVx8uw8ge6drYvVs4WjK+uu4NiynQg0Vios8t5tE Xtf9ClvgkC04kXXlmVD52MVQqEEgfWZgtnrTmIntofy0TjT2m0qlpBMv7o3M33An7WRm m4ZIvBIimvOLQPDK+hen6dmiuKBqSsW/Qkq1T5sw/VDkwm1NAxw9LXqhmFIGz0VlIfUE x6n235YOi+txoSFddjVb8FilVAeAdLy7i72r2vx1qCIC0P6gNu7zFItVxPNDqy8iQouQ PBUIo+sHi/nZsGczJTk+nZHjsz6nmG4OueLwCNJYoRWU5Y8+a94ci5hnUI+1bqolTHMH qxbQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 127si7009121pfg.173.2019.01.01.13.08.33; Tue, 01 Jan 2019 13:08:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726160AbfAARtG (ORCPT + 99 others); Tue, 1 Jan 2019 12:49:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46176 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbfAARtG (ORCPT ); Tue, 1 Jan 2019 12:49:06 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F2A9E85546; Tue, 1 Jan 2019 17:49:05 +0000 (UTC) Received: from localhost (ovpn-112-13.rdu2.redhat.com [10.10.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 236695D756; Tue, 1 Jan 2019 17:49:02 +0000 (UTC) Date: Tue, 01 Jan 2019 09:49:01 -0800 (PST) Message-Id: <20190101.094901.728478837131793069.davem@redhat.com> To: deepa.kernel@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, viro@zeniv.linux.org.uk, arnd@arndb.de, eric.dumazet@gmail.com, y2038@lists.linaro.org Subject: Re: [PATCH v3] sock: Make sock->sk_stamp thread-safe From: David Miller In-Reply-To: <20181228025509.14194-1-deepa.kernel@gmail.com> References: <20181228025509.14194-1-deepa.kernel@gmail.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 01 Jan 2019 17:49:06 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Deepa Dinamani Date: Thu, 27 Dec 2018 18:55:09 -0800 > Al Viro mentioned (Message-ID > <20170626041334.GZ10672@ZenIV.linux.org.uk>) > that there is probably a race condition > lurking in accesses of sk_stamp on 32-bit machines. > > sock->sk_stamp is of type ktime_t which is always an s64. > On a 32 bit architecture, we might run into situations of > unsafe access as the access to the field becomes non atomic. > > Use seqlocks for synchronization. > This allows us to avoid using spinlocks for readers as > readers do not need mutual exclusion. > > Another approach to solve this is to require sk_lock for all > modifications of the timestamps. The current approach allows > for timestamps to have their own lock: sk_stamp_lock. > This allows for the patch to not compete with already > existing critical sections, and side effects are limited > to the paths in the patch. > > The addition of the new field maintains the data locality > optimizations from > commit 9115e8cd2a0c ("net: reorganize struct sock for better data > locality") > > Note that all the instances of the sk_stamp accesses > are either through the ioctl or the syscall recvmsg. > > Signed-off-by: Deepa Dinamani Ok, I'm fine with this, so applied and queued up for -stable. I will note in passing that there are several 32-bit architectures that have 64-bit loads. Sparc is one such case. And they would not need these changes. But I don't think it's practical or worthwhile to add that level of consideration into your changes. I'd rather the commit stay as simple as possible. Thanks!