Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2439486imj; Mon, 18 Feb 2019 06:06:41 -0800 (PST) X-Google-Smtp-Source: AHgI3IYbpO1GW2IXkVui6Ekxf55ge9SgkpkKQvhW8MfinlFJOlkmRISsBqZXLVzrncKQTfHLusEu X-Received: by 2002:a63:1b49:: with SMTP id b9mr19089211pgm.112.1550498801723; Mon, 18 Feb 2019 06:06:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550498801; cv=none; d=google.com; s=arc-20160816; b=AlO0KKJIUGhgWSFVsI8F6VV9QICsqKzNYPNhG4U87vswKiYLelhmUJH7cpHDV84ff0 +0y+YN70Mh1iLQw/jFkCqz5FSfufPld8zPp8VTn9YvPes+Wgyd703r+Ds/NtROYZLiZ9 XVtVHRarlyfhn46XEKjRys87SPnphgC2mig5nOjTXbKRXlFhtVy2T7suUGC0xLFqBN0D Z6CiBYYNpQgMFm4adFHkS55m+zTsLbvhQtTyHRabNBs04eWGpn9aAEgM40RvpFcNbBu4 ay0IcIJ/m7Rnl9k0+aKiBuI2YyfddL3sU+d06ahQ0eFqS7F31P0o4F1bSXkw5DpPg6uU uQ/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=T6ajoR/TFVR+DJAzFDUJ1s+ZvIUW5ilTZFMthZ8d++o=; b=TQwBgOS/3ZhTGDCeKSwxEzYUxg81/V3yNrW7/TnYb+cA2tZonzKbgehct3cnThBYEI 0vAFl40kOVISbkgyPYwR9ZNYLshQ8bz5JDcR6z4GTqYH/cqv3meXqtMFymFlQZKXFvvF 7z9DkUcwcCOPVFqwZbP3Uy6Fo4jPr6svpGPw6fOdeLPTUa+WW/TxJgxKkCiBB8yjPaJy zLdo6rWNES0BjVGpfo5fVhEGKXPdcSdtMbq3XNiUlHDZYgXK66NbcpC5eoAjD9kr9pN1 NDCzPvr7qzFMxJEaRWoj/3R0D3EelWMaeuxOlYfQJrbIpbrKSdnogwglsSziIyBIdmXw acDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qZecZnwg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6si13336626pgg.2.2019.02.18.06.06.25; Mon, 18 Feb 2019 06:06:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qZecZnwg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390176AbfBROFd (ORCPT + 99 others); Mon, 18 Feb 2019 09:05:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:48354 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390152AbfBROFa (ORCPT ); Mon, 18 Feb 2019 09:05:30 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 359E0204FD; Mon, 18 Feb 2019 14:05:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550498728; bh=R49b2dskifUW+hW2ZzMC1TYKj2HjCIxwv/17qx9rknc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qZecZnwgJWliGqmfpY8MZVlb2L/mNzhl17Na6jeajor7nC+e8vj5seHXseLFeghDS HWJzpN+6CECV2Vs5R+QwDyE0Dzx7mt05KptHD/P4UgF0Y3AxciZMl+8I2stCELr+e7 KcEgPn0zUlYpgwrMY73EBIxIHZgbCMZc9FUd92SY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tejun Heo , Linus Torvalds , Ma Shimiao , Arnd Bergmann , Chris Metcalf Subject: [PATCH 4.4 076/143] string: drop __must_check from strscpy() and restore strscpy() usages in cgroup Date: Mon, 18 Feb 2019 14:43:24 +0100 Message-Id: <20190218133531.865846132@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133529.099444112@linuxfoundation.org> References: <20190218133529.099444112@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tejun Heo commit 08a77676f9c5fc69a681ccd2cd8140e65dcb26c7 upstream. e7fd37ba1217 ("cgroup: avoid copying strings longer than the buffers") converted possibly unsafe strncpy() usages in cgroup to strscpy(). However, although the callsites are completely fine with truncated copied, because strscpy() is marked __must_check, it led to the following warnings. kernel/cgroup/cgroup.c: In function ‘cgroup_file_name’: kernel/cgroup/cgroup.c:1400:10: warning: ignoring return value of ‘strscpy’, declared with attribute warn_unused_result [-Wunused-result] strscpy(buf, cft->name, CGROUP_FILE_NAME_MAX); ^ To avoid the warnings, 50034ed49645 ("cgroup: use strlcpy() instead of strscpy() to avoid spurious warning") switched them to strlcpy(). strlcpy() is worse than strlcpy() because it unconditionally runs strlen() on the source string, and the only reason we switched to strlcpy() here was because it was lacking __must_check, which doesn't reflect any material differences between the two function. It's just that someone added __must_check to strscpy() and not to strlcpy(). These basic string copy operations are used in variety of ways, and one of not-so-uncommon use cases is safely handling truncated copies, where the caller naturally doesn't care about the return value. The __must_check doesn't match the actual use cases and forces users to opt for inferior variants which lack __must_check by happenstance or spread ugly (void) casts. Remove __must_check from strscpy() and restore strscpy() usages in cgroup. Signed-off-by: Tejun Heo Suggested-by: Linus Torvalds Cc: Ma Shimiao Cc: Arnd Bergmann Cc: Chris Metcalf [backport only the string.h portion to remove build warnings starting to show up - gregkh] Signed-off-by: Greg Kroah-Hartman --- include/linux/string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/include/linux/string.h +++ b/include/linux/string.h @@ -26,7 +26,7 @@ extern char * strncpy(char *,const char size_t strlcpy(char *, const char *, size_t); #endif #ifndef __HAVE_ARCH_STRSCPY -ssize_t __must_check strscpy(char *, const char *, size_t); +ssize_t strscpy(char *, const char *, size_t); #endif #ifndef __HAVE_ARCH_STRCAT extern char * strcat(char *, const char *);