From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC3D6C3DA4A for ; Thu, 8 Aug 2024 15:48:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E6CD6B0101; Thu, 8 Aug 2024 11:48:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 36EE66B0103; Thu, 8 Aug 2024 11:48:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2362D6B0104; Thu, 8 Aug 2024 11:48:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0456D6B0101 for ; Thu, 8 Aug 2024 11:48:25 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9ACE51C086E for ; Thu, 8 Aug 2024 15:48:25 +0000 (UTC) X-FDA: 82429510170.21.B917B9D Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) by imf07.hostedemail.com (Postfix) with ESMTP id B545C4001C for ; Thu, 8 Aug 2024 15:48:22 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=paul-moore.com header.s=google header.b=Cb0mi2BG; spf=pass (imf07.hostedemail.com: domain of paul@paul-moore.com designates 209.85.219.171 as permitted sender) smtp.mailfrom=paul@paul-moore.com; dmarc=pass (policy=none) header.from=paul-moore.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723132038; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=22xwefQTm5yCA00hBHdSOjXx4hMeWSAiLR6KMP/J2n0=; b=TXdVgCo7fHzrE47yWZCiDGYyz0Yc64qS4RxZnkDiBvozZuFf0KzjptKMtXYniUOlrHXiXh V29N2LSR0m4yFcleO2VLpkW+q//QXYhR0ekL5kwTlfrk/5yiSLtrX5bkJtL3BvICFpX/gc UbfJtPqC2Fl7UYYzR9gxxPwvqJFfqEQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723132038; a=rsa-sha256; cv=none; b=l0qD10+WJVYGPM11Pkvk0d2wDdns4a/RAXbXnWqaJVFrPXIGpTwW8cNH+znVl6CutRxz3I QAkVAIV2xmd2h3vTR8s7B3b8QyjHdTwqm9sxOiZagvlgkLmE6MCSUE8LbdADkMo/n2soxy Zm0gxZwx9foKsrA1HMUiXbFPRi2I3dQ= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=paul-moore.com header.s=google header.b=Cb0mi2BG; spf=pass (imf07.hostedemail.com: domain of paul@paul-moore.com designates 209.85.219.171 as permitted sender) smtp.mailfrom=paul@paul-moore.com; dmarc=pass (policy=none) header.from=paul-moore.com Received: by mail-yb1-f171.google.com with SMTP id 3f1490d57ef6-e0bfa0b70ceso1046365276.2 for ; Thu, 08 Aug 2024 08:48:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1723132102; x=1723736902; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=22xwefQTm5yCA00hBHdSOjXx4hMeWSAiLR6KMP/J2n0=; b=Cb0mi2BGgZAfWgHz87jaf0HZ/xuJtQcNiAmsCVAaDMwsudwZj4/cdFfUGWhuq7Vqai ly2jfFC0glR+7HZwqpIVBxtjf3ptuu4FLvb2pv19Okj9llsBMrYU90OrprHVoHYHgxTF rVjKrzdK3qOxaF0+B6nAb/1rK+7315thOlEF+zxFEm4V77gGJgcvgFmRbsOLECWdJykI uDh0+YVfpJBnAi70AbuH05p4sFS+QHuCKqNrxZ7m7SHgR/RTHd8QOrvfZF/6oN1wJIFf yZFO6gtZGc+pkdgnl5SM1SsZbFiwQ6nASeaeMoN8om0X89DWi5d3MG3dMqI6YbImHpYU KEGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723132102; x=1723736902; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=22xwefQTm5yCA00hBHdSOjXx4hMeWSAiLR6KMP/J2n0=; b=lA7K9ntH5tw/Arhxjul9jPxNwyuWNkS4vE5kLCPXZQqZ5sWyR3Ttbl3XrbSZh7rQDv uvqCQZfbn9yJJQbdvYYEUnBP4JstyEpSf7BBShiQUkEXoPr/7QgW7ph/Y4KEegA4mD9D h/rKn7nFH66gmW08qkJN6z3JRi+ffcZY0EPFLstmGheaDAAFpCBIOvxuWbptppfL2Wxs up/vxbkoX0vfDFgTMA0cfAuyQGatf4Hvyyn6p8eXi8ZPhWoSs0Qgp4TBlTXNJ9LQV6r2 zGsOyYwnSE9r/xK8VXnAXLCKY1hz/MHXuXUCv5zantEQrmWMCxk7tIBIQhZtzW29ytqu dQKw== X-Forwarded-Encrypted: i=1; AJvYcCXIfTzfw6E8FlYmhUwcJkC8NJlKG0gLKpvvvQuuzPXYQE3+Mo1+Jad5ojLQgZrUkZ96dwvrmbPryQ==@kvack.org X-Gm-Message-State: AOJu0YypZyynwxSeLbdPFySvV/Mvgms4q9NEHtzesIeSD8iCP0H6L4SQ 61SByUxgzM49ehnj6a3RGoRYd/31KgQ8d8yn0XhCDZ+ThHGlJCv7Xb3flf4DqFoNrVoJDCg3KcE Q6Dc2vyZttTfmBFQ1k0oVVYjvzzXXy5rpIFlq X-Google-Smtp-Source: AGHT+IFsntQfurwiu3E1dnmz1AS910G1RH89ZcxrIjyTqHbKfs86gPKiV+MEE8/m33GxcSnhu/X33dNFjoVsD6krZTg= X-Received: by 2002:a05:6902:250e:b0:e0b:e279:9940 with SMTP id 3f1490d57ef6-e0e9daaa03cmr2421446276.15.1723132101728; Thu, 08 Aug 2024 08:48:21 -0700 (PDT) MIME-Version: 1.0 References: <20240808130909.1027860-1-wangkefeng.wang@huawei.com> In-Reply-To: From: Paul Moore Date: Thu, 8 Aug 2024 11:48:10 -0400 Message-ID: Subject: Re: [PATCH] Revert "selinux: use vma_is_initial_stack() and vma_is_initial_heap()" To: Stephen Smalley Cc: Kefeng Wang , Ondrej Mosnacek , selinux@vger.kernel.org, Marc Reisner , david@redhat.com, Vlastimil Babka , "Liam R . Howlett" , Lorenzo Stoakes , linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: B545C4001C X-Stat-Signature: hsikdgo8ibjd4txkpj75c7jh87f3g8b8 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1723132102-635701 X-HE-Meta: U2FsdGVkX1/73nJlAMuE01O3nXEEqSnPy4W3tKBV3dCzvAWqRRUEwJWiAvhdiQW33lrL+9FPh3ZX3mihn+Bz2clf0b0c65zPl/HbnZ2897UGuneuMiczAkjmWB+uK7ia8WZj9y3bxmpLZ1k6matMwCv5MVfbffRvIz4KYEXp8dqjopqMt2rZYe2wk1hwi3wjmLA1ZjDu9SJKVLb8UKv3RuOh4zCo83/c6aU3l/VnjF0N1u7qCfM9w5AwypMuzJskAcnVdq+AfZb3/blm6+uI+VwXOgp4EG1gaQcP1DOnGit2UL+jslMIY1WP2BKuF4Plud7Rk/fOtqHsZp9oq2fla9O0B8an5PpHX/0OA0AFhCuDKDAHaHKU37UAgURAb3OAEG/oixbHx6NhLDkjowceTXWbHy6VcBTKgtjLPdxQ0IGJZenZgbMj6Gf07MI1hS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x0r07lXA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Aug 8, 2024 at 9:40=E2=80=AFAM Stephen Smalley wrote: > > On Thu, Aug 8, 2024 at 9:09=E2=80=AFAM Kefeng Wang wrote: > > > > This reverts commit 68df1baf158fddc07b6f0333e4c81fe1ccecd6ff. > > > > The selinux only want to check whether the VMA range is within the heap > > range or not, but vma_is_initial_heap() helper will check the intersect= ion > > between the two ranges, which leads to some issue, let's turn back to t= he > > original validation. > > > > Reported-by: Marc Reisner > > Closes: https://lore.kernel.org/all/ZrPmoLKJEf1wiFmM@marcreisner.com/ > > Fixes: 68df1baf158f ("selinux: use vma_is_initial_stack() and vma_is_in= itial_heap()") > > Signed-off-by: Kefeng Wang > > I was only going to recommend reverting the change to the heap check > but in case Paul is fine with a straight revert, > Acked-by: Stephen Smalley I was hoping that the mm folks would put together a quick patch to fix what looks like a problem with the helper, but I'm not sure when that is going to happen and with other callers I don't want to change the helper and break a different part of the kernel. Unfortunately that leaves us with needing a revert, but like Stephen said, I think reverting just the heap helper is the right thing to do right now; I also want to put a comment in there for the next time someone tries to re-add the vma_is_initial_heap(). Give me some time, I'll have a patch out for this later today. > > --- > > security/selinux/hooks.c | 7 +++++-- > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c > > index 81fbfa5b80d4..f5805d4b0aec 100644 > > --- a/security/selinux/hooks.c > > +++ b/security/selinux/hooks.c > > @@ -3845,10 +3845,13 @@ static int selinux_file_mprotect(struct vm_area= _struct *vma, > > if (default_noexec && > > (prot & PROT_EXEC) && !(vma->vm_flags & VM_EXEC)) { > > int rc =3D 0; > > - if (vma_is_initial_heap(vma)) { > > + if (vma->vm_start >=3D vma->vm_mm->start_brk && > > + vma->vm_end <=3D vma->vm_mm->brk) { > > rc =3D avc_has_perm(sid, sid, SECCLASS_PROCESS, > > PROCESS__EXECHEAP, NULL); > > - } else if (!vma->vm_file && (vma_is_initial_stack(vma) = || > > + } else if (!vma->vm_file && > > + ((vma->vm_start <=3D vma->vm_mm->start_stack= && > > + vma->vm_end >=3D vma->vm_mm->start_stack) = || > > vma_is_stack_for_current(vma))) { > > rc =3D avc_has_perm(sid, sid, SECCLASS_PROCESS, > > PROCESS__EXECSTACK, NULL); > > -- > > 2.41.0 -- paul-moore.com