Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp4035546ybd; Tue, 25 Jun 2019 12:52:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3/EmlUI0Ew2fdMblrxai5nGkWFyBBsYoI0VtIUdlAx8rAPialSC3asMogbK1AMqWw1mKx X-Received: by 2002:a63:78c3:: with SMTP id t186mr41854905pgc.340.1561492363108; Tue, 25 Jun 2019 12:52:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561492363; cv=none; d=google.com; s=arc-20160816; b=g/nrjfdHVYZS8XdVO8xOteIfzMnvjkfIg8RxldwUeRG1t7WspvHT95oTVhvCnXd0Ck V4wKcH+XxxhRt3i7X8g53+m154M8c+Aw83pcJ1SB281KhmOurTlI30P0kMVL69QDQ95M X0gfSNiqQKfH2wGKJTCtLmWu2lx5AGrdmho2ya6jtj8QYGPKyXb1H4eK3g/lYKVB0kWL T3iifspuf8q1l3qdxVYwzeQZqbYDBdwiGjqgc5r5zU4YfkTgLycDvIwmhW+6XfrA+y3U QtAPnHjYR3NFh7QF346lfxR9PNa8sZd75ZUYDmDRBHaaDn0FovrC1KlXrzsOlCLcDXTb yhIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ZecqvOpYjVE4Qmy3iXx46r1+0juBwCPcIwmCKG2SPQo=; b=h7Unbo0U8h4hHgaMq4EcHV1D+/GWtSEL2GVEaJHFR/adL6XYu8S1WJ9KVTK+OzwNnJ /0451Mz9IDRHmLmK0RWuGzUMnDAySb5xOhEWa0tsD+A+gy5SIxDSl6Sid1mTZCDOvOdX Lc0svNA3cr1zjyulHabvSxEUeR7mpDXO+prh+sfBgSWkhRfOZo+nJbvub07CrZu4auth g6JdeWC8l4PZXwACf0G5qy8wG4G8IbmCwU/Wx8qjQU8/l/qFBSCg7uyvRJSRofH7WKDI ZuwgLRXVcwQExtmvNWnTEcjRDdNh1jhvUrMqUN7S3ZfY92YmK32UgiQivKbqK/d7Xzv9 ALlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ec+kKmKZ; 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 u12si579115pgm.289.2019.06.25.12.52.27; Tue, 25 Jun 2019 12:52:43 -0700 (PDT) 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=ec+kKmKZ; 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 S1729002AbfFYSJV (ORCPT + 99 others); Tue, 25 Jun 2019 14:09:21 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39213 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725921AbfFYSJU (ORCPT ); Tue, 25 Jun 2019 14:09:20 -0400 Received: by mail-wr1-f66.google.com with SMTP id x4so18927195wrt.6; Tue, 25 Jun 2019 11:09:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZecqvOpYjVE4Qmy3iXx46r1+0juBwCPcIwmCKG2SPQo=; b=ec+kKmKZbzDX7Zfqdhmxrx2YsnL4UQMEAcBHEVXnDm9Oyg9TktxFuNuPzyhJoO/5AR vtCvPowZ3sDh/R6kWqh72byj6M2c/oA7Nx+PHxC6gh04tc29HswFHyEo2h/qyv7rzsah sFrTVdMifkYhbqGTcAaCT2yCKf4PIDA5ujIqxtsePpkCJrFBSH2AhVdmt2y6YDVpTSKk 31RezxlmomvcVpvRvpHBPJFeqij0pMlJ+lAxSwg2E5s/mv6jeK6NWQZvByqCeku/NO7Z 0UUQcmk+zGSaR6FSFYsnOTiJW6E3GFNye7NaylMoYs074POeeq66EWNxpatFiiF85l8V YMPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZecqvOpYjVE4Qmy3iXx46r1+0juBwCPcIwmCKG2SPQo=; b=EO6xEW9G3WlKp81iL4jI0EhgFqYSyVzppemhGbR6bf+yR88H5BeE4JHesFiK50HaSx zZOHzwP/AiH8rUljiYzMvFVoVuGtdLetpXdY9ksBjLgUZ6GihpWqKq5xB03tRaepeYKW qkbPWLPSHahWsTntKwweLUCyRKC8S7sV38kpiZlz3mXiyZBZ2g06akdzpAvqHj5kHca6 TMNx2b+FA9sw6W8/OQWeN2kvuiIaLAxMzi3fUVQ/jURFWXmeHEF7U1V/mTHBqFv2ZML3 QEyU17F25kzuhjUgJEda2UxvzCWdRQ0pQdl0sHy9tzbfExOyI+qDS6yvnHbPUtg7gnQj Uyeg== X-Gm-Message-State: APjAAAUKX3ZMIpTx72gtRm09FczbzNXyuOaDi0WA4WEdcxRwZtTPFNgY UM9XkoJBLJTGoOvrQIXCEVQ1EjmogyWIKZLCnvY= X-Received: by 2002:a5d:5386:: with SMTP id d6mr19819643wrv.207.1561486158264; Tue, 25 Jun 2019 11:09:18 -0700 (PDT) MIME-Version: 1.0 References: <20190616153804.3604-1-hdanton@sina.com> <20190617134913.GL3436@localhost.localdomain> <20190617144331.GE3500@localhost.localdomain> In-Reply-To: <20190617144331.GE3500@localhost.localdomain> From: Xin Long Date: Wed, 26 Jun 2019 02:09:06 +0800 Message-ID: Subject: Re: general protection fault in sctp_sched_prio_sched To: Marcelo Ricardo Leitner Cc: Hillf Danton , syzbot , davem , LKML , linux-sctp@vger.kernel.org, network dev , Neil Horman , syzkaller-bugs , Vlad Yasevich Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 17, 2019 at 10:43 PM Marcelo Ricardo Leitner wrote: > > On Mon, Jun 17, 2019 at 10:49:13AM -0300, Marcelo Ricardo Leitner wrote: > > Hi, > > > > On Sun, Jun 16, 2019 at 11:38:03PM +0800, Hillf Danton wrote: > > > > > > Hello Syzbot > > > > > > On Sat, 15 Jun 2019 16:36:06 -0700 (PDT) syzbot wrote: > > > > Hello, > > > > > > > > syzbot found the following crash on: > > > > > > ... > > > Check prio_head and bail out if it is not valid. > > > > > > Thanks > > > Hillf > > > ----->8--- > > > --- > > > net/sctp/stream_sched_prio.c | 2 ++ > > > 1 file changed, 2 insertions(+) > > > > > > diff --git a/net/sctp/stream_sched_prio.c b/net/sctp/stream_sched_prio.c > > > index 2245083..db25a43 100644 > > > --- a/net/sctp/stream_sched_prio.c > > > +++ b/net/sctp/stream_sched_prio.c > > > @@ -135,6 +135,8 @@ static void sctp_sched_prio_sched(struct sctp_stream *stream, > > > struct sctp_stream_priorities *prio, *prio_head; > > > > > > prio_head = soute->prio_head; > > > + if (!prio_head) > > > + return; > > > > > > /* Nothing to do if already scheduled */ > > > if (!list_empty(&soute->prio_list)) > > > -- > > > > Thanks but this is not a good fix for this. It will cause the stream > > to never be scheduled. > > > > The problem happens because of the fault injection that happened a bit > > before the crash, in here: > > > > int sctp_stream_init_ext(struct sctp_stream *stream, __u16 sid) > > { > > struct sctp_stream_out_ext *soute; > > > > soute = kzalloc(sizeof(*soute), GFP_KERNEL); > > if (!soute) > > return -ENOMEM; > > SCTP_SO(stream, sid)->ext = soute; <---- [A] > > > > return sctp_sched_init_sid(stream, sid, GFP_KERNEL); > > ^^^^^^^^^^^^---- [B] failed > > } > > > > This causes the 1st sendmsg to bail out with the error. When the 2nd > > one gets in, it will: > > > > sctp_sendmsg_to_asoc() > > { > > ... > > if (unlikely(!SCTP_SO(&asoc->stream, sinfo->sinfo_stream)->ext)) { > > ^^^^^--- [C] > > err = sctp_stream_init_ext(&asoc->stream, sinfo->sinfo_stream); > > if (err) > > goto err; > > } > > > > [A] leaves ext initialized, despite the failed in [B]. Then in [C], it > > will not try to initialize again. > > > > We need to either uninitialize ->ext as error handling for [B], or > > improve the check on [C]. > > The former one, please. This should be enough (untested): > > diff --git a/net/sctp/stream.c b/net/sctp/stream.c > index 93ed07877337..25946604af85 100644 > --- a/net/sctp/stream.c > +++ b/net/sctp/stream.c > @@ -153,13 +153,20 @@ int sctp_stream_init(struct sctp_stream *stream, __u16 outcnt, __u16 incnt, > int sctp_stream_init_ext(struct sctp_stream *stream, __u16 sid) > { > struct sctp_stream_out_ext *soute; > + int ret; > > soute = kzalloc(sizeof(*soute), GFP_KERNEL); > if (!soute) > return -ENOMEM; > SCTP_SO(stream, sid)->ext = soute; > > - return sctp_sched_init_sid(stream, sid, GFP_KERNEL); > + ret = sctp_sched_init_sid(stream, sid, GFP_KERNEL); > + if (ret) { > + kfree(SCTP_SO(stream, sid)->ext); > + SCTP_SO(stream, sid)->ext = NULL; > + } > + > + return ret; > } > > void sctp_stream_free(struct sctp_stream *stream) > Tested-by: Xin Long Hi, Marcelo, please feel free to move forward with this patch, :-)