Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp213559pxx; Wed, 28 Oct 2020 03:01:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkZg5FUV4ngbrLlD57+FvpMJ2wRiFn653aN7wndy0DOsMIxJTdpQI+Gyq6b5ZcrWcrmBfH X-Received: by 2002:aa7:da4d:: with SMTP id w13mr6633412eds.266.1603879307827; Wed, 28 Oct 2020 03:01:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603879307; cv=none; d=google.com; s=arc-20160816; b=i6P+FVt1NErqM/ZgGjst9aOmw7Fv3kpma5wRQpB0xfMdL4Rl7MWiZ/LyTijbbW1txW DskOwxDWqJh725+97JTKR/udzQxqXpE+SZrhbXElKwt/hUZ9tdHqz5zjDdc+96ue3N6d Al91pUOdl27utMiXWctZ7BDRygHQV0pEP4ABHDxKOjOvWzpir3V61cccMGRxMM5YbGgD HpCkL0gyJvv3l8XAvbrPdgU0XfsL07Y6g26AfzMzCH7a5bNpqrx9tfaipJjtTEm2tj7O J1aM8NYuBSvIJBPwFnPZPXQVHUeBntktfgWCpd44zp08MV/kHVPa4PYEyyEvk7m2WTtG hvdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Do0s6FRTvYK6yc2l7mW8jRK1KzPzQ/SHUJwLHroNr54=; b=GH5P17oE7gYA2SpqCY91+E/P/r5F34vv4zB/kJ+vnea/+HH0ggX7DsIhu2LGod9sBy Xen1HubP8tkqXOdyzYsycWWmhLqfn0TT744kEA17QcXMFaRqAAQ9fnAgNM0pjet/k9VR jyl5bpDeCbOhaJVQDbyc0iSh545M7E3M5Si1WU3Dhx5GVFFMJyvCipYp2iq0RltcrqBP /BbKy9I5eRuGO2nhw8K6lugW4wVy6xUvMheYglrySYRZx+CuaRyunj7mRgqqUnrCfKKu jzrTRs8omclB/SOWLwxatidStSdpI2kD6DhKz5Dbh+9kBaviij+EvlnEaXqrk5aEXhAo 6Qqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hNWShjuS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a42si3838927edf.535.2020.10.28.03.01.25; Wed, 28 Oct 2020 03:01:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hNWShjuS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2902252AbgJ0Obn (ORCPT + 99 others); Tue, 27 Oct 2020 10:31:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:55238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759279AbgJ0O2q (ORCPT ); Tue, 27 Oct 2020 10:28:46 -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 7B138206DC; Tue, 27 Oct 2020 14:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603808926; bh=xgx1so219T4rWZKoJhHNU5YSg4YydUSkx+/hJ2YQFVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hNWShjuSjW/pvN0K0VZ3Gkjk6tlcZjVX9DLJ2Veap9aEUAqxqSHoNchspv2b9QzdG xz2QK8MAe9JEY8fUsySIdqK7nUaWWdC9/TSyGbd5gWS2KqmjFp13sgSAOWv2c0RKOc 3Gplnzc6ePhbN4YBTx7TcBMdWSxWj7swA707T0ck= 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.4 012/408] socket: fix option SO_TIMESTAMPING_NEW Date: Tue, 27 Oct 2020 14:49:10 +0100 Message-Id: <20201027135455.624667809@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 @@ -928,8 +928,6 @@ set_rcvbuf: break; case SO_TIMESTAMPING_NEW: - sock_set_flag(sk, SOCK_TSTAMP_NEW); - /* fall through */ case SO_TIMESTAMPING_OLD: if (val & ~SOF_TIMESTAMPING_MASK) { ret = -EINVAL; @@ -958,16 +956,14 @@ set_rcvbuf: } 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: