Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1461206yba; Tue, 2 Apr 2019 09:15:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpMTgtVy/qdJi+crDLtiOmX2np8AKZdboFWHM1pJsrcSOSmgYPtS0ew6yynPNZS/r5dIsC X-Received: by 2002:a17:902:3f83:: with SMTP id a3mr67958697pld.6.1554221753773; Tue, 02 Apr 2019 09:15:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554221753; cv=none; d=google.com; s=arc-20160816; b=tVgFPkuF8XImy0zl7UdkWxndFCdgMH5BtPuhifV3BBXGo9W+TX3vCP4BXw+bOei0fR KE9SBqADJoAeGcQ1ocTmlZnzzneazrsv9B73TnOy9mr7aH0a0237XQo1FSgIKYQQS34W Br8OYMnlJObVox07WO80FBZirtXcVrR6lDqFStm4RigZtrcGWUGSq84zoIy9Soan2XCU d9aQiOXRm0y3qcATvKxQkjzOO543aR2/C+KcpTSlf6FoW4pQB6KhZcIXSTkTBuX+zOLQ HdXo8EmKvVxI1toXoTGlMgDrqoL5UY4DBLs2saQYY/7LVeNQx30iiYwtgQqlZY7TODkU MUZA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Uw79iZ7sAZkoCb17sWgbfAe/sIPibxyl+pAeQRTBWX0=; b=LAm5O1NzGzlHHMjKzahn8mbTa5QYWt0UI54dKDJIZ9ROznlTFvZcH1wGXBOvd18BHx jEIkvC13ptULjIUJ5SZ7+tM3UxXZtzoXCBWE2QwCtQ6HDeq5RN3RDt4dMfNd1/WhdHPW u/oy+fnLPfbuJwPb02UBV8S16Vx09Rjsk01hnk2gkIsDuWsppe9Z0m+jw8TcK42+ouZV +vaMN9qH6zsUGIV2GF9pd8PnBzRzYMV/8yDi7R6pc/rpG8GezAT9ZkWNjqy2afSjb5BH zZSImzFlk6LMbaXev3QzXC8xb37aqqWSuSQJ/Ih41n8flGnwWomto7dGsuSMpCXdsIzP Sajw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g20si11754631pfg.207.2019.04.02.09.15.38; Tue, 02 Apr 2019 09:15:53 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730508AbfDBQNk (ORCPT + 99 others); Tue, 2 Apr 2019 12:13:40 -0400 Received: from relay.sw.ru ([185.231.240.75]:60910 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729384AbfDBQNi (ORCPT ); Tue, 2 Apr 2019 12:13:38 -0400 Received: from [172.16.25.12] by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1hBM2U-00028a-GG; Tue, 02 Apr 2019 19:13:30 +0300 Subject: Re: [RFC PATCH v2 3/3] kasan: add interceptors for all string functions To: Christophe Leroy , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Nicholas Piggin , "Aneesh Kumar K.V" , Alexander Potapenko , Dmitry Vyukov , Daniel Axtens Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com References: <51a6d9d7185de310f37ccbd7e4ebfdd6c7e9791f.1553785020.git.christophe.leroy@c-s.fr> <3211b0f8-7b52-01b7-8208-65d746969248@c-s.fr> From: Andrey Ryabinin Message-ID: Date: Tue, 2 Apr 2019 19:14:02 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <3211b0f8-7b52-01b7-8208-65d746969248@c-s.fr> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/2/19 12:43 PM, Christophe Leroy wrote: > Hi Dmitry, Andrey and others, > > Do you have any comments to this series ? > I don't see justification for adding all these non-instrumented functions. We need only some subset of these functions and only on powerpc so far. Arches that don't use str*() that early simply doesn't need not-instrumented __str*() variant. Also I don't think that auto-replace str* to __str* for all not instrumented files is a good idea, as this will reduce KASAN coverage. E.g. we don't instrument slub.c but there is no reason to use non-instrumented __str*() functions there. And finally, this series make bug reporting slightly worse. E.g. let's look at strcpy(): +char *strcpy(char *dest, const char *src) +{ + size_t len = __strlen(src) + 1; + + check_memory_region((unsigned long)src, len, false, _RET_IP_); + check_memory_region((unsigned long)dest, len, true, _RET_IP_); + + return __strcpy(dest, src); +} If src is not-null terminated string we might not see proper out-of-bounds report from KASAN only a crash in __strlen(). Which might make harder to identify where 'src' comes from, where it was allocated and what's the size of allocated area. > I'd like to know if this approach is ok or if it is better to keep doing as in https://patchwork.ozlabs.org/patch/1055788/ > I think the patch from link is a better solution to the problem.