linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] kernel/audit: convert comma to semicolon
@ 2020-12-11  8:42 Zheng Yongjun
  2020-12-11 15:33 ` Richard Guy Briggs
  0 siblings, 1 reply; 4+ messages in thread
From: Zheng Yongjun @ 2020-12-11  8:42 UTC (permalink / raw)
  To: paul, linux-audit, linux-kernel; +Cc: Zheng Yongjun

Replace a comma between expression statements by a semicolon.

Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
 kernel/audit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index 68cee3bc8cfe..c8497115be35 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -2282,7 +2282,7 @@ static void audit_log_set_loginuid(kuid_t koldloginuid, kuid_t kloginuid,
 
 	uid = from_kuid(&init_user_ns, task_uid(current));
 	oldloginuid = from_kuid(&init_user_ns, koldloginuid);
-	loginuid = from_kuid(&init_user_ns, kloginuid),
+	loginuid = from_kuid(&init_user_ns, kloginuid);
 	tty = audit_get_tty();
 
 	audit_log_format(ab, "pid=%d uid=%u", task_tgid_nr(current), uid);
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] kernel/audit: convert comma to semicolon
  2020-12-11  8:42 [PATCH -next] kernel/audit: convert comma to semicolon Zheng Yongjun
@ 2020-12-11 15:33 ` Richard Guy Briggs
  2020-12-15  2:34   ` Paul Moore
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Guy Briggs @ 2020-12-11 15:33 UTC (permalink / raw)
  To: Zheng Yongjun; +Cc: paul, linux-audit, linux-kernel

On 2020-12-11 16:42, Zheng Yongjun wrote:
> Replace a comma between expression statements by a semicolon.
> 
> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
> ---
>  kernel/audit.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/audit.c b/kernel/audit.c
> index 68cee3bc8cfe..c8497115be35 100644
> --- a/kernel/audit.c
> +++ b/kernel/audit.c
> @@ -2282,7 +2282,7 @@ static void audit_log_set_loginuid(kuid_t koldloginuid, kuid_t kloginuid,
>  
>  	uid = from_kuid(&init_user_ns, task_uid(current));
>  	oldloginuid = from_kuid(&init_user_ns, koldloginuid);
> -	loginuid = from_kuid(&init_user_ns, kloginuid),
> +	loginuid = from_kuid(&init_user_ns, kloginuid);

Nice catch.  That went unnoticed through 3 patches, the last two mine...
Not quite sure why no compiler complained about it...

Reviewed-by: Richard Guy Briggs <rgb@redhat.com>

>  	tty = audit_get_tty();
>  
>  	audit_log_format(ab, "pid=%d uid=%u", task_tgid_nr(current), uid);

- RGB

--
Richard Guy Briggs <rgb@redhat.com>
Sr. S/W Engineer, Kernel Security, Base Operating Systems
Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] kernel/audit: convert comma to semicolon
  2020-12-11 15:33 ` Richard Guy Briggs
@ 2020-12-15  2:34   ` Paul Moore
  2021-01-05  0:45     ` Paul Moore
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Moore @ 2020-12-15  2:34 UTC (permalink / raw)
  To: Zheng Yongjun, Richard Guy Briggs; +Cc: linux-audit, linux-kernel

On Fri, Dec 11, 2020 at 10:33 AM Richard Guy Briggs <rgb@redhat.com> wrote:
> On 2020-12-11 16:42, Zheng Yongjun wrote:
> > Replace a comma between expression statements by a semicolon.
> >
> > Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
> > ---
> >  kernel/audit.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/audit.c b/kernel/audit.c
> > index 68cee3bc8cfe..c8497115be35 100644
> > --- a/kernel/audit.c
> > +++ b/kernel/audit.c
> > @@ -2282,7 +2282,7 @@ static void audit_log_set_loginuid(kuid_t koldloginuid, kuid_t kloginuid,
> >
> >       uid = from_kuid(&init_user_ns, task_uid(current));
> >       oldloginuid = from_kuid(&init_user_ns, koldloginuid);
> > -     loginuid = from_kuid(&init_user_ns, kloginuid),
> > +     loginuid = from_kuid(&init_user_ns, kloginuid);
>
> Nice catch.  That went unnoticed through 3 patches, the last two mine...

Yes, thanks for catching this and submitting a patch.  However, as it
came very late in the v5.10-rcX release cycle I'm going to wait until
after this merge window to merge it into audit/next.

> Not quite sure why no compiler complained about it...

Because it is legal; odd, but legal. :)

The comma operator allows multiple expressions to be executed with
only the last expression returned.  Take the example below:

% cat test.c
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
       int a, b, c;

       a = (b = 1, c = 2);
       printf("a = %d, b = %d, c = %d\n", a, b, c);

       return 0;
}
% gcc -o test test.c
% ./test
a = 2, b = 1, c = 2

... we see both "b=1" and "c=2" are executed, and the last statement
in the comma separated list of expressions is used as the right-hand
value in the "a" assignment.

In the case of this patch, the existing code is actually okay: both
expressions are executed and we don't assign either expression's value
to a variable so it doesn't matter.  However, it definitely looks odd
and is something we should fix.

-- 
paul moore
www.paul-moore.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] kernel/audit: convert comma to semicolon
  2020-12-15  2:34   ` Paul Moore
@ 2021-01-05  0:45     ` Paul Moore
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Moore @ 2021-01-05  0:45 UTC (permalink / raw)
  To: Zheng Yongjun, Richard Guy Briggs; +Cc: linux-audit, linux-kernel

On Mon, Dec 14, 2020 at 9:34 PM Paul Moore <paul@paul-moore.com> wrote:
> On Fri, Dec 11, 2020 at 10:33 AM Richard Guy Briggs <rgb@redhat.com> wrote:
> > On 2020-12-11 16:42, Zheng Yongjun wrote:
> > > Replace a comma between expression statements by a semicolon.
> > >
> > > Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
> > > ---
> > >  kernel/audit.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/kernel/audit.c b/kernel/audit.c
> > > index 68cee3bc8cfe..c8497115be35 100644
> > > --- a/kernel/audit.c
> > > +++ b/kernel/audit.c
> > > @@ -2282,7 +2282,7 @@ static void audit_log_set_loginuid(kuid_t koldloginuid, kuid_t kloginuid,
> > >
> > >       uid = from_kuid(&init_user_ns, task_uid(current));
> > >       oldloginuid = from_kuid(&init_user_ns, koldloginuid);
> > > -     loginuid = from_kuid(&init_user_ns, kloginuid),
> > > +     loginuid = from_kuid(&init_user_ns, kloginuid);
> >
> > Nice catch.  That went unnoticed through 3 patches, the last two mine...
>
> Yes, thanks for catching this and submitting a patch.  However, as it
> came very late in the v5.10-rcX release cycle I'm going to wait until
> after this merge window to merge it into audit/next.

This should be in audit/next now, thanks!

-- 
paul moore
www.paul-moore.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-05  0:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-11  8:42 [PATCH -next] kernel/audit: convert comma to semicolon Zheng Yongjun
2020-12-11 15:33 ` Richard Guy Briggs
2020-12-15  2:34   ` Paul Moore
2021-01-05  0:45     ` 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).