From nobody Wed Jul 6 11:04:04 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 89AAA1D00BFD; Wed, 6 Jul 2022 11:04:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LdGrN3w7Qz3NHK; Wed, 6 Jul 2022 11:04:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657105445; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=bjylwWMjlAtTKYVp4KHfitlakwax2QY8GguSiUjWlLk=; b=mVC8ZRliqnsCXj1a/T1mlobWFj7NVoUkU9Avo1DTmFpAqVXRgSGObaGtGco13xJHw1ttoe 6zDritKNV4nrMcLQLvJ42cTMrh5fe6tcEDVRP0Kqg4dDBGi7MX7v5O63ohPk6XBytEhnn0 cTIySFwPr9mcpVQkSI4P1Hg9fCIsk3HeaAKl7gqS+azE1ny0YXxJ+aaFWttXHqapTjjY6U rXiEIWJ4brA8jcRXNjP8d6NgeYIXV0jbWvuBkFEYv3LacsCLgwgvWOOMlnlHFGNaaBbk/O dDhrgxWDTCgcpCDEodGNazZcX4nQjut/IZ8VCCS14ncZPOVwPkOGTFN37MTNQw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2D86B191E6; Wed, 6 Jul 2022 11:04:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 266B44Hc096502; Wed, 6 Jul 2022 11:04:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 266B4438096501; Wed, 6 Jul 2022 11:04:04 GMT (envelope-from git) Date: Wed, 6 Jul 2022 11:04:04 GMT Message-Id: <202207061104.266B4438096501@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: 2068608ebdbf - stable/13 - kdump: Decode Linux l_sigset_t. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2068608ebdbfaa40ff763af0526e8ee0fb9f3120 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657105445; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=bjylwWMjlAtTKYVp4KHfitlakwax2QY8GguSiUjWlLk=; b=gaWPYrnrDgYUa21oO8k3mU6DfGTHZRQYNA3PsxYT4TiQsir2LNiM0fgLsAlf62fC/tIxhr 924jW3Bj+GllghrX9IjM1Nr61h7Z9hyoMOgR4STnW+CyA8dW6eKHvY/bGKioEbWl8gwrvN JRXbfwHFbPvPm9oPIJasCsisRzARzkRee0MMadJpE6VrpHNhpMuNd6mCNghEr4xURiEfda 07bMg3yVKoXPeU0Q73J3lvDnX/4rQIUL+abu0TGSlIuxuUUFhIA2YOWbwLqiQvCHHfPkFF yfmowiQjTQW16qin9nkUiHOrcsFKaScN83hQQCpa+UJIRnhVMCTr1L7/rIsZvQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657105445; a=rsa-sha256; cv=none; b=eOyU9lRwklW+VO0B4v/KKTu9jtulLbgLVi6T2dOASeobo2TGLI6RLJYh3+2A8L0LsacDIY EdhiQVMoIvugT0+irZo178gs4/Q0jICi4CHAoU/p7xcZy/a08Fjo9pK1Lk4oqRrHPY4MnV IZjFIDojEXlw3Bs1EdNfJ8nCO45LKmROrHuNXNT8Z+i9QxXDGaqLbMCCW6xtf0RizQIOgR 1p94/8HxsckRbPT519FXXgUd2ZDr6tY+wrWEwz5FTFrP1hVX2vEz9et5fZGhY3fHdm1GBP 2/rjoGJXKjGUd4cr+4YtVWMhEn61WgMWDJ1Pt5QfuavD2M8ESFKiZLJRyia0Yw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=2068608ebdbfaa40ff763af0526e8ee0fb9f3120 commit 2068608ebdbfaa40ff763af0526e8ee0fb9f3120 Author: Dmitry Chagin AuthorDate: 2022-06-22 11:15:20 +0000 Commit: Dmitry Chagin CommitDate: 2022-07-06 11:02:13 +0000 kdump: Decode Linux l_sigset_t. Reviewed by: markj Differential revision: https://reviews.freebsd.org/D35153 MFC after: 2 weeks (cherry picked from commit 3606a213bfa42e1970197ba9b3494c88d5827259) --- usr.bin/kdump/kdump.c | 5 ++++- usr.bin/kdump/kdump.h | 1 + usr.bin/kdump/linux.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index 8ed33783e7c7..f3e6787edbe0 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -2061,7 +2061,10 @@ ktrstruct(char *buf, size_t buflen) ktrbitset(name, set, datalen); free(set); } else { - printf("unknown structure\n"); +#ifdef SYSDECODE_HAVE_LINUX + if (ktrstruct_linux(name, data, datalen) == false) +#endif + printf("unknown structure\n"); } return; invalid: diff --git a/usr.bin/kdump/kdump.h b/usr.bin/kdump/kdump.h index dc0515397f48..29bdb1dfbbaf 100644 --- a/usr.bin/kdump/kdump.h +++ b/usr.bin/kdump/kdump.h @@ -77,6 +77,7 @@ bool print_mask_arg_part(bool (*decoder)(FILE *, int, int *), int value, int *rem); #ifdef SYSDECODE_HAVE_LINUX +bool ktrstruct_linux(const char *name, const char *data, size_t datalen); void ktrsyscall_linux(struct ktr_syscall *ktr, register_t **resip, int *resnarg, char *resc); #ifdef __amd64__ diff --git a/usr.bin/kdump/linux.c b/usr.bin/kdump/linux.c index e584b54db36c..ed057a6b8ef6 100644 --- a/usr.bin/kdump/linux.c +++ b/usr.bin/kdump/linux.c @@ -31,7 +31,11 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include +#include +#include #include #include "kdump.h" @@ -45,6 +49,8 @@ __FBSDID("$FreeBSD$"); #include #endif +#include + static void print_linux_signal(int signo) { @@ -183,3 +189,41 @@ ktrsyscall_linux32(struct ktr_syscall *ktr, register_t **resip, *resnarg = narg; } #endif /* __amd64__ */ + +static void +ktrsigset(const char *name, const l_sigset_t *mask, size_t sz) +{ + unsigned long i, c; + + printf("%s [ ", name); + c = 0; + for (i = 1; i <= sz * CHAR_BIT; i++) { + if (!LINUX_SIGISMEMBER(*mask, i)) + continue; + if (c != 0) + printf(", "); + printf("%s", sysdecode_linux_signal(i)); + c++; + } + if (c == 0) + printf("empty ]\n"); + else + printf(" ]\n"); +} + +bool +ktrstruct_linux(const char *name, const char *data, size_t datalen) +{ + l_sigset_t mask; + + if (strcmp(name, "l_sigset_t") == 0) { + /* Old Linux sigset_t is one word size. */ + if (datalen < sizeof(int) || datalen > sizeof(l_sigset_t)) + return (false); + memcpy(&mask, data, datalen); + ktrsigset(name, &mask, datalen); + } else + return (false); + + return (true); +}