All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Liang Jie <buaajxlj@163.com>,
	Kuniyuki Iwashima <kuniyu@amazon.com>,
	Jakub Kicinski <kuba@kernel.org>
Cc: oe-kbuild-all@lists.linux.dev, Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	Michal Luczaj <mhal@rbox.co>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Liang Jie <liangjie@lixiang.com>
Subject: Re: [PATCH net-next v2] af_unix: Refine UNIX pathname sockets autobind identifier length
Date: Sun, 9 Feb 2025 00:26:30 +0800	[thread overview]
Message-ID: <202502090018.NcW3Qcd3-lkp@intel.com> (raw)
In-Reply-To: <20250206054451.4070941-1-buaajxlj@163.com>

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@intel.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

  parent reply	other threads:[~2025-02-08 16:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-06  5:44 [PATCH net-next v2] af_unix: Refine UNIX pathname sockets autobind identifier length Liang Jie
2025-02-06  6:22 ` Kuniyuki Iwashima
2025-02-06  8:19 ` Liang Jie
2025-02-06  8:58   ` Kuniyuki Iwashima
2025-02-06  9:44     ` Liang Jie
2025-02-06 10:09       ` Eric Dumazet
2025-02-08 16:26 ` kernel test robot [this message]
2025-02-08 16:26 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202502090018.NcW3Qcd3-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=buaajxlj@163.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=liangjie@lixiang.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhal@rbox.co \
    --cc=netdev@vger.kernel.org \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.