From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on archive.lwn.net X-Spam-Level: X-Spam-Status: No, score=-5.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham autolearn_force=no version=3.4.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by archive.lwn.net (Postfix) with ESMTP id E4FAF7D062 for ; Thu, 7 Jun 2018 21:21:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752600AbeFGVVW (ORCPT ); Thu, 7 Jun 2018 17:21:22 -0400 Received: from mga11.intel.com ([192.55.52.93]:28726 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751365AbeFGVVU (ORCPT ); Thu, 7 Jun 2018 17:21:20 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jun 2018 14:21:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,488,1520924400"; d="scan'208";a="48167652" Received: from 2b52.sc.intel.com (HELO [143.183.136.51]) ([143.183.136.51]) by orsmga006.jf.intel.com with ESMTP; 07 Jun 2018 14:21:19 -0700 Message-ID: <1528406288.5794.1.camel@2b52.sc.intel.com> Subject: Re: [PATCH 09/10] mm: Prevent madvise from changing shadow stack From: Yu-cheng Yu To: Nadav Amit Cc: Linux Kernel Mailing List , linux-doc@vger.kernel.org, "open list:MEMORY MANAGEMENT" , linux-arch@vger.kernel.org, the arch/x86 maintainers , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , "H.J. Lu" , Vedvyas Shanbhogue , "Ravi V. Shankar" , Dave Hansen , Andy Lutomirski , Jonathan Corbet , Oleg Nesterov , Arnd Bergmann , Mike Kravetz Date: Thu, 07 Jun 2018 14:18:08 -0700 In-Reply-To: References: <20180607143807.3611-1-yu-cheng.yu@intel.com> <20180607143807.3611-10-yu-cheng.yu@intel.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-doc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On Thu, 2018-06-07 at 14:09 -0700, Nadav Amit wrote: > Yu-cheng Yu wrote: > > > Signed-off-by: Yu-cheng Yu > > --- > > mm/madvise.c | 9 +++++++++ > > 1 file changed, 9 insertions(+) > > > > diff --git a/mm/madvise.c b/mm/madvise.c > > index 4d3c922ea1a1..2a6988badd6b 100644 > > --- a/mm/madvise.c > > +++ b/mm/madvise.c > > @@ -839,6 +839,14 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior) > > if (vma && start > vma->vm_start) > > prev = vma; > > > > + /* > > + * Don't do anything on shadow stack. > > + */ > > + if (vma->vm_flags & VM_SHSTK) { > > + error = -EINVAL; > > + goto out_no_plug; > > + } > > + > > blk_start_plug(&plug); > > for (;;) { > > /* Still start < end. */ > > What happens if the madvise() revolves multiple VMAs, the first one is not > VM_SHSTK, but the another one is? Shouldn’t the test be done inside the > loop, potentially in madvise_vma() ? > I will fix it. Thanks! -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html