From mboxrd@z Thu Jan 1 00:00:00 1970 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=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 0A98BC4360C for ; Fri, 27 Sep 2019 18:26:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DC50A21655 for ; Fri, 27 Sep 2019 18:26:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727355AbfI0S0C (ORCPT ); Fri, 27 Sep 2019 14:26:02 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:35226 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726594AbfI0S0C (ORCPT ); Fri, 27 Sep 2019 14:26:02 -0400 Received: from localhost (231-157-167-83.reverse.alphalink.fr [83.167.157.231]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id C9589153ED996; Fri, 27 Sep 2019 11:26:00 -0700 (PDT) Date: Fri, 27 Sep 2019 20:25:59 +0200 (CEST) Message-Id: <20190927.202559.2108440086367535055.davem@davemloft.net> To: jacob.e.keller@intel.com Cc: netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org, jeffrey.t.kirsher@intel.com, richardcochran@gmail.com, felipe.balbi@linux.intel.com, christopher.s.hall@intel.com Subject: Re: [net-next v2 1/2] ptp: correctly disable flags on old ioctls From: David Miller In-Reply-To: <20190926022820.7900-2-jacob.e.keller@intel.com> References: <20190926022820.7900-1-jacob.e.keller@intel.com> <20190926022820.7900-2-jacob.e.keller@intel.com> X-Mailer: Mew version 6.8 on Emacs 26.2 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Fri, 27 Sep 2019 11:26:02 -0700 (PDT) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jacob Keller Date: Wed, 25 Sep 2019 19:28:19 -0700 > Commit 415606588c61 ("PTP: introduce new versions of IOCTLs", > 2019-09-13) introduced new versions of the PTP ioctls which actually > validate that the flags are acceptable values. > > As part of this, it cleared the flags value using a bitwise > and+negation, in an attempt to prevent the old ioctl from accidentally > enabling new features. > > This is incorrect for a couple of reasons. First, it results in > accidentally preventing previously working flags on the request ioctl. > By clearing the "valid" flags, we now no longer allow setting the > enable, rising edge, or falling edge flags. > > Second, if we add new additional flags in the future, they must not be > set by the old ioctl. (Since the flag wasn't checked before, we could > potentially break userspace programs which sent garbage flag data. > > The correct way to resolve this is to check for and clear all but the > originally valid flags. > > Create defines indicating which flags are correctly checked and > interpreted by the original ioctls. Use these to clear any bits which > will not be correctly interpreted by the original ioctls. > > In the future, new flags must be added to the VALID_FLAGS macros, but > *not* to the V1_VALID_FLAGS macros. In this way, new features may be > exposed over the v2 ioctls, but without breaking previous userspace > which happened to not clear the flags value properly. The old ioctl will > continue to behave the same way, while the new ioctl gains the benefit > of using the flags fields. > > Signed-off-by: Jacob Keller Applied to 'net'.