Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp302281pxk; Wed, 2 Sep 2020 23:18:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9Z797nHAq0a2gIzQkFAwa3uV9pot8R3e+628SOS3BK+qZ7MUgYjYbfaFecvp4avUCyU0m X-Received: by 2002:a17:906:1106:: with SMTP id h6mr571171eja.200.1599113930308; Wed, 02 Sep 2020 23:18:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599113930; cv=none; d=google.com; s=arc-20160816; b=xCwY0mya0fS+tN6Pp2uwf2mz69sU08cvMpgl928RRQorx61qS6er0tH8Tbf+NRBCv9 a95gBx5O4GMlS1jzXAFppQJmFAp2TiaF0CBXSfh0Yvw1od94SxM1Py2DIa2hvWXOA8E5 ImQKYXmwo2+og2CrtttAY4tu58p5oECuqT0v+F6PKHptMBJv8hho1I6iEUev6Pz+p8jV QBx4xlx9c+Q1jym8GyzAHG1wD/F8jXzYSdTcpqw/eOZkd3StO/Cc4THA17AKHF/b4DmC TkW61ta4+hRfREM2VeX1muoei1tWVQyvmJz/aotED1FUO2GlD0bK3gyL1Nxwy2vEec2t scIw== 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=bI18p1jk8S8/3SQafTzlbwlFG0HsBT49YxcbiQtoLRY=; b=HLIQtX3B9aehT3FHMgVWM3DonCiE3DnElT0EtGvsbpC+Lyi/4H2kXGxiqJSiPUGVp+ QyiQPq9MtGqY244y3mBpCEDuxM8+fso7izpzxe7PNAjzbFC9NBcf8NZz2+PJVaCqitKk DOCZz5ZM48lhf53P4u+/639zSxhDQd5JHk5JD2x/i1TgWYXK2sIHuOdDipBpULqo6VYB pDgyQLmDZUGryEUrYqW4e8wVKvau6Fo50KIZU7u5Jt6pH2y+Zu0T6Yacdct6fZ59CP+e kpNpAkbEMMoxXD+A7R6LhkOMpgHWkohA7wBrXqW123jk5qFVOiY3NU9C/U5n/t6cfVq0 PYNQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cz6si1265515edb.188.2020.09.02.23.18.26; Wed, 02 Sep 2020 23:18:50 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726317AbgICGRU (ORCPT + 99 others); Thu, 3 Sep 2020 02:17:20 -0400 Received: from brightrain.aerifal.cx ([216.12.86.13]:49162 "EHLO brightrain.aerifal.cx" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726047AbgICGRU (ORCPT ); Thu, 3 Sep 2020 02:17:20 -0400 Date: Thu, 3 Sep 2020 02:17:19 -0400 From: Rich Felker To: John Paul Adrian Glaubitz Cc: Michael Karcher , linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org, Yoshinori Sato Subject: Re: [PATCH 3/4] sh: Add SECCOMP_FILTER Message-ID: <20200903061718.GZ3265@brightrain.aerifal.cx> References: <20200722231322.419642-3-kernel@mkarcher.dialup.fu-berlin.de> <20200828155024.GX3265@brightrain.aerifal.cx> <20200828163057.GY3265@brightrain.aerifal.cx> <82b625c2-23cb-69a4-7495-39427430c306@physik.fu-berlin.de> <20200828170259.GZ3265@brightrain.aerifal.cx> <20200829004939.GB3265@brightrain.aerifal.cx> <20200903035603.GV3265@brightrain.aerifal.cx> <20200903054617.GW3265@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 03, 2020 at 08:04:44AM +0200, John Paul Adrian Glaubitz wrote: > On 9/3/20 7:46 AM, Rich Felker wrote: > > > > OK, I think I have an explanation for the mechanism of the bug, and it > > really is a combination of the 2008 bug (confusion of r0 vs r3) and > > the SECCOMP_FILTER commit. When the syscall_trace_entry code path is > > in use, a syscall with argument 5 having value -1 causes > > do_syscall_trace_enter to return -1 (because it returns regs[0], which > > contains argument 5), which the change in entry-common.S interprets as > > a sign to skip the syscall and jump to syscall_exit, and things blow > > up from there. In particular, SYS_mmap2 is almost always called with > > -1 as the 5th argument (fd), and this is even more common on nommu > > where SYS_brk does not work. > > > > I'll follow up with a new proposed patch. > > I'm not sure whether we need another revision of your first patch. Your > previous analysis was at least right regarding the tests 51 and 58 > but those have been fixed now. > > But there were two other tests failing, weren't there? > > I have to recheck later, I just got up (it's 8 AM CEST). The first patch was surely not right; setting syscall_nr to -1 and letting it -ENOSYS clobbered any return value set by the seccomp filters. The one I've sent now should be right. I'll follow up after testing with libseccomp test cases. Rich