Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp498007pxb; Fri, 8 Jan 2021 10:09:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJzobtUiByWgPP9c2V6VviGcWUvQJjGTd5EU4xmjPomX5+9hDArTzNuZ9VROMzHESD83XWxe X-Received: by 2002:a17:906:8693:: with SMTP id g19mr3658334ejx.111.1610129392225; Fri, 08 Jan 2021 10:09:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610129392; cv=none; d=google.com; s=arc-20160816; b=eY8EVDZfKpkacwa/6BFCk5qrhrWBwApsmj/GST18M9bEOQ3O5pX4Y+iH9FV9nklNp9 tGLWaeO2cYutDB1RH2Xa4M26FXMbYhmcrB7BOJUVzSjLMd/lr1+vKfu6VJ/J3gYZS8jw Wlsb595QB2x9eKEOchHTYxn9sui4LF1tBwIFCHFynQP8IHrw1klgxZgVRBszzNNJyN/7 hxJbg0nXMTr33DuGdAZxxR4po8tE7Vkb5An2LxsyLqzlum5zdLF/2xaosE3Yfnt+BMnY v0QcB78ozWmZufSt7phMyV/NqdSHh+k1q9cLoSg/x+mvERzEAxKvUQsh06bfCtrDxwJ9 8Hog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=bh47P1brEDFK1aky/ZqHTiPgv0coevdsRoxF3788ZRQ=; b=Uwz7lXf/j1tEBEKZPyfqZGKOeDyg1AWeGLM/jgNcRFCHqsLe3ns7DbL8C+c6UQu4h8 qDwBHeFF0G/7X/gEOKgWF0TREy8T9JrtE6fTdVH152MkoWINR5msXE9wWHz+d5CpzYlx ZRO8cAwF/6RKs0UATEaNz1wATVTTIa/9XN38LWpez/Fn8DoXRxMGAC10Epw7tmdTLBuf Itu5L7NnV5PPSI50FCnjCSfxex75xsNx0lhPvQy0c6q6wdzZLgNzF9FD7xX8ls7iCz/J PhDadx61ZGRB4lSrG5/Rs3ve1bKCzVYG1FRyjrooUfJlbCKCoflhdT79Zk74gWf3bTyN mncw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k26si3841635edx.279.2021.01.08.10.09.28; Fri, 08 Jan 2021 10:09:52 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728586AbhAHSIS (ORCPT + 99 others); Fri, 8 Jan 2021 13:08:18 -0500 Received: from mx2.suse.de ([195.135.220.15]:56354 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727648AbhAHSIS (ORCPT ); Fri, 8 Jan 2021 13:08:18 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A12F2AD1E; Fri, 8 Jan 2021 18:07:36 +0000 (UTC) Date: Fri, 8 Jan 2021 19:07:23 +0100 From: Borislav Petkov To: "Chang S. Bae" Cc: tglx@linutronix.de, mingo@kernel.org, luto@kernel.org, x86@kernel.org, len.brown@intel.com, dave.hansen@intel.com, hjl.tools@gmail.com, Dave.Martin@arm.com, jannh@google.com, mpe@ellerman.id.au, tony.luck@intel.com, ravi.v.shankar@intel.com, libc-alpha@sourceware.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov , linux-kselftest@vger.kernel.org Subject: Re: [PATCH v3 4/4] selftest/x86/signal: Include test cases for validating sigaltstack Message-ID: <20210108180716.GA12995@zn.tnic> References: <20201223015312.4882-1-chang.seok.bae@intel.com> <20201223015312.4882-5-chang.seok.bae@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20201223015312.4882-5-chang.seok.bae@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 22, 2020 at 05:53:12PM -0800, Chang S. Bae wrote: > +static int setup_altstack(void *start, unsigned long size) > +{ > + stack_t ss; > + > + memset(&ss, 0, sizeof(ss)); > + ss.ss_size = size; > + ss.ss_sp = start; > + > + return sigaltstack(&ss, NULL); > +} > + > +static jmp_buf jmpbuf; > + > +static void sigsegv(int sig, siginfo_t *info, void *ctx_void) > +{ > + if (sigalrm_expected) { > + printf("[FAIL]\tSIGSEGV signal delivery is wrong.\n"); "Wrong signal delivered: SIGSEGV (expected SIGALRM)." > + nerrs++; > + } else { > + printf("[OK]\tSIGSEGV signal is delivered.\n"); s/is // > + } > + > + siglongjmp(jmpbuf, 1); > +} > + > +static void sigalrm(int sig, siginfo_t *info, void *ctx_void) > +{ > + if (!sigalrm_expected) { > + printf("[FAIL]\tSIGALRM sigal delivery is wrong.\n"); See above. > + nerrs++; > + } else { > + printf("[OK]\tSIGALRM signal is delivered.\n"); Ditto. > + } > +} > + > +static void test_sigaltstack(void *altstack, unsigned long size) > +{ > + if (setup_altstack(altstack, size)) > + err(1, "sigaltstack()"); > + > + sigalrm_expected = (size > at_minstack_size) ? true : false; > + > + sethandler(SIGSEGV, sigsegv, 0); > + sethandler(SIGALRM, sigalrm, SA_ONSTACK); > + > + if (sigsetjmp(jmpbuf, 1) == 0) { if (!sigsetjmp...) > + printf("[RUN]\tTest an (%s) alternate signal stack\n", "Test an alternate signal stack of %ssufficient size.\n" > + sigalrm_expected ? "enough" : "too-small"); "" : "in"); > + printf("\tRaise SIGALRM. %s is expected to be delivered.\n", > + sigalrm_expected ? "It" : "But SIGSEGV"); "It" : "SIGSEGV" Drop "But". Ask if something's not clear. -- Regards/Gruss, Boris. SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg