Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-linus-7.0-ofs1' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux

Pull orangefs updates from Mike Marshall:

- Fixes for string handling in orangefs-debugfs.c and xattr.c (Thorsten
Blum)

* tag 'for-linus-7.0-ofs1' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux:
fs/orangefs: Replace deprecated strcpy with memcpy + strscpy
orangefs: Replace deprecated strcpy with strscpy

+25 -23
+19 -17
fs/orangefs/orangefs-debugfs.c
··· 238 238 static void orangefs_kernel_debug_init(void) 239 239 { 240 240 static char k_buffer[ORANGEFS_MAX_DEBUG_STRING_LEN] = { }; 241 + size_t len = strlen(kernel_debug_string); 241 242 242 243 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__); 243 244 244 - if (strlen(kernel_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) { 245 - strcpy(k_buffer, kernel_debug_string); 246 - strcat(k_buffer, "\n"); 245 + if (len + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) { 246 + memcpy(k_buffer, kernel_debug_string, len); 247 + k_buffer[len] = '\n'; 248 + k_buffer[len + 1] = '\0'; 247 249 } else { 248 - strcpy(k_buffer, "none\n"); 250 + strscpy(k_buffer, "none\n"); 249 251 pr_info("%s: overflow 1!\n", __func__); 250 252 } 251 253 ··· 338 336 */ 339 337 static void orangefs_client_debug_init(void) 340 338 { 341 - 342 339 static char c_buffer[ORANGEFS_MAX_DEBUG_STRING_LEN] = { }; 340 + size_t len = strlen(client_debug_string); 343 341 344 342 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__); 345 343 346 - if (strlen(client_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) { 347 - strcpy(c_buffer, client_debug_string); 348 - strcat(c_buffer, "\n"); 344 + if (len + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) { 345 + memcpy(c_buffer, client_debug_string, len); 346 + c_buffer[len] = '\n'; 347 + c_buffer[len + 1] = '\0'; 349 348 } else { 350 - strcpy(c_buffer, "none\n"); 349 + strscpy(c_buffer, "none\n"); 351 350 pr_info("%s: overflow! 2\n", __func__); 352 351 } 353 352 ··· 751 748 else if (len) 752 749 kernel_debug_string[len - 1] = '\0'; 753 750 else if (type) 754 - strcpy(client_debug_string, "none"); 751 + strscpy(client_debug_string, "none"); 755 752 else 756 - strcpy(kernel_debug_string, "none"); 753 + strscpy(kernel_debug_string, "none"); 757 754 758 755 out: 759 756 gossip_debug(GOSSIP_UTILS_DEBUG, "%s: string:%s:\n", __func__, debug_string); 760 757 761 758 return; 762 - 763 759 } 764 760 765 761 static void do_k_string(void *k_mask, int index) ··· 777 775 strcat(kernel_debug_string, ","); 778 776 } else { 779 777 gossip_err("%s: overflow!\n", __func__); 780 - strcpy(kernel_debug_string, ORANGEFS_ALL); 778 + strscpy(kernel_debug_string, ORANGEFS_ALL); 781 779 goto out; 782 780 } 783 781 } ··· 804 802 strcat(client_debug_string, ","); 805 803 } else { 806 804 gossip_err("%s: overflow!\n", __func__); 807 - strcpy(client_debug_string, ORANGEFS_ALL); 805 + strscpy(client_debug_string, ORANGEFS_ALL); 808 806 goto out; 809 807 } 810 808 } ··· 840 838 841 839 if ((c_mask->mask1 == cdm_array[client_all_index].mask1) && 842 840 (c_mask->mask2 == cdm_array[client_all_index].mask2)) { 843 - strcpy(client_debug_string, ORANGEFS_ALL); 841 + strscpy(client_debug_string, ORANGEFS_ALL); 844 842 rc = 1; 845 843 goto out; 846 844 } 847 845 848 846 if ((c_mask->mask1 == cdm_array[client_verbose_index].mask1) && 849 847 (c_mask->mask2 == cdm_array[client_verbose_index].mask2)) { 850 - strcpy(client_debug_string, ORANGEFS_VERBOSE); 848 + strscpy(client_debug_string, ORANGEFS_VERBOSE); 851 849 rc = 1; 852 850 goto out; 853 851 } ··· 856 854 k_mask = (__u64 *) mask; 857 855 858 856 if (*k_mask >= s_kmod_keyword_mask_map[k_all_index].mask_val) { 859 - strcpy(kernel_debug_string, ORANGEFS_ALL); 857 + strscpy(kernel_debug_string, ORANGEFS_ALL); 860 858 rc = 1; 861 859 goto out; 862 860 }
+6 -6
fs/orangefs/xattr.c
··· 152 152 goto out_unlock; 153 153 154 154 new_op->upcall.req.getxattr.refn = orangefs_inode->refn; 155 - strcpy(new_op->upcall.req.getxattr.key, name); 155 + strscpy(new_op->upcall.req.getxattr.key, name); 156 156 157 157 /* 158 158 * NOTE: Although keys are meant to be NULL terminated textual ··· 173 173 (char *)new_op->upcall.req.getxattr.key); 174 174 cx = kmalloc(sizeof *cx, GFP_KERNEL); 175 175 if (cx) { 176 - strcpy(cx->key, name); 176 + strscpy(cx->key, name); 177 177 cx->length = -1; 178 178 cx->timeout = jiffies + 179 179 orangefs_getattr_timeout_msecs*HZ/1000; ··· 220 220 ret = length; 221 221 222 222 if (cx) { 223 - strcpy(cx->key, name); 223 + strscpy(cx->key, name); 224 224 memcpy(cx->val, buffer, length); 225 225 cx->length = length; 226 226 cx->timeout = jiffies + HZ; 227 227 } else { 228 228 cx = kmalloc(sizeof *cx, GFP_KERNEL); 229 229 if (cx) { 230 - strcpy(cx->key, name); 230 + strscpy(cx->key, name); 231 231 memcpy(cx->val, buffer, length); 232 232 cx->length = length; 233 233 cx->timeout = jiffies + HZ; ··· 267 267 * textual strings, I am going to explicitly pass the 268 268 * length just in case we change this later on... 269 269 */ 270 - strcpy(new_op->upcall.req.removexattr.key, name); 270 + strscpy(new_op->upcall.req.removexattr.key, name); 271 271 new_op->upcall.req.removexattr.key_sz = strlen(name) + 1; 272 272 273 273 gossip_debug(GOSSIP_XATTR_DEBUG, ··· 361 361 * strings, I am going to explicitly pass the length just in 362 362 * case we change this later on... 363 363 */ 364 - strcpy(new_op->upcall.req.setxattr.keyval.key, name); 364 + strscpy(new_op->upcall.req.setxattr.keyval.key, name); 365 365 new_op->upcall.req.setxattr.keyval.key_sz = strlen(name) + 1; 366 366 memcpy(new_op->upcall.req.setxattr.keyval.val, value, size); 367 367 new_op->upcall.req.setxattr.keyval.val_sz = size;