[ceph-client:binary_tracing 2/4] net/ceph/ceph_san_logger.c:313:5: warning: 'strncpy' output may be truncated copying 15 bytes from a string of length 15

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://github.com/ceph/ceph-client.git binary_tracing
head:   242b3aa593381c5ed2f425dbfb145bf7ca42e1fc
commit: 8a1cb95e58001067ea33908f1762ca31d6f93b69 [2/4] ceph_san code
config: arm64-randconfig-004-20250704 (https://download.01.org/0day-ci/archive/20250704/202507041628.HXpoOzaS-lkp@xxxxxxxxx/config)
compiler: aarch64-linux-gcc (GCC) 10.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250704/202507041628.HXpoOzaS-lkp@xxxxxxxxx/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@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202507041628.HXpoOzaS-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

   net/ceph/ceph_san_logger.c: In function 'ceph_san_get_tls_ctx':
>> net/ceph/ceph_san_logger.c:313:5: warning: 'strncpy' output may be truncated copying 15 bytes from a string of length 15 [-Wstringop-truncation]
     313 |     strncpy(ctx->comm, current->comm, TASK_COMM_LEN);
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/strncpy +313 net/ceph/ceph_san_logger.c

   264	
   265	static void ceph_san_tls_release_verbose(void *ptr)
   266	{
   267	    struct ceph_san_tls_ctx *ctx = container_of(ptr, struct ceph_san_tls_ctx, release);
   268	    if (!ctx) {
   269	        pr_err("ceph_san_logger -- Callback : invalid TLS context pointer %d\n", current->pid);
   270	        return;
   271	    }
   272	    if (ctx->debug_poison != CEPH_SAN_CTX_POISON) {
   273	        pr_err("ceph_san_logger -- Callback : invalid TLS context id=%llu has invalid debug_poison value 0x%llx\n",
   274	               ctx->id, (unsigned long long)ctx->debug_poison);
   275	        BUG();
   276	    }
   277	    if (atomic_read(&ctx->refcount) != 1) {
   278	        pr_err("ceph_san_logger -- Callback : invalid TLS context refcount %d for pid %d [%s]\n",
   279	               atomic_read(&ctx->refcount), ctx->pid, ctx->comm);
   280	        BUG();
   281	    }
   282	    ceph_san_tls_release(ctx);
   283	}
   284	/**
   285	 * ceph_san_get_tls_ctx - Get or create TLS context for current task
   286	 *
   287	 * Returns pointer to TLS context or NULL on error
   288	 */
   289	struct ceph_san_tls_ctx *ceph_san_get_tls_ctx(void)
   290	{
   291	    struct ceph_san_tls_ctx *ctx = get_tls_ctx(); /* Inline helper, gets container_of */
   292	
   293	    if (ctx) {
   294	        if (!is_valid_active_ctx(ctx, "Existing TLS")) {
   295	            current->tls_ctx = NULL; /* Invalidate bad pointer */
   296	            BUG();
   297	        }
   298	        return ctx;
   299	    }
   300	
   301	    /* Create new context */
   302	    pr_debug("ceph_san_logger: creating new TLS context for pid %d [%s]\n",
   303	             current->pid, current->comm);
   304	
   305	    ctx = get_new_ctx(); /* Get base context with refcount 0 */
   306	    if (!ctx)
   307	        return NULL;
   308	
   309	    /* Set up TLS specific parts */
   310	    current->tls_ctx = (void *)&ctx->release;
   311	    ctx->task = current;
   312	    ctx->pid = current->pid;
 > 313	    strncpy(ctx->comm, current->comm, TASK_COMM_LEN);
   314	    ctx->comm[TASK_COMM_LEN - 1] = '\0'; /* Ensure null termination */
   315	
   316	    /* Increment refcount from 0 to 1 */
   317	    if (atomic_inc_return(&ctx->refcount) != 1) {
   318	        pr_err("BUG: Failed to set refcount=1 for new TLS context id=%llu (was %d before inc)\n",
   319	                ctx->id, atomic_read(&ctx->refcount) - 1);
   320	        current->tls_ctx = NULL; /* Don't leave partially set up context */
   321	        BUG();
   322	    }
   323	
   324	    pr_debug("ceph_san_logger: successfully created new TLS context id=%llu for pid %d [%s]\n",
   325	           ctx->id, ctx->pid, ctx->comm);
   326	    return ctx;
   327	}
   328	EXPORT_SYMBOL(ceph_san_get_tls_ctx);
   329	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki




[Index of Archives]     [CEPH Users]     [Ceph Large]     [Ceph Dev]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux