[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202502090018.NcW3Qcd3-lkp@intel.com>
Date: Sun, 9 Feb 2025 00:26:30 +0800
From: kernel test robot <lkp@...el.com>
To: Liang Jie <buaajxlj@....com>, Kuniyuki Iwashima <kuniyu@...zon.com>,
Jakub Kicinski <kuba@...nel.org>
Cc: oe-kbuild-all@...ts.linux.dev, Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
Michal Luczaj <mhal@...x.co>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, Liang Jie <liangjie@...iang.com>
Subject: Re: [PATCH net-next v2] af_unix: Refine UNIX pathname sockets
autobind identifier length
Hi Liang,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Liang-Jie/af_unix-Refine-UNIX-pathname-sockets-autobind-identifier-length/20250206-134846
base: net-next/main
patch link: https://lore.kernel.org/r/20250206054451.4070941-1-buaajxlj%40163.com
patch subject: [PATCH net-next v2] af_unix: Refine UNIX pathname sockets autobind identifier length
config: csky-randconfig-001-20250207 (https://download.01.org/0day-ci/archive/20250209/202502090018.NcW3Qcd3-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250209/202502090018.NcW3Qcd3-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502090018.NcW3Qcd3-lkp@intel.com/
All warnings (new ones prefixed by >>):
net/unix/af_unix.c: In function 'unix_autobind':
>> net/unix/af_unix.c:1222:52: warning: 'snprintf' output truncated before the last format character [-Wformat-truncation=]
1222 | snprintf(addr->name->sun_path + 1, 5, "%05x", ordernum);
| ^
net/unix/af_unix.c:1222:9: note: 'snprintf' output 6 bytes into a destination of size 5
1222 | snprintf(addr->name->sun_path + 1, 5, "%05x", ordernum);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +/snprintf +1222 net/unix/af_unix.c
1190
1191 static int unix_autobind(struct sock *sk)
1192 {
1193 struct unix_sock *u = unix_sk(sk);
1194 unsigned int new_hash, old_hash;
1195 struct net *net = sock_net(sk);
1196 struct unix_address *addr;
1197 u32 lastnum, ordernum;
1198 int err;
1199
1200 err = mutex_lock_interruptible(&u->bindlock);
1201 if (err)
1202 return err;
1203
1204 if (u->addr)
1205 goto out;
1206
1207 err = -ENOMEM;
1208 addr = kzalloc(sizeof(*addr) + offsetof(struct sockaddr_un, sun_path) +
1209 UNIX_AUTOBIND_LEN, GFP_KERNEL);
1210 if (!addr)
1211 goto out;
1212
1213 addr->len = offsetof(struct sockaddr_un, sun_path) + UNIX_AUTOBIND_LEN;
1214 addr->name->sun_family = AF_UNIX;
1215 refcount_set(&addr->refcnt, 1);
1216
1217 old_hash = sk->sk_hash;
1218 ordernum = get_random_u32();
1219 lastnum = ordernum & 0xFFFFF;
1220 retry:
1221 ordernum = (ordernum + 1) & 0xFFFFF;
> 1222 snprintf(addr->name->sun_path + 1, 5, "%05x", ordernum);
1223
1224 new_hash = unix_abstract_hash(addr->name, addr->len, sk->sk_type);
1225 unix_table_double_lock(net, old_hash, new_hash);
1226
1227 if (__unix_find_socket_byname(net, addr->name, addr->len, new_hash)) {
1228 unix_table_double_unlock(net, old_hash, new_hash);
1229
1230 /* __unix_find_socket_byname() may take long time if many names
1231 * are already in use.
1232 */
1233 cond_resched();
1234
1235 if (ordernum == lastnum) {
1236 /* Give up if all names seems to be in use. */
1237 err = -ENOSPC;
1238 unix_release_addr(addr);
1239 goto out;
1240 }
1241
1242 goto retry;
1243 }
1244
1245 __unix_set_addr_hash(net, sk, addr, new_hash);
1246 unix_table_double_unlock(net, old_hash, new_hash);
1247 err = 0;
1248
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Powered by blists - more mailing lists