On Mon 2020-01-06 13:06:53, Arnaldo Carvalho de Melo wrote: > From: Andrey Zhizhikin <andrey.z@xxxxxxxxx> > > GCC9 introduced string hardening mechanisms, which exhibits the error > during fs api compilation: > > error: '__builtin_strncpy' specified bound 4096 equals destination size > [-Werror=stringop-truncation] > > This comes when the length of copy passed to strncpy is is equal to > destination size, which could potentially lead to buffer overflow. > > There is a need to mitigate this potential issue by limiting the size of > destination by 1 and explicitly terminate the destination with NULL. > > Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@xxxxxxxxxxxxxxxxxxxx> > Reviewed-by: Petr Mladek <pmladek@xxxxxxxx> > Acked-by: Jiri Olsa <jolsa@xxxxxxxxxx> > Cc: Alexei Starovoitov <ast@xxxxxxxxxx> > Cc: Andrii Nakryiko <andriin@xxxxxx> > Cc: Daniel Borkmann <daniel@xxxxxxxxxxxxx> > Cc: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx> > Cc: Martin KaFai Lau <kafai@xxxxxx> > Cc: Petr Mladek <pmladek@xxxxxxxx> > Cc: Sergey Senozhatsky <sergey.senozhatsky@xxxxxxxxx> > Cc: Song Liu <songliubraving@xxxxxx> > Cc: Yonghong Song <yhs@xxxxxx> > Cc: bpf@xxxxxxxxxxxxxxx > Cc: netdev@xxxxxxxxxxxxxxx > Link: http://lore.kernel.org/lkml/20191211080109.18765-1-andrey.zhizhikin@xxxxxxxxxxxxxxxxxxxx > Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> Reviewed-by: Petr Mladek <pmladek@xxxxxxxx> Best Regards, Petr