RSSAmplifier

Blog

naveen srinivasan

Recent content on naveen srinivasan

naveensrinivasan.comRSS feed ↗69 posts

Latest posts

Read My Blog Over SSH

Try it In your terminal, run: ssh ssh.naveensrinivasan.com , and you don’t need any authentication. The host key fingerprint for this server is SHA256:hK3ttqzsSBKUN18Wxu6eB0JB6lu4v4UBt6n8BX2WkIw . Why SSH? I have enjoyed the minimalism of the man pages, and it is also cool to have the blog accessible via SSH. The added benefits include no browsers, no cookies, no accounts, and no scrapers. Most of…

Finding Hidden Internal Apps Through Public Certificate Logs

Here is how anyone can unwrap the organization’s internal tools/products that no one is supposed to know about. Typically, in software organizations, most of us don’t want to share internal applications on the internet, but we unintentionally share application names by requesting certificates. The issued certs get into the Certificate Transparency (CT) logs…

Measuring an eBPF Cache Without Leaving the Kernel

When testing our eBPF agent, I don’t always get the same experience as our users, especially in performance critical sections. I realize that the benchmark test suite isn’t always enough, because user’s environments can be completely different from our benchmarks. I recently implemented a perf feature, which was inode caching for file access policies, and wanted to understand how it is being…

How Do I Profile eBPF Code?

If we are running any eBPF workload or writing eBPF code, we want to measure its performance impact, and in this post we will demonstrate an example of how to do it. In this example, our goal is to measure the performance of file open operations, one of the most critical functions in the OS. Our code used file open hooks in eBPF, we wanted to measure the performance overhead introduced by adding…

When LLVM's Optimizer Breaks Your eBPF Program

This is a weird bug I ran into while working on the ebpf. A call to the built-in function ‘memset’ is not supported, and the confusing part was that I was using __builtin_memset . Here is the code. #include 'vmlinux.h' #include <bpf/bpf_helpers.h> #include <bpf/bpf_core_read.h> #define PATH_MAX 1024 struct path_key { char container_path[PATH_MAX]; // 1024 bytes char directory_path[PATH_MAX]; //…

google peer bonus

I am deeply honored to once again receive the Google Peer Bonus award for my contributions to the open-source community in 2024. This recognition feels incredibly rewarding. Thank you, Google! I have been fortunate to receive this award in the past, in both 2021 and 2022. The Google Peer Bonus is a small yet significant token of appreciation from Google to open-source contributors. It serves as a…

Enhancing Security with Custom OpenSSF Scorecard Checks

The Open Source Security Foundation (OpenSSF) Scorecard is essential for performing automated security checks in open-source projects. However, its standard checks might not address all organizations&rsquo; specific security policies and compliance requirements. To overcome this limitation, developers can extend the Scorecard with custom checks by integrating it as a dependency in a Go binary.…

Hackers and Painters

Hackers and Painters" https://www.amazon.com/Hackers-Painters-Big-Ideas-Computer/dp/1449389554 by Paul Graham is a book that celebrates the lives of nerds who challenge the status quo and create new things. Graham points out that school is nothing but a glorified babysitter and that being a nerd is the ultimate rebellion. He discusses the history of wealth creation and the importance of making the…

OSS Trailblazer: My Journey of 4,155 Contributions and Membership in Prominent Open Source Organizations

2022 2021 TLDR : I have consistently contributed to open source projects on GitHub for the past two years, making 4,155 contributions in the past year alone. As a result of my dedication, I have become a member of several organizations and received a Google Peer Bonus award. I have also had the opportunity to speak at Linux Foundation conferences about supply chain security. My contributions to…

google peer bonus

I am honored to – once again – be a recipient of this award Google hands out to open source contributors annually. Getting this token of appreciation feels incredible. Thank you, Google! I have been a recipient of this award before, in 2021. The award is a small token of appreciation from Google to open-source contributors. It is a way for Google to say “thank you” for the time and effort you have…

Zero Trust Development Environment

Photo by novia wu on Unsplash I am paranoid about running unknown code on my machine. I have been using a MacBook for some years now, but the way I used to install any software was brew like most developers. Later I asked the question, &ldquo;How do I trust my brew installs ?&rdquo; But like most of us, I had to try new packages and deploy software to do my work.

Stunning Tribble

Defending from including OSV/CVE in go dependencies tldr: If you want to avoid including OSV/CVE in your go.mod/go.sum you can utilize this https://github.com/naveensrinivasan/stunning-tribble tool do that. Here is an example of how this is being used in scorecard https://github.com/ossf/scorecard/blob/9df865c4f83cfb36bae487125e5ccbc6aef448c6/Makefile#L64-L72 I contribute to a project that is…

