From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755551AbcC1XbV (ORCPT ); Mon, 28 Mar 2016 19:31:21 -0400 Received: from smtprelay0027.hostedemail.com ([216.40.44.27]:34788 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750852AbcC1XbT (ORCPT ); Mon, 28 Mar 2016 19:31:19 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:960:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1539:1593:1594:1711:1714:1730:1747:1777:1792:2194:2199:2393:2559:2562:2828:3138:3139:3140:3141:3142:3351:3622:3865:3868:4321:5007:6742:10004:10400:10848:11026:11232:11473:11658:11914:12043:12438:12517:12519:12740:13069:13161:13229:13311:13357:13439:13894:14659:14721:21080:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: knot91_7f0b92b9f8b4d X-Filterd-Recvd-Size: 2256 Message-ID: <1459207831.25110.37.camel@perches.com> Subject: Re: [PATCH v2 1/5] string_helpers: add kstrdup_quotable From: Joe Perches To: Kees Cook , James Morris Cc: "Serge E. Hallyn" , Andrew Morton , Kalle Valo , Mauro Carvalho Chehab , Guenter Roeck , Jiri Slaby , Paul Moore , Stephen Smalley , Mimi Zohar , Casey Schaufler , Andreas Gruenbacher , Andy Shevchenko , Rasmus Villemoes , Ulf Hansson , Vitaly Kuznetsov , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <1459199662-16558-2-git-send-email-keescook@chromium.org> References: <1459199662-16558-1-git-send-email-keescook@chromium.org> <1459199662-16558-2-git-send-email-keescook@chromium.org> Content-Type: text/plain; charset="ISO-8859-1" Date: Mon, 28 Mar 2016 16:30:31 -0700 Mime-Version: 1.0 X-Mailer: Evolution 3.18.5.2-0ubuntu1 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2016-03-28 at 14:14 -0700, Kees Cook wrote: > Handle allocating and escaping a string safe for logging. [] > diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h [] > @@ -68,4 +68,6 @@ static inline int string_escape_str_any_np(const char *src, char *dst, >   return string_escape_str(src, dst, sz, ESCAPE_ANY_NP, only); >  } >   > +char *kstrdup_quotable(char *src); char *kstrdup_quotable(const char *src) but shouldn't this really take a gfp_t like all the other kstr functions? > diff --git a/lib/string_helpers.c b/lib/string_helpers.c [] > +char *kstrdup_quotable(char *src) [] > + BUG_ON(string_escape_mem(src, slen, dst, dlen, flags, esc) != dlen); BUG_ON?  why?