Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4328522pxv; Tue, 20 Jul 2021 00:41:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKlsu11C51hr9pauXXSvSLXsVQXKdiKcse0U/6lZ206y6HBFkAN+cbvWZUY7m6FBAtCab5 X-Received: by 2002:a17:906:2752:: with SMTP id a18mr32655030ejd.458.1626766859898; Tue, 20 Jul 2021 00:40:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626766859; cv=none; d=google.com; s=arc-20160816; b=NioA6LFMoQJT01YsnPHpCnuPBKqB68F28DsOQlSpfJpFl6zKc1FKGH3wXl6ohOJiDZ lZyEMCuCgvF9cadUyUBbs2vyJwglo0W/TCmjlBhYwZ7BZ7OZb73tz0ukqagph0TfVITp IGfjBc0oQ+gMIjzBYa2F8lxNmLv/kVJ1TjlBN7nPft/zSnyRyJN3tXeiSh07A1aUY2NP ThJlP4Dgn2gTIgPs3q0Lke5rG1HD24gubMzQojAS8Y9h0nPNnmjB82CMWE2I0VOZzkx9 QqdVBwhWWy3MJMsm2mIjXkVTPix0U3ubhkPFcFtn7w++4aLt/qIAuQV4r+Zczt7Ms94H mWEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=pwbSHIBLxgN9zlEsecgswveri3V8MEcEgSNn8jds2Tc=; b=l7smrInjJR771GtgK5zJyS8YAfnLPONt0OloOwDEzeEYYdaUEot3YGdHFcyBVMi/07 UaPrf+vQyEQ1OTv8PgYEAi756ldSTf6OVR+9RRITbvGf02U8D7XsE0aHO3DentV/cXlU UCQ61vx0gyvW/cAoR0YYf4rQUFnIBESChp7Xfm+9SqmJCOjrZY0Ae761F/Jn5PSSZjP7 UwMVnTmRV2q3OjDkWAazPBvEZu8oL2WxG8C7nGmT0tTu5WDRvbAQA66qR8o2o0C/jNKL ohmidCWky4E9Mc0rd6/HkiLuU3DyAfaMt4MZjFXXfvF23TGDPPPRh1Ud4FT+FtMdh1Hd nb9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f+ZpcNdy; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q21si23902842edw.595.2021.07.20.00.40.36; Tue, 20 Jul 2021 00:40:59 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f+ZpcNdy; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233639AbhGTG4b (ORCPT + 99 others); Tue, 20 Jul 2021 02:56:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232164AbhGTG4a (ORCPT ); Tue, 20 Jul 2021 02:56:30 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 218DCC061574 for ; Tue, 20 Jul 2021 00:37:08 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id m83so18879199pfd.0 for ; Tue, 20 Jul 2021 00:37:08 -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=pwbSHIBLxgN9zlEsecgswveri3V8MEcEgSNn8jds2Tc=; b=f+ZpcNdyeBneAeWjVRGw6Bdsa73D3S6JwUB+9vz0k13cRWodFdl3JotZDuHy678rf+ GMscKndaIV5JWODN6mftvEkPdQeWkfSsZr3ZSquwkHTmgAwewAu799ggUNfgxt5qoHJY 8mS5dt+lmntFbvJkAyMP1he8RRLsZ542Iwn6D9EBZis+1NvRRst50/I/AI7a5QZ7Mxhx 0Yc+VWcrHNSvrH3ie5AzU2E9obEtD/twmsv01SBpfZqKFvQm/5G1/yKDXNjcKnXtxHRq v1dmgMI4jrupltLtRLMfUJI1g+HRM/Ciwdx1RaUA23JxUIJn1lAY7U8dfm7IY8VGqTzG VgKA== 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=pwbSHIBLxgN9zlEsecgswveri3V8MEcEgSNn8jds2Tc=; b=P3T1xOqbc5vV3UFxm1NrDVRxM2+l0B/arxA+ULxB1Y34czl9jFe9dBpvxG2ehsaszh ZfKLb/meDrqOuml/B0A/KMOJealpQRBj3ExgaPVdSP2qGY3uYgYqP+tMSVdju0Vncfgs /rAYTRem3VqfUgN0QB/kTd5e4x73NoyVELQ5MA5pWKKRpDDye8CxusleWAg2H0gVUcHv jgYL530lpFrGAFFa64ETo+yHzlOflkbh7jfZ09DYWxVruyUr8UAeqPCtcaYkHhONMOkD A37U2uLRhytBngbXwFQdmhkOI9gff3iuHlTYx7UCYdPECXn/2gQkvkHiMvilF1jM5gAs RLvw== X-Gm-Message-State: AOAM531PO3VWx9pntDx6F5i77Lf89IFcA/kPKKi+8Gzd44vnWvEmvyWv 0+LtkEWw5s0N51zYa0agCbWqqczI5i+Nsfu49FI= X-Received: by 2002:a63:114d:: with SMTP id 13mr29931210pgr.180.1626766627504; Tue, 20 Jul 2021 00:37:07 -0700 (PDT) MIME-Version: 1.0 References: <20210121221207.GB2174@grain> In-Reply-To: <20210121221207.GB2174@grain> From: Andrei Vagin Date: Tue, 20 Jul 2021 00:33:11 -0700 Message-ID: Subject: Re: [PATCH] prctl: allow to setup brk for et_dyn executables To: Cyrill Gorcunov Cc: LKML , Keno Fischer , Andrew Morton , Dmitry Safonov <0x7f454c46@gmail.com>, Kirill Tkhai , "Eric W. Biederman" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 21, 2021 at 2:12 PM Cyrill Gorcunov wrote: > > Keno Fischer reported that when a binray loaded via > ld-linux-x the prctl(PR_SET_MM_MAP) doesn't allow to > setup brk value because it lays before mm:end_data. > > For example a test program shows > > | # ~/t > | > | start_code 401000 > | end_code 401a15 > | start_stack 7ffce4577dd0 > | start_data 403e10 > | end_data 40408c > | start_brk b5b000 > | sbrk(0) b5b000 > > and when executed via ld-linux > > | # /lib64/ld-linux-x86-64.so.2 ~/t > | > | start_code 7fc25b0a4000 > | end_code 7fc25b0c4524 > | start_stack 7fffcc6b2400 > | start_data 7fc25b0ce4c0 > | end_data 7fc25b0cff98 > | start_brk 55555710c000 > | sbrk(0) 55555710c000 > > This of course prevent criu from restoring such programs. > Looking into how kernel operates with brk/start_brk inside > brk() syscall I don't see any problem if we allow to setup > brk/start_brk without checking for end_data. Even if someone > pass some weird address here on a purpose then the worst > possible result will be an unexpected unmapping of existing > vma (own vma, since prctl works with the callers memory) but > test for RLIMIT_DATA is still valid and a user won't be able > to gain more memory in case of expanding VMAs via new values > shipped with prctl call. > > Reported-by: Keno Fischer > Signed-off-by: Cyrill Gorcunov > CC: Andrew Morton > CC: Dmitry Safonov <0x7f454c46@gmail.com> > CC: Andrey Vagin Acked-by: Andrey Vagin Fixes: bbdc6076d2e5 ("binfmt_elf: move brk out of mmap when doing direct loader exec") > CC: Kirill Tkhai > CC: Eric W. Biederman > --- > Guys, take a look please once time permit. Hopefully I didn't > miss something 'cause made this patch via code reading only. > > Andrey, do we still have a criu container which tests new kernels, > right? Would be great to run criu tests with this patch applied > to make sure everything is intact. Sorry for the delay. I run tests and everything works as expected. Thanks, Andrei