* [PATCH 2/4] audit: uninitialize global variable audit_sig_sid [not found] ` <20200801184603.310769-1-jbi.octave@gmail.com> @ 2020-08-01 18:46 ` Jules Irenge 2020-08-01 18:55 ` Joe Perches 2020-08-01 18:46 ` [PATCH 3/4] audit: uninitialize static variables Jules Irenge 1 sibling, 1 reply; 6+ messages in thread From: Jules Irenge @ 2020-08-01 18:46 UTC (permalink / raw) To: linux-kernel; +Cc: Jules Irenge, moderated list:AUDIT SUBSYSTEM Checkpatch tool reports an error at variable audit_sig_sid declaration "ERROR: do not initialise globals to 0" To fix this, the global variable has been uninitialized. Signed-off-by: Jules Irenge <jbi.octave@gmail.com> --- kernel/audit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/audit.c b/kernel/audit.c index 8c201f414226..7b1a38a211a9 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -125,7 +125,7 @@ static u32 audit_backlog_wait_time = AUDIT_BACKLOG_WAIT_TIME; /* The identity of the user shutting down the audit system. */ kuid_t audit_sig_uid = INVALID_UID; pid_t audit_sig_pid = -1; -u32 audit_sig_sid = 0; +u32 audit_sig_sid; /* Records can be lost in several ways: 0) [suppressed in audit_alloc] -- 2.26.2 -- Linux-audit mailing list Linux-audit@redhat.com https://www.redhat.com/mailman/listinfo/linux-audit ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/4] audit: uninitialize global variable audit_sig_sid 2020-08-01 18:46 ` [PATCH 2/4] audit: uninitialize global variable audit_sig_sid Jules Irenge @ 2020-08-01 18:55 ` Joe Perches 2020-08-01 20:26 ` Paul Moore 2020-08-02 14:32 ` Jules Irenge 0 siblings, 2 replies; 6+ messages in thread From: Joe Perches @ 2020-08-01 18:55 UTC (permalink / raw) To: Jules Irenge, linux-kernel; +Cc: moderated list:AUDIT SUBSYSTEM On Sat, 2020-08-01 at 19:46 +0100, Jules Irenge wrote: > Checkpatch tool reports an error at variable audit_sig_sid declaration [] > diff --git a/kernel/audit.c b/kernel/audit.c [] > @@ -125,7 +125,7 @@ static u32 audit_backlog_wait_time = AUDIT_BACKLOG_WAIT_TIME; > /* The identity of the user shutting down the audit system. */ > kuid_t audit_sig_uid = INVALID_UID; > pid_t audit_sig_pid = -1; > -u32 audit_sig_sid = 0; > +u32 audit_sig_sid; All of these are unused outside of audit.c and might as well be static and removed from the .h file. -- Linux-audit mailing list Linux-audit@redhat.com https://www.redhat.com/mailman/listinfo/linux-audit ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/4] audit: uninitialize global variable audit_sig_sid 2020-08-01 18:55 ` Joe Perches @ 2020-08-01 20:26 ` Paul Moore 2020-08-02 14:32 ` Jules Irenge 1 sibling, 0 replies; 6+ messages in thread From: Paul Moore @ 2020-08-01 20:26 UTC (permalink / raw) To: Joe Perches, Jules Irenge; +Cc: moderated list:AUDIT SUBSYSTEM, linux-kernel On Sat, Aug 1, 2020 at 2:55 PM Joe Perches <joe@perches.com> wrote: > On Sat, 2020-08-01 at 19:46 +0100, Jules Irenge wrote: > > Checkpatch tool reports an error at variable audit_sig_sid declaration > [] > > diff --git a/kernel/audit.c b/kernel/audit.c > [] > > @@ -125,7 +125,7 @@ static u32 audit_backlog_wait_time = AUDIT_BACKLOG_WAIT_TIME; > > /* The identity of the user shutting down the audit system. */ > > kuid_t audit_sig_uid = INVALID_UID; > > pid_t audit_sig_pid = -1; > > -u32 audit_sig_sid = 0; > > +u32 audit_sig_sid; > > All of these are unused outside of audit.c and might as > well be static and removed from the .h file. There's plenty of time before the merge window closes, doing this would definitely make this patch much more useful than the typical checkpatch noise. -- paul moore www.paul-moore.com -- Linux-audit mailing list Linux-audit@redhat.com https://www.redhat.com/mailman/listinfo/linux-audit ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/4] audit: uninitialize global variable audit_sig_sid 2020-08-01 18:55 ` Joe Perches 2020-08-01 20:26 ` Paul Moore @ 2020-08-02 14:32 ` Jules Irenge 1 sibling, 0 replies; 6+ messages in thread From: Jules Irenge @ 2020-08-02 14:32 UTC (permalink / raw) To: Joe Perches; +Cc: Jules Irenge, moderated list:AUDIT SUBSYSTEM, linux-kernel On Sat, 1 Aug 2020, Joe Perches wrote: > On Sat, 2020-08-01 at 19:46 +0100, Jules Irenge wrote: > > Checkpatch tool reports an error at variable audit_sig_sid declaration > [] > > diff --git a/kernel/audit.c b/kernel/audit.c > [] > > @@ -125,7 +125,7 @@ static u32 audit_backlog_wait_time = AUDIT_BACKLOG_WAIT_TIME; > > /* The identity of the user shutting down the audit system. */ > > kuid_t audit_sig_uid = INVALID_UID; > > pid_t audit_sig_pid = -1; > > -u32 audit_sig_sid = 0; > > +u32 audit_sig_sid; > > All of these are unused outside of audit.c and might as > well be static and removed from the .h file. > Thanks for reply, I will resend a second version with the recommendation, namely make the above static and remove them from the .h file. Jules -- Linux-audit mailing list Linux-audit@redhat.com https://www.redhat.com/mailman/listinfo/linux-audit ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/4] audit: uninitialize static variables [not found] ` <20200801184603.310769-1-jbi.octave@gmail.com> 2020-08-01 18:46 ` [PATCH 2/4] audit: uninitialize global variable audit_sig_sid Jules Irenge @ 2020-08-01 18:46 ` Jules Irenge 2020-08-01 20:21 ` Paul Moore 1 sibling, 1 reply; 6+ messages in thread From: Jules Irenge @ 2020-08-01 18:46 UTC (permalink / raw) To: linux-kernel; +Cc: Jules Irenge, moderated list:AUDIT SUBSYSTEM Checkpatch tool reports an error at variable declaration "ERROR: do not initialise statics to 0" This is due to the fact that these variables are stored in the buffer In the .bss section, one can not set an initial value Here we can trust the compiler to automatically set them to zero. The variable has since been uninitialized. Signed-off-by: Jules Irenge <jbi.octave@gmail.com> --- kernel/audit.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/audit.c b/kernel/audit.c index 7b1a38a211a9..7d79ecb58b01 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -311,8 +311,8 @@ void audit_panic(const char *message) static inline int audit_rate_check(void) { - static unsigned long last_check = 0; - static int messages = 0; + static unsigned long last_check; + static int messages; static DEFINE_SPINLOCK(lock); unsigned long flags; unsigned long now; @@ -348,7 +348,7 @@ static inline int audit_rate_check(void) */ void audit_log_lost(const char *message) { - static unsigned long last_msg = 0; + static unsigned long last_msg; static DEFINE_SPINLOCK(lock); unsigned long flags; unsigned long now; @@ -713,7 +713,7 @@ static int kauditd_send_queue(struct sock *sk, u32 portid, { int rc = 0; struct sk_buff *skb; - static unsigned int failed = 0; + static unsigned int failed; /* NOTE: kauditd_thread takes care of all our locking, we just use * the netlink info passed to us (e.g. sk and portid) */ -- 2.26.2 -- Linux-audit mailing list Linux-audit@redhat.com https://www.redhat.com/mailman/listinfo/linux-audit ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 3/4] audit: uninitialize static variables 2020-08-01 18:46 ` [PATCH 3/4] audit: uninitialize static variables Jules Irenge @ 2020-08-01 20:21 ` Paul Moore 0 siblings, 0 replies; 6+ messages in thread From: Paul Moore @ 2020-08-01 20:21 UTC (permalink / raw) To: Jules Irenge; +Cc: moderated list:AUDIT SUBSYSTEM, linux-kernel On Sat, Aug 1, 2020 at 2:46 PM Jules Irenge <jbi.octave@gmail.com> wrote: > > Checkpatch tool reports an error at variable declaration > > "ERROR: do not initialise statics to 0" > > This is due to the fact that these variables are stored in the buffer > In the .bss section, one can not set an initial value > Here we can trust the compiler to automatically set them to zero. > The variable has since been uninitialized. > > Signed-off-by: Jules Irenge <jbi.octave@gmail.com> > --- > kernel/audit.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) In general this is fine, but it will have to wait until after the merge window closes. > diff --git a/kernel/audit.c b/kernel/audit.c > index 7b1a38a211a9..7d79ecb58b01 100644 > --- a/kernel/audit.c > +++ b/kernel/audit.c > @@ -311,8 +311,8 @@ void audit_panic(const char *message) > > static inline int audit_rate_check(void) > { > - static unsigned long last_check = 0; > - static int messages = 0; > + static unsigned long last_check; > + static int messages; > static DEFINE_SPINLOCK(lock); > unsigned long flags; > unsigned long now; > @@ -348,7 +348,7 @@ static inline int audit_rate_check(void) > */ > void audit_log_lost(const char *message) > { > - static unsigned long last_msg = 0; > + static unsigned long last_msg; > static DEFINE_SPINLOCK(lock); > unsigned long flags; > unsigned long now; > @@ -713,7 +713,7 @@ static int kauditd_send_queue(struct sock *sk, u32 portid, > { > int rc = 0; > struct sk_buff *skb; > - static unsigned int failed = 0; > + static unsigned int failed; > > /* NOTE: kauditd_thread takes care of all our locking, we just use > * the netlink info passed to us (e.g. sk and portid) */ > -- > 2.26.2 -- paul moore www.paul-moore.com -- Linux-audit mailing list Linux-audit@redhat.com https://www.redhat.com/mailman/listinfo/linux-audit ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-08-02 18:42 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <0/4> [not found] ` <20200801184603.310769-1-jbi.octave@gmail.com> 2020-08-01 18:46 ` [PATCH 2/4] audit: uninitialize global variable audit_sig_sid Jules Irenge 2020-08-01 18:55 ` Joe Perches 2020-08-01 20:26 ` Paul Moore 2020-08-02 14:32 ` Jules Irenge 2020-08-01 18:46 ` [PATCH 3/4] audit: uninitialize static variables Jules Irenge 2020-08-01 20:21 ` Paul Moore
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).