Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp903199ybe; Wed, 11 Sep 2019 06:33:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8q1GwlBENvCLxN4+G0F2jjk3N90KRD16ebp/1BHu861S3uLh1b84H8Qne10PZdOyqLjFM X-Received: by 2002:a17:906:6dd4:: with SMTP id j20mr29882386ejt.173.1568208820101; Wed, 11 Sep 2019 06:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568208820; cv=none; d=google.com; s=arc-20160816; b=Yn8rjpx+A28iOcnNXdH1qC08NgS+6npts5h8zuBefqU4Zf3JwpeK1SRHUJ30rI0TzR ab5EgjuZRiEou3iTdOGxSfPInWaW2ZL0obfpzYV4hTrjyU9102PiNQtbjlTSqDTY0TVi B3Oe1zgjLu0WQ8zz8ZxGwNRI4QL+yluggLP1lwpV+ep9/9pFhUdhnKw7sQbF7MA8xipo aLmQZlpiKhhr5amez2WEGfAm74Y1G0PCGeVMOg/DQKgosIboaCsd6kgHAVyOd9GlwAKZ giAYZOyakSEzuOL6won88tBvl6RogzLPM85xRNKdiz+nmel9YB+Yhu2u00x7pPB8XXaq +XFw== 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=PieAfIu3iR5p6nx4npWZGnCLXYUqZ1NrrrK2N8KuV74=; b=pXxTLL7D/BvQLnGrQh8NQXwLFm2UZDEVNW4VpVez8MVtExMwzq03ZDQffrRncUx5JG dHQ4Za8P+Mr5CmiaIFEx86aK+GZ/FgUvfPkjO60jg7oPLCFd1z9gOY7dWhehc3D/mmvE EGp0eR/yyTQvJ0wPyg/SkxRJj3m1mLEdH/BJjHpdDpolmNxaYF/rUka3jjQih+L1M7y8 Ia8LVThehWMu3HLviYZ/tLpFQHtjATjFD8k/+eMcIO10lmJeFFMfRaBWp310pHy4Pd07 aZzmgsaGTo3feWW3qWhr9qJrcZUm0BKKKnijqXmB5JM59c/rRPj2BFNXTBKIxjlR/Ff0 IDPg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s2si6401edr.121.2019.09.11.06.33.14; Wed, 11 Sep 2019 06:33:40 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727782AbfIKNb2 (ORCPT + 99 others); Wed, 11 Sep 2019 09:31:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40330 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726341AbfIKNb2 (ORCPT ); Wed, 11 Sep 2019 09:31:28 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 02E0A309BDB9; Wed, 11 Sep 2019 13:31:28 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.72]) by smtp.corp.redhat.com (Postfix) with SMTP id 35A9D1001B13; Wed, 11 Sep 2019 13:31:21 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Wed, 11 Sep 2019 15:31:27 +0200 (CEST) Date: Wed, 11 Sep 2019 15:31:20 +0200 From: Oleg Nesterov To: Eugene Syromiatnikov Cc: linux-kernel@vger.kernel.org, Christian Brauner , Andrew Morton , "Peter Zijlstra (Intel)" , Ingo Molnar , "Dmitry V. Levin" , Eric Biederman Subject: Re: [PATCH v2] fork: check exit_signal passed in clone3() call Message-ID: <20190911133119.GA17580@redhat.com> References: <20190910175852.GA15572@asgard.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190910175852.GA15572@asgard.redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 11 Sep 2019 13:31:28 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/10, Eugene Syromiatnikov wrote: > > --- a/kernel/fork.c > +++ b/kernel/fork.c > @@ -2338,6 +2338,8 @@ struct mm_struct *copy_init_mm(void) > * > * It copies the process, and if successful kick-starts > * it and waits for it to finish using the VM if required. > + * > + * args->exit_signal is expected to be checked for sanity by the caller. not sure this comment is really useful but it doesn't hurt > long _do_fork(struct kernel_clone_args *args) > { > @@ -2562,6 +2564,16 @@ noinline static int copy_clone_args_from_user(struct kernel_clone_args *kargs, > if (copy_from_user(&args, uargs, size)) > return -EFAULT; > > + /* > + * exit_signal is confined to CSIGNAL mask in legacy syscalls, > + * so it is used unchecked deeper in syscall handling routines; > + * moreover, copying to struct kernel_clone_args.exit_signals > + * trims higher 32 bits, so it is has to be checked that they > + * are zero. > + */ > + if (unlikely(args.exit_signal & ~((u64)CSIGNAL))) > + return -EINVAL; OK, agreed. As you pointed out, this doesn't guarantee valid_signal(exit_signal). But we do no really care as long as it is non-negative, it acts as exit_signal==0. I have no idea if we want to deny exit_signal >= _NSIG in clone3(), this was always allowed... I think this needs the "CC: stable" tag. Acked-by: Oleg Nesterov