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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44D1AC41513 for ; Wed, 19 Jun 2024 17:33:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dEAcc5fI3DOIR7PywStDOYW2rJNbFHAep1/F8fna07o=; b=QsB8WD0bb4zbUbuWGUv3l13ibV GykVfRWPudSgVAbYg19rycCXrxx+vGzohaMWyDSHa0VtU1FkIGDTPtAQoO4dpkVciYKO/KOB0FaIu 5PowR4i+qKQPNF/aM2wcMBrZAElujyRY+YagZkhEIODSCtxW7tFhkqKOOCl5+vGHb0TC2NQSVoHMR 1O85s4yfCb0uam82O2TaEO4rcrwaAM4hPAAWnqHgLuKSIfIrKTAK0xzxzETg0jcBos7y8G7VPKm6C djsMm4nnGAQhcs/LLbbP5qeCxKICO2Ma16C0q122u0O6+1yWaqJt+c6aTRm/JiLvCpsgrcIhaop0I TrVVkp0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJzBh-00000002Ed8-0Pq2; Wed, 19 Jun 2024 17:33:37 +0000 Received: from smtp-out1.suse.de ([195.135.223.130]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJzBb-00000002Ec9-2c3Z for linux-arm-kernel@lists.infradead.org; Wed, 19 Jun 2024 17:33:34 +0000 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0656421A28; Wed, 19 Jun 2024 17:33:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1718818409; h=from:from:reply-to:reply-to: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; bh=dEAcc5fI3DOIR7PywStDOYW2rJNbFHAep1/F8fna07o=; b=17PFQgF4i3aazWqDNL7g3kMLkqJFNEl+udKopJ9WCOifXZM4ft/acIBhjuwD2OfxW46G0L muQP/mfQLiPwIEVjGDhZJBX87LIw7mI2eJYhkze4B3PYfoWrLWAlfRjWeDv/VzVM23Uunf cQYIY3vhsRMO4iF/nNQq6R+SJexRaSU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1718818409; h=from:from:reply-to:reply-to: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; bh=dEAcc5fI3DOIR7PywStDOYW2rJNbFHAep1/F8fna07o=; b=jEK9TtWPeMdoZznUIMy+95NUpMdxrtDvjLUugDSy0187LPdvQi9167dwRibZdQPGfGFZSc ayghp/6tvZqxsMAg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=17PFQgF4; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=jEK9TtWP DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1718818409; h=from:from:reply-to:reply-to: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; bh=dEAcc5fI3DOIR7PywStDOYW2rJNbFHAep1/F8fna07o=; b=17PFQgF4i3aazWqDNL7g3kMLkqJFNEl+udKopJ9WCOifXZM4ft/acIBhjuwD2OfxW46G0L muQP/mfQLiPwIEVjGDhZJBX87LIw7mI2eJYhkze4B3PYfoWrLWAlfRjWeDv/VzVM23Uunf cQYIY3vhsRMO4iF/nNQq6R+SJexRaSU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1718818409; h=from:from:reply-to:reply-to: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; bh=dEAcc5fI3DOIR7PywStDOYW2rJNbFHAep1/F8fna07o=; b=jEK9TtWPeMdoZznUIMy+95NUpMdxrtDvjLUugDSy0187LPdvQi9167dwRibZdQPGfGFZSc ayghp/6tvZqxsMAg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 10DC913668; Wed, 19 Jun 2024 17:33:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id aPznOmcWc2aqSgAAD6G6ig (envelope-from ); Wed, 19 Jun 2024 17:33:27 +0000 Date: Wed, 19 Jun 2024 19:33:24 +0200 From: Petr Vorel To: nobuhiro1.iwamatsu@toshiba.co.jp Cc: chrubis@suse.cz, ltp@lists.linux.it, linux-arm-kernel@lists.infradead.org Subject: Re: [LTP] [PATCH] lib: tst_fd: Add kernel version check to memfd_secret Message-ID: <20240619173324.GA504021@pevik> References: <1718700544-17304-1-git-send-email-nobuhiro1.iwamatsu@toshiba.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spamd-Result: default: False [-3.71 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_RHS_NOT_FQDN(0.50)[]; HAS_REPLYTO(0.30)[pvorel@suse.cz]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DKIM_TRACE(0.00)[suse.cz:+]; TO_DN_NONE(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; MISSING_XM_UA(0.00)[]; REPLYTO_EQ_FROM(0.00)[] X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 0656421A28 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240619_103331_917377_206B3ABE X-CRM114-Status: GOOD ( 31.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Petr Vorel Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org > Hi, > Thanks for your review. > > -----Original Message----- > > From: Cyril Hrubis > > Sent: Tuesday, June 18, 2024 7:16 PM > > To: iwamatsu nobuhiro(岩松 信洋 ○DITC□DIT○OST) > > > > Cc: ltp@lists.linux.it > > Subject: Re: [PATCH] lib: tst_fd: Add kernel version check to memfd_secret > > Hi! > > > memfd_secret is a syscall added since 5.14. On earlier kernels, tests > > > such as accept03, readahead01 and splice07 that use memfd_secret fail. > > > This adds a kernel version check to the tst_fd library when running > > > tests using memfd_secret. > > > Test log on linux-5.10.162/arm32 with version 20240524: > > > ``` > > > $ ./testcases/kernel/syscalls/accept/accept03 > > > tst_test.c:1733: TINFO: LTP version: 20240524 > > > tst_test.c:1617: TINFO: Timeout per run is 0h 00m 30s > > > accept03.c:58: TPASS: accept() on file : ENOTSOCK (88) > > > accept03.c:58: TPASS: accept() on O_PATH file : EBADF (9) > > > accept03.c:58: TPASS: accept() on directory : ENOTSOCK (88) > > > accept03.c:58: TPASS: accept() on /dev/zero : ENOTSOCK (88) > > > accept03.c:58: TPASS: accept() on /proc/self/maps : ENOTSOCK (88) > > > accept03.c:58: TPASS: accept() on pipe read end : ENOTSOCK (88) > > > accept03.c:58: TPASS: accept() on pipe write end : ENOTSOCK (88) > > > accept03.c:58: TPASS: accept() on epoll : ENOTSOCK (88) > > > accept03.c:58: TPASS: accept() on eventfd : ENOTSOCK (88) > > > accept03.c:58: TPASS: accept() on signalfd : ENOTSOCK (88) > > > accept03.c:58: TPASS: accept() on timerfd : ENOTSOCK (88) > > > accept03.c:58: TPASS: accept() on pidfd : ENOTSOCK (88) > > > tst_fd.c:151: TCONF: Skipping fanotify: ENOSYS (38) > > > accept03.c:58: TPASS: accept() on inotify : ENOTSOCK (88) > > > tst_fd.c:170: TCONF: Skipping userfaultfd: ENOSYS (38) > > > accept03.c:58: TPASS: accept() on perf event : ENOTSOCK (88) > > > accept03.c:58: TPASS: accept() on io uring : ENOTSOCK (88) > > > accept03.c:58: TPASS: accept() on bpf map : ENOTSOCK (88) > > > accept03.c:58: TPASS: accept() on fsopen : ENOTSOCK (88) > > > accept03.c:58: TPASS: accept() on fspick : ENOTSOCK (88) > > > accept03.c:58: TPASS: accept() on open_tree : EBADF (9) > > > accept03.c:58: TPASS: accept() on memfd : ENOTSOCK (88) > > > tst_test.c:1677: TBROK: Test killed by SIGILL! > > This looks like a bug either in kernel or libc. > This is caused by __NR_memfd_secure being defined as -1 (0xffffffff)and "Illegal instruction" > occurs when syscall() is executed. And this problem does not occur on x86_64. > I cannot decide if this is a bug or not. I can't decide if this is a bug or not, because this behavior has > existed for a long time. Interesting. But it'd be good to discuss it, right? In case there is something to improve. Cc linux-arm-kernel ML. > > > Summary: > > > passed 20 > > > failed 0 > > > broken 1 > > > skipped 2 > > > warnings 0 > > > ``` > > > Closed: #1145 > > > Signed-off-by: Nobuhiro Iwamatsu > > > --- > > > lib/tst_fd.c | 8 ++++++++ > > > 1 file changed, 8 insertions(+) > > > diff --git a/lib/tst_fd.c b/lib/tst_fd.c index 6538a098c..53f583fa0 > > > 100644 > > > --- a/lib/tst_fd.c > > > +++ b/lib/tst_fd.c > > > @@ -255,8 +255,16 @@ static void open_memfd(struct tst_fd *fd) > > > static void open_memfd_secret(struct tst_fd *fd) { > > > + if ((tst_kvercmp(5, 14, 0)) < 0) { > > > + tst_res(TINFO, "accept() on %s: Linux kernel version is before > > than v5.14", tst_fd_desc(fd)); > > > + errno = ENOSYS; > > > + goto skip; > > > + } > > > + > > > fd->fd = syscall(__NR_memfd_secret, 0); > > > + > > > if (fd->fd < 0) { > > > +skip: > > > tst_res(TCONF | TERRNO, > > > "Skipping %s", tst_fd_desc(fd)); > > > } > > And this looks like you are working around the bug. > Your point is correct... > I would suggest using tst_syscall() to check for syscall undefined instead Well, I guess we don't want to use tst_syscall() otherwise it would call tst_brk(). I proposed similar patch some time ago [1], I suppose you told me privately exactly this. [1] https://patchwork.ozlabs.org/project/ltp/patch/20240124142108.303782-1-pvorel@suse.cz/ > of this modification. How about this modification? > ``` > --- a/lib/tst_fd.c > +++ b/lib/tst_fd.c > @@ -255,7 +255,8 @@ static void open_memfd(struct tst_fd *fd) > static void open_memfd_secret(struct tst_fd *fd) > { > - fd->fd = syscall(__NR_memfd_secret, 0); > + fd->fd = tst_syscall(__NR_memfd_secret, 0); > if (fd->fd < 0) { > tst_res(TCONF | TERRNO, > "Skipping %s", tst_fd_desc(fd)); Therefore how about this? if ((tst_kvercmp(5, 14, 0)) < 0) { tst_res(TCONF, "accept() on %s: skipping due old kernel", tst_fd_desc(fd)); return; } Kind regards, Petr > Best regards, > Nobuhiro