From: mcpain@altlinux.org To: devel-kernel@lists.altlinux.org Subject: [d-kernel] [PATCH 1/2] kiosk: split kiosk_nl_send_* Date: Wed, 6 Aug 2025 16:18:22 +0300 Message-ID: <8c108cab67d36ddb4ac309ce32ffb186201ead3a.1754485062.git.mcpain@altlinux.org> (raw) In-Reply-To: <cover.1754485062.git.mcpain@altlinux.org> From: Oleg Solovyov <mcpain@altlinux.org> kiosk_nl_send_msg is used within two different contexts: - send current kiosk mode - send kiosk list So, we have to use different methods for different contexts. --- security/kiosk/kiosk_lsm.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/security/kiosk/kiosk_lsm.c b/security/kiosk/kiosk_lsm.c index 18f810a1ce0f..20635af4936f 100644 --- a/security/kiosk/kiosk_lsm.c +++ b/security/kiosk/kiosk_lsm.c @@ -148,7 +148,39 @@ static int kiosk_remove_item(struct list_head *list, char *filename, return 0; } -static int kiosk_nl_send_msg(struct sk_buff *skb, struct genl_info *info, +static int kiosk_nl_send_mode(struct sk_buff *skb, struct genl_info *info, + char *msg) +{ + int msg_size; + int res; + struct nlmsghdr *nlh; + struct sk_buff *skb_out; + + msg_size = strlen(msg) + 1; + /* we put string so add space for NUL-terminator */ + + skb_out = genlmsg_new(msg_size, GFP_KERNEL); + if (!skb_out) + return -ENOMEM; + + nlh = genlmsg_put_reply(skb_out, info, &genl_kiosk_family, 0, + KIOSK_REPLY); + if (!nlh) { + nlmsg_free(skb_out); + return -ENOMEM; + } + + res = nla_put_string(skb_out, KIOSK_DATA, msg); + if (res) { + nlmsg_free(skb_out); + return res; + } + + genlmsg_end(skb_out, nlh); + return genlmsg_reply(skb_out, info); +} + +static int kiosk_nl_send_item(struct sk_buff *skb, struct genl_info *info, char *msg) { int msg_size; @@ -206,7 +238,7 @@ static int kiosk_list_items(struct list_head *list, struct rw_semaphore *sem, path = ""; up_read(sem); - return kiosk_nl_send_msg(skb, info, path); + return kiosk_nl_send_item(skb, info, path); } static int kiosk_genl_doit(struct sk_buff *skb, struct genl_info *info) @@ -230,7 +262,7 @@ static int kiosk_genl_doit(struct sk_buff *skb, struct genl_info *info) if (!strlen(pathbuf)) { /* we want to retrieve current mode */ snprintf(buf, sizeof(buf), "%d", kiosk_mode); - return kiosk_nl_send_msg(skb, info, buf); + return kiosk_nl_send_mode(skb, info, buf); } error = kstrtouint(pathbuf, 0, &new_mode); -- 2.50.1
next prev parent reply other threads:[~2025-08-06 13:18 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-08-06 13:18 [d-kernel] [PATCH 0/2] Kiosk: turn off secureexec for allowed executables mcpain 2025-08-06 13:18 ` mcpain [this message] 2025-08-06 13:57 ` [d-kernel] [PATCH 1/2] kiosk: split kiosk_nl_send_* Vitaly Chikunov 2025-08-06 14:26 ` Oleg Solovyov 2025-08-06 13:18 ` [d-kernel] [PATCH 2/2] kiosk: add secureexec parameter mcpain 2025-08-06 14:06 ` [d-kernel] [PATCH 0/2] Kiosk: turn off secureexec for allowed executables Vitaly Chikunov 2025-08-06 14:39 ` [d-kernel] " Oleg Solovyov 2025-08-06 22:40 ` [d-kernel] " Vitaly Chikunov 2025-08-07 8:03 ` [d-kernel] " Oleg Solovyov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=8c108cab67d36ddb4ac309ce32ffb186201ead3a.1754485062.git.mcpain@altlinux.org \ --to=mcpain@altlinux.org \ --cc=devel-kernel@lists.altlinux.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
ALT Linux kernel packages development This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/devel-kernel/0 devel-kernel/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 devel-kernel devel-kernel/ http://lore.altlinux.org/devel-kernel \ devel-kernel@altlinux.org devel-kernel@altlinux.ru devel-kernel@altlinux.com public-inbox-index devel-kernel Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.devel-kernel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git