lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHC9VhRgP3dSExpUkVkxN0Mi3KAXmuyr3TjT37YHs4Yqa9piFQ@mail.gmail.com>
Date:   Thu, 16 Dec 2021 18:14:47 -0500
From:   Paul Moore <paul@...l-moore.com>
To:     Xiu Jianfeng <xiujianfeng@...wei.com>, linux-audit@...hat.com
Cc:     linux-hardening@...r.kernel.org
Subject: Fwd: [PATCH -next, v3 1/2] audit: use struct_size() helper in audit_[send|make]_reply()

Forwarding this to the linux-audit mailing list.

---------- Forwarded message ---------
From: Xiu Jianfeng <xiujianfeng@...wei.com>
Date: Wed, Dec 15, 2021 at 9:08 PM
Subject: [PATCH -next, v3 1/2] audit: use struct_size() helper in
audit_[send|make]_reply()
To: <paul@...l-moore.com>, <eparis@...hat.com>,
<keescook@...omium.org>, <gustavoars@...nel.org>
Cc: <linux-kernel@...r.kernel.org>, <linux-hardening@...r.kernel.org>


Make use of struct_size() helper instead of an open-coded calculation.

Link: https://github.com/KSPP/linux/issues/160
Signed-off-by: Xiu Jianfeng <xiujianfeng@...wei.com>
---
 kernel/audit.c       | 2 +-
 kernel/auditfilter.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index f33028578c60..7778eca34837 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1459,7 +1459,7 @@ static int audit_receive_msg(struct sk_buff
*skb, struct nlmsghdr *nlh)
                        security_release_secctx(ctx, len);
                }
                audit_send_reply(skb, seq, AUDIT_SIGNAL_INFO, 0, 0,
-                                sig_data, sizeof(*sig_data) + len);
+                                sig_data, struct_size(sig_data, ctx, len));
                kfree(sig_data);
                break;
        case AUDIT_TTY_GET: {
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index 19352820b274..42d99896e7a6 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -1092,7 +1092,7 @@ static void audit_list_rules(int seq, struct
sk_buff_head *q)
                                break;
                        skb = audit_make_reply(seq, AUDIT_LIST_RULES, 0, 1,
                                               data,
-                                              sizeof(*data) + data->buflen);
+                                              struct_size(data, buf,
data->buflen));
                        if (skb)
                                skb_queue_tail(q, skb);
                        kfree(data);
--
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