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 X-Spam-Level: X-Spam-Status: No, score=-11.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BEC6C433FE for ; Fri, 17 Sep 2021 03:02:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E33B611C4 for ; Fri, 17 Sep 2021 03:02:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243450AbhIQDDr (ORCPT ); Thu, 16 Sep 2021 23:03:47 -0400 Received: from out4436.biz.mail.alibaba.com ([47.88.44.36]:62115 "EHLO out4436.biz.mail.alibaba.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231556AbhIQDDn (ORCPT ); Thu, 16 Sep 2021 23:03:43 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=alimailimapcm10staff010182156082;MF=yun.wang@linux.alibaba.com;NM=1;PH=DS;RN=22;SR=0;TI=SMTPD_---0UodiUsp_1631847727; Received: from testdeMacBook-Pro.local(mailfrom:yun.wang@linux.alibaba.com fp:SMTPD_---0UodiUsp_1631847727) by smtp.aliyun-inc.com(127.0.0.1); Fri, 17 Sep 2021 11:02:08 +0800 Subject: Re: [PATCH] x86/dumpstack/64: Add guard pages to stack_info To: Peter Zijlstra Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "open list:PERFORMANCE EVENTS SUBSYSTEM" , "open list:PERFORMANCE EVENTS SUBSYSTEM" , "open list:BPF (Safe dynamic programs and tools)" , "open list:BPF (Safe dynamic programs and tools)" , jroedel@suse.de, x86@kernel.org, Josh Poimboeuf References: <20210910153839.GH4323@worktop.programming.kicks-ass.net> <3fb7c51f-696b-da70-1965-1dda9910cb14@linux.alibaba.com> <3f26f7a2-0a09-056a-3a7a-4795b6723b60@linux.alibaba.com> <76de02b7-4d87-4a3a-e4d4-048829749887@linux.alibaba.com> From: =?UTF-8?B?546L6LSH?= Message-ID: Date: Fri, 17 Sep 2021 11:02:07 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/9/16 下午6:02, Peter Zijlstra wrote: [snip] > > +static __always_inline bool in_stack_guard(void *addr, void *begin, void *end) > +{ > +#ifdef CONFIG_VMAP_STACK > + if (addr > (begin - PAGE_SIZE)) > + return true; After fix this logical as: addr >= (begin - PAGE_SIZE) && addr < begin it's working. Regards, Michael Wang > +#endif > + return false; > +} [snip] > > #ifdef CONFIG_X86_ESPFIX64 > @@ -455,9 +456,11 @@ DEFINE_IDTENTRY_DF(exc_double_fault) > * stack even if the actual trigger for the double fault was > * something else. > */ > - if ((unsigned long)task_stack_page(tsk) - 1 - address < PAGE_SIZE) { > - handle_stack_overflow("kernel stack overflow (double-fault)", > - regs, address); > + if (get_stack_info_noinstr((void *)address, current, &info) && > + info.type & STACK_TYPE_GUARD) { > + const char *name = stack_type_name(info.type & ~STACK_TYPE_GUARD); > + pr_emerg("BUG: %s stack guard hit at %p (stack is %p..%p)\n", > + name, (void *)address, info.begin, info.end); > } > #endif > > @@ -708,7 +711,9 @@ asmlinkage __visible noinstr struct pt_regs *vc_switch_off_ist(struct pt_regs *r > sp = regs->sp; > stack = (unsigned long *)sp; > > - if (!get_stack_info_noinstr(stack, current, &info) || info.type == STACK_TYPE_ENTRY || > + if (!get_stack_info_noinstr(stack, current, &info) || > + info.type & STACK_TYPE_GUARD || > + info.type == STACK_TYPE_ENTRY || > info.type >= STACK_TYPE_EXCEPTION_LAST) > sp = __this_cpu_ist_top_va(VC2); > >