From patchwork Tue Oct 27 13:44:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 312449 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B7A5C838AC for ; Tue, 27 Oct 2020 15:49:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C83FD22384 for ; Tue, 27 Oct 2020 15:49:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603813745; bh=8AgK59QZ6Y+V+GpOCn8R6sQwifNuKVGsl3UtLc3qVIk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=LAi2KEJfeJOKyBg61nNAeC2yEeugxtTPYTC7Tu2LQohELIOpJt0JcYo5mbUpnzlH5 Xj7maPsYOgt8bbrWN+LTTgwf06+ho/fiwLqy99t3IHNuIJZnTxTSNRYWBNT7GiDj9v O3vQzWUdj6UO6SC3qjsKNDtIoxkmDC68AWBq6Qfk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1802465AbgJ0Psy (ORCPT ); Tue, 27 Oct 2020 11:48:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:55732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1796412AbgJ0PSU (ORCPT ); Tue, 27 Oct 2020 11:18:20 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E571E222E9; Tue, 27 Oct 2020 15:18:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811892; bh=8AgK59QZ6Y+V+GpOCn8R6sQwifNuKVGsl3UtLc3qVIk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hDqdRAiRbz0+RrNn74epUnWQ7zIiQf2yEDYrVmAbr8m2zB/FoVrmjI8Bww0D5Ela4 W4rVEB1fPJk41LXEIu6QSJzW1ZHvlV35UD6/HL1eFZ41EIszvXdWCveAc32mzVYafo I4EHpeGHbtxfpEnbP5ifvZi6h8ygs4n57CiHSH6U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Eggers , Willem de Bruijn , Deepa Dinamani , Willem de Bruijn , Jakub Kicinski Subject: [PATCH 5.9 020/757] socket: fix option SO_TIMESTAMPING_NEW Date: Tue, 27 Oct 2020 14:44:30 +0100 Message-Id: <20201027135451.464532332@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135450.497324313@linuxfoundation.org> References: <20201027135450.497324313@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Christian Eggers [ Upstream commit 59e611a566e7cd48cf54b6777a11fe3f9c2f9db5 ] The comparison of optname with SO_TIMESTAMPING_NEW is wrong way around, so SOCK_TSTAMP_NEW will first be set and than reset again. Additionally move it out of the test for SOF_TIMESTAMPING_RX_SOFTWARE as this seems unrelated. This problem happens on 32 bit platforms were the libc has already switched to struct timespec64 (from SO_TIMExxx_OLD to SO_TIMExxx_NEW socket options). ptp4l complains with "missing timestamp on transmitted peer delay request" because the wrong format is received (and discarded). Fixes: 9718475e6908 ("socket: Add SO_TIMESTAMPING_NEW") Signed-off-by: Christian Eggers Reviewed-by: Willem de Bruijn Reviewed-by: Deepa Dinamani Acked-by: Willem de Bruijn Acked-by: Deepa Dinamani Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/core/sock.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) --- a/net/core/sock.c +++ b/net/core/sock.c @@ -1007,8 +1007,6 @@ set_sndbuf: __sock_set_timestamps(sk, valbool, true, true); break; case SO_TIMESTAMPING_NEW: - sock_set_flag(sk, SOCK_TSTAMP_NEW); - fallthrough; case SO_TIMESTAMPING_OLD: if (val & ~SOF_TIMESTAMPING_MASK) { ret = -EINVAL; @@ -1037,16 +1035,14 @@ set_sndbuf: } sk->sk_tsflags = val; + sock_valbool_flag(sk, SOCK_TSTAMP_NEW, optname == SO_TIMESTAMPING_NEW); + if (val & SOF_TIMESTAMPING_RX_SOFTWARE) sock_enable_timestamp(sk, SOCK_TIMESTAMPING_RX_SOFTWARE); - else { - if (optname == SO_TIMESTAMPING_NEW) - sock_reset_flag(sk, SOCK_TSTAMP_NEW); - + else sock_disable_timestamp(sk, (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE)); - } break; case SO_RCVLOWAT: