Received: by 2002:ac0:8c8e:0:0:0:0:0 with SMTP id r14csp1051703ima; Wed, 6 Feb 2019 12:52:10 -0800 (PST) X-Google-Smtp-Source: AHgI3IbrPp/jOy8ffvW4JM9BLCLRGnYwNOP9wg0L+JfmHARokph5SZpR2GAJOpZ2XVFWn/3SSPay X-Received: by 2002:a63:ca02:: with SMTP id n2mr1635137pgi.187.1549486330636; Wed, 06 Feb 2019 12:52:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549486330; cv=none; d=google.com; s=arc-20160816; b=ptRs9G1Sb/F6+dKc+9Ghc8o9FZUl0KJxRDz3FG2/WHuTEYc8+sX3EfqiM8DD16ms8s QghXrgv0CLq+pDZ2dmH4fFRqc85oeg/4ui31YMOPfn9MqUALA8a4bpzOPAP+AJYxv7Kk aFD43iABmVPpkT43fEC0ULDdvCO5yWSHWutUKlQ7mpUAK8/V0GnWzU0PDWJA54KPzIGM hcYZ6oyhb3C3rc/d0/wRSI9cFF6KQwrPp83NG9yFZL3GWWBDuZ8bu6K+iiqb1SU0Bkdd iI+sGc7oL6BQ644MWhx+auf5rlFOudR5TJbJMFhdefjCIYBMusqLMKPKnKbvvXyO5p8U gXIA== 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; bh=+Y1Nq4RhCDbQNNUKtBdBfLWMTeejw5o4EelVUniS13U=; b=g/LXPGKrYGUAS3OdSBH5um5vo/wnWZrRMuvVfevp2Nai3k1pg1r8fOLlIks9u+YpBU qapr5mEXlLZw0zl7e+WHolWTJHp3C1RMo+BBnT1Hpvm5FxbaJSY4QebzLD5ts5Ghhj1C OpE2D3MANYQwiuY+/MkVw4z/01Rmkmo89kY05pswu2w3A+tyhHqG+i1LHJbmtGE3HCRK OUgWEMudGGQjR2Oj/4XDmHUH0m2Wsp1LJF4Jxhd2hrjW8waqJejNBj+TgBNdkGQQwdH+ aV84uS1YpDItBH1XoRXU00O8IVSmtZhkkTPNyrSFwvyX3pl9tsgOGrHF5Wvmx/CoRCSC 0n3g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x15si6986298pgq.378.2019.02.06.12.51.53; Wed, 06 Feb 2019 12:52:10 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726852AbfBFUu3 (ORCPT + 99 others); Wed, 6 Feb 2019 15:50:29 -0500 Received: from charlotte.tuxdriver.com ([70.61.120.58]:33835 "EHLO smtp.tuxdriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726001AbfBFUu3 (ORCPT ); Wed, 6 Feb 2019 15:50:29 -0500 Received: from cpe-2606-a000-111b-405a-9816-2c85-c514-8f7a.dyn6.twc.com ([2606:a000:111b:405a:9816:2c85:c514:8f7a] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1grU95-00074p-ED; Wed, 06 Feb 2019 15:50:24 -0500 Date: Wed, 6 Feb 2019 15:49:42 -0500 From: Neil Horman To: Julien Gomes Cc: netdev@vger.kernel.org, linux-sctp@vger.kernel.org, linux-kernel@vger.kernel.org, davem@davemloft.net, marcelo.leitner@gmail.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: <20190206204942.GB16887@hmswarspite.think-freely.org> References: <20190206201430.18830-1-julien@arista.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190206201430.18830-1-julien@arista.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Score: -2.9 (--) X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > Signed-off-by: Julien Gomes > --- > net/sctp/socket.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/sctp/socket.c b/net/sctp/socket.c > index 9644bdc8e85c..f9717e2789da 100644 > --- a/net/sctp/socket.c > +++ b/net/sctp/socket.c > @@ -2311,7 +2311,7 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval, > int i; > > if (optlen > sizeof(struct sctp_event_subscribe)) > - return -EINVAL; > + optlen = sizeof(struct sctp_event_subscribe); > I'm not sure I like this. If you have a userspace application built against more recent uapi headers than the kernel you are actually running on, then by defintion you won't have this check in place, and you'll get EINVAL returns anyway. If you just backport this patch to an older kernel, you'll not get the EINVAL return, but you will get silent failures on event subscriptions that your application thinks exists, but the kernel doesn't recognize. This would make sense if you had a way to communicate back to user space the unrecognized options, but since we don't (currently) have that, I would rather see the EINVAL returned than just have things not work. Neil > if (copy_from_user(&subscribe, optval, optlen)) > return -EFAULT; > -- > 2.20.1 > >