Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1539874imj; Sun, 10 Feb 2019 04:47:00 -0800 (PST) X-Google-Smtp-Source: AHgI3IZJEVIXd+fB9aRgeApaEdG+UmyluZfK2eJL5KWos8noukue3vBXr8NHI1K7qlh2I2eZKPNT X-Received: by 2002:a17:902:8498:: with SMTP id c24mr23170961plo.265.1549802820854; Sun, 10 Feb 2019 04:47:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549802820; cv=none; d=google.com; s=arc-20160816; b=T8dLBqJTl+EZCdya1iB/HM0lZuR3Pz7FASFcjuZeAH3iG9+agm/rb9dR4qOfjdQKUo H1LVhe4vBfO/cHhoOIMYYDdplmx+dv1Rsl4+VhfHHonhrPVG8RtiUlZVoezojsXyoEIc 9Ze+u1QrwQjgLqwtkSJl7yqczWu9BJuEkREAAfbig44Cd+eQaibCkNDOjcFYUWMEnPVE 5qImiaAILhuWHJWGpOQBKrHvrPTfboWP7+TWfpr0+eqvBG0exdGou51d8E2ld36wuCmj 5T96bIueKl5GNjzyLuOgODkjFTk5FuM67yV2xSzukDtT1sa52INeUGw3bGn4OCWh5d35 61hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=YhOXkZX8DvIeXkLgANmgfAGpjEeXnSHUdDX4+pAqzns=; b=NT47zi7gAs5xvr59rfMZtDX9I8qD9Zhw6MnxKBhHUVAXeDUCrsv9Px1lXW725ktDO+ 0s+uinApXHA3/PY+b6My14Y3hHD/BCkpK/NZzeBah6hPpmQtyYxUea6XXRbvl1prSiKa Vg3k8GUth6mtGbX9or5WTkd9CLWhT5KKtmKnB4ocXBSkFu8L0tc2DtgTIr1KnaMB5XhR VwM1HAg85NMAMsBa2juxCoM6KeHcb2F8AmfkIdmbI/FgLCJUzVFUpnbWFZB6dQtvx3P7 YWw4UFJ9unFGhdj51XodP+aL+p9I5QUSdJdVo0R8H2XoseCxGMe11tj1jFOleOzApfy5 jLrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kQy87ahJ; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1si7160253pgg.301.2019.02.10.04.46.45; Sun, 10 Feb 2019 04:47:00 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kQy87ahJ; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726267AbfBJMqW (ORCPT + 99 others); Sun, 10 Feb 2019 07:46:22 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:39266 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726009AbfBJMqW (ORCPT ); Sun, 10 Feb 2019 07:46:22 -0500 Received: by mail-qt1-f194.google.com with SMTP id o6so9177159qtk.6; Sun, 10 Feb 2019 04:46:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=YhOXkZX8DvIeXkLgANmgfAGpjEeXnSHUdDX4+pAqzns=; b=kQy87ahJhd+XqEg/LjOzjuWmGxcN66zhkubDqtPLwpTkJwuLHTpJboUIwSFCDjpBND uzGkvd9kXBN42fl/nnMHJbylWlHm0rc+aiSRRms6W1y63JveNN7lcaozG1vOkojwjQ8K 4dKbt/5fgY+3tgMv+n4+jHq/8ABN/wI0kwqcDiYGnRm3HozLi5/6CPcC5nk5YaD/Zlgn y30UwRGq6H0aRrV0dMT9qIpDZp+Uxa9hiqyrzkU3pFLOFMU/NFKgm1NUO2xISSOMLxoM zV1/2POPUFtaihYzsP2dIFylO66Y+z0chtghaCMjK5ccYpCNrMRtIL0ppKpghrc6qCd8 WDWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=YhOXkZX8DvIeXkLgANmgfAGpjEeXnSHUdDX4+pAqzns=; b=WhwYdDWTuK2S2BuRQdZEqZFSpf1pcca5L7d96STTtZXr22FHtnV1kHL+ipEX+9tN2n kPxothpoymFdTIuSQ9GoK+ZunfDuanABUFhrn0FV+Um0c1yuXk1/m1bNY34sHltcIVIU kjZwwtiZmFbKnorPeVLLQ4TEd31JI5UCKncvqkhqP5UEMUN4xsVrQZC7UJ9tB1vhMCik Fzwl9/4gyQlFffqaJLehDBWiuDL5xu7ApHOgCQRYEVOMh9tguGj+2RTxZR4Au8pQx7hU YIazHNykj09/KlHGjGyVFP3PXpFlPhQo7fG76drCLfpwgDpHZ8GUhNjseDgMIHL/0T60 6zDA== X-Gm-Message-State: AHQUAuYqFXxXIGcJPq0mBOpCZMDAZBGyvK8GsD+HgNnCvnG0v0ZaacJ3 ibWlOcHSDiLALpO9f3JRd4X5ylfo X-Received: by 2002:ac8:3e1a:: with SMTP id z26mr23799873qtf.180.1549802780985; Sun, 10 Feb 2019 04:46:20 -0800 (PST) Received: from localhost.localdomain ([168.194.160.109]) by smtp.gmail.com with ESMTPSA id u128sm5333331qkh.66.2019.02.10.04.46.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Feb 2019 04:46:19 -0800 (PST) Received: by localhost.localdomain (Postfix, from userid 1000) id 056F3180B5B; Sun, 10 Feb 2019 10:46:16 -0200 (-02) Date: Sun, 10 Feb 2019 10:46:16 -0200 From: Marcelo Ricardo Leitner To: David Miller Cc: julien@arista.com, netdev@vger.kernel.org, linux-sctp@vger.kernel.org, linux-kernel@vger.kernel.org, nhorman@tuxdriver.com, vyasevich@gmail.com, lucien.xin@gmail.com Subject: Re: [PATCH net] sctp: make sctp_setsockopt_events() less strict about the option length Message-ID: <20190210124616.GG13621@localhost.localdomain> References: <20190206201430.18830-1-julien@arista.com> <20190206203754.GC13621@localhost.localdomain> <20190209.151217.175627323493244750.davem@davemloft.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190209.151217.175627323493244750.davem@davemloft.net> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 09, 2019 at 03:12:17PM -0800, David Miller wrote: > From: Marcelo Ricardo Leitner > Date: Wed, 6 Feb 2019 18:37:54 -0200 > > > On Wed, Feb 06, 2019 at 12:14:30PM -0800, Julien Gomes wrote: > >> Make sctp_setsockopt_events() able to accept sctp_event_subscribe > >> structures longer than the current definitions. > >> > >> This should prevent unjustified setsockopt() failures due to struct > >> sctp_event_subscribe extensions (as in 4.11 and 4.12) when using > >> binaries that should be compatible, but were built with later kernel > >> uapi headers. > > > > Not sure if we support backwards compatibility like this? > > What a complete mess we have here. > > Use new socket option numbers next time, do not change the size and/or > layout of existing socket options. What about reusing the same socket option, but defining a new struct? Say, MYSOCKOPT supports struct mysockopt, struct mysockopt2, struct mysockopt3... That way we have a clear definition of the user's intent. > > This whole thread, if you read it, is basically "if we compatability > this way, that breaks, and if we do compatability this other way oh > shit this other thing doesn't work." > > I think we really need to specifically check for the difference sizes > that existed one by one, clear out the part not given by the user, and > backport this as far back as possible in a way that in the older kernels > we see if the user is actually trying to use the new features and if so > error out. I'm afraid clearing out may not be enough, though seems it's the best we can do so far. If the struct is allocated but not fully initialized via a memset, but by setting its fields one by one, the remaining new fields will be left uninitinialized. > > Which, btw, is terrible behavior. Newly compiled apps should work on > older kernels if they don't try to use the new features, and if they One use case here is: a given distro is using kernel X and app Foo is built against it. Then upgrades to X+1, Foo is patched to fix an issue and is rebuilt against X+1. The user upgrades Foo package but for whatever reason, doesn't upgrade kernel or reboot the system. Here, Foo doesn't work anymore until the new kernel is also running. > can the ones that want to try to use the new features should be able > to fall back when that feature isn't available in a non-ambiguous > and precisely defined way. > > The fact that the use of the new feature is hidden in the new > structure elements is really rotten. > > This patch, at best, needs some work and definitely a longer and more > detailed commit message.