Google Peer Bonus Award

I’m honored to receive this award Google hands out to open source contributors annually. Getting this token of appreciation feels fantastic, and I’m humbled and grateful I was nominated and selected as a recipient. Thank you, Google! Thank you Google and Abhishek!

How to debug the CrashLoopBackOff in Kubernetes when pod is not starting

Here is my learning of how I debugged the CrashLoopBackOff in kubernetes when the pod wasn’t starting. I wanted to deploy the jenkins docker image in the cluster. As mentioned in the jenkins docker repo I wanted to mount an external drive which is an AWS EBS volume. Here is my deployment yaml. [gist id = “98aa6da98ebb9b7e3d7f996c8ef2cb38”] After starting the deployment the pod never came up and…

Enable Shortcat app in OSX

Shortcat app is a software that I use everyday to keep me productive and reduce my dependency on mouse. But if you have OSX El Captain you get a message to enable the assistive devices,. But it has been changed from the previous versions of OSX. To enable the assistive devices navigate to System Preferences > Security & Privacy > Privacy > Accessibility and enable for shortcat app.

My Docker aliases

I have been using docker very often now and because I have been spending most of time in the terminal it made sense to use alias to reduce the typing. [gist id = “d6b41d000b93f3ecc3e7a1b900c7382c”] I have curated this from others and have also customized to what I want. All my aliases are stored in my github repo https://github.com/naveensrinivasan/dotvim/blob/master/zshrc

How I try avoid using mouse

Like most of the Dev’s I love using my Keyboard more than mouse. I am big vim fan and have been using vim for over 7-8 years. I still consider myself novice. Here are the ways I manage to use keyboard over mouse Shortcat – Great app get rids of use mouse in OSX – This is a Paid App , which IMHO is the best investment for me. There is also a trial version. MacVim – I have been using MacVim as my…

Taking it up a notch with my standing desk with fluidstance

I have been standing at work for the past 2 years. And I have seen significant improvement with respect to my productivity and non-drowsiness with standing desk. The one draw back with that I have seen was standing in a position where I put a lot of stress on one of the legs. And I wanted ti try something different. That’s when I saw fluidstance . Bought myself one which brings in a new challenge.…

Solution to Adventcode Day 7 in FSharp

Here is my solution to adventcode problem 7 using F#. I am using the adventofcode to improve my functional programming skills. The gist of the problem is to solve the logic gates which is represented as 16 bit integer’s and these depend on other gates. The puzzle starts of with simple problem 123 -> x 456 -> y ``Here is my solution to adventcode problem 7 using F#. I am using the adventofcode to…

Parsing GitHub API

I have been contributing to https://github.com/octokit/octokit.net project. It is the API for accessing GitHub. One of the recent questions that came up was to get the list of https://github.com/octokit/octokit.net/issues/968 . The API’s are published in HTML https://developer.github.com/v3/ There are about 63 + categories that have API. Wanted to parse all of these with least manual intervention.

fsharp docker image

The fsharp project has a official docker image https://github.com/fsprojects/docker-fsharp . The one issue with that is it is based on mono 4.0.4 which is buggy and fsharp does not work very well. The latest alpha release of the mono with which fsharp works well is 4.2.0. The 4.2.0 isn’t available in stable channels. So I created a docker image with the latest mono from their alpha repo and using…

View the http redirect and response message from an external authentication provider using ETW

Recently I had to troubleshoot messages that were being sent from an web application hosted on IIS to an external authentication provider. The logs from the application wasn’t something closer to the metal and wasn’t really providing all the details. I really wanted something like fiddler for the webserver. I could have a ran network traces to troubleshoot the issue but the problem was it wasn’t…

Getting my Yoga stats from Yogaglo

Use Eventsource to get the duration of a Start Stop of Custom ETW events

The EventSource library provides an option to get duration of Custom ETW start and stop events and when used with Perfview we could leverage this to stop tracing when the duration is more than what we expect. What it is for example ,there could an external API call the application makes that has to be traced with the start and when it finishes then the stop of the event is called. Ideally we would…

Log dynamic Custom objects in ETW using EventSource

With the latest release of EventSource we could create dynamic events without having to create class that inherits from EventSource. This is will be not be good for Performance. Using these methods we could either log Anonymous objects or Classes that have the EventData Attribute applied to it. The caveat is that these objects public properties alone will be serialized. These properties have to be…

The case of slow Visual Studio startup

