Support for linux stable and glibc tags
cover Support for linux stable and glibc tags
Petr Vorel (4):
lib: Add support for linux stable and glibc tags testinfo.pl: Update parsing more git trees
io_uring02: Add linux-stable-git tag
semctl09: Add glibc-git tag
docparse/testinfo.pl | 102 +++++++++++------- lib/tst_test.c | 41 +++---- .../kernel/syscalls/io_uring/io_uring02.c | 7 ++ .../kernel/syscalls/ipc/semctl/semctl09.c | 17 ++- 4 files changed, 106 insertions(+), 61 deletions(-)
Signature · 1 line
2.30.1
PATCH 1/4 lib: Add support for linux stable and glibc tags
--- lib/tst_test.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-)
lib/tst_test.c +20 -19
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) 2015-2016 Cyril Hrubis <[email protected]> +* Copyright (c) Linux Test Project, 2016-2021 */ #include <limits.h>
@@ -38,6 +39,8 @@ const char *TCID __attribute__((weak));#define LINUX_GIT_URL "https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=" +#define LINUX_STABLE_GIT_URL "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=" +#define GLIBC_GIT_URL "https://sourceware.org/git/?p=glibc.git;a=commit;h="#define CVE_DB_URL "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-"struct tst_test *tst_test;
@@ -492,6 +495,8 @@ static void print_test_tags(void)printf (CVE_DB_URL "%s\n" , tags[i].value); else if (!strcmp(tags[i].name, "linux-git")) printf(LINUX_GIT_URL "%s\n", tags[i].value); + else if (!strcmp(tags[i].name, "linux-stable-git")) +printf (LINUX_STABLE_GIT_URL "%s\n" , tags[i].value);else printf ("%s: %s\n" , tags[i].name, tags[i].value); }
@@ -671,44 +676,40 @@ static void print_colored(const char *str)printf ("%s" , str); } -static void print_failure_hints (void ) +static void print_failure_hint (const char *tag,const char *hint, +const char *url) { -unsigned int i;const struct tst_tag *tags = tst_test->tags;if (!tags)return ; +unsigned int i;int hint_printed =0 ; -for (i =0 ; tags[i].name; i++) { -if (!strcmp (tags[i].name,"linux-git" )) { -if (!hint_printed) { - hint_printed =1 ; -printf ("\n" ); -print_colored ("HINT: " ); -printf ("You _MAY_ be missing kernel fixes, see:\n\n" ); - } -printf (LINUX_GIT_URL "%s\n" , tags[i].value); - } - - } - - hint_printed =0 ;for (i =0 ; tags[i].name; i++) { -if (!strcmp (tags[i].name,"CVE" )) { +if (!strcmp (tags[i].name, tag)) {if (!hint_printed) { hint_printed =1 ;printf ("\n" );print_colored ("HINT: " ); -printf ("You _MAY_ be vulnerable to CVE(s), see:\n\n" ); +printf ("You _MAY_ be %s, see:\n\n" , hint); } -printf (CVE_DB_URL "%s\n" , tags[i].value); +printf ("%s%s\n" , url, tags[i].value); } } } +static void print_failure_hints (void ) +{ +print_failure_hint ("linux-git" ,"missing kernel fixes" ,LINUX_GIT_URL ); +print_failure_hint ("linux-stable-git" ,"missing stable kernel fixes" , +LINUX_STABLE_GIT_URL ); +print_failure_hint ("glibc-git" ,"missing glibc fixes" ,GLIBC_GIT_URL ); +print_failure_hint ("CVE" ,"vulnerable to CVE(s)" ,CVE_DB_URL ); +} +static void do_exit (int ret) {if (results) {
Signature · 1 line
2.30.1
PATCH 1/4 lib: Add support for linux stable and glibc tags
Hi!
lib/tst_test.c static void print_test_tags(void) · line 499
Quoted 12 lines
#define
LINUX_GIT_URL"https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id="lib/tst_test.c +4
-0+#define LINUX_STABLE_GIT_URL "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=" +#define GLIBC_GIT_URL "https://sourceware.org/git/?p=glibc.git;a=commit;h="#define CVE_DB_URL "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-"struct tst_test *tst_test;@@ -492,6 +495,8 @@ static void print_test_tags(void)printf (CVE_DB_URL "%s\n" , tags[i].value); else if (!strcmp(tags[i].name, "linux-git")) printf(LINUX_GIT_URL "%s\n", tags[i].value); + else if (!strcmp(tags[i].name, "linux-stable-git")) +printf (LINUX_STABLE_GIT_URL "%s\n" , tags[i].value);
Shouldn't we add GLIBC_GIT_URL handling here as well?
The rest looks good.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/4 lib: Add support for linux stable and glibc tags
Hi Cyril,
Quoted 6 lines
Hi!
Quoted 4 lines
#define
LINUX_GIT_URL"https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id="lib/tst_test.c +2
-0+#define LINUX_STABLE_GIT_URL "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=" +#define GLIBC_GIT_URL "https://sourceware.org/git/?p=glibc.git;a=commit;h="#define CVE_DB_URL "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-"
Quoted 9 lines
lib/tst_test.c static void print_test_tags(void) · line 499
Quoted 7 lines
struct
tst_test*tst_test;lib/tst_test.c +2
-0@@ -492,6 +495,8 @@ static void print_test_tags(void)printf (CVE_DB_URL "%s\n" , tags[i].value); else if (!strcmp(tags[i].name, "linux-git")) printf(LINUX_GIT_URL "%s\n", tags[i].value); + else if (!strcmp(tags[i].name, "linux-stable-git")) +printf (LINUX_STABLE_GIT_URL "%s\n" , tags[i].value);Shouldn't we add
GLIBC_GIT_URLhandling here as well?
+1 thanks.
Quoted 1 line
The rest looks good.
Thanks! (counting your Reviewed-by: tag for this commit).
Kind regards,
Petr
PATCH 2/4 testinfo.pl: Update parsing more git trees
In reply to Petr Vorelto reflect changes in previous commit.
---
Hi,
agree that using $constant::declared() is really ugly, I'm ok to just put constants there.
Kind regards,
Petr
docparse/testinfo.pl | 102 +++++++++++++++++++++++++++---------------- lib/tst_test.c | 2 + 2 files changed, 66 insertions(+), 38 deletions(-)
docparse/testinfo.pl +64 -38
@@ -1,7 +1,7 @@ #!/usr/bin/perl # SPDX-License-Identifier: GPL-2.0-or-later # Copyright (c) 2019 Cyril Hrubis <[email protected]> -# Copyright (c) 2020 Petr Vorel <[email protected]> +# Copyright (c) 2020-2021 Petr Vorel <[email protected]> use strict; use warnings;
@@ -12,6 +12,15 @@ use File::Basename qw(dirname); use constant OUTDIR => dirname(abs_path($0)); +# tags which expect git tree, also need constant for URL +our @TAGS_GIT = ("linux-git", "linux-stable-git", "glibc-git"); + +# tags should map these in lib/tst_test.c +use constant LINUX_GIT_URL => "https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id="; +use constant LINUX_STABLE_GIT_URL => "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id="; +use constant GLIBC_GIT_URL => "https://sourceware.org/git/?p=glibc.git;a=commit;h="; +use constant CVE_DB_URL => "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-"; + sub load_json { my ($fname, $mode) = @_;
@@ -51,15 +60,21 @@ EOL sub tag_url { my ($tag, $value, $scm_url_base) = @_; - if ($tag eq "CVE") { - return "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-" . $value; + if ($tag eq "fname") { + return $scm_url_base . $value; } - if ($tag eq "linux-git") { - return "https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=" . $value; + + if ($tag eq "CVE") { + return CVE_DB_URL . $value; } - if ($tag eq "fname") { - return $scm_url_base . $value; + + # *_GIT_URL + my $key = tag2env($tag) . "_URL"; + if (defined($constant::declared{"main::$key"})) { + return eval("main::$key") . $value; } + + die("unknown constant '$key' for tag $tag, define it!"); } sub bold
@@ -235,34 +250,46 @@ sub content_filters return $content; } +sub tag2env +{ + my $tag = shift; + $tag =~ s/-/_/g; + return uc($tag); +} + sub detect_git { - unless (defined $ENV{'LINUX_GIT'} && $ENV{'LINUX_GIT'}) { - log_warn("kernel git repository not defined. Define it in \$LINUX_GIT"); - return 0; - } + my %data; - unless (-d $ENV{'LINUX_GIT'}) { - log_warn("\$LINUX_GIT does not exit ('$ENV{'LINUX_GIT'}')"); - return 0; - } + for my $tag (@TAGS_GIT) { + my $env = tag2env($tag); - my $ret = 0; - if (system("which git >/dev/null")) { - log_warn("git not in \$PATH ('$ENV{'PATH'}')"); - return 0; - } + unless (defined $ENV{$env} && $ENV{$env}) { + log_warn("git repository $tag not defined. Define it in \$$env"); + next; + } + + unless (-d $ENV{$env}) { + log_warn("\$$env does not exit ('$ENV{$env}')"); + next; + } - chdir($ENV{'LINUX_GIT'}); - if (!system("git log -1 > /dev/null")) { - log_info("using '$ENV{'LINUX_GIT'}' as kernel git repository"); - $ret = 1; - } else { - log_warn("git failed, git not installed or \$LINUX_GIT is not a git repository? ('$ENV{'LINUX_GIT'}')"); + if (system("which git >/dev/null")) { + log_warn("git not in \$PATH ('$ENV{'PATH'}')"); + next; + } + + chdir($ENV{$env}); + if (!system("git log -1 > /dev/null")) { + log_info("using '$ENV{$env}' as $env repository"); + $data{$tag} = $ENV{$env}; + } else { + log_warn("git failed, git not installed or \$$env is not a git repository? ('$ENV{$env}')"); + } + chdir(OUTDIR); } - chdir(OUTDIR); - return $ret; + return \%data; } sub content_all_tests
@@ -270,15 +297,11 @@ sub content_all_tests my $json = shift; my @names = sort keys %{$json->{'tests'}}; my $letters = paragraph(get_test_letters(\@names)); - my $has_kernel_git = detect_git(); + my $git_url = detect_git(); my $tmp = undef; my $printed = ""; my $content; - unless ($has_kernel_git) { - log_info("Parsing git messages from linux git repository skipped due previous error"); - } - $content .= paragraph("Total $#names tests."); $content .= $letters; $content .= get_test_names(\@names);
@@ -370,15 +393,18 @@ sub content_all_tests my $v = @$tag[1]; my $text = $k; - if ($has_kernel_git && $k eq "linux-git") { + if (defined($$git_url{$k})) { $text .= "-$v"; - unless (defined($commits{$v})) { - chdir($ENV{'LINUX_GIT'}); - $commits{$v} = `git log --pretty=format:'%s' -1 $v`; + + $commits{$k} = () unless (defined($commits{$k})); + unless (defined($commits{$k}{$v})) { + chdir($$git_url{$k}); + $commits{$k}{$v} = `git log --pretty=format:'%s' -1 $v`; chdir(OUTDIR); } - $v = $commits{$v}; + $v = $commits{$k}{$v}; } + my $a = html_a(tag_url($k, @$tag[1]), $text); $content .= "\n|$a\n|$v\n"; $tmp2 = 1;
lib/tst_test.c +2 -0
@@ -38,6 +38,7 @@*/ const char *TCID __attribute__((weak)); +/* update also docparse/testinfo.pl */ #define LINUX_GIT_URL "https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id="#define LINUX_STABLE_GIT_URL "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id="#define GLIBC_GIT_URL "https://sourceware.org/git/?p=glibc.git;a=commit;h="
@@ -701,6 +702,7 @@ static void print_failure_hint(const char *tag, const char *hint, } } +/* update also docparse/testinfo.pl */ static void print_failure_hints (void ) {print_failure_hint ("linux-git" ,"missing kernel fixes" ,LINUX_GIT_URL );
Signature · 1 line
2.30.1
PATCH 2/4 testinfo.pl: Update parsing more git trees
Hi!
Looks good. Acked.
Signature · 2 lines
Cyril Hrubis <[email protected]>
PATCH 3/4 io_uring02: Add linux-stable-git tag
In reply to Petr Vorel--- testcases/kernel/syscalls/io_uring/io_uring02.c | 7 +++++++ 1 file changed, 7 insertions(+)
testcases/kernel/syscalls/io_uring/io_uring02.c +7 -0
@@ -19,6 +19,12 @@* Date: Fri Feb 7 16:05:21 2020 -0700 * * io_uring: grab ->fs as part of async preparation +* +* stable 5.4 specific backport: +* +* commit c4a23c852e80a3921f56c6fbc851a21c84a6d06b +* Author: Nicolai Stange <[email protected]> +* Date: Wed Jan 27 14:34:43 2021 +0100 */ #include <stdio.h>
@@ -252,6 +258,7 @@ static struct tst_test test = { .tags = (const struct tst_tag[]) { {"linux-git" ,"9392a27d88b9" }, {"linux-git" ,"ff002b30181d" }, + {"linux-stable-git" ,"c4a23c852e80" }, {"CVE" ,"2020-29373" }, {} }
Signature · 1 line
2.30.1
PATCH 3/4 io_uring02: Add linux-stable-git tag
PATCH 4/4 semctl09: Add glibc-git tag
In reply to Petr VorelAlso fix formatting:
* remove new line at "to the kernel"
* put glibc info out of docparse (this info is included in glibc-git)
--- testcases/kernel/syscalls/ipc/semctl/semctl09.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
testcases/kernel/syscalls/ipc/semctl/semctl09.c +13 -4
@@ -23,15 +23,20 @@* completely different meaning than their names seems to suggest. * * We also calling semctl() directly by syscall(), because of a glibc bug: -* * semctl SEM_STAT_ANY fails to pass the buffer specified by the caller -* * to the kernel. -* * https://sourceware.org/bugzilla/show_bug.cgi?id=26637 * +* semctl SEM_STAT_ANY fails to pass the buffer specified by the caller +* to the kernel. +* +* https://sourceware.org/bugzilla/show_bug.cgi?id=26637 +\*/ + +/* * The glibc bug was fixed in: +* * * commit 574500a108be1d2a6a0dc97a075c9e0a98371aba * * Author: Dmitry V. Levin <[email protected]> * * Date: Tue, 29 Sep 2020 17:10:20 +0000 (14:10 -0300) -\*/ +*/ #include <stdio.h> #include <pwd.h>
@@ -200,4 +205,8 @@ static struct tst_test test = { .tcnt = ARRAY_SIZE(tests), .test_variants = 2, .needs_root = 1, + .tags = (const struct tst_tag []) { + {"glibc-git" ,"574500a108be" }, + {} + } };
Signature · 1 line
2.30.1
PATCH 4/4 semctl09: Add glibc-git tag
PATCH 4/4 semctl09: Add glibc-git tag
Hi Cyril,
Quoted 1 line
Revieved-by Cyril Hrubis <[email protected]>
Thanks, whole patchset merged, with fixed first commit.
Kind regards,
Petr