Basics
Masks can be used to hide a part of a layer or a layers channel. This can be the value or the texture. You can find the masks in the layer settings.
Adding
Adding masks depends on the channel dropdown. That means that when you have it set to 'Layer' you can add and edit masks for the layer, but when it's set to another channel you change the masks for that channel.
To add a mask, select it from the dropdown or the thumbnail selection. You can add multiple masks to the same channel and then move them up or down.
Preview
The ghost icon next to the mask dropdown allows you to preview the mask stack. This is useful for seeing your mask in more detail.