In this post I would use Perfview /ETW to diagnose the delayed start-up of visual studio. To analyze the problem start-up VS within Perfview as a run command [gist https://gist.github.com/naveensrinivasan/5eb6406d6d38f2143acb] This would launch visual studio and collect etw traces. I have also enabled CodeMarkers , which is ETW traces for Visual Studio in case if you want to trace any extensions…

Managed Stack Explorer using ClrMD

How often we run into an issue in the field where we just want to see the managed call-stack where the exception is or where the thread is hung. One of the options is debugger or something like ETW. So I built a managed stack explorer http://naveensrinivasan.github.io/ManagedStackExplorer/ Managed Stack Explorer provides call stack for .NET applications using managed code with thread local…

Measure GC Allocations and Collections using TraceEvent

In this post I will explore how we could use TraceEvent to measure our code (even at function level) for GC Allocations and Collections. Save this with “.linq” extension and then open in linqpad. [gist https://gist.github.com/naveensrinivasan/b72fd80876eb67557ae8] Here is the TL;DR Why would I want to know GC events on a function level? Doesn’t the PerfMon counter provide that information on an…

Look ma I figured out why my ETW EventSource isn’t tracing

The EventSource class in the framework 4.5 helps in writing custom ETW tracing. When using EventSource class built within the framework, if the order of the methods don’t match ordinal number position in the class it would fail generating ETW traces. The EventSource has dependency on the order of the methods in the class. This code would produce a valid ETW traces

Making an Image Easier to Debug

I am doing security review for a managed application which is obfuscated. So I am doing a lot of disassembling code at runtime using Windbg. One of the issues is that code gets JIT optimized because of the retail build. This makes it harder for me debug when mapping it back. Realized that I could turnoff JIT Optimization’s using the ini file. [sourcecode] [.NET Framework Debugging Control]…

Updating .NET String in memory with Windbg

In this post I would show a simple trick to update .NET strings in memory with Windbg. The caveat is make sure the string that you’re updating is long enough to fit into the string buffer. If not there would be a memory corruption. Here is a simple windows form application with title “Good” The goal is to update the title from “Good” to “Bad”.

Who is is blocking my UI Thread? Diagnosing the cause using Windbg

It so happens most of the applications block the UI thread and do sync I/O, which is most common reason for “Not Responding” window. Here is a post http://blogs.msdn.com/b/nathannesbit/archive/2010/12/28/detecting-ui-thread-misuse.aspx that tries helping in detecting this. I like to handle this from bottom of the stack because we have a cool tool called debugger. The approach is simple as having a…

Correlating between .NET and native thread in Windbg

I recently saw a stackoverflow question where someone wanted to know how they could correlate between managed and native threads within Windbg. Here is the managed thread object within the debugger 0:004> !do 02a1d6c4 Name: System.Threading.Thread MethodTable: 672e001c EEClass: 67018ed8 Size: 48(0x30) bytes File:…

Conditional BreakPoint based on callstack within Windbg – .NET

Someone recently asked me “How to have a break-point on a method based on certain function in the call-stack?” Here is the sample code to demonstrate this [sourcecode language=”csharp”] using System; using System.Threading.Tasks; using System.Data.SqlClient; namespace Test { class Program { string connectionString = @&ldquo;Data Source=.sqlexpress;Initial Catalog=Tfs_Configuration;Integrated…

Saving Dynamic Assembly in .NET 4.0 using Windbg

I recently had to debug a .NET 4.0 process which was loading the dependent assemblies using the AppDomain.AssemblyResolve event. The dependent assemblies were stored within the executable. I couldn’t disassemble the code to look for the dependent assembly because the exe was obfuscated. FYI the dynamic assembly cannot be saved using !SaveModule and here is the reason for I recently had to debug a…

Dumping Generic List in .NET within Windbg

Most of the code uses List for storing items. The present solutions don’ t have a way to dump List within windbg. Even though sosex has an option to dump the List using !mdt it still doesn’t meet the scripting requirements. For example here is an output using sosex “!mdt -e 029a91c0” 0:000> !mdt -e 029a91c0 029a91c0 (System.Collections.Generic.List`1[[Test.Foo, Test]])

Why isn’t the !bpmd in sos / windbg not working?

I recently noticed another blog post refer to one of my post . The issue was, sos wasn’t enabling the break-points on non-jitted functions. The classic example being “Main”. Thanks to Steve I have been using sosex and not sos for setting break-points. From my previous post you can understand how CLR is using clrn/CLRNotificationException to notify sos/sosex on JIT. With this information when I…

Using sosex within windbg to understand IL and Assembly code

Sometimes when debugging managed code within the debugger I would like to see the C# code ,the IL translation for the managed code and the Assembly code for the IL. For example I recently learned that callvirt MSIL instruction must do the null-check before invoking method. C:UsersnaveenDocumentsVisual Studio 2010ProjectsConsoleApplication13Program.cs @ 18: 00bc26d8 8b4dec mov ecx,dword ptr…

Windbg trick – Having custom name for user-defined pseudo-registers

There are 20 user-defined pseudo-registers ( $t0 , $t1 , …, $t19 ) in windbg/cdb . To have scripts with variable names as @$t0 and @$t1 isn’t helpful for readability. The trick to avoid this is by using the “aS” command. Here is an example, for a loop variable I would like to use a variable name like “i” instead of “@$t0” and to use “i” as a variable here is the command aS i “@$t0”

Decoding clr20r3 .NET exception – using mono cecil

I have often seen Devs trying to figure out the cause of the app crash without a memory dump. The only information that is available to analyze is the Windows Error Reporting message in the event viewer which would have “Event Name: CLR20r3” along with Watson bucket information like this. Fault bucket , type 0 Event Name: CLR20r3 Response: Not available Cab Id: 0 Problem signature: P1:…

Script to !SaveAllModules in .NET 4.0 SOS within Windbg

The .NET 4.0 sos doesn’t have save all modules (!SaveAllModules) command. It only has !SaveModule. Recently I was debugging a .NET 4.0 process for which I had to save all the modules. Here is a script that does !SaveAllModules. [sourcecode] !for_each_module .if ($spat ("${@#ImageName}","*.exe")) { !SaveModule ${@#Base} c:temp${@#ModuleName}.exe } .else { !SaveModule ${@#Base}…

Using Managed Code to debug Memory Dumps

I happened to notice the new I happened to notice the new and it had COM based API for dbgeng. The sample code were in VB Script. I much comfortable writing managed code compared to VB script. So I decided to use COM based API in managed code. Here are couple of ways to solve certain problems using this Parallel GC Roots :- Getting GC Roots from memory dump is the most time consuming because SOS…

Downloading PDC10 videos using the new async feature

I knew PDC10 has an OData endpoint which is http://odata.microsoftpdc.com/ODataSchedule.svc/ . The best part about OData is querying for specific data that we are looking for. And here is my OData url for filtering twitter hashtag #languages [sourcecode] http://odata.microsoftpdc.com/ODataSchedule.svc/Sessions()?$filter=startswith(TwitterHashtag, %23languages…

Dumping .NET strings to files using Windbg

In this post I would demonstrate how to dump strings from a memory dump /live process to a file. Recently I had to debug a process which had few big strings where I had to analyze its contents. The !dumpobj from sos would only dump partial strings. I had to dump few hundred XML strings that I had to analyze using some automation. And hence comes the script. [sourcecode] $$ Dumps the managed…

Dumping ASP.NET Session (x86 /x64) within Windbg

This post is going to be about dumping ASP.NET session objects using Windbg. I had recently answered a stackoverflow question in which someone wanted to dump ASP.NET session objects for 64-bit IIS (x64). I thought why not blog about the same which might be useful to others. The challenge is to write one script that should work in both x86/x64. FYI there is a script from Tess that does dump out the…

GC Start and Stop events in .NET using Windbg

I was recently showing someone the new ETW features in .NET especially the GC Event notification and I was asked if we can get this using Windbg. So here is the sample code for the GC Collection [sourcecode language=”csharp”] namespace GCStartStop { public partial class Form1 : Form { public Form1() { InitializeComponent(); button1.Click += (s, b) => GC.Collect(2); button1.Click += (s, b) =>…

Get GC Information in Silverlight

I had earlier written a post on getting GC information on Silverlight using ETW. With that we would have to write code to parse the ETW csv file. In this post I am going to be using Perfmonitor to do this. This tools uses the same ETW under covers, but it does all the plumbing and gives a nice report , which is much easier to read. Here are the reports

Script to load sos within Windbg based on .NET Framework version

I often debug .NET Framework v 2.0 / v 4.0 code within windbg. In v 2.0 the main clr dll was called “mscorwks.dll” and in v 4.0 it is called “clr.dll”. As many of you are aware , to load sos in v 2.0 we would have to enter “.loadby sos mscorwks” and in v 4.0 it would be “.loadby sos clr” . This was a pain for me. Came up with a script to automate loading sos based on clr version

Debugging .NET – mystery between DEBUG versus RELEASE within windbg

I am sure most of us have debugged applications that are build with debug turned on, which is obviously much easier compared to debugging release build (optimized code). In this post I am going to share one of my experiences of debugging release build code. I will demonstrate this with a simple Console Application. Here is the code [sourcecode language=”csharp”] using System; namespace…

Using F# to Automate Reading–The Morning Brew

I guess most of the .NET Devs read The Morning Brew , if not you should. It is a morning newspaper for the dev, so I end up reading it first thing when I go to work. I like to try and automate most of the stuff . So I thought why not write a script that reads the Morning Brew feed, filter the excluded content that I am not interested in and open the urls before I come in. The reason behind using…